本文整理汇总了C++中JSBClass::GetBaseClass方法的典型用法代码示例。如果您正苦于以下问题:C++ JSBClass::GetBaseClass方法的具体用法?C++ JSBClass::GetBaseClass怎么用?C++ JSBClass::GetBaseClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSBClass
的用法示例。
在下文中一共展示了JSBClass::GetBaseClass方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteManagedFunction
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 ";
}
}
示例2: ExportModuleClasses
void JSBTypeScript::ExportModuleClasses(const String& moduleName)
{
JSBModule* module = JSBindings::Instance()->GetModuleByName(moduleName);
if (!module->classes_.Size())
return;
source_ += "\n";
for (unsigned i = 0; i < module->classes_.Size(); i++)
{
JSBClass* klass = module->classes_.At(i);
source_ += " export class " + klass->GetName();
if (klass->GetBaseClass())
source_ += " extends " + klass->GetBaseClass()->GetName();
source_ += " {\n\n";
Vector<String> propertyNames;
klass->GetPropertyNames(propertyNames);
for (unsigned j = 0; j < propertyNames.Size(); j++)
{
JSBProperty* prop = klass->GetProperty(propertyNames[j]);
JSBFunctionType* ftype = NULL;
if (prop->getter_ && !prop->getter_->Skip())
{
ftype = prop->getter_->returnType_;
}
else if (prop->setter_ && !prop->setter_->Skip())
ftype = prop->setter_->parameters_[0];
if (!ftype)
continue;
String scriptType = GetScriptType(ftype);
String scriptName = propertyNames[j];
scriptName[0] = tolower(scriptName[0]);
source_ += " " + scriptName + ": " + scriptType + ";\n";
}
if (propertyNames.Size())
source_ += "\n";
JSBFunction* constructor = klass->GetConstructor();
if (constructor)
{
ExportFunction(constructor);
source_ += "\n";
}
for (unsigned j = 0; j < klass->GetFunctionCount(); j++)
{
JSBFunction* func = klass->GetFunction(j);
if (func->isConstructor_ || func->isDestructor_ || func->Skip())
continue;
ExportFunction(func);
}
source_ += "\n }\n\n";
}
source_ += "\n";
}
示例3: WriteConstructor
void JSFunctionWriter::WriteConstructor(String& source)
{
// TODO: refactor this
if (function_->name_ == "RefCounted")
{
source.Append("// finalizer may be called more than once\n" \
"static int jsb_finalizer_RefCounted(duk_context *ctx)\n" \
"{\n" \
"JSVM* vm = JSVM::GetJSVM(ctx);\n" \
\
"duk_get_prop_index(ctx, 0, JS_INSTANCE_INDEX_FINALIZED);\n" \
\
"if (!duk_is_boolean(ctx, -1))\n" \
"{\n" \
"RefCounted* ref = vm->GetObjectPtr(duk_get_heapptr(ctx, 0));\n" \
"vm->RemoveObject(ref);\n" \
"ref->ReleaseRef();\n" \
"duk_push_boolean(ctx, 1);\n" \
"duk_put_prop_index(ctx, 0, JS_INSTANCE_INDEX_FINALIZED);\n" \
"}\n" \
\
"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())
//.........这里部分代码省略.........
示例4: ExportModuleClasses
void JSBHaxe::ExportModuleClasses(JSBModule* module)
{
Vector<SharedPtr<JSBClass>> classes = module->GetClasses();
if (!classes.Size())
return;
source_ += "\n";
for (unsigned i = 0; i < classes.Size(); i++)
{
JSBClass* klass = classes.At(i);
if (klass->IsNumberArray()) {
source_ += "typedef " + klass->GetName() + " = Array<Float>;\n";
continue;
}
source_ += "@:native(\"Atomic." + klass->GetName() + "\")\n";
source_ += "extern class " + klass->GetName();
JSBClass* base = klass->GetBaseClass();
if (base)
{
source_ += " extends " + base->GetName();
}
source_ += " {\n\n";
Vector<String> propertyNames;
klass->GetPropertyNames(propertyNames);
for (unsigned j = 0; j < propertyNames.Size(); j++)
{
JSBProperty* prop = klass->GetProperty(propertyNames[j]);
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 scriptType = GetScriptType(ftype);
String scriptName = prop->GetCasePropertyName();
if (!checkV(klass, scriptName, scriptType)) {
//rename haxe reserved words
if (scriptName == "override") {
scriptName = "overide";
}
if (scriptName == "dynamic") {
scriptName = "dynamik";
}
source_ += " var " + scriptName + ": " + scriptType + ";\n";
}
}
if (propertyNames.Size())
source_ += "\n";
JSBFunction* constructor = klass->GetConstructor();
if (constructor)
{
ExportFunction(constructor);
source_ += "\n";
}
PODVector<JSBFunction*>& functions = klass->GetFunctions();
for (unsigned j = 0; j < functions.Size(); j++)
{
JSBFunction* func = functions[j];
if (func->IsConstructor() || func->IsDestructor() || func->Skip())
continue;
ExportFunction(func);
}
for (unsigned j = 0; j < klass->GetNumHaxeDecl(); j++)
{
source_ += " " + klass->GetHaxeDecl(j) + "\n";
}
source_ += "\n}\n\n";
}
//.........这里部分代码省略.........
示例5: ExportModuleClasses
void JSBTypeScript::ExportModuleClasses(JSBModule* module)
{
Vector<SharedPtr<JSBClass>> classes = module->GetClasses();
if (!classes.Size())
return;
source_ += "\n";
for (unsigned i = 0; i < classes.Size(); i++)
{
JSBClass* klass = classes.At(i);
source_ += " export class " + klass->GetName();
JSBClass* base = klass->GetBaseClass();
if (base)
{
if (klass->GetPackage() != base->GetPackage())
{
source_ += " extends " + base->GetPackage()->GetName() + "." + base->GetName();
}
else
{
source_ += " extends " + base->GetName();
}
}
source_ += " {\n\n";
Vector<String> propertyNames;
klass->GetPropertyNames(propertyNames);
for (unsigned j = 0; j < propertyNames.Size(); j++)
{
JSBProperty* prop = klass->GetProperty(propertyNames[j]);
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 scriptType = GetScriptType(ftype);
String scriptName = prop->GetCasePropertyName();
source_ += " " + scriptName + ": " + scriptType + ";\n";
}
if (propertyNames.Size())
source_ += "\n";
JSBFunction* constructor = klass->GetConstructor();
if (constructor)
{
ExportFunction(constructor);
source_ += "\n";
}
PODVector<JSBFunction*>& functions = klass->GetFunctions();
for (unsigned j = 0; j < functions.Size(); j++)
{
JSBFunction* func = functions[j];
if (func->IsConstructor() || func->IsDestructor() || func->Skip())
continue;
ExportFunction(func);
}
for (unsigned j = 0; j < klass->GetNumTypeScriptDecl(); j++)
{
source_ += " " + klass->GetTypeScriptDecl(j) + "\n";
}
source_ += "\n }\n\n";
}
source_ += "\n";
}