当前位置: 首页>>代码示例>>C++>>正文


C++ JSBClass类代码示例

本文整理汇总了C++中JSBClass的典型用法代码示例。如果您正苦于以下问题:C++ JSBClass类的具体用法?C++ JSBClass怎么用?C++ JSBClass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了JSBClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GenManagedFunctionParameters

void CSFunctionWriter::WriteManagedFunction(String& source)
{
    JSBClass* klass = function_->GetClass();
    JSBPackage* package = klass->GetPackage();

    String sig;
    String returnType = CSTypeHelper::GetManagedTypeString(function_->GetReturnType());

    GenManagedFunctionParameters(sig);

    String line = "public ";

    if (function_->IsStatic())
    {
        line += "static ";
    }

    bool marked = false;
    JSBClass* baseClass = klass->GetBaseClass();
    if (baseClass)
    {
        JSBFunction* override = baseClass->MatchFunction(function_, true);
        if (override)
        {
            marked = true;
            if (override->IsVirtual())
                line += "override ";
            else
                line += "new ";
        }
    }
开发者ID:Tarik-B,项目名称:AtomicGameEngine,代码行数:31,代码来源:CSFunctionWriter.cpp

示例2: GetClass

void JSBModule::ProcessHaxeDecl()
{
    // Haxe declarations

    JSONValue root = moduleJSON_->GetRoot();

    JSONValue decl = root.GetChild("haxe_decl");

    if (decl.IsObject())
    {
        Vector<String> childNames = decl.GetChildNames();

        for (unsigned j = 0; j < childNames.Size(); j++)
        {
            String classname = childNames.At(j);

            JSBClass* klass = GetClass(classname);

            if (!klass)
            {
                ErrorExit("Bad Haxe decl class");
            }

            JSONValue classdecl = decl.GetChild(classname);

            for (unsigned k = 0; k < classdecl.GetSize(); k++)
            {
                klass->AddHaxeDecl(classdecl.GetString(k));
            }
        }
    }
}
开发者ID:WorldofOpenDev,项目名称:AtomicGameEngine,代码行数:32,代码来源:JSBModule.cpp

示例3: checkV

    bool JSBHaxe::checkV(JSBClass* clazz, const String name, const String type) {
        PODVector<JSBClass*>& base = clazz->GetBaseClasses();
        for (unsigned j = 0; j < base.Size(); j++)
        {
            JSBClass* baseClass = base[j];

            Vector<String> propertyNames;

            baseClass->GetPropertyNames(propertyNames);

            for (unsigned i = 0; i < propertyNames.Size(); i++)
            {
                JSBProperty* prop = baseClass->GetProperty(propertyNames[i]);
                JSBFunctionType* ftype = NULL;

                if (prop->getter_ && !prop->getter_->Skip())
                {
                    ftype = prop->getter_->GetReturnType();
                }
                else if (prop->setter_ && !prop->setter_->Skip())
                    ftype = prop->setter_->GetParameters()[0];

                if (!ftype)
                    continue;

                String scriptName = prop->GetCasePropertyName();
                if (scriptName == name)
                {
                    return true;
                }
            }
        }
        return false;
    }
开发者ID:GREYFOXRGR,项目名称:AtomicGameEngine,代码行数:34,代码来源:JSBHaxe.cpp

示例4: GetNativeFunctionSignature

String CSTypeHelper::GetNativeFunctionSignature(JSBFunction* function, String& returnType)
{

    if (function->Skip())
        return String::EMPTY;

    if (function->IsDestructor())
        return String::EMPTY;

    if (OmitFunction(function))
        return String::EMPTY;

    JSBClass* klass = function->GetClass();
    JSBPackage* package = klass->GetPackage();
    String fname = function->IsConstructor() ? "Constructor" : function->GetName();

    returnType = "void";

    if (function->IsConstructor())
    {
        returnType = "RefCounted*";
    }
    else if (function->GetReturnType())
    {
        if (function->IsConstructor())
        {
            returnType = ToString("%s*", klass->GetNativeName().CString());
        }
        else if (function->GetReturnClass())
        {
            if (!function->GetReturnClass()->IsNumberArray())
            {
                returnType = ToString("const %s*", function->GetReturnClass()->GetNativeName().CString());
            }
        }
        else if (function->GetReturnType()->type_->asStringHashType())
        {
            returnType = "unsigned";
        }
        else
        {
            returnType = ToString("%s", CSTypeHelper::GetNativeTypeString(function->GetReturnType()).CString());

            // ScriptVector is handled by a out parameter
            if (returnType.Contains("ScriptVector"))
                returnType = "void";
        }
    }


    String sig;
    GenNativeFunctionParameterSignature(function, sig);

    String functionSig = ToString("csb_%s_%s_%s_%u(%s)",
                package->GetName().CString(), klass->GetName().CString(),
                fname.CString(), function->GetID(), sig.CString());

    return functionSig;
}
开发者ID:Type1J,项目名称:AtomicGameEngine,代码行数:59,代码来源:CSTypeHelper.cpp

示例5: GenNativeFunctionParameterSignature

void CSTypeHelper::GenNativeFunctionParameterSignature(JSBFunction* function, String& sig)
{
    JSBClass* klass = function->GetClass();

    const Vector<JSBFunctionType*>& parameters = function->GetParameters();

    Vector<String> args;

    if (!function->IsConstructor() && !function->IsStatic())
    {
        args.Push(ToString("%s* self", klass->GetNativeName().CString()));
    }

    if (parameters.Size())
    {
        for (unsigned int i = 0; i < parameters.Size(); i++)
        {
            JSBFunctionType* ptype = parameters.At(i);

            // ignore "Context" parameters
            if (ptype->type_->asClassType())
            {
                JSBClassType* classType = ptype->type_->asClassType();
                JSBClass* klass = classType->class_;
                if (klass->GetName() == "Context")
                {
                    continue;
                }

                args.Push(ToString("%s* %s", klass->GetNativeName().CString(), ptype->name_.CString()));
            }
            else
            {
                args.Push(CSTypeHelper::GetNativeTypeString(ptype) + " " + ptype->name_);
            }

        }
    }

    if (function->GetReturnClass() && function->GetReturnClass()->IsNumberArray())
    {
        args.Push(ToString("%s* returnValue", function->GetReturnClass()->GetNativeName().CString()));
    }

    if (function->GetReturnType())
    {
        JSBVectorType* vtype = function->GetReturnType()->type_->asVectorType();

        if (vtype)
        {
            args.Push("ScriptVector* returnValue");
        }
    }

    sig.Join(args, ", ");

}
开发者ID:Type1J,项目名称:AtomicGameEngine,代码行数:57,代码来源:CSTypeHelper.cpp

示例6: GenManagedFunctionParameters

void CSFunctionWriter::GenManagedFunctionParameters(String& sig)
{
    // generate args
    const Vector<JSBFunctionType*>& parameters = function_->GetParameters();

    if (parameters.Size())
    {
        for (unsigned int i = 0; i < parameters.Size(); i++)
        {
            bool isStruct = false;
            JSBFunctionType* ptype = parameters.At(i);

            // ignore "Context" parameters
            if (ptype->type_->asClassType())
            {
                JSBClassType* classType = ptype->type_->asClassType();
                JSBClass* klass = classType->class_;

                if (klass->GetName() == "Context")
                {
                    continue;
                }

                // TODO: we should have a better system for struct type in general
                // This number array is really for JS
                if (klass->IsNumberArray())
                {
                    isStruct = true;
                }
            }

            String managedTypeString = CSTypeHelper::GetManagedTypeString(ptype);

            if (!ptype->isConst_ && (ptype->isReference_ && isStruct))
            {
                // pass by reference
                managedTypeString = "ref " + managedTypeString;
            }

            sig += managedTypeString;

            String init = ptype->initializer_;

            if (init.Length())
            {
                init = MapDefaultParameter(ptype);
                if (init.Length())
                    sig += " = " + init;

            }

            if (i + 1 != parameters.Size())
                sig += ", ";
        }
    }
}
开发者ID:CTrauma,项目名称:AtomicGameEngine,代码行数:56,代码来源:CSFunctionWriter.cpp

示例7: while

void JSPackageWriter::WriteProtoTypeRecursive(String &source, JSBClass* klass,  Vector<JSBClass*>& written)
{
    if (written.Contains(klass))
        return;

    if (klass->GetModule()->GetDotNetModule())
        return;

    PODVector<JSBClass*>& baseClasses = klass->GetBaseClasses();

    Vector<JSBClass*>::Iterator itr = baseClasses.End() - 1 ;

    while (itr != baseClasses.Begin() - 1)
    {
        WriteProtoTypeRecursive(source, (*itr), written);
        itr--;
    }

    JSBClass* base = baseClasses.Size() ? baseClasses[0] : NULL;

    if (!klass->IsNumberArray() && klass->GetPackage() == package_)
    {
        JSBModule* module = klass->GetModule();

        String moduleGuard = module->GetModuleDefineGuard();

        if (moduleGuard.Length())
        {
            source += ToString("\n%s\n", moduleGuard.CString());
        }

        if (module->Requires("3D"))
            source += "\n#ifdef ATOMIC_3D\n";

        String packageName =  klass->GetModule()->GetPackage()->GetName();
        String basePackage =  base ? base->GetModule()->GetPackage()->GetName() : "";

        source.AppendWithFormat("   js_setup_prototype(vm, \"%s\", \"%s\", \"%s\", \"%s\", %s);\n",
                                packageName.CString(), klass->GetName().CString(),
                                base ? basePackage.CString() : "", base ? base->GetName().CString() : "",
                                klass->HasProperties() ? "true" : "false");

        if (module->Requires("3D"))
            source += "#endif\n\n";

        if (moduleGuard.Length())
        {
            source += ToString("\n#endif\n", moduleGuard.CString());
        }

    }

    written.Push(klass);

}
开发者ID:Type1J,项目名称:AtomicGameEngine,代码行数:55,代码来源:JSPackageWriter.cpp

示例8: WriteForwardDeclarations

void JSBModuleWriter::WriteForwardDeclarations(String& source)
{
    Vector<SharedPtr<JSBClass>> classes = module_->classes_.Values();

    for (unsigned i = 0; i < classes.Size(); i++)
    {
        JSBClass* cls = classes.At(i);

        if (cls->IsNumberArray())
            continue;

        source.AppendWithFormat("static duk_ret_t jsb_constructor_%s(duk_context* ctx);\n", cls->GetName().CString());
        source.AppendWithFormat("static void jsb_class_define_%s(JSVM* vm);\n", cls->GetName().CString());

    }
}
开发者ID:nonconforme,项目名称:AtomicGameEngine,代码行数:16,代码来源:JSBModuleWriter.cpp

示例9: jsb_declare_classes

void JSBModule::WriteClassDeclaration(String& source)
{

    source += "static void jsb_declare_classes(JSVM* vm)\n{\n";

    source += "duk_context* ctx = vm->GetJSContext();\n";

    for (unsigned i = 0; i < classes_.Size(); i++)
    {
        JSBClass* klass = classes_.At(i);

        if (klass->isNumberArray())
            continue;

        source.AppendWithFormat("   js_class_declare(vm, \"%s\", jsb_constructor_%s);\n", klass->GetName().CString(), klass->GetName().CString());

        if (klass->hasProperties())
        {
            source.AppendWithFormat("js_class_push_propertyobject(vm, \"%s\");\n", klass->GetName().CString());


            Vector<String> pnames;
            klass->GetPropertyNames(pnames);

            for (unsigned j = 0; j < pnames.Size(); j++)
            {
                JSBProperty* prop = klass->GetProperty(pnames[j]);

                source.Append("duk_push_object(ctx);\n");

                if (prop->getter_ && !prop->getter_->Skip())
                {
                    source.AppendWithFormat("duk_push_c_function(ctx, jsb_class_%s_%s, 0);\n",
                                            klass->GetName().CString(), prop->getter_->name_.CString());
                    source.Append("duk_put_prop_string(ctx, -2, \"get\");\n");
                }
                if (prop->setter_ && !prop->setter_->Skip())
                {
                    source.AppendWithFormat("duk_push_c_function(ctx, jsb_class_%s_%s, 1);\n",
                                            klass->GetName().CString(), prop->setter_->name_.CString());
                    source.Append("duk_put_prop_string(ctx, -2, \"set\");\n");
                }

                pnames[j][0] = tolower(pnames[j][0]);
                source.AppendWithFormat("duk_put_prop_string(ctx, -2, \"%s\");\n", pnames[j].CString());

            }

            source.Append("duk_pop(ctx);\n");

        }
    }

    source += "\n}\n\n";

}
开发者ID:slagusev,项目名称:AtomicGameEngine,代码行数:56,代码来源:JSBModule.cpp

示例10: Indent

void CSModuleWriter::GenerateManagedModuleClass(String& sourceOut)
{
    Indent();

    String source;
    String line = ToString("public static partial class %sModule\n", module_->GetName().CString());

    source += IndentLine(line);

    source += IndentLine("{\n");

    Indent();

    source += IndentLine("public static void Initialize()\n");

    source += IndentLine("{\n");

    Indent();

    Vector<SharedPtr<JSBClass>> classes = module_->classes_.Values();

    for (unsigned i = 0; i < classes.Size(); i++)
    {
        JSBClass* klass = classes.At(i);
        JSBPackage* package = module_->GetPackage();

        if (klass->IsNumberArray() || klass->IsAbstract())
            continue;

        line = ToString("NativeCore.RegisterNativeType(typeof(%s));\n", klass->GetName().CString());

        source += IndentLine(line);

        line = ToString("NativeCore.nativeClassIDToManagedConstructor [ %s.csb_%s_%s_GetClassIDStatic ()] = (IntPtr x) => {\n",
                        klass->GetName().CString(), package->GetName().CString(), klass->GetName().CString());

        source += IndentLine(line);

        Indent();

        source += IndentLine(ToString("return new %s (x);\n", klass->GetName().CString()));

        Dedent();

        source += IndentLine("};\n");

    }

    Dedent();

    source += IndentLine("}\n");

    Dedent();

    source += IndentLine("}\n");

    sourceOut += source;

    Dedent();
}
开发者ID:GREYFOXRGR,项目名称:AtomicGameEngine,代码行数:60,代码来源:CSModuleWriter.cpp

示例11: GenerateManagedClasses

void CSModuleWriter::GenerateManagedClasses(String& source)
{

    Vector<SharedPtr<JSBClass>> classes = module_->classes_.Values();

    for (unsigned i = 0; i < classes.Size(); i++)
    {
        JSBClass* klass = classes.At(i);

        if (klass->IsNumberArray())
            continue;

        CSClassWriter clsWriter(klass);
        clsWriter.GenerateManagedSource(source);

    }

}
开发者ID:GREYFOXRGR,项目名称:AtomicGameEngine,代码行数:18,代码来源:CSModuleWriter.cpp

示例12: jsb_init_classes

void JSBModule::WriteClassDefine(String& source)
{

    source += "static void jsb_init_classes(JSVM* vm)\n{\n";

    for (unsigned i = 0; i < classes_.Size(); i++)
    {
        JSBClass* klass = classes_.At(i);

        if (klass->isNumberArray())
            continue;

        source.AppendWithFormat("   jsb_class_define_%s(vm);\n", klass->GetName().CString());
    }

    source += "\n}\n\n";

}
开发者ID:slagusev,项目名称:AtomicGameEngine,代码行数:18,代码来源:JSBModule.cpp

示例13: jsb_declare_classes

void JSBModuleWriter::WriteClassDeclaration(String& source)
{
    Vector<SharedPtr<JSBClass>> classes = module_->classes_.Values();

    source += "static void jsb_declare_classes(JSVM* vm)\n{\n";

    source += "duk_context* ctx = vm->GetJSContext();\n";

    String packageName = module_->GetPackage()->GetName();

    for (unsigned i = 0; i < classes.Size(); i++)
    {
        JSBClass* klass = classes.At(i);

        if (klass->IsNumberArray())
            continue;

        source.AppendWithFormat("   js_class_declare<%s>(vm, \"%s\", \"%s\", jsb_constructor_%s);\n", klass->GetNativeName().CString(), packageName.CString(), klass->GetName().CString(), klass->GetName().CString());

        if (klass->HasProperties())
        {
            source.AppendWithFormat("js_class_push_propertyobject(vm, \"%s\", \"%s\");\n", packageName.CString(), klass->GetName().CString());

            Vector<String> pnames;
            klass->GetPropertyNames(pnames);

            for (unsigned j = 0; j < pnames.Size(); j++)
            {
                JSBProperty* prop = klass->GetProperty(pnames[j]);

                source.Append("duk_push_object(ctx);\n");

                if (prop->getter_ && !prop->getter_->Skip())
                {
                    source.AppendWithFormat("duk_push_c_function(ctx, jsb_class_%s_%s, 0);\n",
                                            klass->GetName().CString(), prop->getter_->GetName().CString());
                    source.Append("duk_put_prop_string(ctx, -2, \"get\");\n");
                }
                if (prop->setter_ && !prop->setter_->Skip())
                {
                    source.AppendWithFormat("duk_push_c_function(ctx, jsb_class_%s_%s, 1);\n",
                                            klass->GetName().CString(), prop->setter_->GetName().CString());
                    source.Append("duk_put_prop_string(ctx, -2, \"set\");\n");
                }

                String propertyName = prop->GetCasePropertyName();
                source.AppendWithFormat("duk_put_prop_string(ctx, -2, \"%s\");\n", propertyName.CString());

            }

            source.Append("duk_pop(ctx);\n");

        }
    }

    source += "\n}\n\n";

}
开发者ID:nonconforme,项目名称:AtomicGameEngine,代码行数:58,代码来源:JSBModuleWriter.cpp

示例14: jsb_init_classes

void JSBModuleWriter::WriteClassDefine(String& source)
{
    Vector<SharedPtr<JSBClass>> classes = module_->classes_.Values();

    source += "static void jsb_init_classes(JSVM* vm)\n{\n";

    for (unsigned i = 0; i < classes.Size(); i++)
    {
        JSBClass* klass = classes.At(i);

        if (klass->IsNumberArray())
            continue;

        source.AppendWithFormat("   jsb_class_define_%s(vm);\n", klass->GetName().CString());
    }

    source += "\n}\n\n";

}
开发者ID:nonconforme,项目名称:AtomicGameEngine,代码行数:19,代码来源:JSBModuleWriter.cpp

示例15: GetScriptType

String JSBTypeScript::GetScriptType(JSBFunctionType* ftype)
{
    String scriptType = "number";

    if (ftype->type_->asPrimitiveType())
    {
        JSBPrimitiveType* ptype = ftype->type_->asPrimitiveType();
        if (ptype->kind_ == JSBPrimitiveType::Bool)
            scriptType = "boolean";

    }

    if (ftype->type_->asStringHashType() || ftype->type_->asStringType())
        scriptType = "string";

    if (ftype->type_->asEnumType())
        scriptType = ftype->type_->asEnumType()->enum_->GetName();

    if (ftype->type_->asClassType())
    {
        JSBClass* klass = ftype->type_->asClassType()->class_;

        scriptType = klass->GetName();

        if (klass->GetPackage()->GetName() != package_->GetName())
        {

            scriptType = klass->GetPackage()->GetName() + "." + klass->GetName();

        }

    }

    if (ftype->type_->asVectorType())
    {
        scriptType = "string[]";
    }

    return scriptType;

}
开发者ID:Botankk,项目名称:AtomicGameEngine,代码行数:41,代码来源:JSBTypeScript.cpp


注:本文中的JSBClass类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。