本文整理汇总了C++中FunctionCallbackInfo::Holder方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionCallbackInfo::Holder方法的具体用法?C++ FunctionCallbackInfo::Holder怎么用?C++ FunctionCallbackInfo::Holder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FunctionCallbackInfo
的用法示例。
在下文中一共展示了FunctionCallbackInfo::Holder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JS_Close
void MySQL::JS_Close(const FunctionCallbackInfo<Value> & args){
auto mysql = Instance(args.Holder());
auto mysqlconn = ConnectionInstance(args.Holder());
std::lock_guard<std::mutex> lock{ mysqlconn->lock };
if (mysql->isConnected(mysqlconn->mysql)){
mysql_close(mysqlconn->mysql);
}
}
示例2: 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);
});
}
示例3: 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;
}
}
示例4: 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);
});
}
示例5: 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);
});
}
示例6: Status
void ETW::Status(const FunctionCallbackInfo<Value>& args)
{
Isolate* isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
ETW* obj = ObjectWrap::Unwrap<ETW>(args.Holder());
args.GetReturnValue().Set(Number::New(isolate, obj->m_pTraceSession->Status()));
}
示例7: invoke
inline typename boost::enable_if<boost::is_member_function_pointer<TCallback>, TResult >::type
invoke (const FunctionCallbackInfo<Value> &info)
{
typedef typename mpl::begin<TSignature>::type TSeqFirst;
typedef typename mpl::next< TSeqFirst >::type TSeqInstanceType;
typedef typename boost::remove_const<typename boost::remove_reference<typename TSeqInstanceType::type>::type >::type TInstanceType;
/* Retrieve "this" from V8 */
Local<Object> _this = info.Holder();
/* Get address by casting the External saved value.
Note that it was saved in NativeClass<TClass>::ctor */
TInstanceType *instance = static_cast<TInstanceType *>(_this->GetAlignedPointerFromInternalField(_this->InternalFieldCount() - 2));
# if N
# define BOOST_PP_LOCAL_MACRO(i) V8_BRIDGE_SETUP_ARG(i, TSeqInstanceType)
# define BOOST_PP_LOCAL_LIMITS (0, N-1)
# include BOOST_PP_LOCAL_ITERATE()
# endif
return bridge::detail::invoke_native_raw<TResult>(
this->m_isolationScope
, detail::invoke_tag<TResult, TPointer>()
, this->m_callbackPointer
, instance
BOOST_PP_ENUM_TRAILING_PARAMS(N, resolvedArg)
);
}
示例8: jsToString
//! \verbatim
//! String Quaternion.toString
//! \endverbatim
void Quaternion::jsToString( const FunctionCallbackInfo<v8::Value>& args )
{
Quaternion* ptr = unwrap( args.Holder() );
char result[128];
sprintf_s<128>( result, "Quaternion[%f,%f,%f,%f]", ptr->w, ptr->x, ptr->y, ptr->z );
args.GetReturnValue().Set( Util::allocString( result ) );
}
示例9: hash
void hash(const FunctionCallbackInfo<Value>& args)
{
if (args.Length() < 1) {
Utility::throwException(args.GetIsolate(), Utility::ExceptionInvalidArgumentCount);
return;
}
if (!args[0]->IsInt32()) {
Utility::throwException(args.GetIsolate(), Utility::ExceptionInvalidArgumentType);
return;
}
QByteArray input = ModuleByteArray::unwrapByteArray(args.GetIsolate(), args.Holder());
int algorithm = args[0]->Int32Value();
HandleScope handle_scope(args.GetIsolate());
QByteArray hashValue;
switch (algorithm) {
case QCryptographicHash::Md4:
hashValue = QCryptographicHash::hash(input, QCryptographicHash::Md4);
break;
case QCryptographicHash::Md5:
hashValue = QCryptographicHash::hash(input, QCryptographicHash::Md5);
break;
case QCryptographicHash::Sha1:
hashValue = QCryptographicHash::hash(input, QCryptographicHash::Sha1);
break;
case QCryptographicHash::Sha224:
hashValue = QCryptographicHash::hash(input, QCryptographicHash::Sha224);
break;
case QCryptographicHash::Sha256:
hashValue = QCryptographicHash::hash(input, QCryptographicHash::Sha256);
break;
case QCryptographicHash::Sha384:
hashValue = QCryptographicHash::hash(input, QCryptographicHash::Sha384);
break;
case QCryptographicHash::Sha512:
hashValue = QCryptographicHash::hash(input, QCryptographicHash::Sha512);
break;
case QCryptographicHash::Sha3_224:
hashValue = QCryptographicHash::hash(input, QCryptographicHash::Sha3_224);
break;
case QCryptographicHash::Sha3_256:
hashValue = QCryptographicHash::hash(input, QCryptographicHash::Sha3_256);
break;
case QCryptographicHash::Sha3_384:
hashValue = QCryptographicHash::hash(input, QCryptographicHash::Sha3_384);
break;
case QCryptographicHash::Sha3_512:
hashValue = QCryptographicHash::hash(input, QCryptographicHash::Sha3_512);
break;
default: {
Utility::throwException(args.GetIsolate(), Utility::ExceptionInvalidArgumentValue);
return;
}
}
args.GetReturnValue().Set(ModuleByteArray::wrapByteArray(args.GetIsolate(), hashValue));
}
示例10: broadcast
void broadcast(const FunctionCallbackInfo<Value> &args)
{
uWS::Server *server = (uWS::Server *) args.Holder()->GetAlignedPointerFromInternalField(0);
OpCode opCode = args[1]->BooleanValue() ? BINARY : TEXT;
NativeString nativeString(args[0]);
server->broadcast(nativeString.getData(), nativeString.getLength(), opCode);
}
示例11: Serialize
void ABPFilterParserWrap::Serialize(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
ABPFilterParserWrap* obj =
ObjectWrap::Unwrap<ABPFilterParserWrap>(args.Holder());
int totalSize = 0;
// Serialize data
char* data = obj->serialize(&totalSize);
if (nullptr == data) {
isolate->ThrowException(Exception::TypeError(
String::NewFromUtf8(isolate, "Could not serialize")));
return;
}
MaybeLocal<Object> buffer = node::Buffer::New(isolate, totalSize);
Local<Object> localBuffer;
if (!buffer.ToLocal(&localBuffer)) {
isolate->ThrowException(Exception::TypeError(
String::NewFromUtf8(isolate, "Could not convert MaybeLocal to Local")));
return;
}
memcpy(node::Buffer::Data(localBuffer), data, totalSize);
delete[] data;
args.GetReturnValue().Set(localBuffer);
}
示例12: 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());
}
示例13: Home
void LCDWrapper::Home(const FunctionCallbackInfo<Value>& args){
Isolate* isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
LCDWrapper* temp_obj = ObjectWrap::Unwrap<LCDWrapper>(args.Holder());
temp_obj->lcd->home();
}
示例14: 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));
}
示例15: length
void IdPool::length(const FunctionCallbackInfo<Value>& args)
{
Isolate* isolate = args.GetIsolate();
IdPool* idPool = ObjectWrap::Unwrap<IdPool>(args.Holder());
args.GetReturnValue().Set(Number::New(isolate, idPool->_reserved));
}