Handle<Value> MultiPolygon::New(OGRMultiPolygon *geom, bool owned) { HandleScope scope; if (!geom) { return 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); v8::Handle<v8::Value> ext = v8::External::New(wrapped); v8::Handle<v8::Object> obj = MultiPolygon::constructor->GetFunction()->NewInstance(1, &ext); return scope.Close(obj); }
int main() { Null(); for (;;); return 0; }
Handle<Value> DatasetBands::get(const Arguments& args) { HandleScope scope; Handle<Object> parent = args.This()->GetHiddenValue(String::NewSymbol("parent_"))->ToObject(); Dataset *ds = ObjectWrap::Unwrap<Dataset>(parent); if (ds->uses_ogr){ OGRDataSource* raw = ds->getDatasource(); if (!raw) { return NODE_THROW("Dataset object has already been destroyed"); } return Null(); } else { GDALDataset* raw = ds->getDataset(); if (!raw) { return NODE_THROW("Dataset object has already been destroyed"); } int band_id; NODE_ARG_INT(0, "band id", band_id); GDALRasterBand *band = raw->GetRasterBand(band_id); return scope.Close(RasterBand::New(band, raw)); } }
/// Create - create a fragment reference for a given fragment. /// /// @param pFrag - the given fragment /// @param pOffset - the offset, can be larger than the fragment, but can not /// be larger than the section size. /// @return if the offset is legal, return the fragment reference. Otherwise, /// return NULL. FragmentRef* FragmentRef::Create(Fragment& pFrag, uint64_t pOffset) { int64_t offset = pOffset; Fragment* frag = &pFrag; while (frag != NULL) { offset -= frag->size(); if (offset <= 0) break; frag = frag->getNextNode(); } if ((frag != NULL) && (frag->size() != 0)) { if (offset == 0) frag = frag->getNextNode(); else offset += frag->size(); } if (frag == NULL) return Null(); FragmentRef* result = g_FragRefFactory->allocate(); new (result) FragmentRef(*frag, offset); return result; }
Handle<Value> FieldDefn::New(OGRFieldDefn *def, bool owned) { HandleScope scope; if (!def) { return Null(); } //make a copy of fielddefn owned by a featuredefn // + no need to track when a featuredefn is destroyed // + no need to throw errors when a method trys to modify an owned read-only fielddefn // - is slower if (!owned) { def = new OGRFieldDefn(def); } FieldDefn *wrapped = new FieldDefn(def); wrapped->owned_ = true; v8::Handle<v8::Value> ext = v8::External::New(wrapped); v8::Handle<v8::Object> obj = FieldDefn::constructor->GetFunction()->NewInstance(1, &ext); return scope.Close(obj); }
static void OnServiceRegistered(DNSServiceRef sdRef, DNSServiceFlags flags, DNSServiceErrorType errorCode, const char * name, const char * regtype, const char * domain, void * context) { if ( ! context) return; HandleScope scope; ServiceRef * serviceRef = static_cast<ServiceRef*>(context); Handle<Function> callback = serviceRef->GetCallback(); Handle<Object> this_ = serviceRef->GetThis(); if ( ! callback.IsEmpty() && ! this_.IsEmpty()) { const size_t argc(7); Local<Value> args[argc]; args[0] = Local<Object>::New(serviceRef->handle_); args[1] = Integer::New(flags); args[2] = Integer::New(errorCode); args[3] = String::New(name); args[4] = String::New(regtype); args[5] = String::New(domain); if (serviceRef->GetContext().IsEmpty()) { args[6] = Local<Value>::New(Null()); } else { args[6] = Local<Value>::New(serviceRef->GetContext()); } callback->Call(this_, argc, args); } }
Handle<Value> Projection::Transform(const Arguments& args) { HandleScope scope; Handle<Value> geom_obj; if (args.Length() < 3) { return ThrowException(String::New("Not enough arguments.")); } else { Projection *from = ObjectWrap::Unwrap<Projection>(args[0]->ToObject()); Projection *to = ObjectWrap::Unwrap<Projection>(args[1]->ToObject()); Geometry *geom = ObjectWrap::Unwrap<Geometry>(args[2]->ToObject()); PointTransformer *trans = new ProjectionPointTransformer(from->pj, to->pj); try { geom->ApplyPointTransformation(trans); } catch (TransformerException ex) { delete trans; return ThrowException(String::New(ex.GetDescription())); } delete trans; } return scope.Close(Null()); }
cl_object si_make_foreign_data_from_array(cl_object array) { cl_object tag; if (ecl_unlikely(ecl_t_of(array) != t_array && ecl_t_of(array) != t_vector)) { FEwrong_type_only_arg(ecl_make_fixnum(/*SI::MAKE-FOREIGN-DATA-FROM-ARRAY*/1358), array, ecl_make_fixnum(/*ARRAY*/96)); } tag = ecl_aet_to_ffi_table[array->array.elttype]; if (ecl_unlikely(Null(tag))) { FEerror("Cannot make foreign object from array " "with element type ~S.", 1, ecl_elttype_to_symbol(array->array.elttype)); } { #line 293 const cl_env_ptr the_env = ecl_process_env(); #line 293 #line 293 cl_object __value0 = ecl_make_foreign_data(tag, 0, array->array.self.bc); #line 293 the_env->nvalues = 1; #line 293 return __value0; #line 293 } ; }
Handle<Value> FeatureDefn::New(OGRFeatureDefn *def, bool owned) { HandleScope scope; if (!def) { return Null(); } //make a copy of featuredefn owned by a layer // + no need to track when a layer is destroyed // + no need to throw errors when a method trys to modify an owned read-only featuredefn // - is slower //TODO: cloning maybe unnecessary if reference counting is done right. // def->Reference(); def->Release(); if (!owned) { def = def->Clone(); } FeatureDefn *wrapped = new FeatureDefn(def); wrapped->owned_ = true; def->Reference(); v8::Handle<v8::Value> ext = v8::External::New(wrapped); v8::Handle<v8::Object> obj = FeatureDefn::constructor->GetFunction()->NewInstance(1, &ext); return scope.Close(obj); }
CPointer CObjects::Get(char* szObjectName) { CBaseObject* pvObject; CPointer pObject; pvObject = GetFromMemory(szObjectName); if (pvObject) { pObject.AssignObject(pvObject); return pObject; } pvObject = GetFromDatabase(szObjectName); if (pvObject) { pObject.AssignObject(pvObject); return pObject; } pvObject = GetFromSources(szObjectName); if (pvObject) { pObject.AssignObject(pvObject); return pObject; } return Null(); }
static Result OptionalNull(Reader& input) { if (input.Peek(NULLTag)) { return Null(input); } return Success; }
/* arg0: Ndb arg1: NdbDictionary::Table arg2: resolvedMapping which contains an array "fields" where each element has "columnName" and "fieldName" properties Returns: a constructor function that can be used to create native-backed objects */ Handle<Value> NroBuilder(const Arguments &args) { DEBUG_MARKER(UDEB_DEBUG); HandleScope scope; //Ndb * ndb = unwrapPointer<Ndb *>(args[0]->ToObject()); //Handle<Object> jsDbTable = args[1]->ToObject(); //NdbDictionary::Table * table = unwrapPointer<NdbDictionary::Table *>(jsDbTable); return scope.Close(Null()); //fixme }
static JSVAL fs_stat(JSARGS args) { HandleScope scope; String::Utf8Value path(args[0]->ToString()); struct stat buf; if (stat(*path, &buf) == -1) { return scope.Close(Null()); } return scope.Close(format_stat(buf)); }
int ecl_symbol_type(cl_object s) { if (Null(s)) return ECL_NIL_SYMBOL->symbol.stype; if (ecl_t_of(s) == t_symbol) return s->symbol.stype; FEwrong_type_nth_arg(ecl_make_fixnum(/*SYMBOL-NAME*/843), 1, s, ecl_make_fixnum(/*SYMBOL*/840)); }
int EBuffer::BlockUnmark() { EPoint Null(-1,-1); SetBB(BE); SetBE(Null); SetBB(Null); AutoExtend = 0; return 1; }
cl_object ecl_symbol_package(cl_object s) { if (Null(s)) return ECL_NIL_SYMBOL->symbol.hpack; if (ecl_t_of(s) == t_symbol) return s->symbol.hpack; FEwrong_type_nth_arg(ecl_make_fixnum(/*SYMBOL-PACKAGE*/844), 1, s, ecl_make_fixnum(/*SYMBOL*/840)); }
JSVAL getScalar(JSARGS args) { HandleScope scope; String::Utf8Value sql(args[0]->ToString()); int failure = mysql_query(handle, *sql); if (failure) { return ThrowException(Exception::Error(String::New(mysql_error(handle)))); } MYSQL_RES *result = mysql_store_result(handle); if (!result) { return scope.Close(False()); } unsigned long *lengths = mysql_fetch_lengths(result); MYSQL_FIELD *fields = mysql_fetch_fields(result); MYSQL_ROW row = mysql_fetch_row(result); if (row[0] == NULL) { return Null(); } else { switch (fields[0].type) { case MYSQL_TYPE_TINY: return scope.Close(Integer::New(atoi(row[0]))); case MYSQL_TYPE_SHORT: return scope.Close(Integer::New(atoi(row[0]))); case MYSQL_TYPE_LONG: return scope.Close(Integer::New(atoi(row[0]))); case MYSQL_TYPE_FLOAT: return scope.Close(Integer::New(atoi(row[0]))); case MYSQL_TYPE_DOUBLE: return scope.Close(Integer::New(atoi(row[0]))); case MYSQL_TYPE_NULL: return Null(); case MYSQL_TYPE_TIMESTAMP: return scope.Close(Integer::New(atoi(row[0]))); case MYSQL_TYPE_LONGLONG: return scope.Close(Integer::New(atoi(row[0]))); case MYSQL_TYPE_INT24: return scope.Close(Integer::New(atoi(row[0]))); default: return scope.Close(String::New(row[0], lengths[0])); } } }
Handle<Value> PushbotsModule::getter_exampleProp(Local<String> property, const AccessorInfo& info) { LOGD(TAG, "get exampleProp"); HandleScope scope; JNIEnv *env = titanium::JNIScope::getEnv(); if (!env) { return titanium::JSException::GetJNIEnvironmentError(); } static jmethodID methodID = NULL; if (!methodID) { methodID = env->GetMethodID(PushbotsModule::javaClass, "getExampleProp", "()Ljava/lang/String;"); if (!methodID) { const char *error = "Couldn't find proxy method 'getExampleProp' with signature '()Ljava/lang/String;'"; LOGE(TAG, error); return titanium::JSException::Error(error); } } titanium::Proxy* proxy = titanium::Proxy::unwrap(info.Holder()); if (!proxy) { return Undefined(); } jvalue* jArguments = 0; jobject javaProxy = proxy->getJavaObject(); jstring jResult = (jstring)env->CallObjectMethodA(javaProxy, methodID, jArguments); if (!JavaObject::useGlobalRefs) { env->DeleteLocalRef(javaProxy); } if (env->ExceptionCheck()) { Handle<Value> jsException = titanium::JSException::fromJavaException(); env->ExceptionClear(); return jsException; } if (jResult == NULL) { return Null(); } Handle<Value> v8Result = titanium::TypeConverter::javaStringToJsString(env, jResult); env->DeleteLocalRef(jResult); return v8Result; }
void Grid::EIO_AfterEncode(uv_work_t* req) { HandleScope scope; encode_grid_baton_t *closure = static_cast<encode_grid_baton_t *>(req->data); TryCatch try_catch; if (closure->error) { Local<Value> argv[1] = { Exception::Error(String::New(closure->error_name.c_str())) }; closure->cb->Call(Context::GetCurrent()->Global(), 1, argv); } else { // convert key order to proper javascript array Local<Array> keys_a = Array::New(closure->key_order.size()); std::vector<std::string>::iterator it; unsigned int i; for (it = closure->key_order.begin(), i = 0; it < closure->key_order.end(); ++it, ++i) { keys_a->Set(i, String::New((*it).c_str())); } mapnik::grid const& grid_type = *closure->g->get(); // gather feature data Local<Object> feature_data = Object::New(); if (closure->add_features) { node_mapnik::write_features<mapnik::grid>(grid_type, feature_data, closure->key_order); } // Create the return hash. Local<Object> json = Object::New(); Local<Array> grid_array = Array::New(closure->lines.size()); unsigned array_size = static_cast<unsigned int>(grid_type.width()/closure->resolution); for (unsigned j=0;j<closure->lines.size();++j) { grid_array->Set(j,String::New(&closure->lines[j],array_size)); } json->Set(String::NewSymbol("grid"), grid_array); json->Set(String::NewSymbol("keys"), keys_a); json->Set(String::NewSymbol("data"), feature_data); Local<Value> argv[2] = { Local<Value>::New(Null()), Local<Value>::New(json) }; closure->cb->Call(Context::GetCurrent()->Global(), 2, argv); } if (try_catch.HasCaught()) { FatalException(try_catch); } uv_unref(uv_default_loop()); closure->g->Unref(); closure->cb.Dispose(); delete closure; }
static JSVAL fs_readfile64(JSARGS args) { HandleScope scope; String::Utf8Value path(args[0]->ToString()); int fd = open(*path, O_RDONLY); if (fd == -1) { printf("%s\n%s\n", *path, strerror(errno)); return scope.Close(Null()); } long size = lseek(fd, 0, 2); lseek(fd, 0, 0); unsigned char buf[size]; if (read(fd, buf, size) != size) { return scope.Close(Null()); } close(fd); string encoded = Base64Encode(buf, size); Handle<String>s = String::New(encoded.c_str(), encoded.size()); return scope.Close(s); }
ColumnPtr DataTypeNullable::createConstColumn(size_t size, const Field & field) const { if (field.isNull()) return std::make_shared<ColumnNull>(size, Null(), clone()); /// Actually we return non-const column, because we cannot create const column, corresponding to Nullable type, but with non-NULL value. return std::make_shared<ColumnNullable>( nested_data_type->createConstColumn(size, field)->convertToFullColumnIfConst(), std::make_shared<ColumnUInt8>(size, 0)); }
bool ecl_endp(cl_object x) { if (Null(x)) { return TRUE; } else if (ecl_unlikely(!LISTP(x))) { FEwrong_type_only_arg(ecl_make_fixnum(/*ENDP*/330), x, ecl_make_fixnum(/*LIST*/481)); } return FALSE; }
AnyType linregr_final::run(AnyType& args) { LinRegrState state = args[0].getAs<ByteString>(); // If we haven't seen any data, just return Null. This is the standard // behavior of aggregate function on empty data sets (compare, e.g., // how PostgreSQL handles sum or avg on empty inputs) if (state.numRows == 0) return Null(); AnyType tuple; LinearRegression result(state); tuple << result.coef << result.r2 << result.stdErr << result.tStats << (state.numRows > state.widthOfX ? result.pValues : Null()) << result.conditionNo; return tuple; }
static JSVAL info(JSARGS args) { HandleScope scope; MYSQL *handle = (MYSQL *) args[0]->IntegerValue(); const char *info = mysql_info(handle); if (info) { return scope.Close(String::New(info)); } else { return scope.Close(Null()); } }
int main (){ Any a6 = Null(); Any a7 = Int(1); Any a8 = Int(2); Any a9[] = {a6, a7, a8}; Any a10 = Null(); Any a5 = f ( a9, a10 ); Any a4 = toStr ( a5 ); println ( a4 ); Any a16 = Int(1); Any a17 = Int(2); Any a18 = Null(); Any a19 = Int(10); Any a20[] = {a16, a17, a18, a19}; Any a21 = Int(10); Any a15 = f ( a20, a21 ); Any a14 = toStr ( a15 ); println ( a14 ); return 0; }
v8::Handle<v8::Value> IRBuilder::GetInsertBlock(const v8::Arguments& args) { HandleScope scope; llvm::BasicBlock *llvm_bb = IRBuilder::builder.GetInsertBlock(); if (llvm_bb) { Handle<v8::Value> result = BasicBlock::New(llvm_bb); return scope.Close(result); } else return scope.Close(Null()); }
static cl_object * ecl_symbol_plist(cl_object s) { if (Null(s)) { return &ECL_NIL_SYMBOL->symbol.plist; } if (ecl_t_of(s) == t_symbol) { return &s->symbol.plist; } FEwrong_type_nth_arg(ecl_make_fixnum(/*SYMBOL-PLIST*/845), 1, s, ecl_make_fixnum(/*SYMBOL*/840)); }
int main(int argc, char **argv) { FILE *data, *out; char val, newval; int i, len; if (argc != 3) { fprintf(stderr,"Usage : encode <source> <dest>\n"); exit(1); } data = fopen(argv[1], "rb"); if (data == Null(FILE)) { fprintf(stderr, "Cannot open %s\n", argv[1]); exit(1); } out = fopen(argv[2], "wb"); if (out == Null(FILE)) { fprintf(stderr, "Cannot open %s\n", argv[2]); exit(1); } i = (512 << 16) + 512; fwrite((void *) &i, sizeof(int), 1, out); val = getc(data); len = 1; for (i = 1; i < 512 * 512; i++) { newval = getc(data); if (val == newval) len++; else { if ((len <= 4 ) && (val != 0x00FF)) { for ( ; len > 0; len--) fputc(val, out); } else { fputc(0x00FF, out); fputc(len / 256, out); fputc(len & 0x00FF, out); fputc(val, out); } val = newval; len = 1; } } fclose(data); fclose(out); }
AnyType multi_response_glm_final::run(AnyType& args) { MutableMultiResponseGLMState state = args[0].getAs<MutableByteString>(); // If we haven't seen any valid data, just return Null. This is the standard // behavior of aggregate function on empty data sets (compare, e.g., // how PostgreSQL handles sum or avg on empty inputs) if (state.empty() || state.terminated) { return Null(); } state.apply(); return state.storage(); }
/* ServerInfo call. */ int Util_CountLinks(Object *processor) { Object *procman = Locate(processor, "tasks"); BYTE buffer[IOCDataMax]; word rc; if (procman == Null(Object)) return(-1); rc = ServerInfo(procman, buffer); Close(procman); if (rc < Err_Null) return(-1); return (int)(((ProcStats *) buffer)->NLinks); }