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()); connect_baton_t* baton = new connect_baton_t(); baton->client = client; baton->callback = Persistent<Function>::New(callback); baton->environment = client->m_environment; OBJ_GET_STRING(settings, "connection", baton->connectionStr); 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); 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 Undefined(); }
Handle<Value> OracleClient::CreateConnectionPool(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); uint32_t busyOption; 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_NUMBER(settings, "minConn", baton->minConn, 0); OBJ_GET_NUMBER(settings, "maxConn", baton->maxConn, 4); OBJ_GET_NUMBER(settings, "incrConn", baton->incrConn, 1); OBJ_GET_NUMBER(settings, "timeout", baton->timeout, 0); OBJ_GET_NUMBER(settings, "busyOption", busyOption, 0); baton->busyOption = static_cast<oracle::occi::StatelessConnectionPool::BusyOption>(busyOption); 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_CreateConnectionPool, (uv_after_work_cb)EIO_AfterCreateConnectionPool); return scope.Close(Undefined()); }
Handle<Value> MSMap::DrawMap (const Arguments& args) { HandleScope scope; REQ_FUN_ARG(0, cb); MSMap *map = ObjectWrap::Unwrap<MSMap>(args.This()); char * version = msGetVersion(); char * regex = "SUPPORTS\\=THREADS"; int match; match = 0; if (msEvalRegex(regex, version) == MS_TRUE) { match = 1; } else { // discard the error reported by msEvalRegex saying that it failed msResetErrorList(); } if (match == 1) { drawmap_baton * baton = new drawmap_baton(); baton->request.data = (void*) baton; baton->map = map; baton->cb = Persistent<Function>::New(cb); map->Ref(); uv_queue_work(uv_default_loop(), &baton->request, DrawMapWork, (uv_after_work_cb) DrawMapAfter); } else { Local<Value> argv[2]; argv[0] = Local<Value>::New(Null()); imageObj * im = msDrawMap(map->this_, MS_FALSE); if (im != NULL) { int size; char * data = (char *)msSaveImageBuffer(im, &size, map->this_->outputformat); msFreeImage(im); Buffer * buffer = Buffer::New(data, size, FreeImageBuffer, NULL); argv[1] = Local<Value>::New(buffer->handle_); } else { errorObj * err = msGetErrorObj(); Local<Value> _arg_ = External::New(err); argv[0] = Local<Value>::New(MSError::New(err)); argv[1] = Local<Value>::New(Null()); } cb->Call(Context::GetCurrent()->Global(), 2, argv); } return Undefined(); }
/** * @details This is an asynchronous factory method creating a new `Map` * instance from a string representation of a mapserver mapfile. * * `args` should contain the following parameters: * * @param mapfile A string representing the mapfile. * * @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::FromStringAsync(const Arguments& args) { HandleScope scope; string mapfile; if (args.Length() != 2) { THROW_CSTR_ERROR(Error, "usage: Map.FromString(mapfile, callback)"); } // get the mapfile string from the arguments if (args[0]->IsString()) { mapfile = *String::Utf8Value(args[0]->ToString()); } else if (args[0]->IsObject()) { // see if it's a buffer if (!Buffer::HasInstance(args[0])) { THROW_CSTR_ERROR(TypeError, "Argument 0 must be a string or buffer"); } Local<Object> buffer = args[0]->ToObject(); mapfile = string(Buffer::Data(buffer), Buffer::Length(buffer)); } else { THROW_CSTR_ERROR(TypeError, "Argument 0 must be a string or buffer"); } 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; // Run in a different thread. Note there is *no* `FromStringAfter`: // `FromFileAfter` is used instead. uv_queue_work(uv_default_loop(), &baton->request, FromStringWork, (uv_after_work_cb) FromFileAfter); return Undefined(); }
// db, statement, callback static v8::Handle<Value> ExecuteStatement(const Arguments& args) { v8::HandleScope scope; REQ_DBCONN_ARG(0); REQ_STR_ARG(1, stmt); REQ_FUN_ARG(2, cb); v8::String::Utf8Value statement(stmt); if(dbcmd(dbconn, *statement) == FAIL){ return v8::ThrowException(v8::Exception::Error(v8::String::New("FreeTDS could allocate enough memory for the statement"))); } data_callback_t *callbackData = new data_callback_t(); callbackData->dbconn = dbconn; callbackData->callback = Persistent<Function>::New(cb); if(dbsqlsend(dbconn) == FAIL){ return v8::ThrowException(v8::Exception::Error(v8::String::New("FreeTDS could not send the statement"))); } eio_custom(waitForDataResponse, EIO_PRI_DEFAULT, onDataResponse, callbackData); return v8::Undefined(); }
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()); }
/** * @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(); }
uni::CallbackType OracleClient::Connect(const uni::FunctionCallbackInfo& args) { UNI_SCOPE(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); UNI_RETURN(scope, args, NanUndefined()); }