Example #1
0
        private static ValueTable.ValueTable CreateAnnotationTable(AnnotationDefinition[] annotations)
        {
            var annotationsTable       = EmptyAnnotationsTable();
            var annotationNameColumn   = annotationsTable.Columns.FindColumnByName("Имя");
            var annotationParamsColumn = annotationsTable.Columns.FindColumnByName("Параметры");

            foreach (var annotation in annotations)
            {
                var annotationRow = annotationsTable.Add();
                if (annotation.Name != null)
                {
                    annotationRow.Set(annotationNameColumn, ValueFactory.Create(annotation.Name));
                }
                if (annotation.ParamCount != 0)
                {
                    var parametersTable      = new ValueTable.ValueTable();
                    var parameterNameColumn  = parametersTable.Columns.Add("Имя");
                    var parameterValueColumn = parametersTable.Columns.Add("Значение");

                    annotationRow.Set(annotationParamsColumn, parametersTable);

                    foreach (var annotationParameter in annotation.Parameters)
                    {
                        var parameterRow = parametersTable.Add();
                        if (annotationParameter.Name != null)
                        {
                            parameterRow.Set(parameterNameColumn, ValueFactory.Create(annotationParameter.Name));
                        }
                        parameterRow.Set(parameterValueColumn, annotationParameter.RuntimeValue);
                    }
                }
            }

            return(annotationsTable);
        }
Example #2
0
        private static void FillMethodsTableForType(TypeTypeValue type, ValueTable.ValueTable result)
        {
            var clrType    = GetReflectableClrType(type);
            var clrMethods = clrType.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

            FillMethodsTable(result, ConvertToOsMethods(clrMethods));
        }
Example #3
0
        private static ValueTable.ValueTable EmptyAnnotationsTable()
        {
            var annotationsTable = new ValueTable.ValueTable();

            annotationsTable.Columns.Add("Имя");
            annotationsTable.Columns.Add("Параметры");

            return(annotationsTable);
        }
Example #4
0
        private static void FillPropertiesTableForType(TypeTypeValue type, ValueTable.ValueTable result)
        {
            var clrType    = GetReflectableClrType(type);
            var mapper     = CreatePropertiesMapper(clrType);
            var actualType = mapper.GetType();
            var infos      = (IEnumerable <VariableInfo>)actualType.InvokeMember("GetProperties",
                                                                                 BindingFlags.InvokeMethod,
                                                                                 null,
                                                                                 mapper,
                                                                                 new object[0]);

            FillPropertiesTable(result, infos);
        }
Example #5
0
        private static void FillMethodsTable(ValueTable.ValueTable result, IEnumerable <MethodInfo> methods)
        {
            var nameColumn        = result.Columns.Add("Имя", TypeDescription.StringType(), "Имя");
            var countColumn       = result.Columns.Add("КоличествоПараметров", TypeDescription.IntegerType(), "Количество параметров");
            var isFunctionColumn  = result.Columns.Add("ЭтоФункция", TypeDescription.BooleanType(), "Это функция");
            var annotationsColumn = result.Columns.Add("Аннотации", new TypeDescription(), "Аннотации");
            var paramsColumn      = result.Columns.Add("Параметры", new TypeDescription(), "Параметры");

            foreach (var methInfo in methods)
            {
                if (!methInfo.IsExport)
                {
                    continue;
                }

                ValueTableRow new_row = result.Add();
                new_row.Set(nameColumn, ValueFactory.Create(methInfo.Name));
                new_row.Set(countColumn, ValueFactory.Create(methInfo.ArgCount));
                new_row.Set(isFunctionColumn, ValueFactory.Create(methInfo.IsFunction));

                if (methInfo.AnnotationsCount != 0)
                {
                    new_row.Set(annotationsColumn, CreateAnnotationTable(methInfo.Annotations));
                }

                var paramTable             = new ValueTable.ValueTable();
                var paramNameColumn        = paramTable.Columns.Add("Имя", TypeDescription.StringType(), "Имя");
                var paramByValue           = paramTable.Columns.Add("ПоЗначению", TypeDescription.BooleanType(), "По значению");
                var paramHasDefaultValue   = paramTable.Columns.Add("ЕстьЗначениеПоУмолчанию", TypeDescription.BooleanType(), "Есть значение по-умолчанию");
                var paramAnnotationsColumn = paramTable.Columns.Add("Аннотации", new TypeDescription(), "Аннотации");

                new_row.Set(paramsColumn, paramTable);

                if (methInfo.ArgCount != 0)
                {
                    var index = 0;
                    foreach (var param in methInfo.Params)
                    {
                        var name     = string.Format("param{0}", ++index);
                        var paramRow = paramTable.Add();
                        paramRow.Set(paramNameColumn, ValueFactory.Create(name));
                        paramRow.Set(paramByValue, ValueFactory.Create(param.IsByValue));
                        paramRow.Set(paramHasDefaultValue, ValueFactory.Create(param.HasDefaultValue));
                        if (param.AnnotationsCount != 0)
                        {
                            paramRow.Set(paramAnnotationsColumn, CreateAnnotationTable(param.Annotations));
                        }
                    }
                }
            }
        }
Example #6
0
        private static void FillMethodsTable(ValueTable.ValueTable result, IEnumerable <MethodInfo> methods)
        {
            var nameColumn       = result.Columns.Add("Имя", TypeDescription.StringType(), "Имя");
            var countColumn      = result.Columns.Add("КоличествоПараметров", TypeDescription.IntegerType(), "Количество параметров");
            var isFunctionColumn = result.Columns.Add("ЭтоФункция", TypeDescription.BooleanType(), "Это функция");

            foreach (var methInfo in methods)
            {
                ValueTableRow new_row = result.Add();
                new_row.Set(nameColumn, ValueFactory.Create(methInfo.Name));
                new_row.Set(countColumn, ValueFactory.Create(methInfo.ArgCount));
                new_row.Set(isFunctionColumn, ValueFactory.Create(methInfo.IsFunction));
            }
        }
Example #7
0
        private void FillPropertiesTable(ValueTable.ValueTable result, IEnumerable <VariableInfo> properties)
        {
            var nameColumn     = result.Columns.Add("Имя", TypeDescription.StringType(), "Имя");
            var systemVarNames = new string[] { "этотобъект", "thisobject" };

            foreach (var propInfo in properties)
            {
                if (systemVarNames.Contains(propInfo.Identifier.ToLower()))
                {
                    continue;
                }

                ValueTableRow newRow = result.Add();
                newRow.Set(nameColumn, ValueFactory.Create(propInfo.Identifier));
            }
        }
Example #8
0
        public ValueTable.ValueTable GetMethodsTable(IRuntimeContextInstance target)
        {
            ValueTable.ValueTable Result = new ValueTable.ValueTable();

            var NameColumn       = Result.Columns.Add("Имя", ValueFactory.Create(""), "Имя");                                    // TODO: Доработать после увеличения предела количества параметров
            var CountColumn      = Result.Columns.Add("КоличествоПараметров", ValueFactory.Create(""), "Количество параметров"); // TODO: Доработать после увеличения предела количества параметров
            var IsFunctionColumn = Result.Columns.Add("ЭтоФункция", ValueFactory.Create(""), "Это функция");                     // TODO: Доработать после увеличения предела количества параметров

            foreach (var methInfo in target.GetMethods())
            {
                ValueTableRow new_row = Result.Add();
                new_row.Set(NameColumn, ValueFactory.Create(methInfo.Name));
                new_row.Set(CountColumn, ValueFactory.Create(methInfo.ArgCount));
                new_row.Set(IsFunctionColumn, ValueFactory.Create(methInfo.IsFunction));
            }

            return(Result);
        }
Example #9
0
        public ValueTable.ValueTable GetMethodsTable(IRuntimeContextInstance target)
        {
            ValueTable.ValueTable Result = new ValueTable.ValueTable();

            var NameColumn       = Result.Columns.Add("Имя", TypeDescription.StringType(), "Имя");
            var CountColumn      = Result.Columns.Add("КоличествоПараметров", TypeDescription.IntegerType(), "Количество параметров");
            var IsFunctionColumn = Result.Columns.Add("ЭтоФункция", TypeDescription.BooleanType(), "Это функция");

            foreach (var methInfo in target.GetMethods())
            {
                ValueTableRow new_row = Result.Add();
                new_row.Set(NameColumn, ValueFactory.Create(methInfo.Name));
                new_row.Set(CountColumn, ValueFactory.Create(methInfo.ArgCount));
                new_row.Set(IsFunctionColumn, ValueFactory.Create(methInfo.IsFunction));
            }

            return(Result);
        }
Example #10
0
        private static void FillPropertiesTable(ValueTable.ValueTable result, IEnumerable <VariableInfo> properties)
        {
            var nameColumn        = result.Columns.Add("Имя", TypeDescription.StringType(), "Имя");
            var annotationsColumn = result.Columns.Add("Аннотации", new TypeDescription(), "Аннотации");
            var systemVarNames    = new string[] { "этотобъект", "thisobject" };

            foreach (var propInfo in properties)
            {
                if (systemVarNames.Contains(propInfo.Identifier.ToLower()))
                {
                    continue;
                }

                ValueTableRow new_row = result.Add();
                new_row.Set(nameColumn, ValueFactory.Create(propInfo.Identifier));

                new_row.Set(annotationsColumn, propInfo.AnnotationsCount != 0 ? CreateAnnotationTable(propInfo.Annotations) : EmptyAnnotationsTable());
            }
        }
Example #11
0
        public ValueTable.ValueTable GetMethodsTable(IValue target)
        {
            var result = new ValueTable.ValueTable();

            if (target.DataType == DataType.Object)
            {
                FillMethodsTableForObject(target.AsObject(), result);
            }
            else if (target.DataType == DataType.Type)
            {
                FillMethodsTableForType(target.GetRawValue() as TypeTypeValue, result);
            }
            else
            {
                throw RuntimeException.InvalidArgumentType();
            }

            return(result);
        }
Example #12
0
        public ValueTable.ValueTable GetPropertiesTable(IValue target)
        {
            ValueTable.ValueTable result = new ValueTable.ValueTable();

            if (target.DataType == DataType.Object)
            {
                FillPropertiesTable(result, target.AsObject().GetProperties());
            }
            else if (target.DataType == DataType.Type)
            {
                var type = target.GetRawValue() as TypeTypeValue;
                FillPropertiesTableForType(type, result);
            }
            else
            {
                throw RuntimeException.InvalidArgumentType();
            }

            return(result);
        }
Example #13
0
        public ValueTable.ValueTable GetPropertiesTable(IRuntimeContextInstance target)
        {
            ValueTable.ValueTable Result = new ValueTable.ValueTable();

            var NameColumn = Result.Columns.Add("Имя", TypeDescription.StringType(), "Имя");

            var SystemVarNames = new string[] { "этотобъект", "thisobject" };

            foreach (var propInfo in target.GetProperties())
            {
                if (SystemVarNames.Contains(propInfo.Identifier.ToLower()))
                {
                    continue;
                }

                ValueTableRow new_row = Result.Add();
                new_row.Set(NameColumn, ValueFactory.Create(propInfo.Identifier));
            }

            return(Result);
        }
Example #14
0
        private static void FillPropertiesTableForType(TypeTypeValue type, ValueTable.ValueTable result)
        {
            var clrType     = GetReflectableClrType(type);
            var nativeProps = clrType.GetProperties()
                              .Select(x => new
            {
                PropDef = x.GetCustomAttribute <ContextPropertyAttribute>(),
                Prop    = x
            })
                              .Where(x => x.PropDef != null);

            int indices = 0;
            var infos   = new List <VariableInfo>();

            foreach (var prop in nativeProps)
            {
                var info = new VariableInfo();
                info.Type        = SymbolType.ContextProperty;
                info.Index       = indices++;
                info.Identifier  = prop.PropDef.GetName();
                info.Annotations = GetAnnotations(prop.Prop.GetCustomAttributes <UserAnnotationAttribute>());
                infos.Add(info);
            }

            if (clrType.BaseType == typeof(ScriptDrivenObject))
            {
                var nativeFields = clrType.GetFields();
                foreach (var field in nativeFields)
                {
                    var info = new VariableInfo();
                    info.Type        = SymbolType.ContextProperty;
                    info.Index       = indices++;
                    info.Identifier  = field.Name;
                    info.Annotations = GetAnnotations(field.GetCustomAttributes <UserAnnotationAttribute>());
                    infos.Add(info);
                }
            }

            FillPropertiesTable(result, infos);
        }
Example #15
0
        public ValueTable.ValueTable GetPropertiesTable(IValue target)
        {
            ValueTable.ValueTable result = new ValueTable.ValueTable();

            if (target.DataType == DataType.Object)
            {
                FillPropertiesTable(result, target.AsObject().GetProperties());
            }
            else if (target.DataType == DataType.Type)
            {
                var type        = target.GetRawValue() as TypeTypeValue;
                var clrType     = GetReflectableClrType(type);
                var magicCaller = CreatePropertiesMapper(clrType);
                FillPropertiesTable(result, magicCaller.GetProperties());
            }
            else
            {
                throw RuntimeException.InvalidArgumentType();
            }

            return(result);
        }
 public ValueTableColumnCollection(ValueTable owner)
 {
     _owner = owner;
 }
Example #17
0
 private static void FillMethodsTableForObject(IRuntimeContextInstance target, ValueTable.ValueTable result)
 {
     FillMethodsTable(result, target.GetMethods());
 }
Example #18
0
 public ValueTableRow(ValueTable Owner)
 {
     _owner = new WeakReference(Owner);
 }
 public ValueTableRow(ValueTable owner)
 {
     _owner = owner;
 }