本文整理汇总了C++中Local::ToUint32方法的典型用法代码示例。如果您正苦于以下问题:C++ Local::ToUint32方法的具体用法?C++ Local::ToUint32怎么用?C++ Local::ToUint32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Local
的用法示例。
在下文中一共展示了Local::ToUint32方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertToList
getdns_list* GNUtil::convertToList(Local<Array> array) {
uint32_t len = array->Length();
getdns_list* result = getdns_list_create();
for (uint32_t i = 0; i < len; ++i) {
size_t idx = getdns_list_get_length(result, &idx);
Local<Value> val = array->Get(i);
GetdnsType type = getGetdnsType(val);
switch (type) {
case IntType:
getdns_list_set_int(result, idx, val->ToUint32()->Value());
break;
case BoolType:
if (val->IsTrue()) {
getdns_list_set_int(result, idx, GETDNS_EXTENSION_TRUE);
} else {
getdns_list_set_int(result, idx, GETDNS_EXTENSION_FALSE);
}
break;
case StringType:
{
struct getdns_bindata strdata;
String::Utf8Value utf8Str(val->ToString());
int len = utf8Str.length();
strdata.data = (uint8_t*) *utf8Str;
strdata.size = len;
getdns_list_set_bindata(result, idx, &strdata);
}
break;
case BinDataType:
{
struct getdns_bindata bdata;
bdata.data = (uint8_t*) node::Buffer::Data(val);
bdata.size = node::Buffer::Length(val);
getdns_list_set_bindata(result, idx, &bdata);
}
break;
case ListType:
{
Local<Array> subArray = Local<Array>::Cast(val);
struct getdns_list* sublist = GNUtil::convertToList(subArray);
getdns_list_set_list(result, idx, sublist);
getdns_list_destroy(sublist);
}
break;
case DictType:
{
Local<Object> subObj = val->ToObject();
struct getdns_dict* subdict = GNUtil::convertToDict(subObj);
if (subdict) {
getdns_list_set_dict(result, idx, subdict);
getdns_dict_destroy(subdict);
}
}
break;
default:
break;
}
}
return result;
}
示例2:
/*
* Prototype:
* Stalker.removeCallProbe(id)
*
* Docs:
* TBW
*
* Example:
* TBW
*/
static void
gum_v8_stalker_on_remove_call_probe (
const FunctionCallbackInfo<Value> & info)
{
GumV8Stalker * self = static_cast<GumV8Stalker *> (
info.Data ().As<External> ()->Value ());
Isolate * isolate = info.GetIsolate ();
Local<Value> id = info[0];
if (!id->IsUint32 ())
{
isolate->ThrowException (Exception::TypeError (String::NewFromUtf8 (isolate,
"Stalker.removeCallProbe: argument must be a probe id")));
return;
}
gum_stalker_remove_call_probe (_gum_v8_stalker_get (self),
id->ToUint32 ()->Value ());
return;
}
示例3: convertToDict
getdns_dict* GNUtil::convertToDict(Local<Object> obj) {
if (obj->IsRegExp() || obj->IsDate() ||
obj->IsFunction() || obj->IsUndefined() ||
obj->IsNull() || obj->IsArray()) {
return NULL;
}
Local<Array> names = obj->GetOwnPropertyNames();
getdns_dict* result = getdns_dict_create();
for(unsigned int i = 0; i < names->Length(); i++) {
Local<Value> nameVal = names->Get(i);
Nan::Utf8String name(nameVal);
Local<Value> val = obj->Get(nameVal);
GetdnsType type = getGetdnsType(val);
switch (type) {
case IntType:
getdns_dict_set_int(result, *name, val->ToUint32()->Value());
break;
case BoolType:
if (val->IsTrue()) {
getdns_dict_set_int(result, *name, GETDNS_EXTENSION_TRUE);
} else {
getdns_dict_set_int(result, *name, GETDNS_EXTENSION_FALSE);
}
break;
case StringType:
{
struct getdns_bindata strdata;
String::Utf8Value utf8Str(val->ToString());
int len = utf8Str.length();
strdata.data = (uint8_t*) *utf8Str;
strdata.size = len;
getdns_dict_set_bindata(result, *name, &strdata);
}
break;
case BinDataType:
{
struct getdns_bindata bdata;
bdata.data = (uint8_t*) node::Buffer::Data(val);
bdata.size = node::Buffer::Length(val);
getdns_dict_set_bindata(result, *name, &bdata);
}
break;
case ListType:
{
Local<Array> subArray = Local<Array>::Cast(val);
struct getdns_list* sublist = GNUtil::convertToList(subArray);
getdns_dict_set_list(result, *name, sublist);
getdns_list_destroy(sublist);
}
break;
case DictType:
{
Local<Object> subObj = val->ToObject();
struct getdns_dict* subdict = GNUtil::convertToDict(subObj);
if (subdict) {
getdns_dict_set_dict(result, *name, subdict);
getdns_dict_destroy(subdict);
}
}
break;
default:
break;
}
}
return result;
}