royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [royale-typedefs] branch develop updated: make sure certain consts are true constants. Volunteers welcome to add more config entries for other constants
Date Fri, 19 Oct 2018 06:41:03 GMT
This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-typedefs.git


The following commit(s) were added to refs/heads/develop by this push:
     new 0bf671e  make sure certain consts are true constants.  Volunteers welcome to add
more config entries for other constants
0bf671e is described below

commit 0bf671e7c7ce3003654c7faf38d978b2f9633882
Author: Alex Harui <aharui@apache.org>
AuthorDate: Thu Oct 18 23:40:49 2018 -0700

    make sure certain consts are true constants.  Volunteers welcome to add more config entries
for other constants
---
 js/src/main/config/externc-config.xml | 29 +++++++++++++++++++++++++++++
 js/src/main/javascript/missing.js     | 13 ++++---------
 2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/js/src/main/config/externc-config.xml b/js/src/main/config/externc-config.xml
index 87ac880..f959087 100644
--- a/js/src/main/config/externc-config.xml
+++ b/js/src/main/config/externc-config.xml
@@ -173,6 +173,7 @@
     <exclude><class>SVGStylable</class><name>style</name></exclude>
     <exclude><class>SVGLocatable</class><name>farthestViewportElement</name></exclude>
     <exclude><class>SVGLocatable</class><name>nearestViewportElement</name></exclude>
+    
 
     <!-- read-only properties where we only emit a 'get' accessor method -->
     <field-readonly>
@@ -180,4 +181,32 @@
         <name>timezoneOffset</name>
     </field-readonly>
     
+    <!-- externs use @const for both read-only as well as true constants
+         and you can't give the const an initial value either.
+         From a JS perspective that's fine, you can't write to a const or
+         a read-only and the initial value doesn't matter since it will
+         be provided by the extern, but we want true constants in order 
+         to allow constants as parameter initializers and other places
+         where compile-time constants are required -->
+    <true-constant>
+        <class>int</class>
+        <name>MAX_VALUE</name>
+        <value>2147483647</value>
+    </true-constant>
+    <true-constant>
+        <class>int</class>
+        <name>MIN_VALUE</name>
+        <value>-2147483648</value>
+    </true-constant>
+    <true-constant>
+        <class>uint</class>
+        <name>MAX_VALUE</name>
+        <value>4294967295</value>
+    </true-constant>
+    <true-constant>
+        <class>uint</class>
+        <name>MIN_VALUE</name>
+        <value>0</value>
+    </true-constant>
+    
 </royale-config>
diff --git a/js/src/main/javascript/missing.js b/js/src/main/javascript/missing.js
index a8f6ebc..d1c32b0 100644
--- a/js/src/main/javascript/missing.js
+++ b/js/src/main/javascript/missing.js
@@ -223,31 +223,26 @@ Array.prototype.removeAt = function(index) {};
  */
 Array.prototype.sortOn = function(fieldName, opt_options) {};
 
-
 /**
- * @type {number}
- * @const
+ * @const {int}
  */
 int.MAX_VALUE;
 
 
 /**
- * @type {number}
- * @const
+ * @const {int}
  */
 int.MIN_VALUE;
 
 
 /**
- * @type {number}
- * @const
+ * @const {uint}
  */
 uint.MAX_VALUE;
 
 
 /**
- * @type {number}
- * @const
+ * @const {uint}
  */
 uint.MIN_VALUE;
 


Mime
View raw message