本文整理汇总了C++中JSBClass::GetModule方法的典型用法代码示例。如果您正苦于以下问题:C++ JSBClass::GetModule方法的具体用法?C++ JSBClass::GetModule怎么用?C++ JSBClass::GetModule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSBClass
的用法示例。
在下文中一共展示了JSBClass::GetModule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteProtoTypeRecursive
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);
}
示例2: WriteConstructor
//.........这里部分代码省略.........
"return 0;\n" \
"}\n");
}
JSBClass* klass = function_->class_;
JSBClass* base = klass->GetBaseClass();
// Constructor
source.AppendWithFormat("duk_ret_t jsb_constructor_%s(duk_context* ctx)\n{\n", klass->GetName().CString());
source.Append( "\nJSVM* vm = JSVM::GetJSVM(ctx);\n" \
"duk_push_this(ctx);\n" \
"void *ptr = duk_get_heapptr(ctx, -1);\n" \
"duk_pop(ctx);\n\n");
source.Append(" if (!vm->GetObjectPtr(ptr, true))\n {\n");
if (!klass->IsAbstract() && !klass->IsNumberArray())
{
String marshal;
WriteParameterMarshal(marshal);
String sparams;
int cparam = 0;
const Vector<JSBFunctionType*>& parameters = function_->GetParameters();
for (unsigned i = 0; i < parameters.Size(); i++, cparam++)
{
JSBFunctionType * ptype = parameters.At(i);
String sarg;
if (ptype->type_->asClassType())
{
JSBClassType* classType = ptype->type_->asClassType();
JSBClass* klass = classType->class_;
if (klass->GetName() == "Context")
{
sarg = "vm->GetContext()";
cparam--;
}
}
if (!sarg.Length())
{
sarg.AppendWithFormat("__arg%i", cparam);
}
sparams += sarg;
if (i + 1 < parameters.Size())
sparams += ", ";
}
source.AppendWithFormat("if (!duk_get_top(ctx) || !duk_is_pointer(ctx, 0))\n"\
"{\n"\
"%s\n"\
"%s* native = new %s(%s);\n" \
"vm->AddObject(ptr, native, INSTANTIATION_JAVASCRIPT);\n"\
"}\n" \
"else if (duk_is_pointer(ctx, 0))\n" \
"{\n" \
"RefCounted* rc = (RefCounted*) duk_get_pointer(ctx, 0);\n" \
"vm->AddObject(ptr, rc, rc->GetInstantiationType());\n" \
"}\n", marshal.CString(), klass->GetNativeName().CString(), klass->GetNativeName().CString(), sparams.CString());
}
else
{
if (klass->IsAbstract())
source.Append("assert(0); // abstract class new'd\n");
if (klass->IsNumberArray())
source.Append("assert(0); // number array class new'd\n");
}
source.Append(" }\n");
if (base)
{
String basePackage = base->GetModule()->GetPackage()->GetName();
source.AppendWithFormat(" js_constructor_basecall(ctx, \"%s\", \"%s\");\n", basePackage.CString(), base->GetName().CString());
}
if (function_->name_ == "RefCounted")
{
source.Append("duk_push_this(ctx);\n "\
"duk_push_c_function(ctx, jsb_finalizer_RefCounted, 1);\n "\
"duk_set_finalizer(ctx, -2);\n "\
"duk_pop(ctx);\n");
}
source += " return 0;";
source += "\n}\n";
}