public TheMethod GetMethod(CsEntityMethod pMethod, FactoryExpressionCreator pCreator) { if (pMethod.decl != null) { return(GetMethod((CsMethod)pMethod.decl)); } TheMethod c; if (_entityMethods.TryGetValue(pMethod, out c)) { return(c); } c = new TheMethod(pMethod, this, pCreator); Dictionary <string, bool> methodNames = new Dictionary <string, bool>(); foreach (KeyValuePair <CsEntityMethod, TheMethod> entityMethod in _entityMethods.Where(pEntityMethod => methodNames.ContainsKey(pEntityMethod.Value.Name))) { entityMethod.Value._isUnique = false; c._isUnique = false; } _entityMethods.Add(pMethod, c); return(c); }
public TheEvent(CsEvent pCsEvent, TheClass pTheClass, FactoryExpressionCreator pCreator) { MyClass = pTheClass; if (pCsEvent.declarators.Count > 1) throw new Exception("No more than one event declaration per handler is supported"); _declarator = pCsEvent.declarators.First.Value; Name = _declarator.identifier.identifier;//RealName = //FullRealName = MyClass.FullRealName + "." + RealName; FullName = MyClass.FullName + "." + Name; Modifiers.AddRange(Helpers.GetModifiers(pCsEvent.modifiers)); string eventName = Helpers.GetEventFromAttr(pCsEvent.attributes, pCreator); IsFlashEvent = !string.IsNullOrEmpty(eventName); Add = new TheMethod(_declarator.entity.add, pTheClass, pCreator, true, true); Remove = new TheMethod(_declarator.entity.remove, pTheClass, pCreator, true); EventName = Helpers.GetEventFromAttr(pCsEvent.attributes, pCreator); }
public TheClass(CsEntity pCsEntity, FactoryExpressionCreator pCreator) { IsEntity = true; List <string> name = new List <string>(); CsEntity parent = pCsEntity.parent; while (parent != null && parent is CsEntityNamespace) { if (!string.IsNullOrEmpty(parent.name)) { name.Add(parent.name); } parent = parent.parent; } name.Reverse(); NameSpace = string.Join(".", name.ToArray()); //RealName = pCsEntity.name; //Name = Helpers.GetRealName(pCsEntity, RealName); Name = pCsEntity.name; FullName = NameSpace + "." + Name; //FullRealName = NameSpace + "." + RealName; CsEntityClass klass = pCsEntity as CsEntityClass; if (klass != null) { _baseEntityTyperef = klass.base_type; if (klass.base_type.type != cs_entity_type.et_object) { Extends.Add(Helpers.GetType(klass.base_type)); } if (klass.interfaces != null) { foreach (CsEntityTypeRef @interface in klass.interfaces) { Implements.Add(Helpers.GetType(@interface)); } } Dictionary <string, int> methodNames = new Dictionary <string, int>(); //bool constructorsDone = false; bool methodsDone = false; if (klass.method_implementations == null) { return; } foreach (CsEntityMethodImplementation methodImplementation in klass.method_implementations) { CsEntityMethod m = methodImplementation.implementation_method; TheMethod tm = new TheMethod(m, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!methodsDone) { methodsDone = true; foreach (KeyValuePair <CsMethod, TheMethod> method in _methods) { method.Value._isUnique = false; method.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _entityMethods.Add(m, tm); } return; } CsEntityInterface entityInterface = pCsEntity as CsEntityInterface; if (entityInterface != null) { _baseEntityTyperef = entityInterface.base_type; if (entityInterface.base_type.type != cs_entity_type.et_object) { Extends.Add(Helpers.GetType(entityInterface.base_type)); } if (entityInterface.interfaces != null) { foreach (CsEntityTypeRef @interface in entityInterface.interfaces) { Implements.Add(Helpers.GetType(@interface)); } } Dictionary <string, int> methodNames = new Dictionary <string, int>(); bool methodsDone = false; if (entityInterface.method_implementations == null) { return; } foreach (CsEntityMethodImplementation methodImplementation in entityInterface.method_implementations) { CsEntityMethod m = methodImplementation.implementation_method; TheMethod tm = new TheMethod(m, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!methodsDone) { methodsDone = true; foreach (KeyValuePair <CsMethod, TheMethod> method in _methods) { method.Value._isUnique = false; method.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _entityMethods.Add(m, tm); } return; } CsEntityStruct entityStruct = pCsEntity as CsEntityStruct; if (entityStruct != null) { _baseEntityTyperef = entityStruct.base_type; if (entityStruct.base_type.type != cs_entity_type.et_object) { Extends.Add(Helpers.GetType(entityStruct.base_type)); } if (entityStruct.interfaces != null) { foreach (CsEntityTypeRef @interface in entityStruct.interfaces) { Implements.Add(Helpers.GetType(@interface)); } } Dictionary <string, int> methodNames = new Dictionary <string, int>(); bool methodsDone = false; if (entityStruct.method_implementations == null) { return; } foreach (CsEntityMethodImplementation methodImplementation in entityStruct.method_implementations) { CsEntityMethod m = methodImplementation.implementation_method; TheMethod tm = new TheMethod(m, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!methodsDone) { methodsDone = true; foreach (KeyValuePair <CsMethod, TheMethod> method in _methods) { method.Value._isUnique = false; method.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _entityMethods.Add(m, tm); } return; } throw new NotImplementedException(); }
public TheClass(CsInterface pCsInterface, FactoryExpressionCreator pCreator) { IsInterface = true; List <string> name = new List <string>(); CsNamespace parent = pCsInterface.parent as CsNamespace; if (parent != null) { name.AddRange(parent.qualified_identifier.Select(pArt => pArt.identifier.identifier)); } NameSpace = string.Join(".", name.ToArray()); Name = pCsInterface.identifier.identifier; FullName = NameSpace + "." + Name; if (pCsInterface.type_base != null && pCsInterface.type_base.base_list.Count != 0) { foreach (CsTypeRef typeRef in pCsInterface.type_base.base_list) { object u = typeRef.entity_typeref.u; if (u == null) { continue; } if (u is CsEntityClass) { Extends.Add(Helpers.GetType(typeRef.type_name)); _baseTyperef = typeRef; } else if (u is CsEntityInterface) { Implements.Add(Helpers.GetType(typeRef.type_name)); } else if (u is CsEntityInstanceSpecifier) { Implements.Add(Helpers.GetType(typeRef.type_name)); } else { throw new NotSupportedException(); } } } Dictionary <string, int> methodNames = new Dictionary <string, int>(); bool methodsDone = false; if (pCsInterface.member_declarations != null) { foreach (CsNode memberDeclaration in pCsInterface.member_declarations) { CsMethod m = memberDeclaration as CsMethod; if (m != null) { if (m.interface_type != null) { continue; } TheMethod tm = new TheMethod(m, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!methodsDone) { methodsDone = true; foreach (KeyValuePair <CsMethod, TheMethod> method in _methods) { method.Value._isUnique = false; method.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _methods.Add(m, tm); continue; } CsIndexer i = memberDeclaration as CsIndexer; if (i != null) { _indexers.Add(i, new TheIndexer(i, this, pCreator)); continue; } CsVariableDeclaration v = memberDeclaration as CsVariableDeclaration; if (v != null) { _variables.Add(v, new TheVariable(v, this, pCreator)); continue; } CsProperty p = memberDeclaration as CsProperty; if (p != null) { if (p.interface_type == null) { _properties.Add(p, new TheProperty(p, this, pCreator)); } continue; } throw new NotImplementedException("Unknown type not implemented"); } } Modifiers.AddRange(Helpers.GetModifiers(pCsInterface.modifiers)); }
public TheClass(CsClassStruct pCsClass, FactoryExpressionCreator pCreator) { CsNamespace csNamespace; _creator = pCreator; List <string> name = new List <string>(); if (pCsClass.parent is CsClass) { IsPrivate = true; csNamespace = (CsNamespace)pCsClass.parent.parent; } else { csNamespace = (CsNamespace)pCsClass.parent; } CsQualifiedIdentifier list = csNamespace.qualified_identifier; name.AddRange(list.Select(pIdentifier => pIdentifier.identifier.identifier)); if (IsPrivate) { name.Add(((CsClass)pCsClass.parent).identifier.identifier); } NameSpace = string.Join(".", name.ToArray()); //RealName = pCsClass.identifier.identifier; //Name = Helpers.GetRealName(pCsClass, RealName); Name = pCsClass.identifier.identifier; FullName = NameSpace + "." + Name; //FullRealName = NameSpace + "." + RealName; if (pCsClass.type_base != null && pCsClass.type_base.base_list.Count != 0) { foreach (CsTypeRef typeRef in pCsClass.type_base.base_list) { object u = typeRef.entity_typeref.u; if (u == null) { continue; } if (u is CsEntityClass) { Extends.Add(Helpers.GetType(typeRef.type_name)); _baseTyperef = typeRef; } else if (u is CsEntityInterface) { Implements.Add(Helpers.GetType(typeRef.type_name)); } else if (u is CsEntityInstanceSpecifier) { Implements.Add(Helpers.GetType(typeRef.type_name)); //CsEntityInstanceSpecifier specifier = (CsEntityInstanceSpecifier)typeRef.entity_typeref.u; } else { throw new NotSupportedException(); } } } Dictionary <string, int> methodNames = new Dictionary <string, int>(); bool constructorsDone = false; bool methodsDone = false; if (pCsClass.member_declarations != null) { foreach (CsNode memberDeclaration in pCsClass.member_declarations) { CsConstructor c = memberDeclaration as CsConstructor; if (c != null) { TheConstructor tm = new TheConstructor(c, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!constructorsDone) { constructorsDone = true; foreach (KeyValuePair <CsConstructor, TheConstructor> constructor in _constructors) { constructor.Value._isUnique = false; constructor.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _constructors.Add(c, tm); continue; } CsMethod m = memberDeclaration as CsMethod; if (m != null) { if (m.interface_type != null) { continue; } TheMethod tm = new TheMethod(m, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!methodsDone) { methodsDone = true; foreach (KeyValuePair <CsMethod, TheMethod> method in _methods) { method.Value._isUnique = false; method.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _methods.Add(m, tm); continue; } CsIndexer i = memberDeclaration as CsIndexer; if (i != null) { _indexers.Add(i, new TheIndexer(i, this, pCreator)); continue; } CsVariableDeclaration v = memberDeclaration as CsVariableDeclaration; if (v != null) { _variables.Add(v, new TheVariable(v, this, pCreator)); continue; } CsConstantDeclaration k = memberDeclaration as CsConstantDeclaration; if (k != null) { _constants.Add(k, new TheConstant(k, this, pCreator)); continue; } CsProperty p = memberDeclaration as CsProperty; if (p != null) { if (p.interface_type == null) { _properties.Add(p, new TheProperty(p, this, pCreator)); } continue; } CsDelegate d = memberDeclaration as CsDelegate; if (d != null) { _delegates.Add(d, new TheDelegate(d, this, pCreator)); continue; } CsEvent e = memberDeclaration as CsEvent; if (e != null) { TheEvent theEvent = new TheEvent(e, this, pCreator); _events.Add(theEvent.Name, theEvent); continue; } CsClass csClass = memberDeclaration as CsClass; if (csClass != null) { continue; } throw new NotImplementedException("Unknown type not implemented"); } } Modifiers.AddRange(Helpers.GetModifiers(pCsClass.modifiers)); }
public TheMethod GetMethod(CsEntityMethod pMethod, FactoryExpressionCreator pCreator) { if (pMethod.decl != null) return GetMethod((CsMethod)pMethod.decl); TheMethod c; if (_entityMethods.TryGetValue(pMethod, out c)) return c; c = new TheMethod(pMethod, this, pCreator); Dictionary<string, bool> methodNames = new Dictionary<string, bool>(); foreach (KeyValuePair<CsEntityMethod, TheMethod> entityMethod in _entityMethods.Where(pEntityMethod => methodNames.ContainsKey(pEntityMethod.Value.Name))) { entityMethod.Value._isUnique = false; c._isUnique = false; } _entityMethods.Add(pMethod, c); return c; }
public TheClass(CsEntity pCsEntity, FactoryExpressionCreator pCreator) { IsEntity = true; List<string> name = new List<string>(); CsEntity parent = pCsEntity.parent; while (parent != null && parent is CsEntityNamespace) { if (!string.IsNullOrEmpty(parent.name)) name.Add(parent.name); parent = parent.parent; } name.Reverse(); NameSpace = string.Join(".", name.ToArray()); //RealName = pCsEntity.name; //Name = Helpers.GetRealName(pCsEntity, RealName); Name = pCsEntity.name; FullName = NameSpace + "." + Name; //FullRealName = NameSpace + "." + RealName; CsEntityClass klass = pCsEntity as CsEntityClass; if (klass != null) { _baseEntityTyperef = klass.base_type; if (klass.base_type.type != cs_entity_type.et_object) Extends.Add(Helpers.GetType(klass.base_type)); if (klass.interfaces != null) { foreach (CsEntityTypeRef @interface in klass.interfaces) { Implements.Add(Helpers.GetType(@interface)); } } Dictionary<string, int> methodNames = new Dictionary<string, int>(); //bool constructorsDone = false; bool methodsDone = false; if (klass.method_implementations == null) { return; } foreach (CsEntityMethodImplementation methodImplementation in klass.method_implementations) { CsEntityMethod m = methodImplementation.implementation_method; TheMethod tm = new TheMethod(m, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!methodsDone) { methodsDone = true; foreach (KeyValuePair<CsMethod, TheMethod> method in _methods) { method.Value._isUnique = false; method.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _entityMethods.Add(m, tm); } return; } CsEntityInterface entityInterface = pCsEntity as CsEntityInterface; if (entityInterface != null) { _baseEntityTyperef = entityInterface.base_type; if (entityInterface.base_type.type != cs_entity_type.et_object) Extends.Add(Helpers.GetType(entityInterface.base_type)); if (entityInterface.interfaces != null) { foreach (CsEntityTypeRef @interface in entityInterface.interfaces) { Implements.Add(Helpers.GetType(@interface)); } } Dictionary<string, int> methodNames = new Dictionary<string, int>(); bool methodsDone = false; if (entityInterface.method_implementations == null) { return; } foreach (CsEntityMethodImplementation methodImplementation in entityInterface.method_implementations) { CsEntityMethod m = methodImplementation.implementation_method; TheMethod tm = new TheMethod(m, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!methodsDone) { methodsDone = true; foreach (KeyValuePair<CsMethod, TheMethod> method in _methods) { method.Value._isUnique = false; method.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _entityMethods.Add(m, tm); } return; } CsEntityStruct entityStruct = pCsEntity as CsEntityStruct; if (entityStruct != null) { _baseEntityTyperef = entityStruct.base_type; if (entityStruct.base_type.type != cs_entity_type.et_object) Extends.Add(Helpers.GetType(entityStruct.base_type)); if (entityStruct.interfaces != null) { foreach (CsEntityTypeRef @interface in entityStruct.interfaces) { Implements.Add(Helpers.GetType(@interface)); } } Dictionary<string, int> methodNames = new Dictionary<string, int>(); bool methodsDone = false; if (entityStruct.method_implementations == null) { return; } foreach (CsEntityMethodImplementation methodImplementation in entityStruct.method_implementations) { CsEntityMethod m = methodImplementation.implementation_method; TheMethod tm = new TheMethod(m, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!methodsDone) { methodsDone = true; foreach (KeyValuePair<CsMethod, TheMethod> method in _methods) { method.Value._isUnique = false; method.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _entityMethods.Add(m, tm); } return; } throw new NotImplementedException(); }
public TheClass(CsClassStruct pCsClass, FactoryExpressionCreator pCreator) { CsNamespace csNamespace; _creator = pCreator; List<string> name = new List<string>(); if (pCsClass.parent is CsClass) { IsPrivate = true; csNamespace = (CsNamespace)pCsClass.parent.parent; } else { csNamespace = (CsNamespace)pCsClass.parent; } CsQualifiedIdentifier list = csNamespace.qualified_identifier; name.AddRange(list.Select(pIdentifier => pIdentifier.identifier.identifier)); if (IsPrivate) name.Add(((CsClass)pCsClass.parent).identifier.identifier); NameSpace = string.Join(".", name.ToArray()); //RealName = pCsClass.identifier.identifier; //Name = Helpers.GetRealName(pCsClass, RealName); Name = pCsClass.identifier.identifier; FullName = NameSpace + "." + Name; //FullRealName = NameSpace + "." + RealName; if (pCsClass.type_base != null && pCsClass.type_base.base_list.Count != 0) { foreach (CsTypeRef typeRef in pCsClass.type_base.base_list) { object u = typeRef.entity_typeref.u; if (u == null) continue; if (u is CsEntityClass) { Extends.Add(Helpers.GetType(typeRef.type_name)); _baseTyperef = typeRef; } else if (u is CsEntityInterface) { Implements.Add(Helpers.GetType(typeRef.type_name)); } else if (u is CsEntityInstanceSpecifier) { Implements.Add(Helpers.GetType(typeRef.type_name)); //CsEntityInstanceSpecifier specifier = (CsEntityInstanceSpecifier)typeRef.entity_typeref.u; } else { throw new NotSupportedException(); } } } Dictionary<string, int> methodNames = new Dictionary<string, int>(); bool constructorsDone = false; bool methodsDone = false; if (pCsClass.member_declarations != null) { foreach (CsNode memberDeclaration in pCsClass.member_declarations) { CsConstructor c = memberDeclaration as CsConstructor; if (c != null) { TheConstructor tm = new TheConstructor(c, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!constructorsDone) { constructorsDone = true; foreach (KeyValuePair<CsConstructor, TheConstructor> constructor in _constructors) { constructor.Value._isUnique = false; constructor.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _constructors.Add(c, tm); continue; } CsMethod m = memberDeclaration as CsMethod; if (m != null) { if (m.interface_type != null) continue; TheMethod tm = new TheMethod(m, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!methodsDone) { methodsDone = true; foreach (KeyValuePair<CsMethod, TheMethod> method in _methods) { method.Value._isUnique = false; method.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _methods.Add(m, tm); continue; } CsIndexer i = memberDeclaration as CsIndexer; if (i != null) { _indexers.Add(i, new TheIndexer(i, this, pCreator)); continue; } CsVariableDeclaration v = memberDeclaration as CsVariableDeclaration; if (v != null) { _variables.Add(v, new TheVariable(v, this, pCreator)); continue; } CsConstantDeclaration k = memberDeclaration as CsConstantDeclaration; if (k != null) { _constants.Add(k, new TheConstant(k, this, pCreator)); continue; } CsProperty p = memberDeclaration as CsProperty; if (p != null) { if (p.interface_type == null) _properties.Add(p, new TheProperty(p, this, pCreator)); continue; } CsDelegate d = memberDeclaration as CsDelegate; if (d != null) { _delegates.Add(d, new TheDelegate(d, this, pCreator)); continue; } CsEvent e = memberDeclaration as CsEvent; if (e != null) { TheEvent theEvent = new TheEvent(e, this, pCreator); _events.Add(theEvent.Name, theEvent); continue; } CsClass csClass = memberDeclaration as CsClass; if (csClass != null) { continue; } throw new NotImplementedException("Unknown type not implemented"); } } Modifiers.AddRange(Helpers.GetModifiers(pCsClass.modifiers)); }
public TheClass(CsInterface pCsInterface, FactoryExpressionCreator pCreator) { IsInterface = true; List<string> name = new List<string>(); CsNamespace parent = pCsInterface.parent as CsNamespace; if (parent != null) { name.AddRange(parent.qualified_identifier.Select(pArt => pArt.identifier.identifier)); } NameSpace = string.Join(".", name.ToArray()); Name = pCsInterface.identifier.identifier; FullName = NameSpace + "." + Name; if (pCsInterface.type_base != null && pCsInterface.type_base.base_list.Count != 0) { foreach (CsTypeRef typeRef in pCsInterface.type_base.base_list) { object u = typeRef.entity_typeref.u; if (u == null) continue; if (u is CsEntityClass) { Extends.Add(Helpers.GetType(typeRef.type_name)); _baseTyperef = typeRef; } else if (u is CsEntityInterface) { Implements.Add(Helpers.GetType(typeRef.type_name)); } else if (u is CsEntityInstanceSpecifier) { Implements.Add(Helpers.GetType(typeRef.type_name)); } else { throw new NotSupportedException(); } } } Dictionary<string, int> methodNames = new Dictionary<string, int>(); bool methodsDone = false; if (pCsInterface.member_declarations != null) { foreach (CsNode memberDeclaration in pCsInterface.member_declarations) { CsMethod m = memberDeclaration as CsMethod; if (m != null) { if (m.interface_type != null) continue; TheMethod tm = new TheMethod(m, this, pCreator); if (methodNames.ContainsKey(tm.Name)) { methodNames[tm.Name]++; int index = tm._index = methodNames[tm.Name]; if (!methodsDone) { methodsDone = true; foreach (KeyValuePair<CsMethod, TheMethod> method in _methods) { method.Value._isUnique = false; method.Value._index = --index; } } tm._isUnique = false; } else { methodNames[tm.Name] = tm._index = 1; } _methods.Add(m, tm); continue; } CsIndexer i = memberDeclaration as CsIndexer; if (i != null) { _indexers.Add(i, new TheIndexer(i, this, pCreator)); continue; } CsVariableDeclaration v = memberDeclaration as CsVariableDeclaration; if (v != null) { _variables.Add(v, new TheVariable(v, this, pCreator)); continue; } CsProperty p = memberDeclaration as CsProperty; if (p != null) { if (p.interface_type == null) _properties.Add(p, new TheProperty(p, this, pCreator)); continue; } throw new NotImplementedException("Unknown type not implemented"); } } Modifiers.AddRange(Helpers.GetModifiers(pCsInterface.modifiers)); }