当前位置: 首页>>代码示例>>C++>>正文


C++ Local::ToObject方法代码示例

本文整理汇总了C++中Local::ToObject方法的典型用法代码示例。如果您正苦于以下问题:C++ Local::ToObject方法的具体用法?C++ Local::ToObject怎么用?C++ Local::ToObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Local的用法示例。


在下文中一共展示了Local::ToObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Undefined

// --------------------------------------------------------
Handle<Value> NodeOpenALStream::Buffer(const Arguments& args) {
	HandleScope scope;
	NodeOpenALStream* obj = ObjectWrap::Unwrap<NodeOpenALStream>(args.This());

	if (args.Length() < 1) {
		ThrowException(Exception::TypeError(String::New("Wrong number of arguments")));
		return scope.Close( Undefined() );
	}

	Local<Value> buffer = args[0];
	size_t size = node::Buffer::Length( buffer->ToObject() );
	char* bufferdata = node::Buffer::Data( buffer->ToObject() );

	obj->buffer(size, bufferdata);
	return scope.Close(v8::Undefined());
}
开发者ID:AAorris,项目名称:node-openal,代码行数:17,代码来源:NodeOpenALStream.cpp

示例2: setKeysInOp

void setKeysInOp(Handle<Object> spec, KeyOperation & op) {
  Local<Value> v;
  Local<Object> o;

  v = spec->Get(HELPER_KEY_BUFFER);
  if(! v->IsNull()) {
    o = v->ToObject();
    op.key_buffer = node::Buffer::Data(o);
  }
  
  v = spec->Get(HELPER_KEY_RECORD);
  if(! v->IsNull()) {
    o = v->ToObject();
    op.key_record = unwrapPointer<const Record *>(o);
  }
}
开发者ID:alMysql,项目名称:mysql-js,代码行数:16,代码来源:DBOperationHelper.cpp

示例3:

void ParamRsaPSS::FromV8(Local<Value> v8Value) {
	try {
		Nan::HandleScope();

		if (!v8Value->IsObject()) {
			THROW_ERROR("Parameter 1 MUST be Object", NULL);
		}

		Local<Object> v8Params = v8Value->ToObject();

		// Check data
		if (!check_param_number(v8Params, STR_MGF))
			THROW_ERROR("Attribute 'mgf' MUST be NUMBER", NULL);
		if (!check_param_number(v8Params, STR_SALT_LEN))
			THROW_ERROR("Attribute 'saltLen' MUST be NUMBER", NULL);
		if (!check_param_number(v8Params, STR_HASH_ALG))
			THROW_ERROR("Attribute 'hashAlg' MUST be NUMBER", NULL);

		Free();
		Init();

		param.sLen = Nan::To<v8::Number>(v8Params->Get(Nan::New(STR_SALT_LEN).ToLocalChecked())).ToLocalChecked()->Uint32Value();
		param.mgf = Nan::To<v8::Number>(v8Params->Get(Nan::New(STR_MGF).ToLocalChecked())).ToLocalChecked()->Uint32Value();
		param.hashAlg = Nan::To<v8::Number>(v8Params->Get(Nan::New(STR_HASH_ALG).ToLocalChecked())).ToLocalChecked()->Uint32Value();

	}
	CATCH_ERROR;
}
开发者ID:PeculiarVentures,项目名称:pkcs11js,代码行数:28,代码来源:param_rsa.cpp

示例4: DBOperationHelper_VO

void DBOperationHelper_VO(Handle<Object> spec,  KeyOperation & op) {
  DEBUG_MARKER(UDEB_DETAIL);
  Local<Value> v;
  Local<Object> o;
  Local<Object> valueObj;

  v = spec->Get(HELPER_VALUE_OBJECT);
  valueObj = v->ToObject();
  NdbRecordObject * nro = unwrapPointer<NdbRecordObject *>(valueObj);

  /* Set the key record and key buffer from the helper spec */
  setKeysInOp(spec, op);
  
  /* Set the row record, row buffer, and mask from the VO */
  op.row_record = nro->getRecord();
  op.row_buffer = nro->getBuffer();

  /* A persist operation must write all columns.
     A save operation must write all columns only if the PK has changed.
     Other operations only write columns that have changed since being read.
  */
  if(op.opcode == 2) 
    op.setRowMask(op.row_record->getAllColumnMask());
  else if(op.opcode == 8 && (nro->getMaskValue() & op.row_record->getPkColumnMask())) 
    op.setRowMask(op.row_record->getAllColumnMask());
  else 
    op.setRowMask(nro->getMaskValue());

  op.nblobs = nro->createBlobWriteHandles(op);

  DEBUG_PRINT("  VO   %s -- mask: %u lobs: %d", op.getOperationName(), 
              op.u.maskvalue, op.nblobs);
  nro->resetMask(); 
}
开发者ID:alMysql,项目名称:mysql-js,代码行数:34,代码来源:DBOperationHelper.cpp

示例5: getRequireCache

// Unfortunately native modules don't get a reference
// to require.cache as this happens in Module._compile()
// and native modules aren't compiled, they are loaded
// directly by NativeModule.require() (in Module._load())
// So we need to get it from Module._cache instead (by
// executing require('module')._cache)
static Local<Object> getRequireCache(Handle<Object> module) {
	Nan::EscapableHandleScope scope;
	Handle<Value> args[] = { Nan::New<String>("module").ToLocalChecked() };
	Local<Value> m = module->Get(Nan::New<String>("require").ToLocalChecked())->ToObject()->CallAsFunction(Nan::GetCurrentContext()->Global(), 1, args);
	Local<Object> cache = m->ToObject()->Get(Nan::New<String>("_cache").ToLocalChecked())->ToObject();
	return scope.Escape(cache);
}
开发者ID:apg84,项目名称:appmetrics,代码行数:13,代码来源:appmetrics.cpp

示例6: createQueryOperation

/* JS QueryOperation.create(ndbRootProjection, keyBuffer, depth)
*/
void createQueryOperation(const Arguments & args) {
  DEBUG_MARKER(UDEB_DEBUG);
  REQUIRE_ARGS_LENGTH(3);
  Isolate * isolate = Isolate::GetCurrent();

  int size = args[2]->Int32Value();
  QueryOperation * queryOperation = new QueryOperation(size);
  const NdbQueryOperationDef * root, * current;

  Local<Value> v;
  Local<Object> spec = args[0]->ToObject();

  setRowBuffers(queryOperation, spec);
  current = root = createTopLevelQuery(queryOperation, spec,
                                       args[1]->ToObject());

  while(! (v = spec->Get(GET_KEY(K_next)))->IsNull()) {
    spec = v->ToObject();
    current = createNextLevel(queryOperation, spec, current);
    assert(current->getOpNo() == spec->Get(GET_KEY(K_depth))->Uint32Value());
    setRowBuffers(queryOperation, spec);
  }
  queryOperation->prepare(root);
  args.GetReturnValue().Set(QueryOperation_Wrapper(queryOperation));
}
开发者ID:plasmob,项目名称:mysql-js,代码行数:27,代码来源:QueryOperation_wrapper.cpp

示例7: ParseAsync

void ParseAsync(const Nan::FunctionCallbackInfo<Value> &args) {
  Isolate *isolate = args.GetIsolate();
  int args_length = args.Length();

  if (args_length < 2) {
    isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Wrong number of arguments")));
    return;
  }

  Local<Value> input = args[0];
  if (!ValidateInput(input, isolate)) {
    return;
  }
  if (!args[1]->IsFunction()) {
    isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Second parameter must be a callback")));
    return;
  }

  Nan::Callback *callback = new Nan::Callback(args[1].As<Function>());
  anitomyJs::Worker *worker = new anitomyJs::Worker(callback);

  if (args_length >= 3) {
    Local<Value> options = args[2];
    if (!ValidateOptions(options, isolate) ||
        !worker->GetAnitomy()->SetOptions(options->ToObject(isolate->GetCurrentContext()).ToLocalChecked(), isolate)) {
      return;
    }
  }

  worker->GetAnitomy()->SetInput(input, isolate);
  Nan::AsyncQueueWorker(worker);
  args.GetReturnValue().Set(Nan::Undefined());
}
开发者ID:nevermnd,项目名称:anitomy-js,代码行数:33,代码来源:addon.cpp

示例8: ParseSync

void ParseSync(const Nan::FunctionCallbackInfo<Value> &args) {
  Isolate *isolate = args.GetIsolate();
  int args_length = args.Length();

  if (args_length < 1) {
    isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Wrong number of arguments")));
    return;
  }

  Local<Value> input = args[0];
  if (!ValidateInput(input, isolate)) {
    return;
  }

  anitomyJs::AnitomyJs anitomy;
  if (args_length >= 2) {
    Local<Value> options = args[1];
    if (!ValidateOptions(options, isolate) ||
        !anitomy.SetOptions(options->ToObject(isolate->GetCurrentContext()).ToLocalChecked(), isolate)) {
      return;
    }
  }

  anitomy.SetInput(input, isolate);
  anitomy.Parse();

  args.GetReturnValue().Set(anitomy.ParsedResult(isolate));
}
开发者ID:nevermnd,项目名称:anitomy-js,代码行数:28,代码来源:addon.cpp

示例9: 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;
}
开发者ID:joelpurra,项目名称:getdns-node,代码行数:60,代码来源:GNUtil.cpp

示例10: column_name

const NdbQueryOperationDef * createNextLevel(QueryOperation *queryOp,
                                             Handle<Object> spec,
                                             const NdbQueryOperationDef * parent) {
  NdbQueryBuilder *builder = queryOp->getBuilder();

  /* Pull values out of the JavaScript object */
  Local<Value> v;
  const NdbDictionary::Table * table = 0;
  const NdbDictionary::Index * index = 0;
  int depth = spec->Get(K_depth)->Int32Value();
  DEBUG_PRINT("Creating QueryOperationDef at level %d",depth);

  v = spec->Get(K_tableHandler);
  if(v->IsObject()) {
    v = v->ToObject()->Get(K_dbTable);
    if(v->IsObject()) {
      table = unwrapPointer<const NdbDictionary::Table *>(v->ToObject());
    }
  }
  bool isPrimaryKey = spec->Get(K_isPrimaryKey)->BooleanValue();

  if(! isPrimaryKey) {
    v = spec->Get(K_indexHandler);
    if(v->IsObject()) {
      v = v->ToObject()->Get(K_dbIndex);
      if(v->IsObject()) {
        index = unwrapPointer<const NdbDictionary::Index *> (v->ToObject());
      }
    }
    assert(index);
  }

  v = spec->Get(K_joinTo);
  Local<Array> joinColumns = Array::Cast(*v);

  /* Build the key */
  int nKeyParts = joinColumns->Length();
  const NdbQueryOperand * key_parts[nKeyParts+1];

  for(int i = 0 ; i < nKeyParts ; i++) {
    String::AsciiValue column_name(joinColumns->Get(i));
    key_parts[i] = builder->linkedValue(parent, *column_name);
  }
  key_parts[nKeyParts] = 0;

  return queryOp->defineOperation(index, table, key_parts);
}
开发者ID:WhiteWaterCoder,项目名称:mysql-js,代码行数:47,代码来源:QueryOperation_wrapper.cpp

示例11: DBOperationHelper_NonVO

void DBOperationHelper_NonVO(Handle<Object> spec, KeyOperation & op) {
  HandleScope scope;

  Local<Value> v;
  Local<Object> o;

  setKeysInOp(spec, op);
  
  v = spec->Get(HELPER_ROW_BUFFER);
  if(! v->IsNull()) {
    o = v->ToObject();
    op.row_buffer = V8BINDER_UNWRAP_BUFFER(o);
  }
  
  v = spec->Get(HELPER_ROW_RECORD);
  if(! v->IsNull()) {
    o = v->ToObject();
    const Record * record = unwrapPointer<const Record *>(o);
    op.row_record = record;

    v = spec->Get(HELPER_BLOBS);
    if(v->IsObject()) {
      if(op.opcode == 1) {
        createBlobReadHandles(v->ToObject(), record, op);
      } else {
        createBlobWriteHandles(v->ToObject(), record, op);
      }
    }
  }
  
  v = spec->Get(HELPER_LOCK_MODE);
  if(! v->IsNull()) {
    int intLockMode = v->Int32Value();
    op.lmode = static_cast<NdbOperation::LockMode>(intLockMode);
  }

  v = spec->Get(HELPER_COLUMN_MASK);
  if(! v->IsNull()) {
    Array *maskArray = Array::Cast(*v);
    for(unsigned int m = 0 ; m < maskArray->Length() ; m++) {
      Local<Value> colId = maskArray->Get(m);
      op.useColumn(colId->Int32Value());
    }
  }

  DEBUG_PRINT("Non-VO opcode: %d mask: %u", op.opcode, op.u.maskvalue);
}
开发者ID:kevinsawicki,项目名称:mysql-js,代码行数:47,代码来源:DBOperationHelper.cpp

示例12:

	txn_scope(Local<Value> arg, MDB_env *env) : _env(NULL), _txn(NULL), _readonly(false), _created(false), _commit(false) {
		if (arg->IsObject()) {
			_txn = node::ObjectWrap::Unwrap<txn>(arg->ToObject())->_txn;
		} else {
			_created = true;
			mdb_txn_begin(env, NULL, 0, &_txn);
		}
	}
开发者ID:talrasha007,项目名称:node-kv,代码行数:8,代码来源:db-lmdb.cpp

示例13: SetMediaBox

void PDFPageDriver::SetMediaBox(Local<String> property,Local<Value> value,const AccessorInfo &info)
{
    HandleScope scope;
    
    PDFPageDriver* pageDriver = ObjectWrap::Unwrap<PDFPageDriver>(info.Holder());

    if(!value->IsArray())
        ThrowException(Exception::TypeError(String::New("Media box is set to a value which is not a 4 numbers array")));
    
    if(value->ToObject()->Get(v8::String::New("length"))->ToObject()->Uint32Value() != 4)
        ThrowException(Exception::TypeError(String::New("Media box is set to a value which is not a 4 numbers array")));
    
    pageDriver->mPDFPage->SetMediaBox(PDFRectangle(value->ToObject()->Get(0)->ToNumber()->Value(),
                                                  value->ToObject()->Get(1)->ToNumber()->Value(),
                                                  value->ToObject()->Get(2)->ToNumber()->Value(),
                                                  value->ToObject()->Get(3)->ToNumber()->Value()));
    
}
开发者ID:abyr,项目名称:HummusJS,代码行数:18,代码来源:PDFPageDriver.cpp

示例14: setKeysInOp

void setKeysInOp(Handle<Object> spec, Operation & op) {
  HandleScope scope;

  Local<Value> v;
  Local<Object> o;

  v = spec->Get(HELPER_KEY_BUFFER);
  if(! v->IsNull()) {
    o = v->ToObject();
    op.key_buffer = V8BINDER_UNWRAP_BUFFER(o);
  }
  
  v = spec->Get(HELPER_KEY_RECORD);
  if(! v->IsNull()) {
    o = v->ToObject();
    op.key_record = unwrapPointer<const Record *>(o);
  }
}
开发者ID:rajiv9,项目名称:mysql-js,代码行数:18,代码来源:DBOperationHelper.cpp

示例15: Mutate

void Mutate(const FunctionCallbackInfo<Value>& args) {
  Isolate * isolate = args.GetIsolate();
  Local<Object> target = Local<Object>::New(isolate, persist);

  Local<String> key = String::NewFromUtf8(isolate, "x");
  // pull the current value of prop x out of the object
  double current = target->ToObject()->Get(key)->NumberValue();
  // increment prop x by 42
  target->Set(key, Number::New(isolate,  current + 42));
}
开发者ID:freezer333,项目名称:node-v8-workers,代码行数:10,代码来源:mutate.cpp


注:本文中的Local::ToObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。