Esempio n. 1
0
        /*
        static void GenerateClassMemberVariableGet(Symbol variable, TextWriter tw)
        {
            Symbol Class = variable.parent;

            tw.WriteLine("static QScriptValue " + GetMemberVariableGetCppFuncName(variable) + "(QScriptContext *context, QScriptEngine *engine)");
            tw.WriteLine("{");

            tw.WriteLine(Indent(1) + "if (context->argumentCount() != 0) { printf(\"Error! Invalid number of arguments passed to function " + GetMemberVariableGetCppFuncName(variable) + " in file %s, line %d!\\nExpected 0, but got %d!\\n\", __FILE__, __LINE__, context->argumentCount()); return QScriptValue(); }");

            tw.WriteLine(Indent(1) + Class.name + " *This = " + "TypeFromQScriptValue<" + Class.name + "*>(context->thisObject());");
            tw.WriteLine(Indent(1) + "if (!This) { printf(\"Error! Invalid context->thisObject in file %s, line %d\\n!\", __FILE__, __LINE__); return QScriptValue(); }");

            tw.WriteLine(Indent(1) + "return qScriptValueFromValue(context->engine(), This->" + variable.name + ");");
            tw.WriteLine("}");
            tw.WriteLine("");
        }

        static void GenerateClassMemberVariableSet(Symbol variable, TextWriter tw)
        {
            Symbol Class = variable.parent;

            tw.WriteLine("static QScriptValue " + GetMemberVariableSetCppFuncName(variable) + "(QScriptContext *context, QScriptEngine *engine)");
            tw.WriteLine("{");

            tw.WriteLine(Indent(1) + "if (context->argumentCount() != 1) { printf(\"Error! Invalid number of arguments passed to function " + GetMemberVariableSetCppFuncName(variable) + " in file %s, line %d!\\nExpected 1, but got %d!\\n\", __FILE__, __LINE__, context->argumentCount()); return QScriptValue(); }");

            tw.WriteLine(Indent(1) + Class.name + " *This = " + "TypeFromQScriptValue<" + Class.name + "*>(context->thisObject());");
            tw.WriteLine(Indent(1) + "if (!This) { printf(\"Error! Invalid context->thisObject in file %s, line %d\\n!\", __FILE__, __LINE__); return QScriptValue(); }");
            tw.WriteLine(Indent(1) + variable.type + " " + variable.name + " = qscriptvalue_cast<" + variable.type + ">(context->argument(0));");
            tw.WriteLine(Indent(1) + "This->" + variable.name + " = " + variable.name + ";");
            tw.WriteLine(Indent(1) + "return QScriptValue();");
            tw.WriteLine("}");
            tw.WriteLine("");
        }
        */
        public static bool HasOpaqueQVariantBasedMarshalling(Symbol Class)
        {
            Symbol ctor = Class.FindChildByName(Class.name);
            foreach (string s in ctor.Comments())
            {
                if (s.Contains("[opaque-qtscript]"))
                    return true;
            }
            return false;
        }
Esempio n. 2
0
        /*
        static void GenerateClassMemberVariableGet(Symbol variable, TextWriter tw)
        {
            Symbol Class = variable.parent;

            tw.WriteLine("static QScriptValue " + GetMemberVariableGetCppFuncName(variable) + "(QScriptContext *context, QScriptEngine *engine)");
            tw.WriteLine("{");

            tw.WriteLine(Indent(1) + "if (context->argumentCount() != 0) { printf(\"Error! Invalid number of arguments passed to function " + GetMemberVariableGetCppFuncName(variable) + " in file %s, line %d!\\nExpected 0, but got %d!\\n\", __FILE__, __LINE__, context->argumentCount()); return QScriptValue(); }");

            tw.WriteLine(Indent(1) + Class.name + " *This = " + "TypeFromQScriptValue<" + Class.name + "*>(context->thisObject());");
            tw.WriteLine(Indent(1) + "if (!This) { printf(\"Error! Invalid context->thisObject in file %s, line %d\\n!\", __FILE__, __LINE__); return QScriptValue(); }");

            tw.WriteLine(Indent(1) + "return qScriptValueFromValue(context->engine(), This->" + variable.name + ");");
            tw.WriteLine("}");
            tw.WriteLine("");
        }

        static void GenerateClassMemberVariableSet(Symbol variable, TextWriter tw)
        {
            Symbol Class = variable.parent;

            tw.WriteLine("static QScriptValue " + GetMemberVariableSetCppFuncName(variable) + "(QScriptContext *context, QScriptEngine *engine)");
            tw.WriteLine("{");

            tw.WriteLine(Indent(1) + "if (context->argumentCount() != 1) { printf(\"Error! Invalid number of arguments passed to function " + GetMemberVariableSetCppFuncName(variable) + " in file %s, line %d!\\nExpected 1, but got %d!\\n\", __FILE__, __LINE__, context->argumentCount()); return QScriptValue(); }");

            tw.WriteLine(Indent(1) + Class.name + " *This = " + "TypeFromQScriptValue<" + Class.name + "*>(context->thisObject());");
            tw.WriteLine(Indent(1) + "if (!This) { printf(\"Error! Invalid context->thisObject in file %s, line %d\\n!\", __FILE__, __LINE__); return QScriptValue(); }");
            tw.WriteLine(Indent(1) + variable.type + " " + variable.name + " = qscriptvalue_cast<" + variable.type + ">(context->argument(0));");
            tw.WriteLine(Indent(1) + "This->" + variable.name + " = " + variable.name + ";");
            tw.WriteLine(Indent(1) + "return QScriptValue();");
            tw.WriteLine("}");
            tw.WriteLine("");
        }
        */
        public static bool HasOpaqueQVariantBasedMarshalling(Symbol Class)
        {
            Symbol ctor = Class.FindChildByName(Class.name);
            foreach (string s in ctor.comments)
            {
                if (Class.name == "float3x4")
                    Console.WriteLine(s);
                if (s.Contains("[opaque-qtscript]"))
                    return true;
            }
            return false;
        }