HANDLE get_OSHandleByFileNumber(int fNumber) { HANDLE res; RHO_LOCK(FileHandlers); res = g_arFileHandlers[fNumber-1]; RHO_UNLOCK(FileHandlers); return res; }
int get_NewFileNumber() { int i = 0; int nRes = -1; RHO_LOCK(FileHandlers); for( i = 0; i < g_nMaxFileHandlers; i++ ) { if ( g_arFileHandlers[i] == 0 ) { nRes = i; break; } } RHO_UNLOCK(FileHandlers); return nRes+1; }
VALUE require_compiled(VALUE fname, VALUE* result, int bLoad) { VALUE path; char* szName1 = 0; VALUE retval = Qtrue; if (TYPE(fname) != T_STRING) rb_raise(rb_eLoadError, "can not load non-string"); szName1 = RSTRING_PTR(fname); if ( String_endsWith(szName1,".rb") ) { rb_str_chop_bang(fname); rb_str_chop_bang(fname); rb_str_chop_bang(fname); } //rb_funcall(fname, rb_intern("sub!"), 2, rb_str_new2(".rb"), rb_str_new2("") ); szName1 = RSTRING_PTR(fname); if ( strcmp("strscan",szName1)==0 || strcmp("enumerator",szName1)==0 || strcmp("stringio",szName1)==0 || strcmp("socket",szName1)==0 ) return Qtrue; RHO_LOCK(require_lock); if ( !bLoad && isAlreadyLoaded(fname) == Qtrue ) goto RCompExit; path = find_file(fname); if ( path != 0 ) { VALUE seq; RAWLOG_INFO1("require_compiled: %s", szName1); //optimize require //rb_ary_push(GET_VM()->loaded_features, path); rb_ary_push(GET_VM()->loaded_features, fname); #ifdef RHODES_EMULATOR if ( strstr( RSTRING_PTR(path), ".rb") == 0 ) rb_str_cat(path,".rb",3); GET_VM()->src_encoding_index = rb_utf8_encindex(); rb_load(path, 0); if( rho_simconf_getBool("reload_app_changes") ) { if ( strncmp( RSTRING_PTR(path), rho_native_rhopath(), strlen(rho_native_rhopath()) ) == 0 ) rb_ary_delete(GET_VM()->loaded_features, fname); } #else //rb_gc_disable(); seq = loadISeqFromFile(path); //*result = rb_funcall(seq, rb_intern("eval"), 0 ); *result = rb_iseq_eval(seq); //rb_gc_enable(); #endif goto RCompExit; } RAWLOG_ERROR1("require_compiled: error: can not find %s", RSTRING_PTR(fname)); retval = Qnil; RCompExit: RHO_UNLOCK(require_lock); return retval; }
void set_FileNumber(int fNumber, HANDLE osfh) { RHO_LOCK(FileHandlers); g_arFileHandlers[fNumber-1] = osfh; RHO_UNLOCK(FileHandlers); }