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


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

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


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

示例1: attributeSetValue

void Shape::attributeSetValue(Local<String> name,
                              Local<Value> value,
                              const PropertyCallbackInfo<Value> &info)
{
  Local<Object> self = info.Holder();
  Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
  void *ptr = wrap->Value();
  map<string, int> *indexes = static_cast<map<string, int> *>(ptr);
  wrap = Local<External>::Cast(self->GetInternalField(1));
  ptr = wrap->Value();
  char **values = static_cast<char **>(ptr);

  String::Utf8Value utf8_name(name), utf8_value(value);
  string key = string(*utf8_name);

  map<string, int>::iterator iter = indexes->find(key);

  if (iter == indexes->end()) {
    ThrowException(String::New("Invalid value name."));
  }
  else
  {
    const int &index = (*iter).second;
    msFree(values[index]);
    values[index] = msStrdup(*utf8_value);
  }
}
开发者ID:BentleySystems,项目名称:mapserver,代码行数:27,代码来源:shape.cpp

示例2: Link

void ObjectManager::Link(const Local<Object>& object, uint32_t javaObjectID, jclass clazz)
{
	auto isolate = Isolate::GetCurrent();

	DEBUG_WRITE("Linking js object: %d and java instance id: %d", object->GetIdentityHash(), javaObjectID);

	JEnv env;

	auto jsInstanceInfo = new JSInstanceInfo();
	jsInstanceInfo->JavaObjectID = javaObjectID;
	jsInstanceInfo->clazz = clazz;

	auto objectHandle = new Persistent<Object>(isolate, object);
	auto state = new ObjectWeakCallbackState(this, jsInstanceInfo, objectHandle);
	objectHandle->SetWeak(state, JSObjectWeakCallbackStatic);

	auto jsInfoIdx = static_cast<int>(MetadataNodeKeys::JsInfo);
	bool alreadyLinked = !object->GetInternalField(jsInfoIdx)->IsUndefined();
	//ASSERT_MESSAGE(alreadyLinked, "object should not have been linked before");

	auto jsInfo = External::New(isolate, jsInstanceInfo);
	object->SetInternalField(jsInfoIdx, jsInfo);

	idToObject.insert(make_pair(javaObjectID, objectHandle));
}
开发者ID:nathanfaucett,项目名称:android-runtime,代码行数:25,代码来源:ObjectManager.cpp

示例3: Link

void ObjectManager::Link(const Local<Object>& object, uint32_t javaObjectID, jclass clazz)
{
	int internalFieldCound = NativeScriptExtension::GetInternalFieldCount(object);
	const int count = static_cast<int>(MetadataNodeKeys::END);
	if (internalFieldCound != count)
	{
		string errMsg("Trying to link invalid 'this' to a Java object");
		throw NativeScriptException(errMsg);
	}

	auto isolate = Isolate::GetCurrent();

	DEBUG_WRITE("Linking js object: %d and java instance id: %d", object->GetIdentityHash(), javaObjectID);

	auto jsInstanceInfo = new JSInstanceInfo();
	jsInstanceInfo->JavaObjectID = javaObjectID;
	jsInstanceInfo->clazz = clazz;

	auto objectHandle = new Persistent<Object>(isolate, object);
	auto state = new ObjectWeakCallbackState(this, jsInstanceInfo, objectHandle);
	objectHandle->SetWeak(state, JSObjectWeakCallbackStatic);

	auto jsInfoIdx = static_cast<int>(MetadataNodeKeys::JsInfo);
	bool alreadyLinked = !object->GetInternalField(jsInfoIdx)->IsUndefined();
	//TODO: fail if alreadyLinked is true?

	auto jsInfo = External::New(isolate, jsInstanceInfo);
	object->SetInternalField(jsInfoIdx, jsInfo);

	idToObject.insert(make_pair(javaObjectID, objectHandle));
}
开发者ID:atifzaidi,项目名称:android-runtime,代码行数:31,代码来源:ObjectManager.cpp

示例4:

Handle<Array> jsWindow::WindowEnum( const AccessorInfo &info )
{
    HandleScope scope;

    Handle<Array> retval = Local<Array>::New(Array::New());

    Local<Object> self = info.This();
    Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
    void* ptr = wrap->Value();
    jsWindow* el = static_cast<jsWindow*>(ptr);

    map<string, int> prop_list;
    size_t i;
    for (i = 0; i < ro_props.size(); ++i) {
        prop_list[ro_props[i]] = 1;
    }
    jsPropertyMap::iterator it;
    for (it = el->props.begin(); it != el->props.end(); ++it) {
        prop_list[it->first] = 1;
    }
    map<string, int>::iterator ins;
    i = 0;
    for (ins = prop_list.begin(); ins != prop_list.end(); ++ins) {
        string val = ins->first;
        retval->Set(Number::New(i), String::New(val.c_str()));
        i++;
    }

    return scope.Close(retval);
}
开发者ID:abhishekbhalani,项目名称:webapptools,代码行数:30,代码来源:jsWindow.cpp

示例5: Exception

void *ScriptObject::extractHolder(const Arguments &args)
{
    HandleScope handleScope;

    // Extract first internal field from Argument's holder object

    Local<Object> holderObject = args.Holder();

    if (holderObject->InternalFieldCount() < 1)
        throw bit::Exception("No internal fields found in holder object");

    Local<Value> holderValue = holderObject->GetInternalField(0);

    if (holderValue.IsEmpty())
        throw bit::Exception("Internal field could not be extracted from object");

    if (!holderValue->IsExternal())
        throw bit::Exception("The first field of holder object is not an ExternalObject");

    // Extract void pointer

    void *holderPointer = External::Unwrap(holderValue);

    if (holderPointer == NULL)
        throw bit::Exception("Extracted pointer is null");

    return holderPointer;
}
开发者ID:bagobor,项目名称:BitRPG,代码行数:28,代码来源:ScriptObject.cpp

示例6: SetPointY

void SetPointY(Local<String> property, 
			   Local<Value> value,
			   const PropertyCallbackInfo<Value>& info)
{
	Local<Object> self = info.Holder();
	Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
	void* ptr = wrap->Value();
	static_cast<Point*>(ptr)->y_ = value->Int32Value();
}
开发者ID:chinnurtb,项目名称:GoogleV8Tutorials,代码行数:9,代码来源:main.cpp

示例7:

shared_ptr<Server> Server::GetInstance(Local<Context> context){
	sjs::logger::debug("Getting Instance");
	Local<Object> self = Local<Object>::Cast(context->Global()->Get(STRING2JS(context->GetIsolate(), "$sampjs")));
	Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
	void* ptr = wrap->Value();
	Server* server = static_cast<Server*>(ptr);
	sjs::logger::debug("Casting");
	return make_shared<Server>(*server);
}
开发者ID:damospiderman,项目名称:samp.js,代码行数:9,代码来源:Server.cpp

示例8: GetLocationPort

static Handle<Value> GetLocationPort(Local<String> name, const AccessorInfo& info)
{
    Local<Object> self = info.This();
    Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
    void* ptr = wrap->Value();

    jsLocation* url = static_cast<jsLocation*>(ptr);
    return Int32::New(url->url.port);
}
开发者ID:abhishekbhalani,项目名称:webapptools,代码行数:9,代码来源:jsLocation.cpp

示例9: GetPointY

void GetPointY(Local<String> property,
						const PropertyCallbackInfo<Value>& info)
{
	Local<Object> self = info.Holder();
	Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
	void* ptr = wrap->Value();
	int value = static_cast<Point*>(ptr)->y_;
	info.GetReturnValue().Set(Number::New(value));
}
开发者ID:chinnurtb,项目名称:GoogleV8Tutorials,代码行数:9,代码来源:main.cpp

示例10: SetLocationPort

static void SetLocationPort(Local<String> name, Local<Value> val, const AccessorInfo& info)
{
    Local<Object> self = info.This();
    Local<Value> x = self->GetInternalField(0);
    Local<External> wrap = Local<External>::Cast(x);
    void* ptr = wrap->Value();

    jsLocation* url = static_cast<jsLocation*>(ptr);
    url->url.port = val->Int32Value();
}
开发者ID:abhishekbhalani,项目名称:webapptools,代码行数:10,代码来源:jsLocation.cpp

示例11: SetLocationHost

static void SetLocationHost(Local<String> name, Local<Value> val, const AccessorInfo& info)
{
    Local<Object> self = info.This();
    Local<Value> x = self->GetInternalField(0);
    Local<External> wrap = Local<External>::Cast(x);
    void* ptr = wrap->Value();

    jsLocation* url = static_cast<jsLocation*>(ptr);
    url->url.assign_with_referer(value_to_string(val), &url->url);
}
开发者ID:abhishekbhalani,项目名称:webapptools,代码行数:10,代码来源:jsLocation.cpp

示例12: New

static Handle<Value> GetLocationHash(Local<String> name, const AccessorInfo& info)
{
    Local<Object> self = info.This();
    Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
    void* ptr = wrap->Value();

    jsLocation* url = static_cast<jsLocation*>(ptr);
    string path = url->url.hashlink;
    return String::New(path.c_str());
}
开发者ID:abhishekbhalani,项目名称:webapptools,代码行数:10,代码来源:jsLocation.cpp

示例13: New

Handle<Value> getHeight(Local<String> property, const AccessorInfo &info) {
	Local<Object> self = info.Holder();
	Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
	void* ptr = wrap->Value();
	int value = static_cast<BGJSView*>(ptr)->height;
#ifdef DEBUG
	LOGD("getHeight %u", value);
#endif
	return Integer::New(value);
}
开发者ID:thetuxkeeper,项目名称:ejecta-v8,代码行数:10,代码来源:BGJSView.cpp

示例14: setHeight

void setHeight(Local<String> property, Local<Value> value,
		const AccessorInfo& info) {
	Local<Object> self = info.Holder();
	Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
	void* ptr = wrap->Value();
#ifdef DEBUG
	LOGI("Setting height to %d", value->Int32Value());
#endif
	static_cast<BGJSView*>(ptr)->height = value->Int32Value();
}
开发者ID:thetuxkeeper,项目名称:ejecta-v8,代码行数:10,代码来源:BGJSView.cpp

示例15: attributeGetValue

void Shape::attributeGetValue(Local<String> name,
                              const PropertyCallbackInfo<Value> &info)
{
  Local<Object> self = info.Holder();
  Local<External> wrap = Local<External>::Cast(self->GetInternalField(0));
  void *ptr = wrap->Value();
  map<string, int> *indexes = static_cast<map<string, int> *>(ptr);
  wrap = Local<External>::Cast(self->GetInternalField(1));
  ptr = wrap->Value();
  char **values = static_cast<char **>(ptr);

  String::Utf8Value utf8_value(name);
  string key = string(*utf8_value);
  map<string, int>::iterator iter = indexes->find(key);

  if (iter != indexes->end()) {
    const int &index = (*iter).second;
    info.GetReturnValue().Set(String::New(values[index]));
  }
}
开发者ID:BentleySystems,项目名称:mapserver,代码行数:20,代码来源:shape.cpp


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