本文整理汇总了C++中JSBClass::HasProperties方法的典型用法代码示例。如果您正苦于以下问题:C++ JSBClass::HasProperties方法的具体用法?C++ JSBClass::HasProperties怎么用?C++ JSBClass::HasProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSBClass
的用法示例。
在下文中一共展示了JSBClass::HasProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteClassDeclaration
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";
}