コード例 #1
0
ファイル: dibuilder.cpp プロジェクト: toshok/echojs
 v8::Local<v8::Value> DILexicalBlock::Create(llvm::DILexicalBlock* llvm_dilexicalblock) {
   Nan::EscapableHandleScope scope;
   Local<Object> new_instance = Nan::NewInstance(Nan::New(DILexicalBlock::constructor_func)).ToLocalChecked();
   DILexicalBlock* new_dilexicalblock = new DILexicalBlock(llvm_dilexicalblock);
   new_dilexicalblock->Wrap(new_instance);
   return scope.Escape(new_instance);
 }
コード例 #2
0
ファイル: dibuilder.cpp プロジェクト: toshok/echojs
 v8::Local<v8::Value> DebugLoc::Create(llvm::DebugLoc llvm_debugloc) {
   Nan::EscapableHandleScope scope;
   Local<Object> new_instance = Nan::NewInstance(Nan::New(DebugLoc::constructor_func)).ToLocalChecked();
   DebugLoc* new_debugloc = new DebugLoc(llvm_debugloc);
   new_debugloc->Wrap(new_instance);
   return scope.Escape(new_instance);
 }
コード例 #3
0
ファイル: dibuilder.cpp プロジェクト: toshok/echojs
 v8::Local<v8::Value> DIFile::Create(llvm::DIFile* llvm_difile) {
   Nan::EscapableHandleScope scope;
   Local<Object> new_instance = Nan::NewInstance(Nan::New(DIFile::constructor_func)).ToLocalChecked();
   DIFile* new_difile = new DIFile(llvm_difile);
   new_difile->Wrap(new_instance);
   return scope.Escape(new_instance);
 }
コード例 #4
0
ファイル: dibuilder.cpp プロジェクト: toshok/echojs
 v8::Local<v8::Value> DICompileUnit::Create(llvm::DICompileUnit* llvm_dicompileunit) {
   Nan::EscapableHandleScope scope;
   Local<Object> new_instance = Nan::NewInstance(Nan::New(DICompileUnit::constructor_func)).ToLocalChecked();
   DICompileUnit* new_dicompileunit = new DICompileUnit(llvm_dicompileunit);
   new_dicompileunit->Wrap(new_instance);
   return scope.Escape(new_instance);
 }
コード例 #5
0
ファイル: dibuilder.cpp プロジェクト: toshok/echojs
 v8::Local<v8::Value> DISubprogram::Create(llvm::DISubprogram* llvm_disubprogram) {
   Nan::EscapableHandleScope scope;
   Local<Object> new_instance = Nan::NewInstance(Nan::New(DISubprogram::constructor_func)).ToLocalChecked();
   DISubprogram* new_disubprogram = new DISubprogram(llvm_disubprogram);
   new_disubprogram->Wrap(new_instance);
   return scope.Escape(new_instance);
 }
コード例 #6
0
v8::Local<v8::Value> MSOutputFormat::NewInstance(outputFormatObj *of_ptr) {
  Nan::EscapableHandleScope scope;
  MSOutputFormat* of = new MSOutputFormat();
  of->this_ = of_ptr;
  v8::Local<v8::Value> ext = Nan::New<v8::External>(of);
  return scope.Escape(Nan::New(constructor)->GetFunction()->NewInstance(1, &ext));
}
コード例 #7
0
ファイル: mapnik_grid.cpp プロジェクト: BHare1985/node-mapnik
v8::Local<v8::Value> Grid::_clearSync(Nan::NAN_METHOD_ARGS_TYPE info)
{
    Nan::EscapableHandleScope scope;
    Grid* g = Nan::ObjectWrap::Unwrap<Grid>(info.Holder());
    g->get()->clear();
    return scope.Escape(Nan::Undefined());
}
コード例 #8
0
ファイル: ms_layers.cpp プロジェクト: pagameba/node-mapserver
v8::Local<v8::Value> MSLayers::NewInstance(mapObj *ptr) {
  Nan::EscapableHandleScope scope;
  MSLayers* obj = new MSLayers();
  obj->this_ = ptr;
  v8::Local<v8::Value> ext = Nan::New<v8::External>(obj);
  return scope.Escape(Nan::New(constructor)->GetFunction()->NewInstance(1, &ext));
}
コード例 #9
0
// Unfortunately native modules don't get a reference
// to require.cache as this happens in Module._compile()
// and native modules aren't compiled, they are loaded
// directly by NativeModule.require() (in Module._load())
// So we need to get it from Module._cache instead (by
// executing require('module')._cache)
static Local<Object> getRequireCache(Handle<Object> module) {
    Nan::EscapableHandleScope scope;
    Handle<Value> args[] = { Nan::New<String>("module").ToLocalChecked() };
    Local<Value> m = module->Get(Nan::New<String>("require").ToLocalChecked())->ToObject()->CallAsFunction(Nan::GetCurrentContext()->Global(), 1, args);
    Local<Object> cache = m->ToObject()->Get(Nan::New<String>("_cache").ToLocalChecked())->ToObject();
    return scope.Escape(cache);
}
コード例 #10
0
v8::Local<v8::Value> MemoryDatasource::NewInstance(mapnik::datasource_ptr ds_ptr) {
    Nan::EscapableHandleScope scope;
    MemoryDatasource* d = new MemoryDatasource();
    d->datasource_ = ds_ptr;
    v8::Local<v8::Value> ext = Nan::New<v8::External>(d);
    return scope.Escape( Nan::New(constructor)->GetFunction()->NewInstance(1, &ext));
}
コード例 #11
0
ファイル: gdal_geometry.cpp プロジェクト: tomhughes/node-gdal
Local<Value> Geometry::getConstructor(OGRwkbGeometryType type) {
    Nan::EscapableHandleScope scope;

    type = wkbFlatten(type);
    switch (type) {
    case wkbPoint:
        return scope.Escape(Nan::New(Point::constructor)->GetFunction());
    case wkbLineString:
        return scope.Escape(Nan::New(LineString::constructor)->GetFunction());
    case wkbLinearRing:
        return scope.Escape(Nan::New(LinearRing::constructor)->GetFunction());
    case wkbPolygon:
        return scope.Escape(Nan::New(Polygon::constructor)->GetFunction());
    case wkbGeometryCollection:
        return scope.Escape(Nan::New(GeometryCollection::constructor)->GetFunction());
    case wkbMultiPoint:
        return scope.Escape(Nan::New(MultiPoint::constructor)->GetFunction());
    case wkbMultiLineString:
        return scope.Escape(Nan::New(MultiLineString::constructor)->GetFunction());
    case wkbMultiPolygon:
        return scope.Escape(Nan::New(MultiPolygon::constructor)->GetFunction());
    default:
        return scope.Escape(Nan::Null());
    }
}
コード例 #12
0
ファイル: mapnik_color.cpp プロジェクト: cuulee/node-mapnik
v8::Local<v8::Value> Color::NewInstance(mapnik::color const& color) {
    Nan::EscapableHandleScope scope;
    Color* c = new Color();
    c->this_ = std::make_shared<mapnik::color>(color);
    v8::Local<v8::Value> ext = Nan::New<v8::External>(c);
    return scope.Escape(Nan::New(constructor)->GetFunction()->NewInstance(1, &ext));
}
コード例 #13
0
ファイル: mapnik_feature.cpp プロジェクト: bermi/node-mapnik
v8::Local<v8::Value> Feature::NewInstance(mapnik::feature_ptr f_ptr)
{
    Nan::EscapableHandleScope scope;
    Feature* f = new Feature(f_ptr);
    v8::Local<v8::Value> ext = Nan::New<v8::External>(f);
    return scope.Escape(Nan::New(constructor)->GetFunction()->NewInstance(1, &ext));
}
コード例 #14
0
 v8::Local<v8::Object> operator()(const point<T>& point) {
     Nan::EscapableHandleScope scope;
     v8::Local<v8::Array> result = Nan::New<v8::Array>(2);
     Nan::Set(result, 0, Nan::New(point.x));
     Nan::Set(result, 1, Nan::New(point.y));
     return scope.Escape(result);
 }
コード例 #15
0
Local<Value> MultiPolygon::New(OGRMultiPolygon *geom, bool owned)
{
	Nan::EscapableHandleScope scope;

	if (!geom) {
		return scope.Escape(Nan::Null());
	}

	//make a copy of geometry owned by a feature
	// + no need to track when a feature is destroyed
	// + no need to throw errors when a method trys to modify an owned read-only geometry
	// - is slower

	if (!owned) {
		geom = static_cast<OGRMultiPolygon*>(geom->clone());
	};

	MultiPolygon *wrapped = new MultiPolygon(geom);
	wrapped->owned_ = true;

	UPDATE_AMOUNT_OF_GEOMETRY_MEMORY(wrapped);

	Local<Value> ext = Nan::New<External>(wrapped);
	Local<Object> obj = Nan::New(MultiPolygon::constructor)->GetFunction()->NewInstance(1, &ext);

	return scope.Escape(obj);
}
コード例 #16
0
Handle<Object> createBuffer(char *data, int length) {
	Nan::EscapableHandleScope scope;

	Local<Object> buffer = Nan::CopyBuffer(data, length).ToLocalChecked();

	return scope.Escape(buffer);
}
コード例 #17
0
v8::Local<v8::Value> Featureset::NewInstance(mapnik::featureset_ptr fs_ptr)
{
    Nan::EscapableHandleScope scope;
    Featureset* fs = new Featureset();
    fs->this_ = fs_ptr;
    v8::Local<v8::Value> ext = Nan::New<v8::External>(fs);
    return scope.Escape(Nan::New(constructor)->GetFunction()->NewInstance(1, &ext));
}
コード例 #18
0
 v8::Local<v8::Value> operator()(const std::vector<mbgl::Value>& array) {
     Nan::EscapableHandleScope scope;
     v8::Local<v8::Array> result = Nan::New<v8::Array>();
     for (unsigned int i = 0; i < array.size(); i++) {
         result->Set(i, toJS(array[i]));
     }
     return scope.Escape(result);
 }
コード例 #19
0
ファイル: odbc.cpp プロジェクト: jstopchick/node-odbc
Local<Object> ODBC::GetSQLError (SQLSMALLINT handleType, SQLHANDLE handle) {
    Nan::EscapableHandleScope scope;

    return scope.Escape(GetSQLError(
                            handleType,
                            handle,
                            (char *) "[node-odbc] SQL_ERROR"));
}
コード例 #20
0
 v8::Local<v8::Object> operator()(const std::vector<E>& vector) {
     Nan::EscapableHandleScope scope;
     v8::Local<v8::Array> result = Nan::New<v8::Array>(vector.size());
     for (std::size_t i = 0; i < vector.size(); ++i) {
         Nan::Set(result, i, operator()(vector[i]));
     }
     return scope.Escape(result);
 }
コード例 #21
0
v8::Local<v8::Function> Convert::getCallbackFunction(v8::Local<v8::Value> js)
{
    Nan::EscapableHandleScope scope;
    if (!js->IsFunction())
    {
        throw std::runtime_error("function");
    }
    return scope.Escape(js.As<v8::Function>());
}
コード例 #22
0
ファイル: binding.cpp プロジェクト: vseryakov/bkjs-cache
 Local<Value> next() {
     Nan::EscapableHandleScope scope;
     if (nextIt == items.end()) return scope.Escape(Nan::Undefined());
     Local<Array> obj = Nan::New<Array>();
     obj->Set(Nan::New(0), Nan::New(nextIt->first).ToLocalChecked());
     obj->Set(Nan::New(1), Nan::New(nextIt->second).ToLocalChecked());
     nextIt++;
     return scope.Escape(obj);
 }
コード例 #23
0
ファイル: mapnik_color.cpp プロジェクト: CartoDB/node-mapnik
v8::Local<v8::Value> Color::NewInstance(mapnik::color const& color) {
    Nan::EscapableHandleScope scope;
    Color* c = new Color();
    c->this_ = std::make_shared<mapnik::color>(color);
    v8::Local<v8::Value> ext = Nan::New<v8::External>(c);
    Nan::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance(Nan::New(constructor)->GetFunction(), 1, &ext);
    if (maybe_local.IsEmpty()) Nan::ThrowError("Could not create new Color instance");
    return scope.Escape(maybe_local.ToLocalChecked());
}
コード例 #24
0
ファイル: Connection.cpp プロジェクト: arangodb/fuerte
//
// Creates a new instance of Connection
//
// NOTE : This is not a Javascript Connection method
//
v8::Local<v8::Value> Connection::NewInstance(v8::Local<v8::Value> arg) {
  Nan::EscapableHandleScope scope;

  const unsigned argc = 1;
  v8::Local<v8::Value> argv[argc] = {arg};
  v8::Local<v8::Function> cons = Nan::New<v8::Function>(_constructor);
  v8::Local<v8::Object> instance = cons->NewInstance(argc, argv);

  return scope.Escape(instance);
}
コード例 #25
0
v8::Local<v8::Object> toJS(const Properties& properties) {
    Nan::EscapableHandleScope scope;

    v8::Local<v8::Object> result = Nan::New<v8::Object>();
    for (const auto& property : properties) {
        Nan::Set(result, Nan::New(property.first).ToLocalChecked(), toJS(property.second));
    }

    return scope.Escape(result);
}
コード例 #26
0
ファイル: mapnik_layer.cpp プロジェクト: mapnik/node-mapnik
v8::Local<v8::Value> Layer::NewInstance(mapnik::layer const& lay_ref) {
    Nan::EscapableHandleScope scope;
    Layer* l = new Layer();
    // copy new mapnik::layer into the shared_ptr
    l->layer_ = std::make_shared<mapnik::layer>(lay_ref);
    v8::Local<v8::Value> ext = Nan::New<v8::External>(l);
    Nan::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance(Nan::New(constructor)->GetFunction(), 1, &ext);
    if (maybe_local.IsEmpty()) Nan::ThrowError("Could not create new Layer instance");
    return scope.Escape(maybe_local.ToLocalChecked());
}
コード例 #27
0
Local<Object> SelectResults::NewInstance(const SelectResultsPtr & selectResultsPtr) {
  Nan::EscapableHandleScope scope;
 const unsigned int argc = 0;
  Local<Value> argv[argc] = {};
  Local<Object> instance(Nan::New(SelectResults::constructor())->NewInstance(argc, argv));
  SelectResults * selectResults = new SelectResults(selectResultsPtr);
  selectResults->Wrap(instance);

  return scope.Escape(instance);
}
コード例 #28
0
v8::Local<v8::Value> Featureset::NewInstance(mapnik::featureset_ptr fsp)
{
    Nan::EscapableHandleScope scope;
    Featureset* fs = new Featureset();
    fs->this_ = fsp;
    v8::Local<v8::Value> ext = Nan::New<v8::External>(fs);
    Nan::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance(Nan::New(constructor)->GetFunction(), 1, &ext);
    if (maybe_local.IsEmpty()) Nan::ThrowError("Could not create new Featureset instance");
    return scope.Escape(maybe_local.ToLocalChecked());
}
コード例 #29
0
inline optional<v8::Local<v8::Value>> objectMember(v8::Local<v8::Value> value, const char * name) {
    Nan::EscapableHandleScope scope;
    if (!Nan::Has(Nan::To<v8::Object>(value).ToLocalChecked(), Nan::New(name).ToLocalChecked()).FromJust()) {
        return {};
    }
    Nan::MaybeLocal<v8::Value> result = Nan::Get(Nan::To<v8::Object>(value).ToLocalChecked(), Nan::New(name).ToLocalChecked());
    if (result.IsEmpty()) {
        return {};
    }
    return scope.Escape(result.ToLocalChecked());
}
コード例 #30
0
ファイル: odbc.cpp プロジェクト: jstopchick/node-odbc
Handle<Value> ODBC::CallbackSQLError (SQLSMALLINT handleType,
                                      SQLHANDLE handle,
                                      Nan::Callback* cb) {
    Nan::EscapableHandleScope scope;

    return scope.Escape(CallbackSQLError(
                            handleType,
                            handle,
                            (char *) "[node-odbc] SQL_ERROR",
                            cb));
}