Here is a smaller way of loading the standard library.

I am working on a way of automatically extracting the function list
from somewhere, either the web docs or the source code directly so
that each new release can automatically provide the means of giving us
hackers a quick way of having the whole thing loaded in one hit.

Just save the code into 'stdlib.neko then compile it. Then you just
load the module in the normal way:

    std = $loader.loadmodule("std",$loader)'

then using is just:

    std.file_open()...  etc

Cheers.
Sean Charles

I think I've attached the source file but it may not make it through ?!

---- NEKO SOURCE ----

//!-------------------------------------------------------------------
//! Load NekoVM STD Library functions
//!-------------------------------------------------------------------
//!
//! Define the set of API functions from 'std' we will make available.
//! (NOTE: This string will be auto-generated from the sources one
day!
//!
//! Copyright (c) 2008 Sean Charles
//!
//! This is free software; you can redistribute it and/or
//! modify  it under  the  terms of  the  GNU Lesser  General
//! Public  License   as  published  by   the  Free  Software
//! Foundation;  either version  2.1 of  the License,  or (at
//! your option) any later version.
//!
//! This library is distributed in the hope that it will be
//! useful,  but  WITHOUT  ANY  WARRANTY;  without  even  the
//! implied  warranty  of MERCHANTABILITY  or  FITNESS FOR  A
//! PARTICULAR  PURPOSE.  See the  GNU Lesser  General Public
//! License for more details.
//!
//! You should have received a copy of the GNU Lesser General
//! Public License along with  this library; if not, write to
//! the  Free  Software Foundation,  Inc.,  59 Temple  Place,
//! Suite 330, Boston, MA 02111-1307 USA.
//!
//!-------------------------------------------------------------------
var apiset = 
"buffer_new/0,buffer_add/2,buffer_add_char/2,buffer_add_sub/4,buffer_string/1,buffer_reset/1,date_now/0,date_new/1,date_form\
at/2,date_set_hour/4,date_set_day/4,date_get_day/1,date_get_hour/1,date_get_tz/0,file_open/2,file_close/1,file_name/1,file_write/4,file_r\
ead/4,file_write_char/2,file_read_char/1,file_seek/3,file_tell/1,file_eof/1,file_flush/1,file_contents/1,file_stdin/0,file_stdout/0,file_\
stderr/0,math_atan2/2,math_pow/2,math_abs/1,math_ceil/1,math_floor/1,math_round/1,math_pi/0,math_sqrt/1,math_atan/1,math_cos/1,math_sin/1\
,math_tan/1,math_log/1,math_exp/1,math_acos/1,math_asin/1,make_md5/1,mem_size/1,module_read/2,module_read_path/3,module_exec/1,module_nam\
e/1,module_exports/1,module_loader/1,module_nglobals/1,module_global_get/2,module_global_set/3,module_code_size/1,process_run/2,process_s\
tdout_read/4,process_stderr_read/4,process_stdin_write/4,process_stdin_close/1,process_exit/1,process_pid/1,process_close/1,random_new/0,\
random_set_seed/2,random_int/2,random_float/1,serialize/1,unserialize/2,socket_init/0,socket_new/1,socket_close/1,socket_send_char/2,sock\
et_send/4,socket_recv/4,socket_recv_char/1,socket_write/2,socket_read/1,host_resolve/1,host_to_string/1,host_reverse/1,host_local/0,socke\
t_connect/3,socket_listen/2,socket_select/4,socket_bind/3,socket_accept/1,socket_peer/1,socket_host/1,socket_set_timeout/2,socket_shutdow\
n/3,socket_set_blocking/2,socket_poll_alloc/1,socket_poll_prepare/3,socket_poll_events/2,socket_poll/3,string_split/2,sprintf/2,url_encod\
e/1,url_decode/1,base_encode/2,base_decode/2,get_env/1,put_env/2,sys_env/0,sys_sleep/1,set_time_locale/1,sys_time/0,sys_cpu_time/0,get_cw\
d/0,set_cwd/1,sys_string/0,sys_is64/0,sys_command/1,sys_exit/1,sys_exists/1,file_exists/1,file_delete/1,sys_rename/2,sys_stat/1,sys_file_\
type/1,sys_create_dir/2,sys_remove_dir/1,sys_read_dir/1,file_full_path/1,sys_exe_path/0,sys_getch/1,sys_get_pid/0,thread_create/2,thread_\
current/0,thread_send/2,thread_read_message/1,lock_create/0,lock_release/1,lock_wait/2,tls_create/0,tls_set/2,tls_get/1,mutex_create/0,mu\
tex_acquire/1,mutex_try/1,mutex_release/1,deque_create/0,deque_add/2,deque_push/2,deque_pop/2,utf8_buf_alloc/1,utf8_buf_add/2,utf8_buf_co\
ntent/1,utf8_buf_length/1,utf8_buf_size/1,utf8_validate/1,utf8_length/1,utf8_sub/3,utf8_get/2,utf8_iter/2,utf8_compare/2,parse_xml/2,floa\
t_bytes/2,double_bytes/2,float_of_bytes/2,double_of_bytes/2,run_gc/1,gc_stats/0,enable_jit/1,test/0,print_redirect/1,int32_new/1,int32_to\
_int/1,int32_to_float/1,int32_compare/2,int32_add/2,int32_sub/2,int32_mul/2,int32_div/2,int32_neg/1,int32_ushr/2,int32_shl/2,int32_shr/2,\
int32_mod/2,int32_complement/1,int32_or/2,int32_and/2,int32_xor/2,int32_address/1"

string_split = $loader.loadprim( "[EMAIL PROTECTED]", 2 );
sprintf      = $loader.loadprim( "[EMAIL PROTECTED]", 2 );

process_functions = function( flist ) {
  if ( $istrue( flist )) {
    var fn_arity = string_split( flist[0], "/" );
    var fname    = fn_arity[0];
    var arity    = $int( fn_arity[1][0] );
    $objset( $exports,
             $hash( fname ),
             $loader.loadprim( sprintf( "[EMAIL PROTECTED]", fname ), arity ));
    process_functions( flist[1] ); }}

process_functions( string_split( apiset, "," ));

Attachment: stdlib.neko
Description: Binary data

-- 
Neko : One VM to run them all
(http://nekovm.org)

Reply via email to