本文整理汇总了C++中JSBClass::GetNumberArrayElements方法的典型用法代码示例。如果您正苦于以下问题:C++ JSBClass::GetNumberArrayElements方法的具体用法?C++ JSBClass::GetNumberArrayElements怎么用?C++ JSBClass::GetNumberArrayElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSBClass
的用法示例。
在下文中一共展示了JSBClass::GetNumberArrayElements方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteParameterMarshal
void JSFunctionWriter::WriteParameterMarshal(String& source)
{
// generate args
const Vector<JSBFunctionType*>& parameters = function_->GetParameters();
int cparam = 0;
if (parameters.Size())
{
for (unsigned int i = 0; i < parameters.Size(); i++, cparam++)
{
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")
{
cparam--;
continue;
}
}
String pstring = ptype->ToArgString(cparam);
const String& init = ptype->initializer_;
if (ptype->type_->asClassType())
{
JSBClassType* classType = ptype->type_->asClassType();
JSBClass* klass = classType->class_;
if (!klass->IsNumberArray())
{
if (init.Length())
{
source.AppendWithFormat("%s = duk_get_top(ctx) >= %i ? js_to_class_instance<%s>(ctx, %i, 0) : %s;\n",
pstring.CString(), cparam + 1, klass->GetNativeName().CString(), cparam, init.CString());
}
else
{
source.AppendWithFormat("%s = js_to_class_instance<%s>(ctx, %i, 0);\n",
pstring.CString(), klass->GetNativeName().CString(), cparam);
}
}
else
{
int elements = klass->GetNumberArrayElements();
String elementType = klass->GetArrayElementType();
source.AppendWithFormat("%s arrayData%i[%i];\n", elementType.CString(), cparam, elements);
if (init.Length())
{
source.AppendWithFormat("const %s& defaultArg%i = %s;\n", klass->GetNativeName().CString(), cparam, init.CString());
source.AppendWithFormat("if (duk_get_top(ctx) >= %i) {\n", cparam + 1);
}
for (int j = 0; j < elements; j++)
{
source.AppendWithFormat("duk_get_prop_index(ctx, %i, %i);\n", cparam, j);
source.AppendWithFormat("arrayData%i[%i] = (%s) duk_to_number(ctx, -1);\n", cparam, j, elementType.CString());
}
source.AppendWithFormat("duk_pop_n(ctx, %i);\n", elements);
if (init.Length())
{
source.Append("}\n");
source.AppendWithFormat("%s __arg%i(duk_get_top(ctx) >= %i ? (const %s *) arrayData%i : defaultArg%i.Data());\n",
klass->GetNativeName().CString(), cparam, cparam + 1, elementType.CString(), cparam, cparam);
}
else
{
source.AppendWithFormat("%s __arg%i(arrayData%i);\n", klass->GetNativeName().CString(), cparam, cparam);
}
}
}
else if (ptype->type_->asStringType() || ptype->type_->asStringHashType())
{
if (init.Length())
{
source.AppendWithFormat("%s = duk_get_top(ctx) >= %i ? duk_to_string(ctx, %i) : %s;\n", pstring.CString(), cparam + 1, cparam, init.CString());
}
else
{
source.AppendWithFormat("%s = duk_to_string(ctx, %i);\n", pstring.CString(), cparam);
}
}
else if (ptype->type_->asHeapPtrType())
{
if (init.Length())
{
source.AppendWithFormat("%s = duk_get_top(ctx) >= %i ? duk_get_heapptr(ctx, %i) : %s;\n", pstring.CString(), cparam + 1, cparam, init.CString());
}
//.........这里部分代码省略.........