Ejemplo n.º 1
0
        protected IEnumerable <IMember> GetExportedDeclaredAndGeneratedFields(ITypeDefinition ce, bool isStatic)
        {
            foreach (var pe in ce.GetFields(t => t.IsStatic == isStatic, GetMemberOptions.IgnoreInheritedMembers))
            {
                if (!JMeta.IsJsExported(pe))
                {
                    continue;
                }
                yield return(pe);
            }

            foreach (var pe in ce.GetEvents(t => t.IsStatic == isStatic, GetMemberOptions.IgnoreInheritedMembers))
            {
                if (!JMeta.IsJsExported(pe))
                {
                    continue;
                }
                yield return(pe);
            }

            foreach (var fe in GeneratePropertyFields(ce, isStatic))
            {
                yield return(fe);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Generates backing fields for automatic properties, and fake fields for properties who are defined as fields
 /// </summary>
 /// <param name="ce"></param>
 /// <returns></returns>
 protected IEnumerable <IField> GeneratePropertyFields(ITypeDefinition ce, bool isStatic)
 {
     //var list = new List<IField>();
     foreach (var pe in ce.GetProperties(t => t.IsStatic == isStatic, GetMemberOptions.IgnoreInheritedMembers))
     {
         if (!JMeta.IsJsExported(pe))
         {
             continue;
         }
         if (JMeta.IsNativeField(pe))
         {
             yield return(GenerateFakeField(pe));
         }
         else if (pe.IsAutomaticProperty(Compiler.Project))
         {
             yield return(GenerateBackingField(pe));
         }
     }
     //return list;
 }
Ejemplo n.º 3
0
        public virtual List <JEntityDeclaration> _VisitEnum(ITypeDefinition ce)
        {
            var unit = new JUnit {
                Statements = new List <JStatement>()
            };

            ExportTypeNamespace(ce);
            var  att = ce.GetMetadata <JEnumAttribute>();
            bool valuesAsNames;

            JMeta.UseJsonEnums(ce, out valuesAsNames);
            //var valuesAsNames = att != null && att.ValuesAsNames;
            var constants = ce.GetConstants().ToList();

            if (!valuesAsNames && constants.Where(t => t.ConstantValue == null).FirstOrDefault() != null)
            {
                var value = 0L;
                foreach (var c in constants)
                {
                    if (c.ConstantValue == null)
                    {
                        c.SetConstantValue(value);
                    }
                    else
                    {
                        value = Convert.ToInt64(c.ConstantValue);
                    }
                    value++;
                }
            }
            constants.RemoveAll(t => !JMeta.IsJsExported(t));
            var json = new JJsonObjectExpression {
                NamesValues = new List <JJsonNameValue>()
            };

            json.NamesValues.AddRange(constants.Select(t => Export(t, valuesAsNames)));
            var st = ce.JAccess().Assign(json).Statement();

            unit.Statements.Add(st);
            throw new NotSupportedException();
        }
Ejemplo n.º 4
0
        protected List <IMethod> GetAccessorsToExport(IProperty pe)
        {
            var list = new List <IMethod>();

            if (pe.IsAutomaticProperty(Compiler.Project) && !JMeta.IsNativeField(pe))
            {
                list.Add(pe.Getter);
                list.Add(pe.Setter);
            }
            else
            {
                if (pe.Getter != null)
                {
                    list.Add(pe.Getter);
                }
                if (pe.Setter != null)
                {
                    list.Add(pe.Setter);
                }
            }
            list.RemoveAll(t => !JMeta.IsJsExported(t));
            return(list);
        }
Ejemplo n.º 5
0
        //JsTypeImporter_ExtJs ExtJsExport;

        private bool ShouldExportType(ITypeDefinition ce)
        {
            return(JMeta.IsJsExported(ce));
        }
Ejemplo n.º 6
0
 bool ShouldExportMethodBody(IMethod me)
 {
     return(JMeta.IsJsExported(me) && me.GetMethodDeclaration() != null && !me.IsAnonymousMethod());
 }