本文整理汇总了C++中FunctionCallbackInfo::GetIsolate方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionCallbackInfo::GetIsolate方法的具体用法?C++ FunctionCallbackInfo::GetIsolate怎么用?C++ FunctionCallbackInfo::GetIsolate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FunctionCallbackInfo
的用法示例。
在下文中一共展示了FunctionCallbackInfo::GetIsolate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printable
void printable(const FunctionCallbackInfo<Value>& args)
{
QByteArray data = ModuleByteArray::unwrapByteArray(args.GetIsolate(), args.Holder());
QString placeholder = ".";
if (args.Length() >= 1) {
if (!args[0]->IsString()) {
Utility::throwException(args.GetIsolate(), Utility::ExceptionInvalidArgumentType);
return;
}
placeholder = Utility::toString(args[0]);
}
QString result;
result.reserve(data.length());
for (int i = 0; i < data.length(); i++) {
char c = data.at(i);
if (QChar::isPrint(c))
result.append(c);
else
result.append(placeholder);
}
args.GetReturnValue().Set(Utility::toV8String(args.GetIsolate(), result));
}
示例2: JS_New
void MySQL::JS_New(const FunctionCallbackInfo<Value> & args){
auto mysql = Instance(args.Holder());
auto conn_tmpl = ObjectTemplate::New(args.GetIsolate());
conn_tmpl->SetInternalFieldCount(1);
MYSQL *mysql2 = mysql_init(NULL);
auto conn = mysql->createConnection();
JS_Object jsconn(conn_tmpl->NewInstance());
jsconn.Set("connect", JS_Connect);
jsconn.Set("query", JS_Query);
jsconn.Set("escape", JS_RealEscape);
jsconn.Set("close", JS_Close);
jsconn.Set("connected", JS_Connected);
jsconn.Set("ping", JS_Connected);
jsconn.get()->SetInternalField(0, External::New(args.GetIsolate(), conn));
JS_Object parentConn(Local<Object>::Cast(args[0]));
parentConn.Set("internal", jsconn.get());
}
示例3: jsCreateMyClass
void jsCreateMyClass(const FunctionCallbackInfo<Value>& args)
{
if (args.Length() != 1)
{
args.GetIsolate()->ThrowException(
String::NewFromUtf8(args.GetIsolate(), "Bad parameters",
NewStringType::kNormal).ToLocalChecked());
return;
}
Isolate* isolate = args.GetIsolate();
Local<ObjectTemplate> myClassTemplate =
Local<ObjectTemplate>::New(isolate, gMyClassTemplate);
Local<Object> myClassObj = myClassTemplate->NewInstance(
isolate->GetCurrentContext()).ToLocalChecked();
int numValue =
args[0]->Int32Value(isolate->GetCurrentContext()).FromMaybe(0);
gMyClass = new ObjectWrap(numValue);
gMyClass->Wrap(myClassObj);
args.GetReturnValue().Set(myClassObj);
}
示例4: getAddress
void getAddress(const FunctionCallbackInfo<Value> &args)
{
uWS::Socket::Address address = unwrapSocket(args[0]->ToNumber()).getAddress();
Local<Array> array = Array::New(args.GetIsolate(), 3);
array->Set(0, Integer::New(args.GetIsolate(), address.port));
array->Set(1, String::NewFromUtf8(args.GetIsolate(), address.address));
array->Set(2, String::NewFromUtf8(args.GetIsolate(), address.family));
args.GetReturnValue().Set(array);
}
示例5: JS_ReloadScript
void Server::JS_ReloadScript(const FunctionCallbackInfo<Value> & args){
if (args.Length() < 1) return;
if (!args[0]->IsString()) return;
JS_SCOPE(args.GetIsolate());
string file = JS2STRING(args[0]);
auto server = Server::GetInstance(args.GetIsolate()->GetCallingContext());
Reload(file, server->GetAMX());
}
示例6: create
//! \verbatim
//! Quaternion()
//! Quaternion( Radian rotation, Vector3 axis )
//! Quaternion( Real w, Real x, Real y, Real z )
//! Quaternion([Real w, Real x, Real y, Real z])
//! Quaternion({Real w, Real x, Real y, Real z})
//! \endverbatim
void Quaternion::create( const FunctionCallbackInfo<v8::Value>& args )
{
HandleScope handleScope( args.GetIsolate() );
if ( !args.IsConstructCall() )
{
args.GetIsolate()->ThrowException(
Util::allocString( "Function called as non-constructor" ) );
return;
}
Ogre::Quaternion qtn( Ogre::Quaternion::IDENTITY );
if ( args.Length() == 4 )
{
qtn.w = args[0]->NumberValue();
qtn.x = args[1]->NumberValue();
qtn.y = args[2]->NumberValue();
qtn.z = args[3]->NumberValue();
}
else if ( args.Length() == 2 )
{
Vector3* axis = Util::extractVector3( 1, args );
qtn.FromAngleAxis( Ogre::Radian( args[0]->NumberValue() ), *axis );
}
else if ( args.Length() == 1 )
{
if ( args[0]->IsArray() )
{
v8::Local<v8::Array> arr = v8::Local<v8::Array>::Cast( args[0] );
if ( arr->Length() == 4 )
{
qtn.w = arr->Get( 0 )->NumberValue();
qtn.x = arr->Get( 1 )->NumberValue();
qtn.y = arr->Get( 2 )->NumberValue();
qtn.z = arr->Get( 3 )->NumberValue();
}
}
else if ( args[0]->IsObject() )
{
v8::Local<v8::Value> val = args[0]->ToObject()->Get( Util::allocString( "w" ) );
if ( val->IsNumber() )
qtn.w = val->NumberValue();
val = args[0]->ToObject()->Get( Util::allocString( "x" ) );
if ( val->IsNumber() )
qtn.x = val->NumberValue();
val = args[0]->ToObject()->Get( Util::allocString( "y" ) );
if ( val->IsNumber() )
qtn.y = val->NumberValue();
val = args[0]->ToObject()->Get( Util::allocString( "z" ) );
if ( val->IsNumber() )
qtn.z = val->NumberValue();
}
}
Quaternion* object = new Quaternion( qtn );
object->wrap( args.This() );
args.GetReturnValue().Set( args.This() );
}
示例7: register_master_timer
void register_master_timer(const FunctionCallbackInfo<Value>& args) {
if (args.Length() != 3) {
LOG_ERROR("register_master_timer args error, length: %d\n", args.Length());
return;
}
int timer_id = args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromMaybe(0);
int interval = args[1]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromMaybe(0);
int first_tick_internal = args[2]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromMaybe(0);
LOG_ERROR("register_master_timer,timer_id:%d, interval:%dms, first_tick_internal:%ds\n", timer_id, interval, first_tick_internal);
MASTER_TIMER->register_v8_handler(timer_id, interval, first_tick_internal);
}
示例8: JS_GetMemory
void Server::JS_GetMemory(const FunctionCallbackInfo<Value> & args){
size_t peak = sampjs::getPeakRSS();
size_t current = sampjs::getCurrentRSS();
Local<Object> mem = Object::New(args.GetIsolate());
mem->Set(String::NewFromUtf8(args.GetIsolate(), "current"), Integer::New(args.GetIsolate(),current));
mem->Set(String::NewFromUtf8(args.GetIsolate(), "peak"), Integer::New(args.GetIsolate(), peak));
args.GetReturnValue().Set(mem);
}
示例9: push_master_client_buffer
void push_master_client_buffer(const FunctionCallbackInfo<Value>& args) {
if (args.Length() != 2) {
LOG_ERROR("push_master_client_buffer args error, length: %d\n", args.Length());
return;
}
int cid = args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromMaybe(0);
Block_Buffer *buf= unwrap_buffer(args[1]->ToObject(args.GetIsolate()->GetCurrentContext()).ToLocalChecked());
if (buf) {
MASTER_GATE_SERVER->push_block(cid, buf);
}
}
示例10: scope
void Texture2D::New(const FunctionCallbackInfo<Value>& args) {
HandleScope scope(args.GetIsolate());
ScriptHelper helper(args.GetIsolate());
auto filepath = ScriptEngine::current().resolvePath(
helper.GetString(args[0]));
try {
auto texture = new Texture2D(args.GetIsolate(), filepath);
args.GetReturnValue().Set(texture->v8Object());
}
catch (std::exception& ex) {
ScriptEngine::current().ThrowTypeError(ex.what());
}
}
示例11: sync_data_to_game
void sync_data_to_game(const FunctionCallbackInfo<Value>& args) {
if (args.Length() != 2) {
LOG_ERROR("sync_data_to_game args error, length: %d\n", args.Length());
return;
}
Master_Player *player = unwrap_master_player(args.Holder());
if (!player) {
return;
}
int msg_id = args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromMaybe(0);
Block_Buffer *buf = unwrap_buffer(args[1]->ToObject(args.GetIsolate()->GetCurrentContext()).ToLocalChecked());
player->sync_data_to_game(msg_id, buf);
}
示例12: jsMyFunction1
void jsMyFunction1(const FunctionCallbackInfo<Value>& args)
{
if (args.Length() != 1)
{
args.GetIsolate()->ThrowException(
String::NewFromUtf8(args.GetIsolate(), "Bad parameters",
NewStringType::kNormal).ToLocalChecked());
return;
}
String::Utf8Value str(args[0]);
const char* cstr = ToCString(str);
myFunction1(cstr);
}
示例13: setData
void setData(const FunctionCallbackInfo<Value> &args)
{
uWS::Socket socket = unwrapSocket(args[0]->ToNumber());
if (socket.getData()) {
/* reset data when only specifying the socket */
if (args.Length() == 1) {
((Persistent<Value> *) socket.getData())->Reset();
delete (Persistent<Value> *) socket.getData();
} else {
((Persistent<Value> *) socket.getData())->Reset(args.GetIsolate(), args[1]);
}
} else {
socket.setData(new Persistent<Value>(args.GetIsolate(), args[1]));
}
}
示例14: game_player_respond_success_result
void game_player_respond_success_result(const FunctionCallbackInfo<Value>& args) {
if (args.Length() != 2) {
LOG_ERROR("respond_success_result args error, length: %d\n", args.Length());
return;
}
Game_Player *player = unwrap_game_player(args.Holder());
if (!player) {
return;
}
int msg_id = args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromMaybe(0);
Block_Buffer *buf = unwrap_buffer(args[1]->ToObject(args.GetIsolate()->GetCurrentContext()).ToLocalChecked());
player->respond_success_result(msg_id, buf);
}
示例15: game_player_respond_error_result
void game_player_respond_error_result(const FunctionCallbackInfo<Value>& args) {
if (args.Length() != 2) {
LOG_ERROR("respond_error_result args error, length: %d\n", args.Length());
return;
}
Game_Player *player = unwrap_game_player(args.Holder());
if (!player) {
return;
}
int msg_id = args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromMaybe(0);
int error_code = args[1]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromMaybe(0);
player->respond_error_result(msg_id, error_code);
}