Exemple #1
0
        static void GenerateBindings(CodeStructure s, string className, string outFilename)
        {
            if (!s.symbolsByName.ContainsKey(className))
            {
                Console.WriteLine("Error: Symbol " + className + " not found");
                return;
            }

            Symbol classSymbol = s.symbolsByName[className];
            if (classSymbol.kind != "class" && classSymbol.kind != "struct")
            {
                Console.WriteLine("Error: Symbol " + className + " is not a class or a struct!");
                return;
            }

            TextWriter tw = new StreamWriter(outFilename);
            tw.WriteLine("#include \"QtScriptBindingsHelpers.h\"");
            tw.WriteLine("");

            GenerateToExistingScriptValue(classSymbol, tw);

            HashSet<string> functionNames = new HashSet<string>();
            foreach (Symbol child in classSymbol.children)
            {
                if (!IsScriptable(child))
                    continue;

                if (child.kind == "function" && !child.name.Contains("operator"))
                {
                    GenerateClassFunction(child, tw);
                    functionNames.Add(child.name);
                }
                else if (child.kind == "variable" && !child.isStatic && IsScriptable(child) && child.visibilityLevel == VisibilityLevel.Public)
                {
//                    GenerateClassMemberVariableGet(child, tw);
//                    GenerateClassMemberVariableSet(child, tw);
                }
            }

            foreach (string functionName in functionNames)
                GenerateClassFunctionSelector(classSymbol, functionName, tw);

            //GenerateClassCtor(classSymbol, tw);

//            GenerateScriptClass(classSymbol, tw);
            GenerateFromScriptValue(classSymbol, tw);
            GenerateToScriptValue(classSymbol, tw);
            GenerateToScriptValueConst(classSymbol, tw);
            GenerateClassPrototype(classSymbol, tw);

            tw.Close();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            if (args.Length < 3)
            {
                Console.WriteLine("First cmdline parameter should be the absolute path to the root where doxygen generated the documentation XML files.");
                Console.WriteLine("Second cmdline parameter should be the output directory.");
                Console.WriteLine("Trhid and all subsequent parameters specify class names to generate bindings for.");
                return;
            }

            CodeStructure s = new CodeStructure();
            s.LoadSymbolsFromDirectory(args[0]);

            string outputDirectory = args[1];

            for(int i = 2; i < args.Length; ++i)
                GenerateBindings(s, args[i], outputDirectory + "\\qscript_" + args[i] + ".cpp");
        }