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


C++ Persistent::Reset方法代码示例

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


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

示例1: Purge

	void Purge()
	{
		if (!bAbandoned)
		{
			bAbandoned = true;

			WrappedObject.Reset();

			ClearDelegateObjects();

			context_.Reset();
		}
	}
开发者ID:Galvarezss,项目名称:Unreal.js,代码行数:13,代码来源:Delegates.cpp

示例2: CheckWeakObjectsAreAlive

void ObjectManager::CheckWeakObjectsAreAlive(const vector<PersistentObjectIdPair>& instances, DirectBuffer& inputBuff, DirectBuffer& outputBuff)
{
	JEnv env;

	for (const auto& poIdPair : instances)
	{
		int javaObjectId = poIdPair.javaObjectId;

		bool success = inputBuff.Write(javaObjectId);

		if (!success)
		{
			int length = inputBuff.Length();
			env.CallStaticVoidMethod(PlatformClass, CHECK_WEAK_OBJECTS_ARE_ALIVE_METHOD_ID, (jobject) inputBuff, (jobject) outputBuff, length);
			//
			int *released = outputBuff.GetData();
			for (int i = 0; i < length; i++)
			{
				bool isReleased = *released++ != 0;

				if (isReleased)
				{
					Persistent<Object> *po = instances[i].po;
					po->Reset();
				}
			}
			//
			inputBuff.Reset();
			success = inputBuff.Write(javaObjectId);
			assert(success);
		}
	}
	int size = inputBuff.Size();
	if (size > 0)
	{
		env.CallStaticVoidMethod(PlatformClass, CHECK_WEAK_OBJECTS_ARE_ALIVE_METHOD_ID, (jobject) inputBuff, (jobject) outputBuff, size);
		int *released = outputBuff.GetData();
		for (int i = 0; i < size; i++)
		{
			bool isReleased = *released++ != 0;

			if (isReleased)
			{
				Persistent<Object> *po = instances[i].po;
				po->Reset();
			}
		}
	}

}
开发者ID:atifzaidi,项目名称:android-runtime,代码行数:50,代码来源:ObjectManager.cpp

示例3: locker

extern "C" void Java_io_neft_Native_renderer_1callAnimationFrame(JNIEnv * env, jobject obj) {
    using namespace renderer;

    // enter isolate
    Isolate* isolate = JS::GetIsolate();
    Locker locker(isolate);
    Isolate::Scope isolate_scope(isolate);
    HandleScope handle_scope(isolate);

    // get local context and enter it
    Local<Context> context = Local<Context>::New(isolate, JS::GetContext());
    Context::Scope context_scope(context);

    // call all registered functions
    const int length = animationFrameCalls.size();
    for (int i = 0; i < length; i++){
        Persistent<Function, CopyablePersistentTraits<Function>> func = animationFrameCalls[i];

        // get local function
        Local<Function> localFunc = Local<Function>::New(isolate, func);

        // call function
        localFunc->Call(context->Global(), 0, NULL);

        // clear persistent
        func.Reset();
    }

    // remove called functions
    animationFrameCalls.erase(animationFrameCalls.begin(), animationFrameCalls.begin() + length);
}
开发者ID:Neft-io,项目名称:neft,代码行数:31,代码来源:renderer.cpp

示例4: onConnection

void onConnection(const FunctionCallbackInfo<Value> &args) {
    uWS::Server *server = (uWS::Server *) args.Holder()->GetAlignedPointerFromInternalField(0);
    Isolate *isolate = args.GetIsolate();
    Persistent<Function> *connectionCallback = (Persistent<Function> *) args.Holder()->GetAlignedPointerFromInternalField(CONNECTION_CALLBACK);
    connectionCallback->Reset(isolate, Local<Function>::Cast(args[0]));
    server->onConnection([isolate, connectionCallback](uWS::Socket socket) {
        HandleScope hs(isolate);
        Local<Value> argv[] = {wrapSocket(socket, isolate)};
        node::MakeCallback(isolate, isolate->GetCurrentContext()->Global(), Local<Function>::New(isolate, *connectionCallback), 1, argv);
    });
}
开发者ID:cuongquay,项目名称:uWebSockets,代码行数:11,代码来源:addon.cpp

示例5: New

void Shape::New(const v8::FunctionCallbackInfo<Value>& args)
{
  HandleScope scope;
  Handle<Object> self = args.Holder();
  Shape *shape;

  if (args[0]->IsExternal())
  {
    Local<External> ext = Local<External>::Cast(args[0]);
    void *ptr = ext->Value();
    shape = static_cast<Shape*>(ptr);
    shape->Wrap(args.Holder());
  }
  else
  {
    shapeObj *s = (shapeObj *)msSmallMalloc(sizeof(shapeObj));

    msInitShape(s);
    if(args.Length() >= 1) {
      s->type = args[0]->Int32Value();
    }
    else {
      s->type = MS_SHAPE_NULL;
    }

    shape = new Shape(s);
    shape->Wrap(self);
  }

  /* create the attribute template. should use ObjectWrap in future */
  Handle<ObjectTemplate> attributes_templ = ObjectTemplate::New();
  attributes_templ->SetInternalFieldCount(2);
  attributes_templ->SetNamedPropertyHandler(attributeGetValue,
                                            attributeSetValue);
  Handle<Object> attributes = attributes_templ->NewInstance();
  map<string, int> *attributes_map = new map<string, int>();
  attributes->SetInternalField(0, External::New(attributes_map));
  attributes->SetInternalField(1, External::New(shape->get()->values));  
  attributes->SetHiddenValue(String::New("__parent__"), self);

  if (shape->layer) {
    for (int i=0; i<shape->layer->numitems; ++i) {
      (*attributes_map)[string(shape->layer->items[i])] = i;
    }
  }

  Persistent<Object> pattributes;
  pattributes.Reset(Isolate::GetCurrent(), attributes);
  pattributes.MakeWeak(attributes_map, attributeWeakCallback);
  pattributes.MarkIndependent();

  self->Set(String::New("attributes"), attributes);
}
开发者ID:BentleySystems,项目名称:mapserver,代码行数:53,代码来源:shape.cpp

示例6: on

void on(const FunctionCallbackInfo<Value> &args)
{
    lws::Server *server = (lws::Server *) args.Holder()->GetAlignedPointerFromInternalField(0);
    Isolate *isolate = args.GetIsolate();

    String::Utf8Value eventName(args[0]->ToString());
    if (!strncmp(*eventName, "error", eventName.length()) && !server) {
        Local<Function>::Cast(args[1])->Call(Null(isolate), 0, nullptr);
    }
    else if (server && !strncmp(*eventName, "connection", eventName.length())) {
        connectionCallback.Reset(isolate, Local<Function>::Cast(args[1]));
        server->onConnection([isolate](lws::Socket socket) {
            *socket.getUser() = nullptr;
            HandleScope hs(isolate);
            Local<Value> argv[] = {wrapSocket(&socket, isolate)->Clone()};
            Local<Function>::New(isolate, connectionCallback)->Call(Null(isolate), 1, argv);
        });
    }
    else if (server && !strncmp(*eventName, "close", eventName.length())) {
        closeCallback.Reset(isolate, Local<Function>::Cast(args[1]));
        server->onDisconnection([isolate](lws::Socket socket) {
            HandleScope hs(isolate);
            Local<Value> argv[] = {wrapSocket(&socket, isolate)};
            Local<Function>::New(isolate, closeCallback)->Call(Null(isolate), 1, argv);
            delete ((string *) *socket.getUser());
        });
    }
    else if (server && !strncmp(*eventName, "message", eventName.length())) {
        messageCallback.Reset(isolate, Local<Function>::Cast(args[1]));
        server->onMessage([isolate](lws::Socket socket, char *data, size_t length, bool binary) {
            HandleScope hs(isolate);
            Local<Value> argv[] = {wrapSocket(&socket, isolate),
                                   /*ArrayBuffer::New(isolate, data, length)*/
                                   node::Buffer::New(isolate, data, length, [](char *data, void *hint) {}, nullptr).ToLocalChecked(),
                                   Boolean::New(isolate, binary)};
            Local<Function>::New(isolate, messageCallback)->Call(Null(isolate), 3, argv);
        });
    }
}
开发者ID:iamapinan,项目名称:node-lws,代码行数:39,代码来源:addon.cpp

示例7: JS_Query

void MySQL::JS_Query(const FunctionCallbackInfo<Value> & args){
	auto mysql = Instance(args.Holder());
	auto mysqlconn = ConnectionInstance(args.Holder());

	string query = JS2STRING(args[0]);

	if (args[1]->IsFunction()){
		Persistent<Function, CopyablePersistentTraits<Function>> func;
		func.Reset(args.GetIsolate(), Local<Function>::Cast(args[1]));
		mysql->QueryAsync(mysqlconn->id, query, func);
		return;
	}
}
开发者ID:steilman,项目名称:samp.js,代码行数:13,代码来源:MySQL.cpp

示例8: onDisconnection

void onDisconnection(const FunctionCallbackInfo<Value> &args) {
    uWS::Server *server = (uWS::Server *) args.Holder()->GetAlignedPointerFromInternalField(0);
    Isolate *isolate = args.GetIsolate();
    Persistent<Function> *disconnectionCallback = (Persistent<Function> *) args.Holder()->GetAlignedPointerFromInternalField(DISCONNECTION_CALLBACK);
    disconnectionCallback->Reset(isolate, Local<Function>::Cast(args[0]));
    server->onDisconnection([isolate, disconnectionCallback](uWS::Socket socket, int code, char *message, size_t length) {
        HandleScope hs(isolate);
        Local<Value> argv[] = {wrapSocket(socket, isolate),
                               Integer::New(isolate, code),
                               node::Buffer::New(isolate, (char *) message, length, [](char *data, void *hint) {}, nullptr).ToLocalChecked(),
                               getDataV8(socket, isolate)};
        node::MakeCallback(isolate, isolate->GetCurrentContext()->Global(), Local<Function>::New(isolate, *disconnectionCallback), 4, argv);
    });
}
开发者ID:cuongquay,项目名称:uWebSockets,代码行数:14,代码来源:addon.cpp

示例9: onMessage

void onMessage(const FunctionCallbackInfo<Value> &args) {
    uWS::Server *server = (uWS::Server *) args.Holder()->GetAlignedPointerFromInternalField(0);
    Isolate *isolate = args.GetIsolate();
    Persistent<Function> *messageCallback = (Persistent<Function> *) args.Holder()->GetAlignedPointerFromInternalField(MESSAGE_CALLBACK);
    messageCallback->Reset(isolate, Local<Function>::Cast(args[0]));
    server->onMessage([isolate, messageCallback](uWS::Socket socket, const char *message, size_t length, uWS::OpCode opCode) {
        HandleScope hs(isolate);
        Local<Value> argv[] = {wrapSocket(socket, isolate),
                               node::Buffer::New(isolate, (char *) message, length, [](char *data, void *hint) {}, nullptr).ToLocalChecked(),
                               Boolean::New(isolate, opCode == BINARY),
                               getDataV8(socket, isolate)};
        node::MakeCallback(isolate, isolate->GetCurrentContext()->Global(), Local<Function>::New(isolate, *messageCallback), 4, argv);
    });
}
开发者ID:cuongquay,项目名称:uWebSockets,代码行数:14,代码来源:addon.cpp

示例10: udeb_setLogger

void udeb_setLogger(const Arguments &args) {
  EscapableHandleScope scope(args.GetIsolate());

  if(! udeb_initialized) {
    JSLoggerFunction.Reset(args.GetIsolate(), args[0]->ToObject());
    // JSLoggerFunction.Reset(Function::Cast(* (args[0])));
    // Local<Function> f = Function::Cast(* (args[0]));
    // JSLoggerFunction = Persistent<Function>::New(f);
    udeb_initialized = 1;

    udeb_print("unified_debug.cpp", UDEB_DEBUG, 
               "unified_debug.cpp C++ unified_debug enabled");
  }
  args.GetReturnValue().Set(true);
}
开发者ID:alMysql,项目名称:mysql-js,代码行数:15,代码来源:unified_debug.cpp

示例11: scope

Handle<Object> Log::Wrap()
{
	Isolate *isolate = jsCompiler_.GetIsolate();
	HandleScope scope(isolate);

	if (logTemplate.IsEmpty()) {
		Handle<ObjectTemplate> objTemplate = MakeLogTemplate(isolate);
		logTemplate.Reset(isolate, objTemplate);
	}
	Handle<ObjectTemplate> local = Local<ObjectTemplate>::New(isolate, logTemplate);
	Handle<Object> obj = local->NewInstance();
	Handle<External> log_ptr = External::New(this);
	obj->SetInternalField(0, log_ptr);
	return scope.Close(obj);
}
开发者ID:Nightaway,项目名称:dragon,代码行数:15,代码来源:Log.cpp

示例12: Init

void Init(Isolate * isolate)
{
	Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
	tpl->SetClassName(v8::String::NewFromUtf8(isolate, "Transformable"));
	tpl->InstanceTemplate()->SetInternalFieldCount(2);
	Local<ObjectTemplate> proto = tpl->PrototypeTemplate();
//	proto->SetInternalFieldCount(1);
	proto->SetAccessor(v8::String::NewFromUtf8(isolate, "x"), GetX, SetX);
	proto->SetAccessor(v8::String::NewFromUtf8(isolate, "y"), GetY, SetY);
	proto->SetAccessor(v8::String::NewFromUtf8(isolate, "rotation"), GetRotation, SetRotation);
	proto->SetAccessor(v8::String::NewFromUtf8(isolate, "scaleX"), GetScaleX, SetScaleX);
	proto->SetAccessor(v8::String::NewFromUtf8(isolate, "scaleY"), GetScaleY, SetScaleY);
	proto->SetAccessor(v8::String::NewFromUtf8(isolate, "originX"), GetOriginX, SetOriginX);
	proto->SetAccessor(v8::String::NewFromUtf8(isolate, "originY"), GetOriginY, SetOriginY);
	tpl_ref.Reset(isolate, tpl);
}
开发者ID:seobyeongky,项目名称:gunman,代码行数:16,代码来源:v8_transformable.cpp

示例13: Main

void Main(Local<Object> exports)
{
    Isolate *isolate = exports->GetIsolate();
    Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, constructor);
    tpl->InstanceTemplate()->SetInternalFieldCount(1);

    NODE_SET_PROTOTYPE_METHOD(tpl, "on", on);
    NODE_SET_PROTOTYPE_METHOD(tpl, "send", send);
    NODE_SET_PROTOTYPE_METHOD(tpl, "setUserData", setUserData);
    NODE_SET_PROTOTYPE_METHOD(tpl, "getUserData", getUserData);
    NODE_SET_PROTOTYPE_METHOD(tpl, "getFd", getFd);

    exports->Set(String::NewFromUtf8(isolate, "Server"), tpl->GetFunction());

    Local<ObjectTemplate> socketTemplate = ObjectTemplate::New(isolate);
    socketTemplate->SetInternalFieldCount(2);
    persistentSocket.Reset(isolate, socketTemplate->NewInstance());
}
开发者ID:iamapinan,项目名称:node-lws,代码行数:18,代码来源:addon.cpp

示例14:

    ~executeBaton() {
        obj = NULL;
        // the StmtObject will free sqlany_stmt
        sqlany_stmt = NULL;
        CLEAN_STRINGS( string_vals );
        CLEAN_STRINGS( colNames );
        CLEAN_NUMS( num_vals );
        CLEAN_NUMS( int_vals );
        CLEAN_NUMS( string_len );
        col_types.clear();
        callback.Reset();

        for( size_t i = 0; i < params.size(); i++ ) {
            if( params[i].value.is_null != NULL ) {
                delete params[i].value.is_null;
                params[i].value.is_null = NULL;
            }
        }
        params.clear();
    }
开发者ID:jpheur,项目名称:node-sqlanywhere,代码行数:20,代码来源:sqlanywhere.cpp

示例15: ThrowException

/* Execute a javascript file */
static Handle<Value> msV8ExecuteScript(const char *path, int throw_exception = MS_FALSE)
{
  char fullpath[MS_MAXPATHLEN];
  map<string, Persistent<Script> >::iterator it;
  Isolate *isolate = Isolate::GetCurrent();
  V8Context *v8context = (V8Context*)isolate->GetData();

  /* construct the path */
  msBuildPath(fullpath, v8context->paths.top().c_str(), path);
  char *filepath = msGetPath((char*)fullpath);
  v8context->paths.push(filepath);
  free(filepath);

  Handle<Script> script;
  it = v8context->scripts.find(fullpath);
  if (it == v8context->scripts.end()) {
    Handle<Value> source = msV8ReadFile(v8context, fullpath);
    Handle<String> script_name = String::New(msStripPath((char*)path));
    script = msV8CompileScript(source->ToString(), script_name);
    if (script.IsEmpty()) {
      v8context->paths.pop();
      if (throw_exception) {
        return ThrowException(String::New("Error compiling script"));
      }
    }
    /* cache the compiled script */
    Persistent<Script> pscript;
    pscript.Reset(isolate, script);
    v8context->scripts[fullpath] = pscript;
  } else {
    script = v8context->scripts[fullpath];
  }

  Handle<Value> result = msV8RunScript(script);
  v8context->paths.pop();
  if (result.IsEmpty() && throw_exception) {
    return ThrowException(String::New("Error running script"));
  }

  return result;
}
开发者ID:BentleySystems,项目名称:mapserver,代码行数:42,代码来源:mapv8.cpp


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