本文整理汇总了C++中Any::makeVariant方法的典型用法代码示例。如果您正苦于以下问题:C++ Any::makeVariant方法的具体用法?C++ Any::makeVariant怎么用?C++ Any::makeVariant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Any
的用法示例。
在下文中一共展示了Any::makeVariant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: invoke
static Value* invoke(const char* iid, int number, InterfaceMethod** self, ListValue* list)
{
if (!self)
{
throw getErrorInstance("TypeError");
}
Reflect::Interface interface = es::getInterface(iid);
Reflect::Method method(interface.getMethod(number));
PRINTF("invoke %s.%s(%p)\n", interface.getName().c_str(), method.getName().c_str(), self);
// Set up parameters
Any argv[9];
Any* argp = argv;
int ext = 0; // extra parameter count
// Set this
*argp++ = Any(reinterpret_cast<intptr_t>(self));
// In the following implementation, we assume no out nor inout attribute is
// used for parameters.
Reflect::Type returnType = method.getReturnType();
switch (returnType.getType())
{
case Reflect::kAny:
// Any op(void* buf, int len, ...);
// FALL THROUGH
case Reflect::kString:
// const char* op(xxx* buf, int len, ...);
*argp++ = Any(reinterpret_cast<intptr_t>(heap));
*argp++ = Any(sizeof(heap));
break;
case Reflect::kSequence:
// int op(xxx* buf, int len, ...);
*argp++ = Any(reinterpret_cast<intptr_t>(heap));
++ext;
*argp++ = Any(static_cast<int32_t>(((*list)[0])->toNumber()));
break;
case Reflect::kArray:
// void op(xxx[x] buf, ...);
*argp++ = Any(reinterpret_cast<intptr_t>(heap));
break;
}
Reflect::Parameter param = method.listParameter();
for (int i = ext; param.next(); ++i, ++argp)
{
Reflect::Type type(param.getType());
Value* value = (*list)[i];
switch (type.getType())
{
case Reflect::kAny:
// Any variant, ...
switch (value->getType()) {
case Value::BoolType:
*argp = Any(static_cast<bool>(value->toBoolean()));
break;
case Value::StringType:
*argp = Any(value->toString().c_str());
break;
case Value::NumberType:
*argp = Any(static_cast<double>(value->toNumber()));
break;
case Value::ObjectType:
if (InterfacePointerValue* unknown = dynamic_cast<InterfacePointerValue*>(value))
{
*argp = Any(unknown->getObject());
}
else
{
// XXX expose ECMAScript object
*argp = Any(static_cast<Object*>(0));
}
break;
default:
*argp = Any();
break;
}
argp->makeVariant();
break;
case Reflect::kSequence:
// xxx* buf, int len, ...
// XXX Assume sequence<octet> now...
*argp++ = Any(reinterpret_cast<intptr_t>(value->toString().c_str()));
value = (*list)[++i];
*argp = Any(static_cast<int32_t>(value->toNumber()));
break;
case Reflect::kString:
*argp = Any(value->toString().c_str());
break;
case Reflect::kArray:
// void op(xxx[x] buf, ...);
// XXX expand data
break;
case Reflect::kObject:
if (InterfacePointerValue* unknown = dynamic_cast<InterfacePointerValue*>(value))
{
*argp = Any(unknown->getObject());
}
//.........这里部分代码省略.........