diff --git a/CHANGES.current b/CHANGES.current index 77f58275e..bc53a19ce 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,15 @@ Version 1.3.25 (In progress) ============================ +03/17/2005: wuzzeb (John Lenz) + [Chicken] + + Fix a whole bunch of bugs in the chicken module. The entire + test suite now compiles, with the exception of the tests that require + std_vector.i, std_deque.i, and so on, which chicken does not have yet. + + + Add support for %exception and %typemap(exceptions). Exceptions are + thrown with a call to (abort) and can be handled by (handle-exceptions) + 03/15/2005: wsfulton [Java] Patch from Scott Michel for directors. Modifications to the typemaps giving users fine control over memory ownership and lifetime of director classes. diff --git a/Doc/Manual/Chicken.html b/Doc/Manual/Chicken.html index b62306c64..8d1fbffb4 100644 --- a/Doc/Manual/Chicken.html +++ b/Doc/Manual/Chicken.html @@ -23,17 +23,21 @@
  • Modules
  • Constants and Variables
  • Functions +
  • Exceptions -
  • TinyCLOS -
  • Compilation -
  • Linkage +
  • TinyCLOS +
  • Compilation +
  • Linkage -
  • Typemaps -
  • Pointers -
  • Unsupported features and known problems +
  • Typemaps +
  • Pointers + +
  • Unsupported features and known problems @@ -141,7 +145,6 @@ So for the C++ mode of SWIG CHICKEN, example_wrap.cxx and oexample.c are the files that must be compiled to object files and linked into your project. -

    17.2 Code Generation

    @@ -183,6 +186,7 @@

    CHICKEN will be able to access the module using the (declare (uses modulename)) CHICKEN Scheme form. +

    17.2.3 Constants and Variables

    @@ -230,19 +234,55 @@ parameters).

    -

    17.3 TinyCLOS

    +

    17.2.5 Exceptions

    + + +

    The SWIG chicken module has support for exceptions thrown from + C or C++ code to be caught in scheme. + See Exception handling with %exception + for more information about declaring exceptions in the interface file. +

    + +

    Chicken supports both the SWIG_exception(int code, const char *msg) interface + as well as a SWIG_ThrowException(C_word val) function for throwing exceptions from + inside the %exception blocks. SWIG_exception will throw a list consiting of the code + (as an integer) and the message. Both of these will throw an exception using (abort), + which can be handled by (handle-exceptions). See + Chicken manual on Exceptions + and SFRI-12. Since the exception values are thrown + directly, if (condition-case) is used to catch an exception the exception will come through in the val () case. +

    + +

    The following simple module

    + +
    +%module exception_test
    +
    +%inline %{
    +  void test_throw(int i) throws (int) { 
    +    if (i == 1) throw 15; 
    +  }
    +%}
    +
    + +

    could be run with

    + +
    +(handle-exceptions exvar (if (= exvar 15) (print "Correct!") (print "Threw something else " exvar)) (test-throw 1))
    +
    + + +

    17.3 TinyCLOS

    The author of TinyCLOS, Gregor Kiczales, describes TinyCLOS as: -

    -
    - Tiny CLOS is a Scheme implementation of a `kernelized' CLOS, with a + "Tiny CLOS is a Scheme implementation of a `kernelized' CLOS, with a metaobject protocol. The implementation is even simpler than the simple CLOS found in `The Art of the Metaobject Protocol,' weighing in at around 850 lines of code, including (some) - comments and documentation. -
    + comments and documentation." +

    Almost all good Scheme books describe how to use metaobjects and @@ -275,7 +315,7 @@

    -

    17.4 Compilation

    +

    17.4 Compilation

    @@ -289,7 +329,7 @@ much simpler csc or csc.bat.

    -

    17.5 Linkage

    +

    17.5 Linkage

    @@ -303,7 +343,7 @@ loadable module.

    -

    17.5.1 Shared library

    +

    17.5.1 Shared library

    @@ -312,13 +352,13 @@ in example.i and the C functions being wrapped are in example_impl.c.

    -
    -
    -   $ swig -chicken example.i
    -   $ csc -svk example.scm example_impl.c example_wrap.c
    -   $ csi example.so test_script.scm
    -   
    -
    +
    +
    +$ swig -chicken example.i
    +$ csc -svk example.scm example_impl.c example_wrap.c
    +$ csi example.so test_script.scm
    +
    +

    You must be careful not to name the example_impl.c file example.c because @@ -331,20 +371,20 @@ be accessable to the loader. You might need to set LD_LIBRARY_PATH.

    -

    17.5.2 Static binary

    +

    17.5.2 Static binary

    Again, we can easily use csc to build a binary.

    -
    -
    -   $ swig -chicken example.i
    -   $ csc -vk example.scm example_impl.c example_wrap.c test_script.scm -o example
    -   $ ./example
    -   
    -
    +
    +
    +$ swig -chicken example.i
    +$ csc -vk example.scm example_impl.c example_wrap.c test_script.scm -o example
    +$ ./example
    +
    +
    -

    17.6 Typemaps

    +

    17.6 Typemaps

    @@ -353,7 +393,7 @@ Lib/chicken/chicken.swg.

    -

    17.7 Pointers

    +

    17.7 Pointers

    @@ -383,17 +423,42 @@ wrapper code calls the function SWIG_ConvertPtr(C_word s, void **result, swig_type_info *type, int flags), passing a pointer to a struct representing the expected pointer - type. + type. flags is either zero or SWIG_POINTER_DISOWN (see below).

    -

    17.8 Unsupported features and known problems

    +

    17.7.1 Garbage collection

    + + +

    If the owner flag in the SWIG_NewPointerObj is 1, NewPointerObj will add a + finalizer to the type which will call the destructor or delete method of + that type. The destructor and delete functions are no longer exported for + use in scheme code, instead SWIG and chicken completly manage pointers. +

    + +

    In situations where SWIG knows that a function is returning a type that should + be garbage collected, SWIG will automaticly set the owner flag to 1. For other functions, + The %newobject directive must be specified for functions whose return values + should be garbage collected. See + Object ownership and %newobject for more information. +

    + +

    In situations where a C or C++ function will assume ownership of a pointer, and thus + chicken should no longer garbage collect this type, SWIG provides the DISOWN input typemap. + After applying this typemap (see the Typemaps chapter for more information on how to apply typemaps), + any pointer that gets passed in will no longer be garbage collected. + An object is disowned by passing the SWIG_POINTER_DISOWN flag to SWIG_ConvertPtr. + Warning: Since the lifetime of the object is now controlled by the underlying code, the object might + get deleted while the scheme code still holds a pointer to it. Further use of this pointer + can lead to a crash. +

    + +

    17.8 Unsupported features and known problems

    diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index ba0c4de69..3a384104b 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -223,7 +223,7 @@
  • Class extension
  • Templates
  • Namespaces -
  • Exception specifiers +
  • Exception specifications
  • Pointers to Members
  • Smart pointers and operator->()
  • Using declarations and inheritance @@ -505,17 +505,21 @@
  • Modules
  • Constants and Variables
  • Functions +
  • Exceptions -
  • TinyCLOS -
  • Compilation -
  • Linkage +
  • TinyCLOS +
  • Compilation +
  • Linkage -
  • Typemaps -
  • Pointers -
  • Unsupported features and known problems +
  • Typemaps +
  • Pointers + +
  • Unsupported features and known problems @@ -938,6 +942,7 @@
  • C++ namespaces
  • C++ templates
  • C++ Smart Pointers +
  • C++ Reference Counted Objects (ref/unref)
  • Further details on the Python class interface