Esempio n. 1
0
 void initDecoders()
 {
     myDecoders[typeof(String)]    = new StringDecoder();
     myDecoders[typeof(UInt32)]    = new NumberDecoder <UInt32>();
     myDecoders[typeof(Int32)]     = new NumberDecoder <Int32>();
     myDecoders[typeof(UInt64)]    = new NumberDecoder <UInt64>();
     myDecoders[typeof(Int64)]     = new NumberDecoder <Int64>();
     myDecoders[typeof(float)]     = new NumberDecoder <float>();
     myDecoders[typeof(double)]    = new NumberDecoder <double>();
     myDecoders[typeof(bool)]      = new BoolDecoder();
     myDecoders[typeof(LuaObject)] = new LuaObjectDecoder();
 }
Esempio n. 2
0
        private static void _fieldSetter(int classId, IntPtr instancePtr, string fieldName, IntPtr valueBuffer, int bufferSize)
        {
            if (instancePtr != IntPtr.Zero &&
                _exportsFields.ContainsKey(classId) &&
                _exportsFields[classId].ContainsKey(fieldName))
            {
                LuaObjectClass instance     = Marshal.GetObjectForIUnknown(instancePtr) as LuaObjectClass;
                PropertyInfo   propertyInfo = _exportsFields[classId][fieldName];
                if (instance != null && propertyInfo != null && propertyInfo.CanWrite)
                {
                    LuaObjectDecoder decoder = new LuaObjectDecoder(valueBuffer, bufferSize);
                    LuaValue         value   = decoder.readObject() as LuaValue;

                    propertyInfo.SetValue(instance, getNativeValueForLuaValue(propertyInfo.PropertyType, value), null);
                }
            }
        }
Esempio n. 3
0
        private static void _fieldSetter(int classId, Int64 instancePtr, string fieldName, IntPtr valueBuffer, int bufferSize)
        {
            if (instancePtr != 0 &&
                _exportsFields.ContainsKey(classId) &&
                _exportsFields[classId].ContainsKey(fieldName))
            {
                LuaObjectReference objRef       = LuaObjectReference.findObject(instancePtr);
                LuaObjectClass     instance     = objRef.target as LuaObjectClass;
                PropertyInfo       propertyInfo = _exportsFields[classId][fieldName];
                if (instance != null && propertyInfo != null && propertyInfo.CanWrite)
                {
                    LuaObjectDecoder decoder = new LuaObjectDecoder(valueBuffer, bufferSize);
                    LuaValue         value   = decoder.readObject() as LuaValue;

                    propertyInfo.SetValue(instance, getNativeValueForLuaValue(propertyInfo.PropertyType, value), null);
                }
            }
        }
Esempio n. 4
0
        private static void _fieldSetterInvoke(int contextId, string className, Int64 instance, string fieldName, IntPtr valueBuffer, int bufferSize)
        {
            Type t = _exportsClasses [contextId][className];

            if (t != null &&
                instance != 0 &&
                _exportsFieldSetters.ContainsKey(className) &&
                _exportsFieldSetters[className].ContainsKey(fieldName))
            {
                LuaObjectReference objRef       = LuaObjectReference.findObject(instance);
                PropertyInfo       propertyInfo = _exportsFieldSetters[className][fieldName];
                if (objRef.target != null && propertyInfo != null && propertyInfo.CanWrite)
                {
                    LuaObjectDecoder decoder = new LuaObjectDecoder(valueBuffer, bufferSize);
                    LuaValue         value   = decoder.readObject() as LuaValue;

                    propertyInfo.SetValue(objRef.target, getNativeValueForLuaValue(propertyInfo.PropertyType, value), null);
                }
            }
        }
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="decode">解码器.</param>
 public LuaObjectInstanceDescriptor(LuaObjectDecoder decode)
     : base(decode)
 {
 }