public static void GenerateClass() { /*if (type.IsInterface) * { * Debug.Log("Interface: " + type.ToString() + " ignored."); * return; * }*/ JSMgr.ATypeInfo ti; int slot = JSMgr.AddTypeInfo(type, out ti); var sbCons = BuildConstructors(type, ti.constructors, slot); var sbFields = BuildFields(type, ti.fields, slot); var sbProperties = BuildProperties(type, ti.properties, slot); var sbMethods = BuildMethods(type, ti.methods, slot); var sbClass = BuildClass(type, sbFields, sbProperties, sbMethods, sbCons); HandleStringFormat(sbClass); string fileName = JSMgr.jsGeneratedDir + "/" + className + ".javascript"; var writer2 = OpenFile(fileName, false); writer2.Write(sbClass.ToString()); writer2.Close(); }
public static void GenerateClass() { /*if (type.IsInterface) * { * Debug.Log("Interface: " + type.ToString() + " ignored."); * return; * }*/ JSMgr.ATypeInfo ti; /*int slot = */ JSMgr.AddTypeInfo(type, out ti); // var sbCons = BuildConstructors(type, ti.constructors, slot); // var sbFields = BuildFields(type, ti.fields, slot); // var sbProperties = BuildProperties(type, ti.properties, slot); // var sbMethods = BuildMethods(type, ti.methods, slot); // var sbClass = BuildClass(type, sbFields, sbProperties, sbMethods, sbCons); // HandleStringFormat(sbClass); ClassCallbackNames ccbn = new ClassCallbackNames(); { ccbn.type = type; ccbn.fields = new List <string>(ti.fields.Length); ccbn.properties = new List <string>(ti.properties.Length); ccbn.constructors = new List <string>(ti.constructors.Length); ccbn.methods = new List <string>(ti.methods.Length); ccbn.constructorsCSParam = new List <string>(ti.constructors.Length); ccbn.methodsCSParam = new List <string>(ti.methods.Length); } var sbFields = BuildFields(type, ti.fields, ccbn); var sbProperties = BuildProperties(type, ti.properties, ccbn); var sbMethods = BuildMethods(type, ti.methods, ti.methodsOLInfo, ccbn); var sbCons = BuildConstructors(type, ti.constructors, ccbn); var sbRegister = BuildRegisterFunction(ccbn, ti); var sbClass = BuildClass(type, sbFields, sbProperties, sbMethods, sbCons, sbRegister); /* * 0 typeName * 1 class contents * 2 type namespace */ string fmtFile = @" using UnityEngine; using System; using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine.Rendering; {2} public class {0}Generated [[ {1} ]] "; var sbFile = new StringBuilder(); string nameSpaceString = string.Empty; if (type.Namespace != null) { nameSpaceString = type.Namespace; if (nameSpaceString == "UnityEngine") { nameSpaceString = string.Empty; } } sbFile.AppendFormat(fmtFile, type.Name, sbClass, nameSpaceString.Length > 0?"using " + nameSpaceString + ";":""); HandleStringFormat(sbFile); sbFile.Replace("\r\n", "\n"); string fileName = JSMgr.csGeneratedDir + "/" + type.Name + "Generated.cs"; var writer2 = OpenFile(fileName, false); writer2.Write(sbFile.ToString()); writer2.Close(); }