private bool loadBaseEntries(Chilkat.Log log) { // Do not add base entries for CkString or CkByteData. if (GenericName.Equals("CkString") || GenericName.Equals("CkByteData")) { return(true); } Chilkat.Xml xmlBase = new Chilkat.Xml(); //string baseXmlPath = NoBaseEntries ? GenBase.m_baseUtf8XmlPath : GenBase.m_baseEntriesXmlPath; string strBaseEntriesXml = ""; if (NoBaseEntries) { strBaseEntriesXml = AppData.GetAppData("appData/apiManager/basePropUtf8.xml"); } else { strBaseEntriesXml = AppData.GetAppData("appData/apiManager/baseEntries.xml"); } if (!xmlBase.LoadXml(strBaseEntriesXml)) //if (!xmlBase.LoadXmlFile(baseXmlPath)) { log.LogError("Failed to load baseEntries.xml"); return(false); } // No longer need this.. //xmlBase.AddOrUpdateAttribute("sourceXmlPath", baseXmlPath); addClassEntries(xmlBase); return(true); }
public bool SaveClass(Chilkat.Log log) { string path = GenBase.m_xmlApiDefPath + @"/" + GenericName + ".xml"; bool success = m_xml.SaveXml(path); return(success); }
bool GenerateClass(string genericClassName) { XClass xclass = new XClass(); Chilkat.Log log = new Chilkat.Log(); if (!xclass.LoadClass(genericClassName, log)) { return(false); } // Skip some classes we don't want.. if (xclass.DnEventArgs) { return(true); } if (xclass.Deprecated) { return(true); } // Generate the wrapper for this class to a StringBuilder, and then // write the contents of the StringBuilder to a file. StringBuilder sbSourceFile = new StringBuilder(); if (!generateClassToSb(xclass, sbSourceFile, log)) { return(false); } GenBase.writeFileIfModified(AppDataDir.BaseDir + "/sampleOutput/Ruby/" + ChilkatApi.GenBase.m_generateForMicroVersion + "/" + genericClassName + ".rb", sbSourceFile.ToString()); return(true); }
bool generateMethod(XMethod xmethod, XClass xclass, StringBuilder sbOut, Chilkat.Log log, bool lowerCaseAlt = false) { sbOut.Append("\r\n\t\t# Method: " + xmethod.EntryName + "\r\n\t\t#\r\n"); // lets add description... IEnumerable <string> chunked = chunkSplit(xmethod.Descrip, 100); foreach (var chunk in chunked) { sbOut.Append("\t\t# " + chunk.Trim().Replace("#\t\t", "# ") + "\r\n"); } sbOut.Append("\t\t#\r\n"); sbOut.Replace("=\r\n\t\t# _", " _"); //if (xmethod.Deprecated) // sbOut.Append("\t\t# This method has been deprecated. Do not use it.\r\n"); //sbOut.Append("\t\t# ==== Attributes\r\n\t\t#\r\n"); if (!genMethodSignature(xmethod, xclass, sbOut, log, lowerCaseAlt)) { return(false); } //sbOut.Append("\t\t\t{\r\n"); // Generate the method body here. This would include whatever code is necessary to prep input args, // make the call to the Chilkat API, and return the result.. sbOut.Append("\t\t\t# ...\r\n"); sbOut.Append("\t\tend\r\n\r\n"); if (!lowerCaseAlt && xmethod.ToLowerCaseStringMethod() != null) { generateMethod(xmethod, xclass, sbOut, log, true); } return(true); }
bool GenerateClass(string genericClassName) { XClass xclass = new XClass(); Chilkat.Log log = new Chilkat.Log(); if (!xclass.LoadClass(genericClassName, log)) { return(false); } // Skip some classes we don't want.. if (xclass.DnEventArgs) { return(true); } if (xclass.Deprecated) { return(true); } // Generate the wrapper for this class to a StringBuilder, and then // write the contents of the StringBuilder to a file. StringBuilder sbSourceFile = new StringBuilder(); if (!generateClassToSb(xclass, sbSourceFile, log)) { return(false); } GenBase.writeFileIfModified(txtOutputDir.Text + genericClassName + ".au3", sbSourceFile.ToString()); return(true); }
private bool loadStandardEvents(Chilkat.Log log) { string standardEventsXmlPath = AppDataDir.BaseDir + "/appData/apiManager/standardEvents.xml"; Chilkat.Xml xml = new Chilkat.Xml(); if (!xml.LoadXmlFile(standardEventsXmlPath)) { log.LogError("Failed to load standard events XML"); return(false); } xml.AddOrUpdateAttribute("sourceXmlPath", standardEventsXmlPath); // The root of this XML document is an "events" node.. int n = xml.NumChildren; for (int i = 0; i < n; i++) { Chilkat.Xml xEntry = xml.GetChild(i); XMethod xEvent = new XMethod(); xEvent.LoadMethodXml(xEntry); m_events.Add(xEvent.EntryName, xEvent); m_eventList.Add(xEvent); } return(true); }
// Load common links, such as those for UnlockComponent, from appData\apiManager\commonLinks.xml private bool integrateCommonLinks(Chilkat.Log log) { // No need for refdoc links if we're not using this code for refdoc generation. if (AppData.GitHubCodeBase) { return(true); } Chilkat.Xml xmlCommon = new Chilkat.Xml(); if (!xmlCommon.LoadXmlFile(AppData.BaseDir + "/appData/apiManager/commonLinks.xml")) { log.LogError("Failed to load commonLinks.xml"); return(false); } int i; int n = xmlCommon.NumChildren; string strName = null; for (i = 0; i < n; i++) { xmlCommon.GetChild2(i); strName = xmlCommon.GetAttrValue("name"); if ((strName != null) && xmlCommon.HasChildWithTag("links2")) { if (xmlCommon.TagEquals("method")) { XMethod method = GetMethodByName(strName); if (method != null) { xmlCommon.FindChild2("links2"); method.CopyLinks(xmlCommon); xmlCommon.GetParent2(); } } else if (xmlCommon.TagEquals("property")) { XProperty prop = GetPropertyByName(strName); if (prop != null) { xmlCommon.FindChild2("links2"); prop.CopyLinks(xmlCommon); xmlCommon.GetParent2(); } } } xmlCommon.GetParent2(); } return(true); }
public bool SaveClass(Chilkat.Log log) { // The GitHubCodeBase is read-only w.r.t. app data.. if (AppData.GitHubCodeBase) { return(true); } string path = GenBase.m_xmlApiDefPath + @"/" + GenericName + ".xml"; bool success = m_xml.SaveXml(path); return(success); }
bool generateProperty(XProperty xprop, XClass xclass, StringBuilder sbOut, Chilkat.Log log) { // All properties have getters.. // Types can be emitted using an existing conversion, or you could write your own.. sbOut.Append("\t" + ChilkatTypes.genericToAxPrimitive(xprop.m_gt) + " get_" + xprop.EntryName + "() { ... }\r\n"); // If the property is not read-only, generate the setter. if (!xprop.ReadOnly) { sbOut.Append("\tset_" + xprop.EntryName + "(" + ChilkatTypes.genericToAxPrimitive(xprop.m_gt) + " newval) { ... }\r\n"); } return(true); }
bool generateMethod(XMethod xmethod, XClass xclass, StringBuilder sbOut, Chilkat.Log log) { sbOut.Append("\r\n// Method: " + xmethod.EntryName + "\r\n"); if (!genMethodSignature(xmethod, xclass, sbOut, log)) { return(false); } sbOut.Append("\t{\r\n"); // Generate the method body here. This would include whatever code is necessary to prep input args, // make the call to the Chilkat API, and return the result.. sbOut.Append("\t// ...\r\n"); sbOut.Append("\t}\r\n"); return(true); }
// Load common links, such as those for UnlockComponent, from C:\ck2000\appData\apiManager\commonLinks.xml private bool integrateCommonLinks(Chilkat.Log log) { Chilkat.Xml xmlCommon = new Chilkat.Xml(); if (!xmlCommon.LoadXmlFile(PATH_COMMON_LINKS_XML)) { log.LogError("Failed to load commonLinks.xml"); return(false); } int i; int n = xmlCommon.NumChildren; string strName = null; for (i = 0; i < n; i++) { xmlCommon.GetChild2(i); strName = xmlCommon.GetAttrValue("name"); if ((strName != null) && xmlCommon.HasChildWithTag("links2")) { if (xmlCommon.TagEquals("method")) { XMethod method = GetMethodByName(strName); if (method != null) { xmlCommon.FindChild2("links2"); method.CopyLinks(xmlCommon); xmlCommon.GetParent2(); } } else if (xmlCommon.TagEquals("property")) { XProperty prop = GetPropertyByName(strName); if (prop != null) { xmlCommon.FindChild2("links2"); prop.CopyLinks(xmlCommon); xmlCommon.GetParent2(); } } } xmlCommon.GetParent2(); } return(true); }
private bool loadBaseEntries(Chilkat.Log log) { // Do not add base entries for CkString or CkByteData. if (GenericName.Equals("CkString") || GenericName.Equals("CkByteData")) { return(true); } Chilkat.Xml xmlBase = new Chilkat.Xml(); string baseXmlPath = NoBaseEntries ? GenBase.m_baseUtf8XmlPath : GenBase.m_baseEntriesXmlPath; if (!xmlBase.LoadXmlFile(baseXmlPath)) { log.LogError("Failed to load baseEntries.xml"); return(false); } xmlBase.AddOrUpdateAttribute("sourceXmlPath", baseXmlPath); addClassEntries(xmlBase); return(true); }
bool genMethodSignature(XMethod xmethod, XClass xclass, StringBuilder sbOut, Chilkat.Log log) { string rtnType = m_types.gtToAxI(xmethod.m_gt, xmethod.GenericType); sbOut.Append(rtnType + " " + xmethod.EntryName + "("); // Iterate over the method args.. int i = 1; foreach (MethodArg arg in xmethod.Args) { if (i > 1) { sbOut.Append(", "); } sbOut.Append(m_types.gtToAxI(arg.Gt, arg.DataType) + " " + arg.Name); i++; } sbOut.Append(")\r\n"); return(true); }
bool generateClassToSb(XClass xclass, StringBuilder sbOut, Chilkat.Log log) { // We're just going to generate some pseudo-code... sbOut.Append("class " + xclass.GenericName + " {\r\n\r\n"); // We could generate constructors, destructors, creation functions, etc. here... // Loop over properties and generate each.. int i; for (i = 0; i < xclass.NumProperties; i++) { XProperty xprop = xclass.GetProperty(i); // Skip some properties we may not want.. // (What you do here depends on your needs..) if (xprop.Deprecated) { continue; } if (!xprop.AxEnabled) { continue; // We don't want properties that do not exist in the ActiveX.. } if (xprop.IsBytes) { continue; // maybe we don't want to deal with the few properties that are binary data. } if (xprop.IsEventRelated()) { continue; } // ... if (!generateProperty(xprop, xclass, sbOut, log)) { return(false); } } // Loop over methods and generate each... for (i = 0; i < xclass.NumMethods; i++) { XMethod xmethod = xclass.GetMethod(i); // Skip some properties we may not want.. // (What you do here depends on your needs..) if (xmethod.Deprecated) { continue; } if (!xmethod.AxEnabled) { continue; // We don't want properties that do not exist in the ActiveX.. } if (xmethod.IsBytes || xmethod.HasArgWithGt(ChilkatTypes.GT_BYTES)) { continue; // Maybe we don't want to deal with binary return values or args.. } // ... if (!generateMethod(xmethod, xclass, sbOut, log)) { return(false); } } sbOut.Append("};\r\n"); return(true); }
bool genMethodSignature(XMethod xmethod, XClass xclass, StringBuilder sbOut, Chilkat.Log log, bool lowerCaseAlt = false) { string rtnType = m_types.gtToRubyDuck(xmethod.m_gt, xmethod.GenericType); if (!lowerCaseAlt && xmethod.CppMethodReturnGt == 4) { rtnType = "Boolean"; } int i = 1; /*foreach (MethodArg arg in xmethod.Args) * { * //if (i > 1) sbOut.Append(", "); * sbOut.Append("\t\t# +" + arg.Name + "+ - " + m_types.gtToRubyDuck(arg.Gt, arg.DataType) + "\r\n"); * i++; * } * sbOut.Append("\t\t# returns " + rtnType + "\r\n"); * sbOut.Append("\t\t#\r\n\t\t# YARD =>\r\n\t\t#\r\n");*/ foreach (MethodArg arg in xmethod.Args) { //if (i > 1) sbOut.Append(", "); sbOut.Append("\t\t# @param " + arg.Name + " [" + m_types.gtToRubyDuck(arg.Gt, arg.DataType) + "]\r\n"); i++; } if (!lowerCaseAlt && (xmethod.m_gt == 1 || xmethod.m_gt == 6)) { sbOut.Append("\t\t# @param " + xmethod.CppOutputArgName + " [" + xmethod.CppOutputArgCppType.Replace(" &", "") + "]\r\n"); } sbOut.Append("\t\t#\r\n\t\t# @return [" + rtnType + "]\r\n"); if (xmethod.Deprecated) { sbOut.Append("\t\t# @deprecated This method has been deprecated. Do not use it.\r\n"); } if (!lowerCaseAlt) { sbOut.Append("\t\tdef " + xmethod.EntryName + "("); } else { sbOut.Append("\t\tdef " + xmethod.EntryNameLowercaseNoCk + "("); } // Iterate over the method args.. i = 1; foreach (MethodArg arg in xmethod.Args) { if (i > 1) { sbOut.Append(", "); } sbOut.Append(arg.Name); i++; } if (!lowerCaseAlt && (xmethod.m_gt == 1 || xmethod.m_gt == 6)) { if (i > 1) { sbOut.Append(", "); } sbOut.Append(xmethod.CppOutputArgName); } sbOut.Append(")\r\n"); return(true); }
bool generateProperty(XProperty xprop, XClass xclass, StringBuilder sbOut, Chilkat.Log log, bool lowerCaseAlt = false) { // lets add description... IEnumerable <string> chunked = chunkSplit(xprop.Descrip, 100); foreach (var chunk in chunked) { sbOut.Append("\t\t# " + chunk.Trim().Replace("#\t\t", "# ") + "\r\n"); } sbOut.Append("\t\t#\r\n"); sbOut.Replace("=\r\n\t\t# _", " _"); // All properties have getters.. // Types can be emitted using an existing conversion, or you could write your own.. string klass = m_types.gtToRubyDuck(xprop.m_gt, xprop.GenericType); string param = "newval"; if (!lowerCaseAlt && (!xprop.ReadOnly || xprop.IsBaseEntry)) { switch (xprop.GenericType) { case "string": klass = "CkString"; param = "ckStr"; break; case "bytes": klass = "CkByteData"; param = "ckByteData"; break; default: // do nothing. break; } } //if (!lowerCaseAlt && xprop.HasCppOutputArg && (!xprop.ReadOnly || xprop.IsBaseEntry)) // sbOut.Append("\t\t# +" + param + "+ - [" + klass + "]\r\n"); //if (!xprop.ReadOnly) // sbOut.Append("\t\t# returns " + ChilkatTypes.genericToRubyPrimitive(xprop.m_gt) + "\r\n\t\t#\r\n"); //if (xprop.Deprecated) // sbOut.Append("\t\t# This method has been deprecated. Do not use it.\r\n"); if (!lowerCaseAlt && xprop.HasCppOutputArg && (!xprop.ReadOnly || xprop.IsBaseEntry)) { sbOut.Append("\t\t# @param " + param + " [" + klass + "]\r\n\t\t#\r\n"); } sbOut.Append("\t\t# @return [" + ChilkatTypes.genericToRubyPrimitive(xprop.m_gt) + "]\r\n"); if (xprop.Deprecated) { sbOut.Append("\t\t# @deprecated This method has been deprecated. Do not use it.\r\n"); } if (xprop.IsEventRelated()) { sbOut.Append("\t\t#\r\n\t\t# @event\r\n"); } if (lowerCaseAlt) { sbOut.Append("\t\tdef " + xprop.EntryNameLowercaseNoCk + "() end\r\n\r\n"); } else { if ((!xprop.ReadOnly || xprop.IsBaseEntry) && xprop.HasCppOutputArg) { //MessageBox.Show(xprop.NumArgs.ToString()); sbOut.Append("\t\tdef get_" + xprop.EntryName + "(" + param + ") end\r\n\r\n"); } else { sbOut.Append("\t\tdef get_" + xprop.EntryName + "() end\r\n\r\n"); } } // If the property is not read-only, generate the setter. if (!xprop.ReadOnly) { /*sbOut.Append("\t\t# ==== Attributes\r\n"); * sbOut.Append("\t\t# +newval+ - " + ChilkatTypes.genericToRubyPrimitive(xprop.m_gt) + "\r\n"); * if (xprop.Deprecated) * sbOut.Append("\t\t# This method has been deprecated. Do not use it.\r\n"); * sbOut.Append("\t\t#\r\n");*/ // lets add description... chunked = chunkSplit(xprop.Descrip, 100); foreach (var chunk in chunked) { sbOut.Append("\t\t# " + chunk.Trim().Replace("#\t\t", "# ") + "\r\n"); } sbOut.Append("\t\t#\r\n"); sbOut.Replace("=\r\n\t\t# _", " _"); sbOut.Append("\t\t# @param newval [" + ChilkatTypes.genericToRubyPrimitive(xprop.m_gt) + "]\r\n"); if (xprop.IsEventRelated()) { sbOut.Append("\t\t#\r\n\t\t# @event\r\n"); sbOut.Append("\t\t#\r\n\t\t# @!method\r\n"); } if (xprop.Deprecated) { sbOut.Append("\t\t#\r\n\t\t# @deprecated This method has been deprecated. Do not use it.\r\n"); } if (lowerCaseAlt && xprop.ReadOnly) { sbOut.Append("\t\tdef " + xprop.EntryNameLowercaseNoCk + "() end\r\n\r\n"); } else { sbOut.Append("\t\tdef put_" + xprop.EntryName + "(newval) end\r\n\r\n"); } } if (!lowerCaseAlt && xprop.ToLowerCaseStringMethod() != null) { generateProperty(xprop, xclass, sbOut, log, true); } return(true); }
public bool LoadClass(string className, Chilkat.Log log) { m_methods.Clear(); m_props.Clear(); m_events.Clear(); m_methodList.Clear(); m_propList.Clear(); m_eventList.Clear(); string path = GenBase.m_xmlApiDefPath + @"/" + className + ".xml"; if (!m_xml.LoadXmlFile(path)) { log.LogData("failedToLoad", path); return(false); } // Always indicate the source of the XML in the root node. // This makes it possible to save the entire XML document from any node // by getting the root XML node, then getting the sourceXmlPath, ... m_xml.AddOrUpdateAttribute("sourceXmlPath", path); addClassEntries(m_xml); if (!this.DnEventArgs) { // The base entries never actually get added to the m_xml. They are present in the // m_methods, m_props, and m_events. if (!loadBaseEntries(log)) { log.LogError("Failed to add base entries."); return(false); } } if (!integrateCommonLinks(log)) { log.LogError("Failed to integrate common links."); return(false); } if (HasEvents) { if (!loadStandardEvents(log)) { log.LogError("Failed to add standard events."); return(false); } } m_methodList.Sort(); m_propList.Sort(); m_eventList.Sort(); // Just to be sure.. string genericName = GenericName; if (genericName.Equals("CkString") || genericName.Equals("CkByteData")) { m_hasWideCharClass = false; } return(true); }