Example #1
0
 void VerifyProperties()
 {
     if (!allPropertiesVerified)
     {
         allPropertiesVerified = true;
         if (_PropertiesByName == null)
         {
             _PropertiesByName = new JsObject();
             _Properties       = new JsExtendedArray();
         }
         FillProperties(_JsType.definition);
         FillProperties(_JsType.staticDefinition);
         var baseType = BaseType;
         if (baseType != null)
         {
             var props = baseType.GetProperties();
             foreach (var pe in props)
             {
                 string name = pe.As <JsImplPropertyInfo>()._Name;
                 if (!_PropertiesByName.hasOwnProperty(name))
                 {
                     _PropertiesByName[name] = pe;
                     _Properties.push(pe);
                 }
             }
         }
     }
 }
Example #2
0
        void VerifyProperty(string name)
        {
            if (_PropertiesByName == null)
            {
                _PropertiesByName = new JsObject();
                _Properties       = new JsExtendedArray();
            }
            if (_PropertiesByName.hasOwnProperty(name))
            {
                return;
            }
            if (TryFillProperty(_JsType.definition, name))
            {
                return;
            }
            if (TryFillProperty(_JsType.staticDefinition, name))
            {
                return;
            }
            var baseType = BaseType;

            if (baseType != null)
            {
                var pe = baseType.GetProperty(name);
                if (pe != null)
                {
                    _PropertiesByName[name] = pe;
                    _Properties.push(pe);
                    return;
                }
            }
            _PropertiesByName[name] = null;            //mark as non existent
        }
Example #3
0
 void VerifyMethods()
 {
     if (_MethodsByName == null)
     {
         _MethodsByName = new JsObject <JsArray <MethodInfo> >();
         _Methods       = new JsExtendedArray();
         FillMethods(_JsType.definition);
         FillMethods(_JsType.staticDefinition);
         var baseType = BaseType;
         if (baseType != null)
         {
             var methods = baseType.GetMethods();
             foreach (var me in methods)
             {
                 if (_JsType.definition != null && _JsType.definition.hasOwnProperty(me.As <JsImplMethodInfo>().JsName))
                 {
                     continue;
                 }
                 if (_JsType.staticDefinition != null && _JsType.staticDefinition.hasOwnProperty(me.As <JsImplMethodInfo>().JsName))
                 {
                     continue;
                 }
                 var list = _MethodsByName[me.As <JsImplMethodInfo>()._Name];
                 if (list == null)
                 {
                     list = new JsArray <MethodInfo>();
                     _MethodsByName[me.As <JsImplMethodInfo>()._Name] = list;
                 }
                 list.push(me);
                 _Methods.push(me);
             }
         }
     }
 }
Example #4
0
        Type _MakeGenericType(JsExtendedArray typeArguments)
        {
            if (_MakeGenericTypeCache == null)
            {
                _MakeGenericTypeCache = new JsObject();
            }
            var key = "";

            for (var i = 0; i < typeArguments.length; i++)
            {
                var typeArg = typeArguments[i].As <JsImplType>();
                key += typeArg._Name;
            }
            var t = _MakeGenericTypeCache[key].As <JsImplType>();

            if (t == null)
            {
                t = new JsImplType(_JsType);
                _MakeGenericTypeCache[key] = t;
                t._Name = _Name;
                t._GenericTypeDefinition = this;
                t._TypeArguments         = typeArguments;
                t._Properties            = _Properties;
                t._PropertiesByName      = _PropertiesByName;
                t._Methods          = _Methods;
                t._MethodsByName    = _MethodsByName;
                t._DeclaringType    = _DeclaringType;
                t._CustomAttributes = _CustomAttributes;
            }
            return(t.As <Type>());
        }
Example #5
0
 void VerifyProperties()
 {
     if (!allPropertiesVerified)
     {
         allPropertiesVerified = true;
         if (_PropertiesByName == null)
         {
             _PropertiesByName = new JsObject();
             _Properties       = new JsExtendedArray();
         }
         FillProperties(_JsType.definition);
         FillProperties(_JsType.staticDefinition);
         var baseType = BaseType;
         if (baseType != null)
         {
             foreach (var pe in baseType.GetProperties())
             {
                 if (!_PropertiesByName.hasOwnProperty(pe._Name))
                 {
                     _PropertiesByName[pe._Name] = pe;
                     _Properties.push(pe);
                 }
             }
         }
     }
 }
Example #6
0
        public JsImplStringBuilder Remove(int start, int count)
        {
            var s = this.array.join("");

            s           = s.As <string>().Remove(start, count);
            this.array  = new object[] { s }.As <JsExtendedArray>();
            this.length = s.length;
            return(this);
        }
Example #7
0
        /// <summary>
        /// Retrieves an array of the values of the constants in a specified enumeration.
        /// </summary>
        /// <param name="enumType">Type of the enum.</param>
        /// <returns>An array that contains the values of the constants in enumType.</returns>
        /// <exception cref="ArgumentNullException"><para>enumType</para> is null.</exception>
        public static object[] GetValues(Type enumType)
		{
            if (enumType == null) throw new ArgumentNullException("enumType");

            var jsType = enumType.As<JsImplType>()._JsType;
			var array = new JsExtendedArray();
			foreach (var p in jsType.staticDefinition)
				array.push(jsType.staticDefinition[p]);
			return array.As<object[]>();
		}
Example #8
0
		public static object[] GetValues(Type type)
		{
			var jsType = type.As<JsImplType>()._JsType;
			var array = new JsExtendedArray();
			foreach (var p in jsType.staticDefinition)
			{
				array.push(jsType.staticDefinition[p]);
			}
			return array.As<object[]>();
		}
Example #9
0
		public static string[] GetNames(Type type)
		{
			var jsType = type.As<JsImplType>()._JsType;
			var array = new JsExtendedArray();
			foreach (var p in jsType.staticDefinition)
			{
				array.push(p);
			}
			return array.As<string[]>();
		}
Example #10
0
        public static object[] GetValues(Type type)
        {
            var jsType = type.As <JsImplType>()._JsType;
            var array  = new JsExtendedArray();

            foreach (var p in jsType.staticDefinition)
            {
                array.push(jsType.staticDefinition[p]);
            }
            return(array.As <object[]>());
        }
Example #11
0
        public static string[] GetNames(Type type)
        {
            var jsType = type.As <JsImplType>()._JsType;
            var array  = new JsExtendedArray();

            foreach (var p in jsType.staticDefinition)
            {
                array.push(p);
            }
            return(array.As <string[]>());
        }
Example #12
0
        public JsImplQueue(IEnumerable <T> collection)
        {
            var enumerator = collection.GetEnumerator();

            this._list = new JsExtendedArray();
            int i = 0;

            while (enumerator.MoveNext())
            {
                this._list[i++] = enumerator.Current;
            }
        }
Example #13
0
        /// <summary>
        /// Retrieves an array of the values of the constants in a specified enumeration.
        /// </summary>
        /// <param name="enumType">Type of the enum.</param>
        /// <returns>An array that contains the values of the constants in enumType.</returns>
        /// <exception cref="ArgumentNullException"><para>enumType</para> is null.</exception>
        public static object[] GetValues(Type enumType)
        {
            if (enumType == null)
            {
                throw new ArgumentNullException("enumType");
            }

            var jsType = enumType.As <JsImplType>()._JsType;
            var array  = new JsExtendedArray();

            foreach (var p in jsType.staticDefinition)
            {
                array.push(jsType.staticDefinition[p]);
            }
            return(array.As <object[]>());
        }
Example #14
0
        void VerifyConstructors()
        {
            if (_Constructors == null)
            {
                VerifyMethods();
                _Constructors = new JsExtendedArray();
                for (int i = 0; i < _JsType.ctors.As <JsArray>().length; i++)
                {
                    JsObject         ctorMeta   = _JsType.ctors[i.As <string>()].As <JsObject>();
                    string           ctorName   = ctorMeta["name"].As <string>();
                    JsArray <string> ctorParams = ctorMeta["parameters"].As <JsArray <string> >();
                    JsFunction       ctorFunc   = ctorMeta["_type"].As <JsObject>()[ctorName].As <JsFunction>();

                    var method = new JsImplConstructorInfo(ctorName, ctorFunc, ctorParams);
                    method._DeclaringType = this;
                    //method.JsName = funcName;
                    //method.JsFunction = func;
                    _Constructors.push(method);
                }
            }
        }
Example #15
0
 void VerifyMethods()
 {
     if (_MethodsByName == null)
     {
         _MethodsByName = new JsObject();
         _Methods       = new JsExtendedArray();
         FillMethods(_JsType.definition);
         FillMethods(_JsType.staticDefinition);
         var baseType = BaseType;
         if (baseType != null)
         {
             foreach (var pe in baseType.GetMethods())
             {
                 if (_MethodsByName[pe._Name] == null)
                 {
                     _MethodsByName[pe._Name] = pe;
                     _Methods.push(pe);
                 }
             }
         }
     }
 }
Example #16
0
        void FillMethods(JsObject def)
        {
            var isStatic = def == _JsType.staticDefinition;

            foreach (var funcName in def)
            {
                if (funcName == "toString")
                {
                    continue;
                }
                var func = def[funcName].As <JsFunction>();
                if (Js.Typeof(func) != "function")
                {
                    continue;
                }
                var methodName = JsNamingHelper.JsFunctionNameToClrMethodName(funcName);
                var methods    = _MethodsByName[methodName].As <JsExtendedArray>();
                if (methods == null)
                {
                    methods = new JsExtendedArray();
                    _MethodsByName[methodName] = methods;
                }
                //TODO: check overrides and parameters
                var method = new JsImplMethodInfo();
                methods.push(method);
                _Methods.push(method);
                method._Name          = methodName;
                method.JsName         = funcName;
                method.JsFunction     = func;
                method._DeclaringType = this;
                method._IsStatic      = _JsType.staticDefinition != null && _JsType.staticDefinition[funcName] == func;
                //var propType = VM.resolveMemberType2(def, propName);
                //if (propType != null)
                //  prop._MethodType = _TypeOf(propType);
            }
        }
Example #17
0
 public JsImplQueue()
 {
     this._list = new JsExtendedArray();
 }
Example #18
0
 public JsImplQueue(int capacity)
 {
     this._list = new JsExtendedArray(capacity);
 }
Example #19
0
 public JsImplStringBuilder(string s)
 {
     this.array  = new string[] { s }.As <JsExtendedArray>();
     this.length = s == null ? 0 : s.Length;
 }
Example #20
0
 public JsImplStack()
 {
     this._list = new JsExtendedArray();
 }
Example #21
0
 public JsImplStringBuilder()
 {
     this.array  = new string[0].As <JsExtendedArray>();
     this.length = 0;
 }