Exemplo n.º 1
0
 JsImplType _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;
 }
Exemplo n.º 2
0
 void VerifyMethods()
 {
     if (_MethodsByName == null)
     {
         _MethodsByName = new JsObject<JsArray<JsImplMethodInfo>>();
         _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.JsName))
                     continue;
                 if (_JsType.staticDefinition != null && _JsType.staticDefinition.hasOwnProperty(me.JsName))
                     continue;
                 var list = _MethodsByName[me._Name];
                 if (list == null)
                 {
                     list = new JsArray<JsImplMethodInfo>();
                     _MethodsByName[me._Name] = list;
                 }
                 list.push(me);
                 _Methods.push(me);
             }
         }
     }
 }
Exemplo n.º 3
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)
             {
                 if (!_PropertiesByName.hasOwnProperty(pe._Name))
                 {
                     _PropertiesByName[pe._Name] = pe;
                     _Properties.push(pe);
                 }
             }
         }
     }
 }
Exemplo n.º 4
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
 }
Exemplo n.º 5
0
		void VerifyMethods()
		{
			if (_MethodsByName == null)
			{
				_MethodsByName = new JsObject();
				_Methods = new JsExtendedArray();
				FillMethods(_JsType.definition);
				FillMethods(_JsType.staticDefinition);
				var baseType = BaseType;
				if (baseType != null)
				{
                    var methods = baseType.GetMethods();
					foreach (var pe in methods)
					{
						if (_MethodsByName[pe._Name] == null)
						{
							_MethodsByName[pe._Name] = pe;
							_Methods.push(pe);
						}
					}
				}
			}
		}
Exemplo n.º 6
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);
			}

		}