You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@royale.apache.org by GitBox <gi...@apache.org> on 2018/05/23 16:47:06 UTC

[GitHub] jgranick commented on issue #245: Uncaught ReferenceError: org is not defined

jgranick commented on issue #245: Uncaught ReferenceError: org is not defined
URL: https://github.com/apache/royale-asjs/issues/245#issuecomment-391419420
 
 
   After removing circular dependencies, we are ending up with some stuff like:
   
   ```js
   /**
    * Generated by Apache Royale Compiler from starling\rendering\VertexDataFormat.as
    * starling.rendering.VertexDataFormat
    *
    * @fileoverview
    *
    * @suppress {missingRequire|checkTypes|accessControls}
    */
   
   goog.provide('starling.rendering.VertexDataFormat');
   /* Royale Dependency List: flash.display3D.VertexBuffer3D,flash.errors.ArgumentError,starling.core.Starling,starling.rendering.VertexDataAttribute,starling.utils.StringUtil*/
   /* Royale Static Dependency List: flash.utils.Dictionary*/
   
   goog.require('flash.utils.Dictionary');
   
   
   
   /** Don't use the constructor, but call <code>VertexDataFormat.fromString</code> instead.
    * @constructor
    */
   starling.rendering.VertexDataFormat = function() {
     this._attributes = org.apache.royale.utils.Language.Vector();
   };
   
   
   /**
    * Prevent renaming of class. Needed for reflection.
    */
   goog.exportSymbol('starling.rendering.VertexDataFormat', starling.rendering.VertexDataFormat);
   
   
   /**
    * @private
    * @type {string}
    */
   starling.rendering.VertexDataFormat.prototype._format;
   
   
   /**
    * @private
    * @type {number}
    */
   starling.rendering.VertexDataFormat.prototype._vertexSize = 0;
   
   
   /**
    * @private
    * @type {Array}
    */
   starling.rendering.VertexDataFormat.prototype._attributes;
   
   
   /**
    * @private
    * @type {flash.utils.Dictionary}
    */
   starling.rendering.VertexDataFormat.sFormats = new flash.utils.Dictionary();
   
   
   /** Creates a new VertexDataFormat instance from the given String, or returns one from
    *  the cache (if an equivalent String has already been used before).
    *
    *  @asparam format
    *
    *  Describes the attributes of each vertex, consisting of a comma-separated
    *  list of attribute names and their format, e.g.:
    *
    *  <pre>"position:float2, texCoords:float2, color:bytes4"</pre>
    *
    *  <p>This set of attributes will be allocated for each vertex, and they will be
    *  stored in exactly the given order.</p>
    *
    *  <ul>
    *    <li>Names are used to access the specific attributes of a vertex. They are
    *        completely arbitrary.</li>
    *    <li>The available formats can be found in the <code>Context3DVertexBufferFormat</code>
    *        class in the <code>flash.display3D</code> package.</li>
    *    <li>Both names and format strings are case-sensitive.</li>
    *    <li>Always use <code>bytes4</code> for color data that you want to access with the
    *        respective methods.</li>
    *    <li>Furthermore, the attribute names of colors should include the string "color"
    *        (or the uppercase variant). If that's the case, the "alpha" channel of the color
    *        will automatically be initialized with "1.0" when the VertexData object is
    *        created or resized.</li>
    *  </ul>
    * @export
    * @param {string} format
    * @return {starling.rendering.VertexDataFormat}
    */
   starling.rendering.VertexDataFormat.fromString = function(format) {
     if (format in starling.rendering.VertexDataFormat.sFormats)
       return starling.rendering.VertexDataFormat.sFormats[format]; else {
       var /** @type {starling.rendering.VertexDataFormat} */ instance = new starling.rendering.VertexDataFormat();
       instance.parseFormat(format);
       var /** @type {string} */ normalizedFormat = instance._format;
       if (normalizedFormat in starling.rendering.VertexDataFormat.sFormats)
         instance = starling.rendering.VertexDataFormat.sFormats[normalizedFormat];
       starling.rendering.VertexDataFormat.sFormats[format] = instance;
       starling.rendering.VertexDataFormat.sFormats[normalizedFormat] = instance;
       return instance;
     }
   };
   
   
   /** Creates a new VertexDataFormat instance by appending the given format string
    * @export
    * @param {string} format
    * @return {starling.rendering.VertexDataFormat}
    */
   starling.rendering.VertexDataFormat.prototype.extend = function(format) {
     return starling.rendering.VertexDataFormat.fromString(this._format + ", " + format);
   };
   
   
   /** Returns the size of a certain vertex attribute in bytes. 
    * @export
    * @param {string} attrName
    * @return {number}
    */
   starling.rendering.VertexDataFormat.prototype.getSize = function(attrName) {
     return this.getAttribute(attrName).size;
   };
   
   
   /** Returns the size of a certain vertex attribute in 32 bit units. 
    * @export
    * @param {string} attrName
    * @return {number}
    */
   starling.rendering.VertexDataFormat.prototype.getSizeIn32Bits = function(attrName) {
     return this.getAttribute(attrName).size / 4;
   };
   
   
   /** Returns the offset (in bytes) of an attribute within a vertex. 
    * @export
    * @param {string} attrName
    * @return {number}
    */
   starling.rendering.VertexDataFormat.prototype.getOffset = function(attrName) {
     return this.getAttribute(attrName).offset;
   };
   
   
   /** Returns the offset (in 32 bit units) of an attribute within a vertex. 
    * @export
    * @param {string} attrName
    * @return {number}
    */
   starling.rendering.VertexDataFormat.prototype.getOffsetIn32Bits = function(attrName) {
     return this.getAttribute(attrName).offset / 4;
   };
   
   
   /** Returns the format of a certain vertex attribute, identified by its name.
    * @export
    * @param {string} attrName
    * @return {string}
    */
   starling.rendering.VertexDataFormat.prototype.getFormat = function(attrName) {
     return this.getAttribute(attrName).format;
   };
   
   
   /** Returns the name of the attribute at the given position within the vertex format. 
    * @export
    * @param {number} attrIndex
    * @return {string}
    */
   starling.rendering.VertexDataFormat.prototype.getName = function(attrIndex) {
     return this._attributes[attrIndex].name;
   };
   
   
   /** Indicates if the format contains an attribute with the given name. 
    * @export
    * @param {string} attrName
    * @return {boolean}
    */
   starling.rendering.VertexDataFormat.prototype.hasAttribute = function(attrName) {
     var /** @type {number} */ numAttributes = this._attributes.length;
     for (var /** @type {number} */ i = 0; i < numAttributes; ++i)
       if (this._attributes[i].name == attrName)
         return true;
     return false;
   };
   
   
   /** Specifies which vertex data attribute corresponds to a single vertex shader
    *  program input. This wraps the <code>Context3D</code>-method with the same name,
    *  automatically replacing <code>attrName</code> with the corresponding values for
    * @export
    * @param {number} index
    * @param {flash.display3D.VertexBuffer3D} buffer
    * @param {string} attrName
    */
   starling.rendering.VertexDataFormat.prototype.setVertexBufferAt = function(index, buffer, attrName) {
     var /** @type {starling.rendering.VertexDataAttribute} */ attribute = this.getAttribute(attrName);
     starling.core.Starling["context"].setVertexBufferAt(index, buffer, attribute.offset / 4, attribute.format);
   };
   
   
   /**
    * @private
    * @param {string} format
    */
   starling.rendering.VertexDataFormat.prototype.parseFormat = function(format) {
     if (format != null && format != "") {
       this._attributes.length = 0;
       this._format = "";
       var /** @type {Array} */ parts = format.split(",");
       var /** @type {number} */ numParts = parts.length;
       var /** @type {number} */ offset = 0;
       for (var /** @type {number} */ i = 0; i < numParts; ++i) {
         var /** @type {string} */ attrDesc = org.apache.royale.utils.Language.string(parts[i]);
         var /** @type {Array} */ attrParts = attrDesc.split(":");
         if (attrParts.length != 2)
           throw new flash.errors.ArgumentError("Missing colon: " + attrDesc);
         var /** @type {string} */ attrName = starling.utils.StringUtil.trim(attrParts[0]);
         var /** @type {string} */ attrFormat = starling.utils.StringUtil.trim(attrParts[1]);
         if (attrName.length == 0 || attrFormat.length == 0)
           throw new flash.errors.ArgumentError(("Invalid format string: " + attrDesc));
         var /** @type {starling.rendering.VertexDataAttribute} */ attribute = new starling.rendering.VertexDataAttribute(attrName, attrFormat, offset);
         offset += attribute.size;
         this._format += (i == 0 ? "" : ", ") + attribute.name + ":" + attribute.format;
         this._attributes[this._attributes.length] = attribute;
       }
       this._vertexSize = offset;
     } else {
       this._format = "";
     }
   };
   
   
   /** Returns the normalized format string. 
    * @export
    * @return {string}
    */
   starling.rendering.VertexDataFormat.prototype.toString = function() {
     return this._format;
   };
   
   
   /** @asprivate 
    * @param {string} attrName
    * @return {starling.rendering.VertexDataAttribute}
    */
   starling.rendering.VertexDataFormat.prototype.getAttribute = function(attrName) {
     var /** @type {number} */ i = 0, /** @type {starling.rendering.VertexDataAttribute} */ attribute;
     var /** @type {number} */ numAttributes = this._attributes.length;
     for (i = 0; i < numAttributes; ++i) {
       attribute = this._attributes[i];
       if (attribute.name == attrName)
         return attribute;
     }
     return null;
   };
   
   
   starling.rendering.VertexDataFormat.prototype.get__attributes = function() {
     return this._attributes;
   };
   
   
   starling.rendering.VertexDataFormat.prototype.get__formatString = function() {
     return this._format;
   };
   
   
   starling.rendering.VertexDataFormat.prototype.get__vertexSize = function() {
     return this._vertexSize;
   };
   
   
   starling.rendering.VertexDataFormat.prototype.get__vertexSizeIn32Bits = function() {
     return this._vertexSize / 4;
   };
   
   
   starling.rendering.VertexDataFormat.prototype.get__numAttributes = function() {
     return this._attributes.length;
   };
   
   
   Object.defineProperties(starling.rendering.VertexDataFormat.prototype, /** @lends {starling.rendering.VertexDataFormat.prototype} */ {
   /**
     * @export
     * @type {Vector.<VertexDataAttribute>} */
   attributes: {
   get: starling.rendering.VertexDataFormat.prototype.get__attributes},
   /**
     * @export
     * @type {string} */
   formatString: {
   get: starling.rendering.VertexDataFormat.prototype.get__formatString},
   /**
     * @export
     * @type {number} */
   vertexSize: {
   get: starling.rendering.VertexDataFormat.prototype.get__vertexSize},
   /**
     * @export
     * @type {number} */
   vertexSizeIn32Bits: {
   get: starling.rendering.VertexDataFormat.prototype.get__vertexSizeIn32Bits},
   /**
     * @export
     * @type {number} */
   numAttributes: {
   get: starling.rendering.VertexDataFormat.prototype.get__numAttributes}}
   );
   
   
   /**
    * Metadata
    *
    * @type {Object.<string, Array.<Object>>}
    */
   starling.rendering.VertexDataFormat.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'VertexDataFormat', qName: 'starling.rendering.VertexDataFormat', kind: 'class' }] };
   
   
   
   /**
    * Reflection
    *
    * @return {Object.<string, Function>}
    */
   starling.rendering.VertexDataFormat.prototype.ROYALE_REFLECTION_INFO = function () {
     return {
       variables: function () {return {};},
       accessors: function () {
         return {
           'formatString': { type: 'String', access: 'readonly', declaredBy: 'starling.rendering.VertexDataFormat'},
           'vertexSize': { type: 'int', access: 'readonly', declaredBy: 'starling.rendering.VertexDataFormat'},
           'vertexSizeIn32Bits': { type: 'int', access: 'readonly', declaredBy: 'starling.rendering.VertexDataFormat'},
           'numAttributes': { type: 'int', access: 'readonly', declaredBy: 'starling.rendering.VertexDataFormat'}
         };
       },
       methods: function () {
         return {
           'VertexDataFormat': { type: '', declaredBy: 'starling.rendering.VertexDataFormat'},
           '|fromString': { type: 'starling.rendering.VertexDataFormat', declaredBy: 'starling.rendering.VertexDataFormat', parameters: function () { return [  { index: 1, type: 'String', optional: false } ]; }},
           'extend': { type: 'starling.rendering.VertexDataFormat', declaredBy: 'starling.rendering.VertexDataFormat', parameters: function () { return [  { index: 1, type: 'String', optional: false } ]; }},
           'getSize': { type: 'int', declaredBy: 'starling.rendering.VertexDataFormat', parameters: function () { return [  { index: 1, type: 'String', optional: false } ]; }},
           'getSizeIn32Bits': { type: 'int', declaredBy: 'starling.rendering.VertexDataFormat', parameters: function () { return [  { index: 1, type: 'String', optional: false } ]; }},
           'getOffset': { type: 'int', declaredBy: 'starling.rendering.VertexDataFormat', parameters: function () { return [  { index: 1, type: 'String', optional: false } ]; }},
           'getOffsetIn32Bits': { type: 'int', declaredBy: 'starling.rendering.VertexDataFormat', parameters: function () { return [  { index: 1, type: 'String', optional: false } ]; }},
           'getFormat': { type: 'String', declaredBy: 'starling.rendering.VertexDataFormat', parameters: function () { return [  { index: 1, type: 'String', optional: false } ]; }},
           'getName': { type: 'String', declaredBy: 'starling.rendering.VertexDataFormat', parameters: function () { return [  { index: 1, type: 'int', optional: false } ]; }},
           'hasAttribute': { type: 'Boolean', declaredBy: 'starling.rendering.VertexDataFormat', parameters: function () { return [  { index: 1, type: 'String', optional: false } ]; }},
           'setVertexBufferAt': { type: 'void', declaredBy: 'starling.rendering.VertexDataFormat', parameters: function () { return [  { index: 1, type: 'int', optional: false },{ index: 2, type: 'flash.display3D.VertexBuffer3D', optional: false },{ index: 3, type: 'String', optional: false } ]; }},
           'toString': { type: 'String', declaredBy: 'starling.rendering.VertexDataFormat'}
         };
       }
     };
   };
   ```
   
   A number of classes define `static const` instances of `VertexDataFormat`, so they call `new VertexDataFormat` (or more specifically, `VertexDataFormat.fromString`, which calls `new`) but we don't have access to the `Language` module for `Vector.<T>` support yet

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services