本文整理汇总了C++中v8::FunctionCallbackInfo::Callee方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionCallbackInfo::Callee方法的具体用法?C++ FunctionCallbackInfo::Callee怎么用?C++ FunctionCallbackInfo::Callee使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v8::FunctionCallbackInfo
的用法示例。
在下文中一共展示了FunctionCallbackInfo::Callee方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NewImage
void ImageWrapper::NewImage( const v8::FunctionCallbackInfo< v8::Value >& args)
{
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope handleScope( isolate);
if(!args.IsConstructCall())
{
DALI_SCRIPT_EXCEPTION( isolate, "Image constructor called without 'new'");
return;
}
// find out the callee function name...e.g. BufferImage, ResourceImage
v8::Local<v8::Function> callee = args.Callee();
v8::Local<v8::Value> v8String = callee->GetName();
std::string typeName = V8Utils::v8StringToStdString( v8String );
ImageType imageType = GetImageType( typeName );
if( imageType == UNKNOWN_IMAGE_TYPE )
{
DALI_SCRIPT_EXCEPTION( isolate, "unknown image type");
return;
}
Image image = (ImageApiLookup[imageType].constructor)( args );
if( ! image )
{
// a v8 exception will have been thrown by the constructor
return;
}
v8::Local<v8::Object> localObject = WrapImage( isolate, image, imageType );
args.GetReturnValue().Set( localObject );
}
示例2: frameWait
void frameWait(const v8::FunctionCallbackInfo<v8::Value>& args) {
Interface::frameWait();
Local<External> shapeManagerExternal = Local<External>::Cast(args.Callee()->Get(String::NewFromUtf8(Isolate::GetCurrent(), shapeManagerStr.c_str())));
ShapeManager2d* shapeManager = static_cast<ShapeManager2d*>(shapeManagerExternal->Value());
UDPsocket socket = SDLNet_UDP_Open(0); // socket for writing.
std::stringstream sstream;
bostream out(sstream);
out << *shapeManager;
std::string str = sstream.str();
UDPpacket* packet = SDLNet_AllocPacket(str.size());
if(!packet) {
std::cerr << "SDLNet_AllocPacket: " << SDLNet_GetError() << std::endl;
// perhaps do something else since you can't make this packet
} else {
packet->len = str.size();
memcpy(packet->data, str.c_str(), str.size());
SDLNet_ResolveHost(&packet->address, "127.0.0.1", 54321);
SDLNet_UDP_Send(socket, -1, packet);
SDLNet_FreePacket(packet);
}
SDLNet_UDP_Close(socket);
args.GetReturnValue().Set(Boolean::New(Isolate::GetCurrent(), true));
}
示例3:
void V8PerIsolateData::constructorOfToString(const v8::FunctionCallbackInfo<v8::Value>& info)
{
// The DOM constructors' toString functions grab the current toString
// for Functions by taking the toString function of itself and then
// calling it with the constructor as its receiver. This means that
// changes to the Function prototype chain or toString function are
// reflected when printing DOM constructors. The only wart is that
// changes to a DOM constructor's toString's toString will cause the
// toString of the DOM constructor itself to change. This is extremely
// obscure and unlikely to be a problem.
v8::Handle<v8::Value> value = info.Callee()->Get(v8::String::NewSymbol("toString"));
if (!value->IsFunction()) {
v8SetReturnValue(info, v8::String::Empty(info.GetIsolate()));
return;
}
v8SetReturnValue(info, V8ScriptRunner::callInternalFunction(v8::Handle<v8::Function>::Cast(value), info.This(), 0, 0, v8::Isolate::GetCurrent()));
}
示例4: makeLine
void makeLine(const v8::FunctionCallbackInfo<v8::Value>& args) {
if(args.Length() != 4) {
args.GetReturnValue().Set(Boolean::New(Isolate::GetCurrent(), false));
return;
}
Local<External> shapeManagerExternal = Local<External>::Cast(args.Callee()->Get(String::NewFromUtf8(Isolate::GetCurrent(), shapeManagerStr.c_str())));
ShapeManager2d* shapeManager = static_cast<ShapeManager2d*>(shapeManagerExternal->Value());
Point2d p1{args[0]->NumberValue(), args[1]->NumberValue()};
Point2d p2{args[2]->NumberValue(), args[3]->NumberValue()};
Local<Object> obj = initShape()->NewInstance();
unsigned int shape = shapeManager->makeLine(p1, p2);
obj->SetInternalField(0, shapeManagerExternal);
obj->SetInternalField(1, Integer::NewFromUnsigned(Isolate::GetCurrent(), shape));
args.GetReturnValue().Set(obj);
}
示例5: constructorOfToString
static void constructorOfToString(const v8::FunctionCallbackInfo<v8::Value>& info)
{
// The DOM constructors' toString functions grab the current toString
// for Functions by taking the toString function of itself and then
// calling it with the constructor as its receiver. This means that
// changes to the Function prototype chain or toString function are
// reflected when printing DOM constructors. The only wart is that
// changes to a DOM constructor's toString's toString will cause the
// toString of the DOM constructor itself to change. This is extremely
// obscure and unlikely to be a problem.
v8::Isolate* isolate = info.GetIsolate();
v8::Local<v8::Value> value;
if (!info.Callee()->Get(isolate->GetCurrentContext(), v8AtomicString(isolate, "toString")).ToLocal(&value) || !value->IsFunction()) {
v8SetReturnValue(info, v8::String::Empty(isolate));
return;
}
v8::Local<v8::Value> result;
if (V8ScriptRunner::callInternalFunction(v8::Local<v8::Function>::Cast(value), info.This(), 0, 0, isolate).ToLocal(&result))
v8SetReturnValue(info, result);
}