Example #1
0
        public NativeDescriptor MarshalPropertyInfo(
            PropertyInfo prop,
            JsDictionaryObject owner)
        {
            JsSetter setter = (JsSetter)null;
            JsGetter getter = !prop.CanRead || prop.GetGetMethod() == null ? (JsGetter)(that => (JsInstance)JsUndefined.Instance) : this.WrapGetProperty(prop);

            if (prop.CanWrite && prop.GetSetMethod() != null)
            {
                setter = this.WrapSetProperty(prop);
            }
            NativeDescriptor nativeDescriptor1;

            if (setter != null)
            {
                NativeDescriptor nativeDescriptor2 = new NativeDescriptor(owner, prop.Name, getter, setter);
                nativeDescriptor2.Enumerable = true;
                nativeDescriptor1            = nativeDescriptor2;
            }
            else
            {
                nativeDescriptor1            = new NativeDescriptor(owner, prop.Name, getter);
                nativeDescriptor1.Enumerable = true;
            }
            return(nativeDescriptor1);
        }
Example #2
0
        public NativeDescriptor MarshalFieldInfo(
            FieldInfo prop,
            JsDictionaryObject owner)
        {
            JsGetter getter;
            JsSetter setter;

            if (prop.IsLiteral)
            {
                JsInstance value = (JsInstance)null;
                getter = (JsGetter)(that =>
                {
                    if (value == null)
                    {
                        value = (JsInstance)typeof(Marshaller).GetMethod("MarshalClrValue").MakeGenericMethod(prop.FieldType).Invoke((object)this, new object[1]
                        {
                            prop.GetValue((object)null)
                        });
                    }
                    return(value);
                });
                setter = (JsSetter)((that, v) => {});
            }
            else
            {
                getter = this.WrapGetField(prop);
                setter = this.WrapSetField(prop);
            }
            NativeDescriptor nativeDescriptor = new NativeDescriptor(owner, prop.Name, getter, setter);

            nativeDescriptor.Enumerable = true;
            return(nativeDescriptor);
        }
    private void _addBtnClick(object sender, EventArgs e)
    {
        var theButton       = (Button)sender;
        NativeDescriptor nd = (NativeDescriptor)_nativeNameDDL.SelectedItem;

        var textToAppend = "";

        if (_propertyControlGrid.SelectedRows.Count > 0)
        {
            textToAppend = _propertyControlGrid.SelectedRows[0].Cells[1].Value.ToString();
        }
        else
        {
            textToAppend = nd.ToCodeFormat();
        }

        if (theButton.Name == "_addOnTickBtn")
        {
            _ontickText.AppendText(textToAppend);
            _ontickText.AppendText("");
            _ontickText.Select();
        }
        else if (theButton.Name == "_addImmediateBtn")
        {
            _immediateText.AppendText(textToAppend);
            _immediateText.AppendText("");
            _immediateText.Select();
        }
        else if (theButton.Name == "_addToPropBtn")
        {
            OnAddProp(nd.NativeName, nd.ToCodeFormat());
        }
    }
 public ImmediateBoundItem(NativeDescriptor nativeDescriptor)
 {
     if (nativeDescriptor == null)
     {
         return;
     }
     Name = nativeDescriptor.NativeName;
 }
    // Native Name selected
    void _nativeNameDDL_SelectedValueChanged(object sender, EventArgs e)
    {
        NativeDescriptor nd = (NativeDescriptor)_nativeNameDDL.SelectedItem;

        _addToPropBtn.Enabled       = true;
        _addOnTickBtn.Enabled       = true;
        _addImmediateButton.Enabled = true;
        Debug.WriteLine(nd.ToLongName());
    }
 public static NativeDescriptor InitNativeDescriptor(UInt64 hash)
 {
     if (hash == 0)
     {
         // For testing param marshalling
         _currentNativeDescriptor = NativeDescriptor.TestNativeDescriptor;
     }
     else
     {
         _currentNativeDescriptor = _nativeDescriptorMap.ContainsKey(hash) ? _nativeDescriptorMap[hash] : null;
         if (_currentNativeDescriptor == null)
         {
             Debug.WriteLine("Init Hash lookup not found: " + hash);
             return(_currentNativeDescriptor);
         }
         _currentNativeDescriptor.Reset();
         _currentNativeDescriptor.NativeProcessState = NativeProcessState.ReadyInit;
         _currentNativeDescriptor.IsNativeFiltered   = (_filterList.Contains(_currentNativeDescriptor.NativeName));
     }
     return(_currentNativeDescriptor);
 }
Example #7
0
    private static void buildNativeMap()
    {
        try
        {
            var fileLines = getNativesList();

            ItemGroup currentItemGroup = ItemGroup.Select;
            foreach (var _line in fileLines)
            {
                var line = _line.Trim();

                if (!line.StartsWith("static") && !line.StartsWith("namespace"))
                    continue;

                // var nativeDescriptor = new NativeDescriptor();
                NativeDescriptor nativeDescriptor = new NativeDescriptor();

                if (line.StartsWith("namespace"))
                {
                    var category = line.Split(" ".ToCharArray())[1];
                    currentItemGroup = (ItemGroup) Enum.Parse(typeof (ItemGroup), category);
                    nativeDescriptor.ItemGroup = currentItemGroup;
                }
                else if (line.StartsWith("static"))
                {
                    nativeDescriptor.ParamList = new List<NativeParam>();

                    // var nativeBoundItem = new NativeBoundItem();

                    var methodDeclare = line.Split("{".ToCharArray())[0].Trim();
                    var invokeDeclare = line.Split("{".ToCharArray())[1].Trim();
                    var methodParts = methodDeclare.Split(" ".ToCharArray());

                    var hashDeclare =
                        invokeDeclare.Split("(".ToCharArray())[1].Split(",".ToCharArray())[0].Split(")".ToCharArray())[0
                            ];

                    nativeDescriptor.NativeHash = UInt64.Parse(hashDeclare.Replace("0x", ""), NumberStyles.HexNumber);

                    nativeDescriptor.ReturnTypeName = methodParts[1];

                    var methodNameFirstParamDeclare = methodParts[2].Split("(".ToCharArray());
                    nativeDescriptor.NativeName = methodNameFirstParamDeclare[0];

                    if (methodNameFirstParamDeclare[1] != ")")
                    {
                        // Params
                        var methodParamList = methodDeclare.Split("(".ToCharArray());
                        var paramListString = methodParamList[1].TrimEnd(")".ToCharArray());
                        var typeAndNameParts = paramListString.Split(",".ToCharArray());
                        foreach (var _typeAndNamePair in typeAndNameParts)
                        {
                            var typeAndNamePair = _typeAndNamePair.Trim();
                            var typeAndName = typeAndNamePair.Split(" ".ToCharArray());
                            if (typeAndName.Length == 1)
                                typeAndName = typeAndNameParts;

                            var paramTypeName = typeAndName[0];
                            var paramName = typeAndName[1];

                            nativeDescriptor.ParamList.Add(new NativeParam(paramTypeName, paramName));
                        }
                    }

                    nativeDescriptor.ItemGroup = currentItemGroup;
                    _nativeDescriptorMap.Add(nativeDescriptor.NativeHash, nativeDescriptor);
                }
            }
        }
        catch (Exception e)
        {
            throw new Exception("Init Failed ", e);
        }
    }
Example #8
0
 public static NativeDescriptor InitNativeDescriptor(UInt64 hash)
 {
     if (hash == 0)
     {
         // For testing param marshalling
         _currentNativeDescriptor = NativeDescriptor.TestNativeDescriptor;
     }
     else
     {
         _currentNativeDescriptor = _nativeDescriptorMap.ContainsKey(hash) ? _nativeDescriptorMap[hash] : null;
         if (_currentNativeDescriptor == null)
         {
             Debug.WriteLine("Init Hash lookup not found: " + hash);
             return _currentNativeDescriptor;
         }
         _currentNativeDescriptor.Reset();
         _currentNativeDescriptor.NativeProcessState = NativeProcessState.ReadyInit;
         _currentNativeDescriptor.IsNativeFiltered = (_filterList.Contains(_currentNativeDescriptor.NativeName));
     }
     return _currentNativeDescriptor;
 }
    private static void buildNativeMap()
    {
        try
        {
            var fileLines = getNativesList();

            ItemGroup currentItemGroup = ItemGroup.Select;
            foreach (var _line in fileLines)
            {
                var line = _line.Trim();

                if (!line.StartsWith("static") && !line.StartsWith("namespace"))
                {
                    continue;
                }

                // var nativeDescriptor = new NativeDescriptor();
                NativeDescriptor nativeDescriptor = new NativeDescriptor();

                if (line.StartsWith("namespace"))
                {
                    var category = line.Split(" ".ToCharArray())[1];
                    currentItemGroup           = (ItemGroup)Enum.Parse(typeof(ItemGroup), category);
                    nativeDescriptor.ItemGroup = currentItemGroup;
                }
                else if (line.StartsWith("static"))
                {
                    nativeDescriptor.ParamList = new List <NativeParam>();

                    // var nativeBoundItem = new NativeBoundItem();

                    var methodDeclare = line.Split("{".ToCharArray())[0].Trim();
                    var invokeDeclare = line.Split("{".ToCharArray())[1].Trim();
                    var methodParts   = methodDeclare.Split(" ".ToCharArray());

                    var hashDeclare =
                        invokeDeclare.Split("(".ToCharArray())[1].Split(",".ToCharArray())[0].Split(")".ToCharArray())[0
                        ];

                    nativeDescriptor.NativeHash = UInt64.Parse(hashDeclare.Replace("0x", ""), NumberStyles.HexNumber);

                    nativeDescriptor.ReturnTypeName = methodParts[1];

                    var methodNameFirstParamDeclare = methodParts[2].Split("(".ToCharArray());
                    nativeDescriptor.NativeName = methodNameFirstParamDeclare[0];

                    if (methodNameFirstParamDeclare[1] != ")")
                    {
                        // Params
                        var methodParamList  = methodDeclare.Split("(".ToCharArray());
                        var paramListString  = methodParamList[1].TrimEnd(")".ToCharArray());
                        var typeAndNameParts = paramListString.Split(",".ToCharArray());
                        foreach (var _typeAndNamePair in typeAndNameParts)
                        {
                            var typeAndNamePair = _typeAndNamePair.Trim();
                            var typeAndName     = typeAndNamePair.Split(" ".ToCharArray());
                            if (typeAndName.Length == 1)
                            {
                                typeAndName = typeAndNameParts;
                            }

                            var paramTypeName = typeAndName[0];
                            var paramName     = typeAndName[1];

                            nativeDescriptor.ParamList.Add(new NativeParam(paramTypeName, paramName));
                        }
                    }

                    nativeDescriptor.ItemGroup = currentItemGroup;
                    _nativeDescriptorMap.Add(nativeDescriptor.NativeHash, nativeDescriptor);
                }
            }
        }
        catch (Exception e)
        {
            throw new Exception("Init Failed ", e);
        }
    }
Example #10
0
 public ImmediateBoundItem(NativeDescriptor nativeDescriptor)
 {
     if (nativeDescriptor == null)
         return;
     Name = nativeDescriptor.NativeName;
 }