public NativeSchemaInfo(XmlSchemaTypeLoader typeLoader) { m_nativeClasses = new List <NativeClassInfo>(); // parse schema & add our Annotations foreach (DomNodeType domType in typeLoader.GetNodeTypes()) { IEnumerable <XmlNode> annotations = domType.GetTagLocal <IEnumerable <XmlNode> >(); if (annotations == null) { continue; } NativeClassInfo classInfo = null; foreach (XmlNode annot in annotations) { XmlElement elm = annot as XmlElement; if (elm.LocalName == SchemaStrings.LegeNativeType) { classInfo = new NativeClassInfo(elm, domType.IsAbstract); m_nativeClasses.Add(classInfo); break; } } if (classInfo == null) { continue; } foreach (XmlNode annot in annotations) { XmlElement elm = annot as XmlElement; if (elm.LocalName == SchemaStrings.LeGeNativeProperty) { NativePropertyInfo info = new NativePropertyInfo(elm); classInfo.Properties.Add(info); } else if (elm.LocalName == SchemaStrings.LeGeNativeElement) { NativeListInfo info = new NativeListInfo(elm); classInfo.Lists.Add(info); } } } }
private static void GenerateListDefinition(StringBuilder sb, NativeClassInfo classInfo, NativeListInfo info) { WriteLine(sb, ""); WriteLine(sb, "//-----------------------------------------------------------------------------"); WriteLine(sb, "void {0}_{1}_Add({2} parentId, {2} childId, int index)", classInfo.NativeName, info.NativeName, ConstStrings.ObjectID); WriteLine(sb, "{{"); WriteLine(sb, " {0}* parent = reinterpret_cast<{0}*>(parentId);", classInfo.NativeName); WriteLine(sb, " {0}* child = reinterpret_cast<{0}*>(childId);", info.NativeType); WriteLine(sb, " parent->Add{0}(child, index);", info.NativeName); WriteLine(sb, "}}"); WriteLine(sb, ""); WriteLine(sb, "//-----------------------------------------------------------------------------"); WriteLine(sb, "void {0}_{1}_Remove({2} parentId, {2} childId)", classInfo.NativeName, info.NativeName, ConstStrings.ObjectID); WriteLine(sb, "{{"); WriteLine(sb, " {0}* parent = reinterpret_cast<{0}*>(parentId);", classInfo.NativeName); WriteLine(sb, " {0}* child = reinterpret_cast<{0}*>(childId);", info.NativeType); WriteLine(sb, " parent->Remove{0}(child);", info.NativeName); WriteLine(sb, "}}"); }
private static void GenerateListRegistration(StringBuilder sb, NativeClassInfo classInfo, NativeListInfo info) { WriteLine(sb, " bridge.RegisterChildList( \"{0}\", \"{1}\", &{0}_{1}_Add, &{0}_{1}_Remove);", classInfo.NativeName, info.NativeName, info.NativeType); }
public NativeSchemaInfo(XmlSchemaTypeLoader typeLoader) { m_nativeClasses = new List<NativeClassInfo>(); // parse schema & add our Annotations foreach (DomNodeType domType in typeLoader.GetNodeTypes()) { IEnumerable<XmlNode> annotations = domType.GetTagLocal<IEnumerable<XmlNode>>(); if (annotations == null) continue; NativeClassInfo classInfo = null; foreach (XmlNode annot in annotations) { XmlElement elm = annot as XmlElement; if (elm.LocalName == SchemaStrings.LegeNativeType) { classInfo = new NativeClassInfo(elm, domType.IsAbstract); m_nativeClasses.Add(classInfo); break; } } if (classInfo == null) continue; foreach (XmlNode annot in annotations) { XmlElement elm = annot as XmlElement; if (elm.LocalName == SchemaStrings.LeGeNativeProperty) { NativePropertyInfo info = new NativePropertyInfo(elm); classInfo.Properties.Add(info); } else if (elm.LocalName == SchemaStrings.LeGeNativeElement) { NativeListInfo info = new NativeListInfo(elm); classInfo.Lists.Add(info); } } } }