Changeset 428

Show
Ignore:
Timestamp:
11/02/08 18:59:46 (2 months ago)
Author:
mooneer
Message:

* System.directory module added (ticket #63).
* Added support for using libc functions in interface.language.c.
* Added tell() function to System.file.
* Added System.exceptions.SystemCallFailure? exception, which

pulls perror() to pull exception string.

Location:
interpreter/trunk
Files:
4 added
10 modified

Legend:

Unmodified
Added
Removed
  • interpreter/trunk/ChangeLog

    r426 r428  
     111/2/2008: 
     2    * System.directory module added (ticket #63) 
     3    * Added support for using libc functions in interface.language.c. 
     4        * Added tell() function to System.file. 
     5    * Added System.exceptions.SystemCallFailure exception, which pulls 
     6          perror() to pull exception string. 
     7 
    1810/26/2008: 
    29    * Performance improvements. 
  • interpreter/trunk/modules/Makefile.am

    r423 r428  
    88        System/vm/compiler.c System/vm/loader.c System/vm.c \ 
    99        System/math/range.c System/vm/thread.c System/network/socket.c \ 
    10         __internal.c __internal/_regex.c \ 
     10        System/directory.c __internal.c __internal/_regex.c \ 
    1111        __internal/_regex_match.c __internal/_exception.c \ 
    1212        __internal/_cinvoke_context.c __internal/_cinvoke_library.c \ 
     
    1414        __internal/_cinvoke_callback.c 
    1515 
    16 nobase_dist_pkglib_SCRIPTS = System.kt System/network/wrapper.kt System/collections.kt \ 
    17         System/doc.kt System/doc/outputters.kt System/regex.kt System/vm/debugger.kt \ 
    18         System/exceptions.kt System/network.kt interface.kt interface/http.kt interface/http/cgi.kt \ 
    19         interface/language.kt interface/language/c.kt interface/text.kt interface/text/readline.kt \ 
    20         interface/text/base64.kt interface/text/binary.kt all_modules.kt 
     16nobase_dist_pkglib_SCRIPTS = System.kt System/network/wrapper.kt \ 
     17    System/collections.kt System/doc.kt System/doc/outputters.kt System/regex.kt \ 
     18        System/vm/debugger.kt System/exceptions.kt System/network.kt interface.kt \ 
     19        interface/http.kt interface/http/cgi.kt interface/language.kt interface/language/c.kt \ 
     20        interface/text.kt interface/text/readline.kt interface/text/base64.kt \ 
     21        interface/text/binary.kt all_modules.kt 
    2122 
    2223AM_CFLAGS = -I../objs -fPIC -W -Wall -DCINVOKE_BUILD 
  • interpreter/trunk/modules/System/exceptions.kt

    r382 r428  
    233233]; 
    234234 
     235class SystemCallFailure 
     236    /[Failure while calling system call.]/ 
     237[ 
     238    construct() 
     239        /[Class constructor.]/ 
     240    [ 
     241        base|__construct__(this|get_perror()); 
     242    ] 
     243]; 
  • interpreter/trunk/modules/System/file.c

    r417 r428  
    133133    fclose(this->builtin_data.filevalue); 
    134134    this->builtin_data.filevalue = NULL; 
     135} 
     136 
     137/***************************************************************************** 
     138 * Emit current position in file. 
     139 ****************************************************************************/ 
     140KITE_CLASS_METHOD(File_tell) { 
     141    KITE_NO_ARGS; 
     142 
     143    CHECK_FILE_OPEN; 
     144    kite_vm_return(thd, kite_new_integer(thd, ftell(this->builtin_data.filevalue))); 
    135145} 
    136146 
     
    196206                                  "Move current position in file.", 1, 
    197207                                  "pos", "Position in file to move to.")); 
     208    kite_add_method(thread, newclass, "tell",  
     209        kite_new_method_with_docs(thread, FUNC_COMPILED, File_tell,  
     210                                  "Return current position in file.", 0)); 
    198211    kite_add_method(thread, newclass, "close",  
    199212        kite_new_method_with_docs(thread, FUNC_COMPILED, File_close,  
  • interpreter/trunk/modules/__internal/_cinvoke_function.c

    r403 r428  
    5454    ret = KITE_GET_STRING_VALUE(retString); 
    5555    params = KITE_GET_STRING_VALUE(paramString); 
    56      
     56 
    5757    func = cinv_function_create(ctx, CINV_CC_CDECL, ret, params); 
    5858    typeList = kite_new_list(thd); 
  • interpreter/trunk/modules/__internal/_cinvoke_library.c

    r402 r428  
    5151     
    5252    ctx = (CInvContext*)ctxObj->builtin_data.filevalue; 
    53     lib = KITE_GET_STRING_VALUE(libString); 
     53    if (libString->type == OBJ_NULL) 
     54        lib = NULL; 
     55    else lib = KITE_GET_STRING_VALUE(libString); 
    5456     
    5557    this->builtin_data.listvalue.car =  
  • interpreter/trunk/modules/__internal/_exception.c

    r378 r428  
    4444    KITE_NO_ARGS; 
    4545    kite_vm_return(thd, kite_object_name(thd, this)); 
     46} 
     47/***************************************************************************** 
     48 * Perror of errno 
     49 ****************************************************************************/ 
     50KITE_CLASS_METHOD(Exception_perror) { 
     51    KITE_NO_ARGS; 
     52 
     53    char str[256]; 
     54    perror(str); 
     55 
     56    kite_vm_return(thd, kite_new_string(thd, str)); 
    4657} 
    4758 
     
    103114        kite_new_method_with_docs(thread, FUNC_COMPILED, Exception_str,  
    104115                                  "Returns string representation of exception.", 0)); 
     116    kite_add_method(thread, newclass, "get_perror",  
     117        kite_new_method_with_docs(thread, FUNC_COMPILED, Exception_perror,  
     118                                  "Internal use only.", 0)); 
    105119    kite_add_method(thread, newclass, "throw",  
    106120        kite_new_method_with_docs(thread, FUNC_COMPILED, Exception_throw,  
  • interpreter/trunk/modules/all_modules.kt

    r423 r428  
    3131import "System.collections"; 
    3232import "System.date"; 
     33import "System.directory"; 
    3334import "System.doc"; 
    3435import "System.exceptions"; 
  • interpreter/trunk/modules/interface/language/c.kt

    r389 r428  
    384384    property fx; 
    385385    property i; 
    386      
     386 
    387387    fx = make interface.language.c.function_prototype(); 
    388388    fx.ret_type = interface.language.c.param_types.type_characters[ret_type]; 
  • interpreter/trunk/tests/Makefile.am

    r422 r428  
    246246./objs/binary/binary_test.kt \ 
    247247./objs/binary/binary_test.kt.out \ 
     248./objs/dir/tmp_dir.kt \ 
     249./objs/dir/tmp_dir.kt.out \ 
    248250./exception/exception_backtrace.kt.out \ 
    249251./exception/nested_exceptions.kt \