Exemple #1
0
 public void UpdateArg(string argName, string objcName, string genericType)
 {
     m_name     = argName;
     m_objcName = objcName;
     m_dataType = genericType;
     m_gt       = ChilkatTypes.genericToGt(m_dataType);
 }
Exemple #2
0
 public void LoadArgXml(Chilkat.Xml x)
 {
     m_name     = x.GetAttrValue("name");
     m_objcName = x.GetAttrValue("objcName");
     m_dataType = x.GetAttrValue("type");
     m_ref      = x.HasAttrWithValue("ref", "1");
     m_objPtr   = x.HasAttrWithValue("objPtr", "1");
     m_gt       = ChilkatTypes.genericToGt(m_dataType);
     if (m_gt == ChilkatTypes.GT_CPP_CUSTOM)
     {
         m_dataType = x.GetAttrValue("cppType");
     }
 }
        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);
        }
        // For a method to be fully loaded from XML, the args must also be cached.
        protected void loadEntryXml(Chilkat.Xml p)
        {
            if (p == null)
            {
                return;
            }

            if (m_xml == p)
            {
                return;
            }
            m_xml = p;

            m_entryType = EntryTypeMethod;
            if (m_xml.TagEquals("property"))
            {
                m_entryType = EntryTypeProperty;
            }
            else if (m_xml.TagEquals("event"))
            {
                m_entryType = EntryTypeEvent;
            }

            // Cache info...
            m_name = m_xml.GetAttrValue("name");
            // We no longer user "cppType" in the XML.  It is derived from the generic type
            m_xml.RemoveChild("cppType");
            //m_cppType = m_xml.GetChildContent("cppType");
            //

            m_genericType = m_xml.GetChildContent("gType");
            if (m_genericType.Equals("long"))
            {
                GenericType = "int";
            }
            if (m_genericType.Equals("unsigned int") || m_genericType.Equals("uint32"))
            {
                GenericType = "unsigned long";
            }

            m_gt = ChilkatTypes.genericToGt(m_genericType);
            if (m_gt == ChilkatTypes.GT_DATE)
            {
                Chilkat.Xml gtXml = m_xml.FindChild("gType");
                m_outputArgFileTime   = gtXml.HasAttrWithValue("filetime", "1");
                m_outputArgSystemTime = gtXml.HasAttrWithValue("systemtime", "1");

                // If both are false, then assume systemtime.
                if (!m_outputArgFileTime && !m_outputArgSystemTime)
                {
                    m_outputArgSystemTime = true;
                }
            }


            m_hasCppOutputArg = (m_gt == ChilkatTypes.GT_STRING || m_gt == ChilkatTypes.GT_BYTES || m_gt == ChilkatTypes.GT_DATE);
            if (m_hasCppOutputArg)
            {
                m_cppOutputArgName = m_xml.GetAttrValue("outArgName");
                if (m_cppOutputArgName == null)
                {
                    if (m_gt == ChilkatTypes.GT_DATE)
                    {
                        m_cppOutputArgName = "outDate";
                    }
                    else if (m_gt == ChilkatTypes.GT_BYTES)
                    {
                        m_cppOutputArgName = "outBytes";
                    }
                    else
                    {
                        m_cppOutputArgName = "outStr";
                    }
                }
            }

            m_descrip      = m_xml.GetChildContent("descrip");
            m_ifdef        = m_xml.GetChildContent("ifdef");
            m_introVersion = m_xml.GetChildContent("iversion");

            m_cppEnabled = m_xml.HasAttrWithValue("cpp", "1");
            m_dnEnabled  = m_xml.HasAttrWithValue("dn", "1");
            m_axEnabled  = m_xml.HasAttrWithValue("ax", "1");

            m_hasEvents       = m_xml.HasAttrWithValue("events", "1");
            m_hasStatusReturn = m_xml.HasAttrWithValue("status", "1");
            m_isBaseEntry     = m_xml.HasAttrWithValue("baseEntry", "1");
            m_noPublish       = m_xml.HasAttrWithValue("noPublish", "1");
            m_deprecated      = m_xml.HasAttrWithValue("deprecated", "1");
            m_noxojo          = m_xml.HasAttrWithValue("noxojo", "1");
            m_windowsOnly     = m_xml.HasAttrWithValue("windowsOnly", "1");
            m_noSwig          = m_xml.HasAttrWithValue("noSwig", "1");
            m_noObjectiveC    = m_xml.HasAttrWithValue("noObjC", "1");
            m_noNodeJs        = m_xml.HasAttrWithValue("noNodeJs", "1");
            m_noSwig          = m_xml.HasAttrWithValue("noSwig", "1");
            m_noC             = m_xml.HasAttrWithValue("noC", "1");
            m_noWinRT         = m_xml.HasAttrWithValue("noWinRT", "1");


            m_lnameCk = m_lnameNoCk = StringUtil.ToLowerFirstChar(m_name);
            if (m_lnameCk.Equals("stat") || m_lnameCk.Equals("accept") || m_lnameCk.Equals("from"))
            {
                m_lnameCk = "ck_" + m_lnameCk;
            }

            m_refdocLinks = initRefdocLinks();

            return;
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        // Convert method XML to its Async variant so that we can use the normal code generation methods..
        static private void convertMethodToAsync(Chilkat.Xml xml)
        {
            //<method cpp="1" dn="1" ax="1" events="1" name="QuickGetObj" axId="221">
            //    <gType>HttpResponse</gType>
            //    <cppType>CkHttpResponse *</cppType>

            string returnType = xml.GetChildContent("gType");
            // Is this an object?  If so, we'll add a link to the async_returnObject example
            int returnGt = ChilkatTypes.genericToGt(returnType);


            xml.UpdateChildContent("gType", "Task");
            xml.UpdateChildContent("cppType", "CkTask *");
            xml.RemoveAttribute("status");      // It returns a Task object, not a status bool..
            xml.RemoveAttribute("outArgName");  // If this method had an output arg, the async does not...

            int axId = xml.GetAttrValueInt("axId");

            axId += 500;
            xml.UpdateAttributeInt("axId", axId);

            string origMethodName = xml.GetAttrValue("name");

            xml.UpdateAttribute("name", origMethodName + "Async");

            xml.UpdateChildContent("descrip", "Creates an asynchronous task to call the " + origMethodName +
                                   " method with the arguments provided.  (Async methods are available starting in Chilkat v9.5.0.52.)");

            xml.RemoveChild("links");

            //bool bAlreadyHasAsyncExamples = false;

            // Check to see if this method already has async examples.
            // If so, when we leave it alone.
            // Otherwise, we add the default example..
            //RefdocLinks rdLinks = new RefdocLinks();
            // Chilkat.Xml xLinks2 = xml.FindChild("links2");
            //if (xLinks2 != null)
            //    {
            //    int numChildren = xLinks2.NumChildren;
            //    for (int i = 0; i < numChildren; i++)
            //        {
            //        Chilkat.Xml xLink = xLinks2.GetChild(i);
            //        if (xLink.HasAttrWithValue("async", "1"))
            //            {
            //            //bAlreadyHasAsyncExamples = true;
            //            break;
            //            }
            //        }
            //    }

            //if (!bAlreadyHasAsyncExamples)
            //    {
            //    xml.RemoveChild("links2");

            // Add to the links, because these standard links will be placed in the superscript link area..
            Chilkat.Xml xmlLinks2 = xml.FindChild("links2");
            if (xmlLinks2 == null)
            {
                xmlLinks2 = xml.NewChild("links2", "");
            }

            Chilkat.Xml xmlLink;

            xmlLink = xmlLinks2.NewChild("link", "");
            xmlLink.AddAttribute("lang", "activex");
            xmlLink.AddAttribute("linkType", "external");
            xmlLink.AddAttribute("async", "1");
            xmlLink.AddAttribute("superscriptAsync", "1");
            xmlLink.NewChild2("text", "VB6 Programs MUST Call FinalizeThreadPool Just Before Exiting");
            xmlLink.NewChild2("url", "https://www.example-code.com/vb6/async_finalize_thread_pool_on_exit.asp");

            xmlLink = xmlLinks2.NewChild("link", "");
            xmlLink.AddAttribute("lang", "nodejs");
            xmlLink.AddAttribute("linkType", "external");
            xmlLink.AddAttribute("async", "1");
            xmlLink.AddAttribute("superscriptAsync", "1");
            xmlLink.NewChild2("text", "How to Run a Node.js Asynchronous Task");
            xmlLink.NewChild2("url", "http://www.cknotes.com/asynchronous-chilkat-methods-in-node-js/");

            xmlLink = xmlLinks2.NewChild("link", "");
            xmlLink.AddAttribute("lang", "activex");
            xmlLink.AddAttribute("linkType", "external");
            xmlLink.AddAttribute("async", "1");
            xmlLink.AddAttribute("superscriptAsync", "1");
            xmlLink.NewChild2("text", "Asynchronous Methods in VB6 - Be Very Careful with Callbacks");
            xmlLink.NewChild2("url", "http://www.chilkatforum.com/questions/10870/asynchronous-methods-in-vb6-be-very-careful-with-callbacks");

            xmlLink = xmlLinks2.NewChild("link", "");
            xmlLink.AddAttribute("skiplang", "nodejs");
            xmlLink.AddAttribute("async", "1");
            xmlLink.AddAttribute("superscriptAsync", "1");
            xmlLink.AddAttribute("linkType", "example");
            xmlLink.NewChild2("text", "How to Run an Asynchronous Task");
            xmlLink.NewChild2("url", "async_task.asp");

            if (returnGt == ChilkatTypes.GT_OBJECT)
            {
                xmlLink = xmlLinks2.NewChild("link", "");
                xmlLink.AddAttribute("skiplang", "nodejs");
                xmlLink.AddAttribute("async", "1");
                xmlLink.AddAttribute("superscriptAsync", "1");
                xmlLink.AddAttribute("linkType", "example");
                xmlLink.NewChild2("text", "How to Return an Object from an Async Task");
                xmlLink.NewChild2("url", "async_returnObject.asp");
            }
            //}


            return;
        }