本文整理汇总了C++中Undefined函数的典型用法代码示例。如果您正苦于以下问题:C++ Undefined函数的具体用法?C++ Undefined怎么用?C++ Undefined使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Undefined函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ThrowException
Handle<Value> ZipFile::Open(const Arguments& args)
{
if (args.Length() != 1 || !args[0]->IsString())
return ThrowException(Exception::TypeError(
String::New("Argument must be a file name inside the zip")));
std::string name = TOSTR(args[0]);
// TODO - enforce valid index
ZipFile* zf = ObjectWrap::Unwrap<ZipFile>(args.This());
if (zf->Busy())
return ThrowException(Exception::Error(String::New("Zipfile already in use..")));
zf->file_index = -1;
std::vector<std::string>::iterator it = std::find(zf->names.begin(), zf->names.end(), name);
if (it!=zf->names.end()) {
zf->file_index = distance(zf->names.begin(), it);
}
if (zf->file_index == -1) {
std::stringstream s;
s << "No file found by the name of: '" << name << "\n";
return ThrowException(Exception::Error(String::New(s.str().c_str())));
}
if ((zf->file=zip_fopen_index(zf->archive, zf->file_index, 0)) == NULL) {
zip_fclose(zf->file);
zf->file = NULL;
std::stringstream s;
s << "cannot open file #" << zf->file_index << " in " << name << ": archive error: " << zip_strerror(zf->archive) << "\n";
return ThrowException(Exception::Error(String::New(s.str().c_str())));
}
return Undefined();
}
示例2: REQ_OBJECT_ARG
Handle<Value> OracleClient::Connect(const Arguments& args) {
HandleScope scope;
REQ_OBJECT_ARG(0, settings);
REQ_FUN_ARG(1, callback);
OracleClient* client = ObjectWrap::Unwrap<OracleClient>(args.This());
ConnectBaton* baton = new ConnectBaton(client, client->m_environment, &callback);
OBJ_GET_STRING(settings, "hostname", baton->hostname);
OBJ_GET_STRING(settings, "user", baton->user);
OBJ_GET_STRING(settings, "password", baton->password);
OBJ_GET_STRING(settings, "database", baton->database);
OBJ_GET_NUMBER(settings, "port", baton->port, 1521);
OBJ_GET_STRING(settings, "tns", baton->tns);
client->Ref();
uv_work_t* req = new uv_work_t();
req->data = baton;
uv_queue_work(uv_default_loop(), req, EIO_Connect, (uv_after_work_cb)EIO_AfterConnect);
return scope.Close(Undefined());
}
示例3: THROW_CSTR_ERROR
/**
* @details This is an asynchronous factory method creating a new `Map`
* instance from a mapserver mapfile.
*
* `args` should contain the following parameters:
*
* @param mapfile A string representing the mapfile path.
*
* @param callback A function that is called on error or when the map has been
* created. It should have the signature `callback(err, map)`.
*/
Handle<Value> Map::FromFileAsync(const Arguments& args) {
HandleScope scope;
if (args.Length() != 2) {
THROW_CSTR_ERROR(Error, "usage: Map.FromFile(mapfile, callback)");
}
REQ_STR_ARG(0, mapfile);
REQ_FUN_ARG(1, callback);
MapfileBaton *baton = new MapfileBaton();
baton->request.data = baton;
baton->map = NULL;
baton->callback = Persistent<Function>::New(callback);
baton->error = NULL;
baton->mapfile = *mapfile;
uv_queue_work(uv_default_loop(),
&baton->request,
FromFileWork,
(uv_after_work_cb) FromFileAfter);
return Undefined();
}
示例4: resourceExists
Handle<Value> resourceExists(const Arguments &args) {
bool exists;
if (args.Length() < 1) {
exists = false;
}
else {
exists = boost::filesystem::exists(
System::resourceLocation() + V8::StringToStdString(args[0]->ToString())
);
}
Handle<Value> callbackArgs[] = {
Boolean::New(exists)
};
Handle<Function> callback = args[1].As<Function>();
callback->Call(Context::GetCurrent()->Global(), 1, callbackArgs);
return Undefined();
}
示例5: projection
Handle<Value> Dataset::setGCPs(const Arguments& args)
{
Dataset *ds = ObjectWrap::Unwrap<Dataset>(args.This());
if(!ds->this_) return NODE_THROW("Dataset object has already been destroyed");
Handle<Array> gcps;
std::string projection("");
NODE_ARG_ARRAY(0, "gcps", gcps);
NODE_ARG_OPT_STR(1, "projection", projection);
GDAL_GCP* list = new GDAL_GCP [gcps->Length()];
GDAL_GCP* gcp = list;
for (unsigned int i = 0; i < gcps->Length(); ++i) {
Local<Value> val = gcps->Get(i);
if (!val->IsObject()) {
return NODE_THROW("list of GCPs must only contain objects");
}
Local<Object> obj = val->ToObject();
NODE_STR_FROM_OBJ_OPT(obj, "pszId", gcp->pszId);
NODE_STR_FROM_OBJ_OPT(obj, "pszInfo", gcp->pszInfo);
NODE_DOUBLE_FROM_OBJ(obj, "dfGCPPixel", gcp->dfGCPPixel);
NODE_DOUBLE_FROM_OBJ(obj, "dfGCPLine", gcp->dfGCPLine);
NODE_DOUBLE_FROM_OBJ(obj, "dfGCPX", gcp->dfGCPX);
NODE_DOUBLE_FROM_OBJ(obj, "dfGCPY", gcp->dfGCPY);
NODE_DOUBLE_FROM_OBJ_OPT(obj, "dfGCPZ", gcp->dfGCPZ);
gcp++;
}
if (list) delete [] list;
CPLErr err = ds->this_->SetGCPs(gcps->Length(), list, projection.c_str());
if(err) return NODE_THROW_CPLERR(err);
return Undefined();
}
示例6: Undefined
Handle<Value> TiUIBase::_animate(void* userContext, TiObject*, const Arguments& args)
{
HandleScope handleScope;
TiUIBase* self = static_cast<TiUIBase*>(userContext);
NativeControlObject *native = static_cast<NativeControlObject*>(self->getNativeObject());
TiObject* tiObject = TiObject::getTiObjectFromJsObject(args[0]);
if(!tiObject) {
Local<Object> jsObject = Local<Object>::Cast(args[0]);
if(args.Length() > 1 && args[1]->IsFunction()) {
Handle<Function> callback = Handle<Function>::Cast(args[1]);
Handle<Object> source = Handle<Object>::Cast(self->getValue());
TiV8Event* event = TiV8Event::createEvent("complete", callback, source);
native->animate(jsObject, event);
} else {
native->animate(jsObject);
}
} else {
native->animate(tiObject->getNativeObject());
}
return Undefined();
}
示例7: q
Handle<Value> Datasource::featureset(const Arguments& args)
{
HandleScope scope;
Datasource* ds = node::ObjectWrap::Unwrap<Datasource>(args.This());
mapnik::featureset_ptr fs;
try
{
mapnik::query q(ds->datasource_->envelope());
mapnik::layer_descriptor ld = ds->datasource_->get_descriptor();
std::vector<mapnik::attribute_descriptor> const& desc = ld.get_descriptors();
std::vector<mapnik::attribute_descriptor>::const_iterator itr = desc.begin();
std::vector<mapnik::attribute_descriptor>::const_iterator end = desc.end();
while (itr != end)
{
q.add_property_name(itr->get_name());
++itr;
}
fs = ds->datasource_->features(q);
}
catch (std::exception const& ex)
{
return ThrowException(Exception::Error(
String::New(ex.what())));
}
if (fs)
{
return scope.Close(Featureset::New(fs));
}
return Undefined();
}
示例8: startMsgLoop
//*,{
// "type":"function",
// "name":"startMsgLoop([qMsg])",
// "text":"启动消息循环。startMsgLoop 函数执行后会一直运行,而不会执行它后面的语句,直到运行了 exitMsgLoop 函数。窗口程序必须运行 startMsgLoop 函数,否则程序会立即退出,且无法响应用户操作。",
// "param":[
// {
// "type":"boolean",
// "name":"[qMsg]",
// "text":"启动消息循环的种类,是否是非窗口消息循环,默认是 false。"
// }
// ],
// "return":{
// "type":"void",
// "text":"函数没有返回值。"
// },
// "remark":[
// "startMsgLoop 内部启动两种消息循环,窗口类和非窗口类。非窗口类的消息循环效率更高,但是非窗口类消息循环必须没有使用任何窗口的时候调用,而且需要启用了对应的机制,否则函数失败立即返回。",
// "当一个应用程序含有窗口的时候,关闭主窗口会自动调用 exitMsgLoop 机制,从而退出应用程序。如果应用程序没有窗口,则必须自己处理在哪里调用 exitMsgLoop,否则程序被挂起,永远不会退出。"
// ],
// "example":[
// "setTimer(function(){",
// " //这里每 3 秒调用一次,一般 alert 会阻止程序继续运行直到用户关闭了对话框,但是它不会阻止 Timer 的调用,对话框会持续的弹出。",
// " alert(\"click to call exitMsgLoop\");",
// " //退出消息循环,startMsgLoop 返回,程序退出。",
// " exitMsgLoop();",
// "},3000);",
// "startMsgLoop();"
// ]
//}//*
Handle<Value> startMsgLoop(const Arguments& args){
bool qMsg = GET_ARGS_VALUE(0,false,Boolean);
_env->queue.Start(qMsg);
return Undefined();
}
示例9: LogWarning
Handle<Value> LogWarning(const Arguments& args)
{
LOG_WARNING(ToStdString(args[0]));
return Undefined();
}
示例10: LogInfo
Handle<Value> LogInfo(const Arguments& args)
{
LOG_INFO(ToStdString(args[0]));
return Undefined();
}
示例11: LogError
Handle<Value> LogError(const Arguments& args)
{
LOG_ERROR(ToStdString(args[0]));
return Undefined();
}
示例12: LogAlways
Handle<Value> LogAlways(const Arguments& args)
{
LOG_ALWAYS(ToStdString(args[0]));
return Undefined();
}
示例13: LogDebug
Handle<Value> LogDebug(const Arguments& args)
{
LOG_DEBUG(ToStdString(args[0]));
return Undefined();
}
示例14: MSAddSpawner
Handle<Value> MSAddSpawner(const Arguments& args)
{
HandleScope scope;
dtEntity::MapSystem* ms = UnwrapMapSystem(args.This());
if(args.Length() != 1)
{
return ThrowError("Usage: addSpawner({components, name, guicategory, mapname, addtospawnerstore, iconpath})");
}
Handle<Object> obj = Handle<Object>::Cast(args[0]);
Handle<Value> vname = obj->Get(String::New("name"));
Handle<Value> vcomponents = obj->Get(String::New("components"));
if(vname.IsEmpty() || vcomponents.IsEmpty())
{
return ThrowError("Usage: addSpawner({components, name, guicategory, mapname, addtospawnerstore, iconpath, parentname})");
}
Handle<Value> vguicategory = obj->Get(String::New("guicategory"));
Handle<Value> vmapname = obj->Get(String::New("mapname"));
Handle<Value> vaddtospawnerstore = obj->Get(String::New("addtospawnerstore"));
Handle<Value> viconpath = obj->Get(String::New("iconpath"));
Handle<Value> vparentname = obj->Get(String::New("parentname"));
std::string name = ToStdString(vname);
std::string mapname = vmapname.IsEmpty() ? "" : ToStdString(vmapname);
Handle<Object> components = Handle<Object>::Cast(vcomponents);
dtEntity::Spawner* parent = NULL;
if(!vparentname.IsEmpty() && !vparentname->IsUndefined())
{
ms->GetSpawner(ToStdString(vparentname), parent);
}
osg::ref_ptr<dtEntity::Spawner> spawner = new dtEntity::Spawner(name, mapname, parent);
if(!vguicategory.IsEmpty() && !vguicategory->IsUndefined())
{
spawner->SetGUICategory(ToStdString(vguicategory));
}
if(!vaddtospawnerstore.IsEmpty() && !vaddtospawnerstore->IsUndefined())
{
spawner->SetAddToSpawnerStore(vaddtospawnerstore->BooleanValue());
}
if(!viconpath.IsEmpty() && !viconpath->IsUndefined())
{
spawner->SetIconPath(ToStdString(viconpath));
}
Handle<Array> keys = components->GetPropertyNames();
for(unsigned int i = 0; i < keys->Length(); ++i)
{
Handle<Value> key = keys->Get(Integer::New(i));
std::string keyname = ToStdString(key);
dtEntity::StringId ctype = dtEntity::SIDHash(keyname);
dtEntity::ComponentPluginManager::GetInstance().StartEntitySystem(ms->GetEntityManager(), ctype);
if(ms->GetEntityManager().HasEntitySystem(ctype))
{
Handle<Value> val = components->Get(key);
if(val->IsObject())
{
Handle<Object> compobj = Handle<Object>::Cast(val);
Handle<Array> compkeys = compobj->GetPropertyNames();
dtEntity::GroupProperty props;
for(unsigned int j = 0; j < compkeys->Length(); ++j)
{
Handle<Value> compkey = compkeys->Get(Integer::New(j));
std::string compkeystr = ToStdString(compkey);
Handle<Value> compval = compobj->Get(compkey);
dtEntity::Property* prop = ConvertValueToProperty(compval);
props.Add(dtEntity::SIDHash(compkeystr), prop);
}
spawner->AddComponent(ctype, props);
}
}
}
ms->AddSpawner(*spawner);
return Undefined();
}
示例15: Undefined
Handle<Value> TiObject::onFunctionCall(const Arguments&)
{
// Default function call returns "Undefined"
return Undefined();
}