Handle<Value> ODBCStatement::New(const Arguments& args) { DEBUG_PRINTF("ODBCStatement::New\n"); HandleScope scope; REQ_EXT_ARG(0, js_henv); REQ_EXT_ARG(1, js_hdbc); REQ_EXT_ARG(2, js_hstmt); HENV hENV = static_cast<HENV>(js_henv->Value()); HDBC hDBC = static_cast<HDBC>(js_hdbc->Value()); HSTMT hSTMT = static_cast<HSTMT>(js_hstmt->Value()); //create a new OBCResult object ODBCStatement* stmt = new ODBCStatement(hENV, hDBC, hSTMT); //specify the buffer length stmt->bufferLength = MAX_VALUE_SIZE - 1; //initialze a buffer for this object stmt->buffer = (uint16_t *) malloc(stmt->bufferLength + 1); //TODO: make sure the malloc succeeded //set the initial colCount to 0 stmt->colCount = 0; //initialize the paramCount stmt->paramCount = 0; stmt->Wrap(args.Holder()); return scope.Close(args.Holder()); }
void BatchImpl_freeImpl(const Arguments &args) { BatchImpl * set = unwrapPointer<BatchImpl *>(args.Holder()); delete set; set = 0; wrapPointerInObject(set, BatchImplEnvelope, args.Holder()); args.GetReturnValue().SetUndefined(); }
v8::Handle<v8::Value> InputSystem_v8::New(const Arguments &args) { HandleScope scope; new InputSystem_v8(args.Holder()); return args.Holder(); }
Handle<Value> ODBC::New(const Arguments& args) { DEBUG_PRINTF("ODBC::New\n"); HandleScope scope; ODBC* dbo = new ODBC(); dbo->Wrap(args.Holder()); dbo->m_hEnv = NULL; uv_mutex_lock(&ODBC::g_odbcMutex); int ret = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &dbo->m_hEnv); uv_mutex_unlock(&ODBC::g_odbcMutex); if (!SQL_SUCCEEDED(ret)) { DEBUG_PRINTF("ODBC::New - ERROR ALLOCATING ENV HANDLE!!\n"); Local<Object> objError = ODBC::GetSQLError(SQL_HANDLE_ENV, dbo->m_hEnv); ThrowException(objError); } SQLSetEnvAttr(dbo->m_hEnv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3, SQL_IS_UINTEGER); return scope.Close(args.Holder()); }
Handle<Value> Tail::close(const Arguments& args) { HandleScope scope; assert(!args.Holder().IsEmpty()); assert(args.Holder()->InternalFieldCount() > 0); void* ptr = args.Holder()->GetPointerFromInternalField(0); Tail* tail_instance = static_cast<Tail*>(ptr); uv_unref(reinterpret_cast<uv_handle_t*>(&tail_instance->_event_handle)); tail_instance->Emit(end_symbol, 0, NULL); return scope.Close(Undefined()); }
v8::Handle<v8::Value> Image_v8::DrawLine(const Arguments &args) { HandleScope scope; Image_v8 *image_v8 = ObjectWrap::Unwrap<Image_v8>(args.Holder()); if (NULL == image_v8) { return ThrowException(v8::Exception::ReferenceError(String::NewSymbol( "Image::drawLine(): NULL Holder." ))); } Handle<Array> dimensions = args[0].As<Array>(); image_v8->image->drawLine( dimensions->Get(0)->Int32Value(), dimensions->Get(1)->Int32Value(), dimensions->Get(2)->Int32Value(), dimensions->Get(3)->Int32Value(), args[1]->Uint32Value(), args[2]->Uint32Value(), args[3]->Uint32Value(), args[4]->Uint32Value(), static_cast<Image::DrawMode>(args[5]->Uint32Value()) ); return v8::Undefined(); }
Handle<Value> ODBCResult::CloseSync(const Arguments& args) { DEBUG_PRINTF("ODBCResult::CloseSync\n"); HandleScope scope; OPT_INT_ARG(0, closeOption, SQL_DESTROY); ODBCResult* result = ObjectWrap::Unwrap<ODBCResult>(args.Holder()); DEBUG_PRINTF("ODBCResult::CloseSync closeOption=%i m_canFreeHandle=%i\n", closeOption, result->m_canFreeHandle); if (closeOption == SQL_DESTROY && result->m_canFreeHandle) { result->Free(); } else if (closeOption == SQL_DESTROY && !result->m_canFreeHandle) { //We technically can't free the handle so, we'll SQL_CLOSE uv_mutex_lock(&ODBC::g_odbcMutex); SQLFreeStmt(result->m_hSTMT, SQL_CLOSE); uv_mutex_unlock(&ODBC::g_odbcMutex); } else { uv_mutex_lock(&ODBC::g_odbcMutex); SQLFreeStmt(result->m_hSTMT, closeOption); uv_mutex_unlock(&ODBC::g_odbcMutex); } return scope.Close(True()); }
Handle<Value> Proxy::hasListenersForEventType(const Arguments& args) { JNIEnv* env = JNIScope::getEnv(); if (!env) { return JSException::GetJNIEnvironmentError(); } Proxy* proxy = NativeObject::Unwrap<Proxy>(args.Holder()); Local<String> eventType = args[0]->ToString(); Local<Boolean> hasListeners = args[1]->ToBoolean(); jobject javaProxy = proxy->getJavaObject(); jobject krollObject = env->GetObjectField(javaProxy, JNIUtil::krollProxyKrollObjectField); jstring javaEventType = TypeConverter::jsStringToJavaString(eventType); if (!JavaObject::useGlobalRefs) { env->DeleteLocalRef(javaProxy); } env->CallVoidMethod(krollObject, JNIUtil::krollObjectSetHasListenersForEventTypeMethod, javaEventType, TypeConverter::jsBooleanToJavaBoolean(hasListeners)); env->DeleteLocalRef(krollObject); env->DeleteLocalRef(javaEventType); return Undefined(); }
Handle<Value> Texture::LoadFile(const Arguments &args) { HandleScope scope; if (args[0]->IsString()) { Texture *texture = ObjectWrap::Unwrap<Texture>(args.This()); if (args[1]->IsFunction()) { if (!texture->load_finished_cb) { texture->load_finished_cb = new NodeCallback(); } else { texture->load_finished_cb->Holder.Dispose(); texture->load_finished_cb->cb.Dispose(); } texture->load_finished_cb->Holder = Persistent<Object>::New(args.Holder()); texture->load_finished_cb->cb = Persistent<Function>::New(Handle<Function>::Cast(args[1])); Texture::_LoadFile(texture, *String::Utf8Value(args[0]->ToString()), TRUE); } else { Texture::_LoadFile(texture, *String::Utf8Value(args[0]->ToString()), FALSE); } } return args.This(); }
Handle<Value> ODBCStatement::ExecuteSync(const Arguments& args) { DEBUG_PRINTF("ODBCStatement::ExecuteSync\n"); HandleScope scope; ODBCStatement* stmt = ObjectWrap::Unwrap<ODBCStatement>(args.Holder()); SQLRETURN ret = SQLExecute(stmt->m_hSTMT); if(ret == SQL_ERROR) { ThrowException(ODBC::GetSQLError( SQL_HANDLE_STMT, stmt->m_hSTMT, (char *) "[node-odbc] Error in ODBCStatement::ExecuteSync" )); return scope.Close(Null()); } else { Local<Value> args[3]; bool* canFreeHandle = new bool(false); args[0] = External::New(stmt->m_hENV); args[1] = External::New(stmt->m_hDBC); args[2] = External::New(stmt->m_hSTMT); args[3] = External::New(canFreeHandle); Local<Object> js_result(ODBCResult::constructor_template-> GetFunction()->NewInstance(4, args)); return scope.Close(js_result); } }
Handle<Value> ODBCStatement::ExecuteNonQuery(const Arguments& args) { DEBUG_PRINTF("ODBCStatement::ExecuteNonQuery\n"); HandleScope scope; REQ_FUN_ARG(0, cb); ODBCStatement* stmt = ObjectWrap::Unwrap<ODBCStatement>(args.Holder()); uv_work_t* work_req = (uv_work_t *) (calloc(1, sizeof(uv_work_t))); execute_work_data* data = (execute_work_data *) calloc(1, sizeof(execute_work_data)); data->cb = Persistent<Function>::New(cb); data->stmt = stmt; work_req->data = data; uv_queue_work( uv_default_loop(), work_req, UV_ExecuteNonQuery, (uv_after_work_cb)UV_AfterExecuteNonQuery); stmt->Ref(); return scope.Close(Undefined()); }
Handle<Value> TxtRecordRef::New(const Arguments & args) { HandleScope scope; TxtRecordRef * o = new TxtRecordRef(); o->Wrap(args.Holder()); return args.This(); }
Handle<Value> ODBCStatement::ExecuteNonQuerySync(const Arguments& args) { DEBUG_PRINTF("ODBCStatement::ExecuteNonQuerySync\n"); HandleScope scope; ODBCStatement* stmt = ObjectWrap::Unwrap<ODBCStatement>(args.Holder()); SQLRETURN ret = SQLExecute(stmt->m_hSTMT); if(ret == SQL_ERROR) { ThrowException(ODBC::GetSQLError( SQL_HANDLE_STMT, stmt->m_hSTMT, (char *) "[node-odbc] Error in ODBCStatement::ExecuteSync" )); return scope.Close(Null()); } else { SQLLEN rowCount = 0; SQLRETURN ret = SQLRowCount(stmt->m_hSTMT, &rowCount); if (!SQL_SUCCEEDED(ret)) { rowCount = 0; } uv_mutex_lock(&ODBC::g_odbcMutex); SQLFreeStmt(stmt->m_hSTMT, SQL_CLOSE); uv_mutex_unlock(&ODBC::g_odbcMutex); return scope.Close(Number::New(rowCount)); } }
Handle<Value> ODBCStatement::CloseSync(const Arguments& args) { DEBUG_PRINTF("ODBCStatement::CloseSync\n"); HandleScope scope; OPT_INT_ARG(0, closeOption, SQL_DESTROY); ODBCStatement* stmt = ObjectWrap::Unwrap<ODBCStatement>(args.Holder()); DEBUG_PRINTF("ODBCStatement::CloseSync closeOption=%i\n", closeOption); if (closeOption == SQL_DESTROY) { stmt->Free(); } else { uv_mutex_lock(&ODBC::g_odbcMutex); SQLFreeStmt(stmt->m_hSTMT, closeOption); uv_mutex_unlock(&ODBC::g_odbcMutex); } return scope.Close(True()); }
// getResult(id, objectWrapper): IMMEDIATE void queryGetResult(const Arguments & args) { REQUIRE_ARGS_LENGTH(2); v8::Isolate * isolate = args.GetIsolate(); QueryOperation * op = unwrapPointer<QueryOperation *>(args.Holder()); size_t id = args[0]->Uint32Value(); Handle<Object> wrapper = args[1]->ToObject(); QueryResultHeader * header = op->getResult(id); if(header) { if(header->data) { wrapper->Set(GET_KEY(K_data), LOCAL_BUFFER(node::Buffer::New(isolate, header->data, op->getResultRowSize(header->depth), doNotFreeQueryResultAtGC, 0))); } else { wrapper->Set(GET_KEY(K_data), Null(isolate)); } wrapper->Set(GET_KEY(K_level), v8::Uint32::New(isolate, header->depth)); wrapper->Set(GET_KEY(K_tag), v8::Uint32::New(isolate, header->tag)); args.GetReturnValue().Set(true); } else { args.GetReturnValue().Set(false); } }
Handle<Value> ODBC::CreateConnectionSync(const Arguments& args) { DEBUG_PRINTF("ODBC::CreateConnectionSync\n"); HandleScope scope; ODBC* dbo = ObjectWrap::Unwrap<ODBC>(args.Holder()); HDBC hDBC; uv_mutex_lock(&ODBC::g_odbcMutex); //allocate a new connection handle SQLRETURN ret = SQLAllocHandle(SQL_HANDLE_DBC, dbo->m_hEnv, &hDBC); if (!SQL_SUCCEEDED(ret)) { //TODO: do something! } uv_mutex_unlock(&ODBC::g_odbcMutex); Local<Value> params[2]; params[0] = External::New(dbo->m_hEnv); params[1] = External::New(hDBC); Local<Object> js_result(ODBCConnection::constructor_template-> GetFunction()->NewInstance(2, params)); return scope.Close(js_result); }
Handle<Value> ODBC::CreateConnection(const Arguments& args) { DEBUG_PRINTF("ODBC::CreateConnection\n"); HandleScope scope; REQ_FUN_ARG(0, cb); ODBC* dbo = ObjectWrap::Unwrap<ODBC>(args.Holder()); //initialize work request uv_work_t* work_req = (uv_work_t *) (calloc(1, sizeof(uv_work_t))); //initialize our data create_connection_work_data* data = (create_connection_work_data *) (calloc(1, sizeof(create_connection_work_data))); data->cb = Persistent<Function>::New(cb); data->dbo = dbo; work_req->data = data; uv_queue_work(uv_default_loop(), work_req, UV_CreateConnection, (uv_after_work_cb)UV_AfterCreateConnection); dbo->Ref(); return scope.Close(Undefined()); }
Handle<Value> TiFilesystemObject::_getFile(void* userContext, TiObject* , const Arguments& args) { // Get the paths from the arguments QString path = ""; for(int i = 0, len = args.Length(); i < len; i++) { String::Utf8Value v8UtfString(Handle<String>::Cast(args[i])); const char* cStr = *v8UtfString; path.append(cStr).append("/"); } // remove the last "/" path.remove(path.length() - 1, 1); // in case there is double slashesh, remove them // Ti.Filesyste.getFile( Ti.Filestem.resourceDirectory, '/app.js') // or // Ti.Filesyste.getFile( Ti.Filestem.resourceDirectory, 'app.js') path.replace("//", "/"); HandleScope handleScope; // Get the Filesystem object TiFilesystemObject* obj = (TiFilesystemObject*) userContext; Handle<ObjectTemplate> global = getObjectTemplateFromJsObject(args.Holder()); Handle<Object> result = global->NewInstance(); // Create a File object TiFilesystemFileObject* fileObject = new TiFilesystemFileObject(path); fileObject->setNativeObjectFactory(obj->_objectFactory); fileObject->setValue(result); // Return it setTiObjectToJsObject(result, fileObject); return handleScope.Close(result); }
/* Call destructor */ void destroy(const Arguments &args) { DEBUG_MARKER(UDEB_DEBUG); REQUIRE_ARGS_LENGTH(0); AsyncNdbContext *c = unwrapPointer<AsyncNdbContext *>(args.Holder()); delete c; args.GetReturnValue().SetUndefined(); }
/* Call destructor */ Handle<Value> destroy(const Arguments &args) { DEBUG_MARKER(UDEB_DEBUG); REQUIRE_ARGS_LENGTH(0); AsyncNdbContext *c = unwrapPointer<AsyncNdbContext *>(args.Holder()); delete c; return Undefined(); }
Handle<Value> Watch::Cancel(const Arguments &args) { NodeCallback *callback = node::ObjectWrap::Unwrap<Watch>(args.Holder())->callback; if(callback && callback->getFuture()) fdb_future_cancel(callback->getFuture()); return Null(); }
Handle<Value> ODBCResult::New(const Arguments& args) { DEBUG_PRINTF("ODBCResult::New\n"); HandleScope scope; REQ_EXT_ARG(0, js_henv); REQ_EXT_ARG(1, js_hdbc); REQ_EXT_ARG(2, js_hstmt); REQ_EXT_ARG(3, js_canFreeHandle); HENV hENV = static_cast<HENV>(js_henv->Value()); HDBC hDBC = static_cast<HDBC>(js_hdbc->Value()); HSTMT hSTMT = static_cast<HSTMT>(js_hstmt->Value()); bool* canFreeHandle = static_cast<bool *>(js_canFreeHandle->Value()); //create a new OBCResult object ODBCResult* objODBCResult = new ODBCResult(hENV, hDBC, hSTMT, *canFreeHandle); DEBUG_PRINTF("ODBCResult::New m_hDBC=%X m_hDBC=%X m_hSTMT=%X canFreeHandle=%X\n", objODBCResult->m_hENV, objODBCResult->m_hDBC, objODBCResult->m_hSTMT, objODBCResult->m_canFreeHandle ); //free the pointer to canFreeHandle delete canFreeHandle; //specify the buffer length objODBCResult->bufferLength = MAX_VALUE_SIZE - 1; //initialze a buffer for this object objODBCResult->buffer = (uint16_t *) malloc(objODBCResult->bufferLength + 1); //TODO: make sure the malloc succeeded //set the initial colCount to 0 objODBCResult->colCount = 0; //default fetchMode to FETCH_OBJECT objODBCResult->m_fetchMode = FETCH_OBJECT; objODBCResult->Wrap(args.Holder()); return scope.Close(args.Holder()); }
v8::Handle<v8::Value> Input_v8::New(const Arguments &args) { HandleScope scope; new Input_v8(args.Holder()); Handle<Function> Mixin = Context::GetCurrent()->Global()->Get( String::New("Mixin") ).As<Function>(); Handle<Function> EventEmitter = Context::GetCurrent()->Global()->Get( String::New("EventEmitter") ).As<Function>(); Handle<Value> argv[] = {args.Holder(), EventEmitter}; Mixin->Call(Context::GetCurrent()->Global(), 2, argv); return args.Holder(); }
Handle<Value> Proxy::getProperty(const Arguments& args) { if (args.Length() < 1) { return JSException::Error("Requires property name as first argument."); } Local<String> name = args[0]->ToString(); return getPropertyForProxy(name, args.Holder()); }
Handle<Value> BThread::_start(const Arguments& args){ HandleScope store; base::Thread* th = getThread(args.Holder()); int v; if(args.Length()>0) v = args[0]->Uint32Value(); else v = 0; th->CallStd<void>(&BThread::_threadProc,(void*)(INT_PTR)v); return Undefined(); }
Handle<Value> CudaDevice::totalMem(const Arguments& args) { HandleScope scope; CudaDevice *cu = ObjectWrap::Unwrap<CudaDevice>(args.Holder()); size_t totalGlobalMem; cuDeviceTotalMem(&totalGlobalMem, cu->m_device); return scope.Close(Number::New(totalGlobalMem)); }
static Handle<Value> gum_script_file_on_file_write (const Arguments & args) { FILE * file = static_cast<FILE *> ( args.Holder ()->GetPointerFromInternalField (0)); gboolean argument_valid = FALSE; const gchar * data = NULL; gint data_length = 0; Local<Value> data_val = args[0]; if (data_val->IsString ()) { argument_valid = TRUE; } else if (data_val->IsObject () && !data_val->IsNull ()) { Local<Object> array = data_val->ToObject (); if (array->HasIndexedPropertiesInExternalArrayData () && array->GetIndexedPropertiesExternalArrayDataType () == kExternalUnsignedByteArray) { argument_valid = TRUE; data = static_cast<gchar *> ( array->GetIndexedPropertiesExternalArrayData ()); data_length = array->GetIndexedPropertiesExternalArrayDataLength (); } } if (!argument_valid) { ThrowException (Exception::TypeError (String::New ( "File.write: argument must be a string or raw byte array"))); return Undefined (); } if (file != NULL) { if (data == NULL) { String::Utf8Value utf_val (data_val); fwrite (*utf_val, utf_val.length (), 1, file); } else { fwrite (data, data_length, 1, file); } } else { ThrowException (Exception::TypeError (String::New ( "File.write: file is closed"))); } return Undefined (); }
static Handle<Value> gum_script_file_on_file_close (const Arguments & args) { FILE * file = static_cast<FILE *> ( args.Holder ()->GetPointerFromInternalField (0)); if (file != NULL) { fclose (file); args.Holder ()->SetPointerInInternalField (0, NULL); } else { ThrowException (Exception::TypeError (String::New ( "File.close: file is already closed"))); } return Undefined (); }
Handle<Value> TiObject::_functCallback(const Arguments& args) { HandleScope handleScope; TiObject* obj = getTiObjectFromJsObject(args.Holder()); if (obj == NULL) { return Undefined(); } return handleScope.Close(obj->onFunctionCall(args)); }
Handle<Value> ScriptEnvironment::Function_Script_clearInterval(const Arguments& args) { auto self = static_cast<ScriptEnvironment*>(args.Holder()->GetPointerFromInternalField(0)); if (args.Length() >= 1) { boost::mutex::scoped_lock lock(self->mutex_); self->timer_events_.erase(args[0]->ToInteger()->Int32Value()); } return Undefined(); }