Harbs, did you test trying calling defineSimpleGetter then
defineSimpleSetter to define a read/write property?  I would think
defineSimpleSetter would wipe out the getter.  IIRC, the object passed to
Object.defineProperty is not merged with any existing/prior object.

Thanks,
-Alex

On 3/15/18, 2:06 AM, "[email protected]" <[email protected]> wrote:

>This is an automated email from the ASF dual-hosted git repository.
>
>harbs pushed a commit to branch develop
>in repository 
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitbox.ap
>ache.org%2Frepos%2Fasf%2Froyale-asjs.git&data=02%7C01%7Caharui%40adobe.com
>%7C68535bf386224e27c2b008d58a541c7f%7Cfa7b1b5a7b34438794aed2c178decee1%7C0
>%7C0%7C636567016216425669&sdata=alUyYJmeNSjS%2BH3SIspygisJzNeysA1YjfjBKtna
>6lU%3D&reserved=0
>
>
>The following commit(s) were added to refs/heads/develop by this push:
>     new af19f12  Added utility function for adding JS getters
>af19f12 is described below
>
>commit af19f12fb623a473e16a4d83e0d89234abdaea4d
>Author: Harbs <[email protected]>
>AuthorDate: Thu Mar 15 11:06:51 2018 +0200
>
>    Added utility function for adding JS getters
>    
>    Added IEEventAdapterBead which adds required name getters for
>MouseEvent and KeyboardEvent protoypes.
>---
> .../Basic/src/main/resources/basic-manifest.xml    |  1 +
> .../apache/royale/html/beads/IEEventAdapterBead.as | 66
>++++++++++++++++++++++
> .../projects/Core/src/main/royale/CoreClasses.as   |  2 +
> .../org/apache/royale/utils/object/defineGetter.as | 34 +++++++++++
> .../royale/utils/object/defineSimpleGetter.as      | 38 +++++++++++++
> 5 files changed, 141 insertions(+)
>
>diff --git 
>a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
>b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
>index dbff20e..442fc49 100644
>--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
>+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
>@@ -96,6 +96,7 @@
> 
>     <component id="ApplicationParameters"
>class="org.apache.royale.html.beads.ApplicationParametersBead"/>
>     <component id="ApplicationParametersCaseInsensitive"
>class="org.apache.royale.html.beads.ApplicationParametersCaseInsensitiveBe
>ad"/>
>+    <component id="IEEventAdapter"
>class="org.apache.royale.html.beads.IEEventAdapterBead"/>
> 
>     <component id="SimpleAlert"
>class="org.apache.royale.html.SimpleAlert"/>
>     <component id="Alert" class="org.apache.royale.html.Alert"/>
>diff --git 
>a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/I
>EEventAdapterBead.as
>b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/I
>EEventAdapterBead.as
>new file mode 100644
>index 0000000..41711a6
>--- /dev/null
>+++ 
>b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/I
>EEventAdapterBead.as
>@@ -0,0 +1,66 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+//  Licensed to the Apache Software Foundation (ASF) under one or more
>+//  contributor license agreements.  See the NOTICE file distributed with
>+//  this work for additional information regarding copyright ownership.
>+//  The ASF licenses this file to You under the Apache License, Version
>2.0
>+//  (the "Licens"); you may not use this file except in compliance with
>+//  the License.  You may obtain a copy of the License at
>+//
>+//      
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.apache
>.org%2Flicenses%2FLICENSE-2.0&data=02%7C01%7Caharui%40adobe.com%7C68535bf3
>86224e27c2b008d58a541c7f%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6365
>67016216425669&sdata=Gg6raEdIO9ac3PPOqDowCbknYLq2LDgOb0ODKK8OIVs%3D&reserv
>ed=0
>+//
>+//  Unless required by applicable law or agreed to in writing, software
>+//  distributed under the License is distributed on an "AS IS" BASIS,
>+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+//  See the License for the specific language governing permissions and
>+//  limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+package org.apache.royale.html.beads
>+{
>+    import org.apache.royale.core.IBead;
>+    import org.apache.royale.core.IStrand;
>+      COMPILE::JS
>+      {
>+              import org.apache.royale.utils.object.defineSimpleGetter;
>+      }
>+
>+      /**
>+       *  The IEEventAdapterBead is used to get URL parameter values specified
>+     *  when loading an application. It's different than the
>ApplicationParametersBead
>+     *  in that URL parameter keys are case insensitive.
>+       * 
>+       *  @langversion 3.0
>+       *  @playerversion Flash 10.2
>+       *  @playerversion AIR 2.6
>+       *  @productversion Royale 0.9.2
>+       */
>+    public class IEEventAdapterBead implements IBead
>+    {
>+        public function IEEventAdapterBead()
>+        {
>+            
>+        }
>+
>+              /**
>+               *  @copy org.apache.royale.core.IBead#strand
>+               *  
>+               *  @langversion 3.0
>+               *  @playerversion Flash 10.2
>+               *  @playerversion AIR 2.6
>+               *  @productversion Royale 0.9.3
>+               */
>+              public function set strand(value:IStrand):void
>+              {
>+                      COMPILE::JS
>+                      {
>+                              if(typeof 
>window["KeyboardEvent"].prototype["name"] == "undefined")
>+                              {// IE does not have a prototype name property
>+                                      
>defineSimpleGetter(window["KeyboardEvent"].prototype,"name","Keyboar
>dEvent");
>+                                      
>defineSimpleGetter(window["MouseEvent"].prototype,"name","MouseEvent
>");
>+                              }
>+                      }
>+              }
>+
>+    }
>+}
>\ No newline at end of file
>diff --git a/frameworks/projects/Core/src/main/royale/CoreClasses.as
>b/frameworks/projects/Core/src/main/royale/CoreClasses.as
>index f29e2e5..8685789 100644
>--- a/frameworks/projects/Core/src/main/royale/CoreClasses.as
>+++ b/frameworks/projects/Core/src/main/royale/CoreClasses.as
>@@ -222,6 +222,8 @@ internal class CoreClasses
>       {
>               import org.apache.royale.core.WrappedHTMLElement 
> ;WrappedHTMLElement;
>           import org.apache.royale.core.IRoyaleElement; IRoyaleElement;
>+              import org.apache.royale.utils.object.defineGetter; 
>defineGetter;
>+              import org.apache.royale.utils.object.defineSimpleGetter;
>defineSimpleGetter;
>       }
>       //Package Level Functions
>       import org.apache.royale.debugging.assert; assert;
>diff --git 
>a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/object/
>defineGetter.as 
>b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/object/
>defineGetter.as
>new file mode 100644
>index 0000000..501cd14
>--- /dev/null
>+++ 
>b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/object/
>defineGetter.as
>@@ -0,0 +1,34 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+//  Licensed to the Apache Software Foundation (ASF) under one or more
>+//  contributor license agreements.  See the NOTICE file distributed with
>+//  this work for additional information regarding copyright ownership.
>+//  The ASF licenses this file to You under the Apache License, Version
>2.0
>+//  (the "License"); you may not use this file except in compliance with
>+//  the License.  You may obtain a copy of the License at
>+//
>+//      
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.apache
>.org%2Flicenses%2FLICENSE-2.0&data=02%7C01%7Caharui%40adobe.com%7C68535bf3
>86224e27c2b008d58a541c7f%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6365
>67016216425669&sdata=Gg6raEdIO9ac3PPOqDowCbknYLq2LDgOb0ODKK8OIVs%3D&reserv
>ed=0
>+//
>+//  Unless required by applicable law or agreed to in writing, software
>+//  distributed under the License is distributed on an "AS IS" BASIS,
>+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+//  See the License for the specific language governing permissions and
>+//  limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+package org.apache.royale.utils.object
>+{
>+      /**
>+       *  Defines a getter function on a Javascript object (often used to add
>to prototypes)
>+     *  Takes a function which returns a value
>+       *  @langversion 3.0
>+       *  @playerversion Flash 10.2
>+       *  @playerversion AIR 2.6
>+       *  @productversion Royale 0.9.3
>+       */
>+    public function
>defineGetter(obj:Object,prop:String,getterFunction:Function):void
>+    {
>+            Object.defineProperty(obj, prop, {"get": getterFunction});
>+        }
>+    
>+}
>\ No newline at end of file
>diff --git 
>a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/object/
>defineSimpleGetter.as
>b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/object/
>defineSimpleGetter.as
>new file mode 100644
>index 0000000..42b5d9f
>--- /dev/null
>+++ 
>b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/object/
>defineSimpleGetter.as
>@@ -0,0 +1,38 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+//  Licensed to the Apache Software Foundation (ASF) under one or more
>+//  contributor license agreements.  See the NOTICE file distributed with
>+//  this work for additional information regarding copyright ownership.
>+//  The ASF licenses this file to You under the Apache License, Version
>2.0
>+//  (the "License"); you may not use this file except in compliance with
>+//  the License.  You may obtain a copy of the License at
>+//
>+//      
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.apache
>.org%2Flicenses%2FLICENSE-2.0&data=02%7C01%7Caharui%40adobe.com%7C68535bf3
>86224e27c2b008d58a541c7f%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6365
>67016216425669&sdata=Gg6raEdIO9ac3PPOqDowCbknYLq2LDgOb0ODKK8OIVs%3D&reserv
>ed=0
>+//
>+//  Unless required by applicable law or agreed to in writing, software
>+//  distributed under the License is distributed on an "AS IS" BASIS,
>+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+//  See the License for the specific language governing permissions and
>+//  limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+package org.apache.royale.utils.object
>+{
>+      /**
>+       *  Defines a getter function on a Javascript object (often used to add
>to prototypes)
>+     *  Takes a simple value to return.
>+       *  @langversion 3.0
>+       *  @playerversion Flash 10.2
>+       *  @playerversion AIR 2.6
>+       *  @productversion Royale 0.9.3
>+       */
>+    public function
>defineSimpleGetter(obj:Object,prop:String,returnVal:*):void
>+    {
>+            Object.defineProperty(obj, prop, {
>+                "get": function ():* {
>+                    return returnVal;
>+                }
>+            });
>+        }
>+    
>+}
>\ No newline at end of file
>
>-- 
>To stop receiving notification emails like this one, please contact
>[email protected].

Reply via email to