本文整理汇总了C++中Arguments::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ Arguments::Length方法的具体用法?C++ Arguments::Length怎么用?C++ Arguments::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arguments
的用法示例。
在下文中一共展示了Arguments::Length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VException
Handle<Value>
DynamicJpegStack::New(const Arguments &args)
{
HandleScope scope;
if (args.Length() > 1)
return VException("One argument max - buffer type.");
buffer_type buf_type = BUF_RGB;
if (args.Length() == 1) {
if (!args[0]->IsString())
return VException("First argument must be a string. Either 'rgb', 'bgr', 'rgba' or 'bgra'.");
String::AsciiValue bt(args[0]->ToString());
if (!(str_eq(*bt, "rgb") || str_eq(*bt, "bgr") ||
str_eq(*bt, "rgba") || str_eq(*bt, "bgra")))
{
return VException("Buffer type must be 'rgb', 'bgr', 'rgba' or 'bgra'.");
}
if (str_eq(*bt, "rgb"))
buf_type = BUF_RGB;
else if (str_eq(*bt, "bgr"))
buf_type = BUF_BGR;
else if (str_eq(*bt, "rgba"))
buf_type = BUF_RGBA;
else if (str_eq(*bt, "bgra"))
buf_type = BUF_BGRA;
else
return VException("Buffer type wasn't 'rgb', 'bgr', 'rgba' or 'bgra'.");
}
DynamicJpegStack *jpeg = new DynamicJpegStack(buf_type);
jpeg->Wrap(args.This());
return args.This();
}
示例2: ThrowException
/**
* Executes a command.
*/
Handle<Value> Exec(const Arguments& args) {
HandleScope scope;
if (args.Length() < 1) {
return ThrowException(
Exception::TypeError(String::New("First argument must be a string"))
);
}
Local<String> str = args[0]->ToString();
std::string cmd = FlattenString(str);
int result = exec(cmd.c_str());
return scope.Close(Integer::New(result));
}
示例3: Undefined
Handle<Value> DecoderNotifier::Done(const Arguments& args) {
HandleScope scope;
DecoderNotifier* obj = ObjectWrap::Unwrap<DecoderNotifier>(args.This());
if(args.Length() == 0){
// Process next frame
uv_queue_work(uv_default_loop(),
&(obj->pBaton->request),
AsyncWork,
(uv_after_work_cb)AsyncAfter);
}
return Undefined();
}
示例4: GlobalVariable
Handle< ::v8::Value> GlobalVariable::New(const Arguments& args)
{
HandleScope scope;
if (args.Length()) {
REQ_LLVM_MODULE_ARG(0, module);
REQ_LLVM_TYPE_ARG(1, type);
REQ_UTF8_ARG(2, name);
REQ_LLVM_CONST_ARG(3, init);
GlobalVariable* val = new GlobalVariable(new ::llvm::GlobalVariable(*module, type, false, llvm::GlobalValue::InternalLinkage, init, *name));
val->Wrap(args.This());
}
return args.This();
}
示例5: ALUTLoadMemoryHelloWorldCallback
Handle<Value> ALUTLoadMemoryHelloWorldCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 3)
return v8::Undefined();
//get arguments
Handle<Array> arg0 = Array::Cast(args[0]);
Handle<Array> arg1 = Array::Cast(args[1]);
Handle<Array> arg2 = Array::Cast(args[2]);
//make call
alutLoadMemoryHelloWorld((ALenum*)arg0, (ALsizei*)arg1, (ALfloat*)arg2);
return v8::Undefined();
}
示例6: ALUTCreateBufferFromFileImageCallback
Handle<Value> ALUTCreateBufferFromFileImageCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2)
return v8::Undefined();
//get arguments
String::Utf8Value value0(args[0]);
char* key0 = *value0;
void* arg0 = font_[key0];
//make call
alutCreateBufferFromFileImage((const ALvoid*)arg0, (ALsizei)arg1);
return v8::Undefined();
}
示例7: ALUTInitWithoutContextCallback
Handle<Value> ALUTInitWithoutContextCallback(const Arguments& args) {
//if less that nbr of formal parameters then do nothing
if (args.Length() < 2)
return v8::Undefined();
//get arguments
Handle<Array> arg0 = Array::Cast(args[0]);
String::Utf8Value value1(args[1]);
char* arg1 = *value1;
//make call
alutInitWithoutContext((int*)arg0, (char**)arg1);
return v8::Undefined();
}
示例8: ThrowException
Handle<Value> Expression::New(const Arguments& args)
{
HandleScope scope;
if (!args.IsConstructCall())
return ThrowException(String::New("Cannot call constructor as function, you need to use 'new' keyword"));
if (args[0]->IsExternal())
{
//std::clog << "external!\n";
Local<External> ext = Local<External>::Cast(args[0]);
void* ptr = ext->Value();
Expression* e = static_cast<Expression*>(ptr);
e->Wrap(args.This());
return args.This();
}
mapnik::expression_ptr e_ptr;
try
{
if (args.Length() == 1 && args[0]->IsString()){
e_ptr = mapnik::parse_expression(TOSTR(args[0]),"utf8");
} else {
return ThrowException(Exception::Error(
String::New("invalid arguments: accepts a single argument of string type")));
}
}
catch (std::exception const& ex)
{
return ThrowException(Exception::Error(
String::New(ex.what())));
}
if (e_ptr)
{
Expression* e = new Expression();
e->Wrap(args.This());
e->this_ = e_ptr;
return args.This();
}
else
{
return ThrowException(Exception::Error(
String::New("unknown exception happened, please file bug")));
}
return Undefined();
}
示例9: ERROR_BADINSTANCE
// メソッドの呼び出し
Handle<Value>
TJSObject::caller(const Arguments& args)
{
tTJSVariant self;
if (getVariant(self, args.This())) {
Handle<Value> ret;
// 引数変換
tjs_int argc = args.Length();
tTJSVariant **argv = new tTJSVariant*[argc];
for (tjs_int i=0;i<argc;i++) {
argv[i] = new tTJSVariant();
*argv[i] = toVariant(args[i]);
}
if (self.AsObjectClosureNoAddRef().IsInstanceOf(0, NULL, NULL, L"Class", NULL) == TJS_S_TRUE) {
// クラスオブジェクトならコンストラクタ呼び出し
iTJSDispatch2 *instance = NULL;
tjs_error error;
if (TJS_SUCCEEDED(error = self.AsObjectClosureNoAddRef().CreateNew(0, NULL, NULL, &instance, argc, argv, NULL))) {
ret = toJSValue(tTJSVariant(instance, instance));
instance->Release();
} else {
ret = ERROR_KRKR(error);
}
} else {
// メソッド呼び出し
tTJSVariant result;
tjs_error error;
if (TJS_SUCCEEDED(error = self.AsObjectClosureNoAddRef().FuncCall(0, NULL, NULL, &result, argc, argv, NULL))) {
ret = toJSValue(result);
} else {
ret = ERROR_KRKR(error);
}
}
// 引数解放
if (argv) {
for (int i=0;i<argc;i++) {
delete argv[i];
}
delete[] argv;
}
return ret;
}
return ERROR_BADINSTANCE();
}
示例10: ThrowException
Handle<Value> TiAppPropertiesObject::_removeProperty(void* /*userContext*/, TiObject* /*caller*/, const Arguments& args)
{
if (args.Length() < 1)
{
return ThrowException(String::New(Ti::Msg::Missing_argument));
}
if (!args[0]->IsString() && !args[0]->IsStringObject())
{
return ThrowException(String::New((string(Ti::Msg::Invalid_argument_expected_) + "String").c_str()));
}
QString key = QString::fromUtf8(*String::Utf8Value(args[0]));
settings.remove(key);
return Undefined();
}
示例11: ThrowException
Handle<Value> Scene_GetMainComponent(const Arguments& args)
{
HandleScope handle_scope;
Scene* ptr = GetPtr(args.This());
assert(ptr);
Component* pComponent = 0;
if ((args.Length() == 1) && args[0]->IsUint32())
pComponent = ptr->getMainComponent((tComponentType) args[0]->ToUint32()->Value());
else
return ThrowException(String::New("Invalid parameters, valid syntax:\ngetMainComponent(type)"));
return handle_scope.Close(toJavaScript(pComponent));
}
示例12: ThrowException
Handle<Value> Grid::view(const Arguments& args)
{
HandleScope scope;
if ( (args.Length() != 4) || (!args[0]->IsNumber() && !args[1]->IsNumber() && !args[2]->IsNumber() && !args[3]->IsNumber() ))
return ThrowException(Exception::TypeError(
String::New("requires 4 integer arguments: x, y, width, height")));
unsigned x = args[0]->IntegerValue();
unsigned y = args[1]->IntegerValue();
unsigned w = args[2]->IntegerValue();
unsigned h = args[3]->IntegerValue();
Grid* g = ObjectWrap::Unwrap<Grid>(args.This());
return scope.Close(GridView::New(g,x,y,w,h));
}
示例13: ThrowException
v8::Handle<v8::Value> CompoundShape_GetChildShape(const Arguments& args)
{
HandleScope handle_scope;
if ((args.Length() == 1) && args[0]->IsUint32())
{
CompoundShape* ptr = GetPtr(args.This());
assert(ptr);
unsigned int index = args[0]->ToUint32()->Value();
if (index < ptr->getNbChildShapes())
return handle_scope.Close(Uint32::New((unsigned int) ptr->getChildShape(index)));
}
return ThrowException(String::New("Invalid parameters, valid syntax:\ngetChildShape(childIndex)"));
}
示例14: ThrowException
Handle<Value> ComponentsManager_Create(const Arguments& args)
{
HandleScope handle_scope;
ComponentsManager* ptr = GetPtr(args.This());
assert(ptr);
if ((args.Length() == 3) && args[0]->IsString() && args[1]->IsString() && args[2]->IsObject())
{
return handle_scope.Close(toJavaScript(ptr->create(*String::AsciiValue(args[0]->ToString()),
*String::AsciiValue(args[1]->ToString()),
fromJSComponentsList(args[2]))));
}
return ThrowException(String::New("Invalid parameters, valid syntax:\ncreate(type, name, components_list)"));
}
示例15: ThrowException
Handle<Value> Nodehun::SpellDictionary::New(const Arguments& args) {
HandleScope scope;
int argl = args.Length();
if (!args.IsConstructCall())
return ThrowException(Exception::Error(String::New("Use the new operator to create an instance of this object.")));
if(argl < 2)
return ThrowException(Exception::Error(String::New("Constructor requires two arguments.")));
if(!Buffer::HasInstance(args[0]))
return ThrowException(Exception::TypeError(String::New("First argument must be a buffer")));
if(!Buffer::HasInstance(args[1]))
return ThrowException(Exception::TypeError(String::New("Second argument must be a buffer")));
Nodehun::SpellDictionary *obj = new Nodehun::SpellDictionary(Buffer::Data(args[0].As<Object>()), Buffer::Data(args[1].As<Object>()));
obj->Wrap(args.This());
return args.This();
}