Lots more bug fixes for the chicken module: almost the entire test-sutie now runs
The only tests that are failing are ones that depend on std_vector.i and similar git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7079 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a28fc0f8c4
commit
897e5ad40d
17 changed files with 322 additions and 43 deletions
|
|
@ -390,7 +390,6 @@
|
|||
|
||||
|
||||
<ul>
|
||||
<li>No exception handling.</li>
|
||||
<li>No director support.</li>
|
||||
<li>No support for c++ standard types like std::vector.</li>
|
||||
<li>Importing multiple SWIG modules not working with TinyCLOS. (Planned on fixing for 1.3.25) </li>
|
||||
|
|
|
|||
|
|
@ -754,7 +754,8 @@ CHICKEN_COMPILED_MAIN_OBJECT = $(CHICKEN_COMPILED_MAIN:.c=.@OBJEXT@)
|
|||
# Build a CHICKEN dynamically loadable module
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
chicken: $(SRCS)
|
||||
# This is the old way to build chicken, but it does not work correctly with exceptions
|
||||
chicken_direct: $(SRCS)
|
||||
$(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE)
|
||||
$(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
|
||||
-dynamic -feature chicken-compile-shared \
|
||||
|
|
@ -764,7 +765,7 @@ chicken: $(SRCS)
|
|||
$(LDSHARED) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \
|
||||
$(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO)
|
||||
|
||||
chicken_cpp: $(CXXSRCS) $(CHICKSRCS)
|
||||
chicken_direct_cpp: $(CXXSRCS) $(CHICKSRCS)
|
||||
$(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE)
|
||||
$(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
|
||||
-dynamic -feature chicken-compile-shared \
|
||||
|
|
@ -807,13 +808,13 @@ chicken_static_cpp: $(CXXSRCS) $(CHICKSRCS)
|
|||
# Build a shared library using csc
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
chicken_csc:
|
||||
chicken:
|
||||
$(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE)
|
||||
$(CHICKEN_CSC) -sv $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ISRCS) -o $(TARGET)$(SO)
|
||||
$(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ISRCS) -o $(TARGET)$(SO)
|
||||
|
||||
chicken_csc_cpp:
|
||||
chicken_cpp:
|
||||
$(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE)
|
||||
$(CHICKEN_CSC) -sv $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO)
|
||||
$(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO)
|
||||
|
||||
chicken_clean:
|
||||
rm -f *.@OBJEXT@ *$(SO) *_wrap* *~ .~* core @EXTRA_CLEAN@ *_chicken*
|
||||
|
|
|
|||
2
Examples/test-suite/chicken/cpp_enum_runme.ss
Normal file
2
Examples/test-suite/chicken/cpp_enum_runme.ss
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(load-library 'cpp-enum "cpp_enum.so")
|
||||
(include "../schemerunme/cpp_enum.scm")
|
||||
2
Examples/test-suite/chicken/li_std_string_runme.ss
Normal file
2
Examples/test-suite/chicken/li_std_string_runme.ss
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(load-library 'li-std-string "li_std_string.so")
|
||||
(include "../schemerunme/li_std_string.scm")
|
||||
28
Examples/test-suite/chicken/throw_exception_runme.ss
Normal file
28
Examples/test-suite/chicken/throw_exception_runme.ss
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
(load-library 'throw-exception "throw_exception.so")
|
||||
|
||||
(define-macro (check-throw expr check)
|
||||
`(if (handle-exceptions exvar (if ,check #f (begin (print "Error executing: " ',expr " " exvar) (exit 1))) ,expr #t)
|
||||
(print "Expression did not throw an error: " ',expr)))
|
||||
|
||||
(define f (new-Foo))
|
||||
|
||||
(check-throw (Foo-test-int f) (= exvar 37))
|
||||
(check-throw (Foo-test-msg f) (string=? exvar "Dead"))
|
||||
(check-throw (Foo-test-cls f) (test-is-Error exvar))
|
||||
(check-throw (Foo-test-cls-ptr f) (test-is-Error exvar))
|
||||
(check-throw (Foo-test-cls-ref f) (test-is-Error exvar))
|
||||
(check-throw (Foo-test-cls-td f) (test-is-Error exvar))
|
||||
(check-throw (Foo-test-cls-ptr-td f) (test-is-Error exvar))
|
||||
(check-throw (Foo-test-cls-ref-td f) (test-is-Error exvar))
|
||||
|
||||
; don't know how to test this... it is returning a SWIG wrapped int *
|
||||
;(check-throw (Foo-test-array f) (equal? exvar '(0 1 2 3 4 5 6 7 8 9)))
|
||||
|
||||
(check-throw (Foo-test-multi f 1) (= exvar 37))
|
||||
(check-throw (Foo-test-multi f 2) (string=? exvar "Dead"))
|
||||
(check-throw (Foo-test-multi f 3) (test-is-Error exvar))
|
||||
|
||||
(set! f #f)
|
||||
(gc #t)
|
||||
|
||||
(exit 0)
|
||||
5
Examples/test-suite/guile/cpp_enum_runme.scm
Normal file
5
Examples/test-suite/guile/cpp_enum_runme.scm
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_cpp_enum_module" (dynamic-link "./cpp_enum.so"))
|
||||
(load "../schemerunme/cpp_enum.scm")
|
||||
5
Examples/test-suite/guile/li_std_string_runme.scm
Normal file
5
Examples/test-suite/guile/li_std_string_runme.scm
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_li_std_string_module" (dynamic-link "./libli_std_string.so"))
|
||||
(load "../schemerunme/li_std_string.scm")
|
||||
|
|
@ -277,6 +277,11 @@ inline const char* mangle ## #@__VA_ARGS__ () {
|
|||
/* chiao */
|
||||
#endif;
|
||||
|
||||
#ifdef SWIGCHICKEN
|
||||
/* define is a scheme keyword (and thus an invalid variable name), so SWIG warns about it */
|
||||
%warnfilter(314) define;
|
||||
#endif
|
||||
|
||||
#ifdef SWIGRUBY
|
||||
%rename(ddefined) defined;
|
||||
#endif
|
||||
|
|
|
|||
21
Examples/test-suite/schemerunme/cpp_enum.scm
Normal file
21
Examples/test-suite/schemerunme/cpp_enum.scm
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
(define f (new-Foo))
|
||||
|
||||
(if (not (= (Foo-hola-get f) (Foo-Hello)))
|
||||
(error "Error 1"))
|
||||
|
||||
(Foo-hola-set f (Foo-Hi))
|
||||
|
||||
(if (not (= (Foo-hola-get f) (Foo-Hi)))
|
||||
(error "Error 2"))
|
||||
|
||||
(Foo-hola-set f (Foo-Hello))
|
||||
|
||||
(if (not (= (Foo-hola-get f) (Foo-Hello)))
|
||||
(error "Error 3"))
|
||||
|
||||
(hi (Hello))
|
||||
|
||||
(if (not (= (hi) (Hello)))
|
||||
(error "Error 4"))
|
||||
|
||||
(exit 0)
|
||||
17
Examples/test-suite/schemerunme/li_std_string.scm
Normal file
17
Examples/test-suite/schemerunme/li_std_string.scm
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
(define x "hello")
|
||||
|
||||
(if (not (string=? (test-value x) x))
|
||||
(begin (error "Error 1") (exit 1)))
|
||||
|
||||
(if (not (string=? (test-const-reference x) x))
|
||||
(begin (error "Error 2") (exit 1)))
|
||||
|
||||
(define y (test-pointer-out))
|
||||
(test-pointer y)
|
||||
(define z (test-const-pointer-out))
|
||||
(test-const-pointer z)
|
||||
|
||||
(define a (test-reference-out))
|
||||
(test-reference a)
|
||||
|
||||
(exit 0)
|
||||
|
|
@ -13,12 +13,12 @@
|
|||
(if (not (char=? (value-char (var-char)) #\w))
|
||||
(begin (display "Runtime test 3 failed.\n") (exit 1)))
|
||||
|
||||
(var-unsigned-char (createref-unsigned-char #\nl))
|
||||
(if (not (char=? (value-unsigned-char (var-unsigned-char)) #\nl))
|
||||
(var-unsigned-char (createref-unsigned-char #\newline))
|
||||
(if (not (char=? (value-unsigned-char (var-unsigned-char)) #\newline))
|
||||
(begin (display "Runtime test 4 failed.\n") (exit 1)))
|
||||
|
||||
(var-signed-char (createref-signed-char #\nl))
|
||||
(if (not (char=? (value-signed-char (var-signed-char)) #\nl))
|
||||
(var-signed-char (createref-signed-char #\newline))
|
||||
(if (not (char=? (value-signed-char (var-signed-char)) #\newline))
|
||||
(begin (display "Runtime test 5 failed.\n") (exit 1)))
|
||||
|
||||
(var-unsigned-short (createref-unsigned-short 10))
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
class Error {
|
||||
};
|
||||
|
||||
void test_is_Error(Error *r) {}
|
||||
|
||||
namespace Namespace {
|
||||
typedef Error ErrorTypedef;
|
||||
typedef const Error& ErrorRef;
|
||||
|
|
|
|||
|
|
@ -78,58 +78,86 @@
|
|||
$result = to_scheme (convtype ($varname));
|
||||
%}
|
||||
|
||||
%typemap(throws) type_
|
||||
%{
|
||||
SWIG_Chicken_ThrowException(to_scheme ( convtype ($1)));
|
||||
%}
|
||||
|
||||
#else
|
||||
|
||||
%typemap(out) type_
|
||||
%{
|
||||
{
|
||||
C_word *space = C_alloc(storage_);
|
||||
$result = to_scheme (&space, convtype ($1));
|
||||
}
|
||||
%}
|
||||
|
||||
/* References to primitive types. Return by value */
|
||||
|
||||
%typemap(out) const type_ &
|
||||
%{
|
||||
$result = to_scheme (convtype (*$1));
|
||||
{
|
||||
C_word *space = C_alloc(storage_);
|
||||
$result = to_scheme (&space, convtype (*$1));
|
||||
}
|
||||
%}
|
||||
|
||||
/* --- Variable output --- */
|
||||
%typemap(varout) type_
|
||||
%{
|
||||
{
|
||||
C_word *space = C_alloc(storage_);
|
||||
$result = to_scheme (&space, convtype ($varname));
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(throws) type_
|
||||
%{
|
||||
{
|
||||
C_word *space = C_alloc(storage_);
|
||||
SWIG_Chicken_ThrowException(to_scheme (&space, convtype ($1)));
|
||||
}
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
||||
/* --- Constants --- */
|
||||
|
||||
#if ("type_" == "char") || ("type_" == "unsigned char") || ("type_" == "signed char")
|
||||
%typemap(constcode) type_
|
||||
"static const $1_type $result = '$value';"
|
||||
#else
|
||||
%typemap(constcode) type_
|
||||
"static const $1_type $result = $value;"
|
||||
#endif
|
||||
|
||||
%enddef
|
||||
|
||||
SIMPLE_TYPEMAP(int, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
|
||||
SIMPLE_TYPEMAP(enum SWIGTYPE, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
|
||||
//SIMPLE_TYPEMAP(enum SWIGTYPE, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
|
||||
SIMPLE_TYPEMAP(short, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
|
||||
SIMPLE_TYPEMAP(long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), C_SIZEOF_FLONUM);
|
||||
SIMPLE_TYPEMAP(long long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), C_SIZEOF_FLONUM);
|
||||
SIMPLE_TYPEMAP(long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM);
|
||||
SIMPLE_TYPEMAP(long long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM);
|
||||
SIMPLE_TYPEMAP(unsigned int, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
|
||||
SIMPLE_TYPEMAP(unsigned short, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
|
||||
SIMPLE_TYPEMAP(unsigned long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), C_SIZEOF_FLONUM);
|
||||
SIMPLE_TYPEMAP(unsigned long long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), C_SIZEOF_FLONUM);
|
||||
SIMPLE_TYPEMAP(unsigned char, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
|
||||
SIMPLE_TYPEMAP(signed char, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
|
||||
SIMPLE_TYPEMAP(unsigned long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM);
|
||||
SIMPLE_TYPEMAP(unsigned long long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM);
|
||||
SIMPLE_TYPEMAP(unsigned char, C_character_code, C_make_character, C_swig_is_char, (unsigned int), 0);
|
||||
SIMPLE_TYPEMAP(signed char, C_character_code, C_make_character, C_swig_is_char, (int), 0);
|
||||
SIMPLE_TYPEMAP(char, C_character_code, C_make_character, C_swig_is_char, (char), 0);
|
||||
SIMPLE_TYPEMAP(bool, C_truep, C_mk_bool, C_swig_is_bool, (bool), 0);
|
||||
SIMPLE_TYPEMAP(float, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), C_SIZEOF_FLONUM);
|
||||
SIMPLE_TYPEMAP(double, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), C_SIZEOF_FLONUM);
|
||||
|
||||
/* enum SWIGTYPE */
|
||||
%apply int { enum SWIGTYPE };
|
||||
%apply const int& { const enum SWIGTYPE& };
|
||||
|
||||
%typemap(varin) enum SWIGTYPE
|
||||
{
|
||||
if (!C_swig_is_fixnum($input) && sizeof(int) != sizeof($1)) {
|
||||
swig_barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "enum variable '$name' can not be set");
|
||||
}
|
||||
*((int *)(void *)&$1) = C_unfix($input);
|
||||
}
|
||||
|
||||
|
||||
/* --- Input arguments --- */
|
||||
|
||||
/* Strings */
|
||||
|
|
@ -287,6 +315,17 @@ SIMPLE_TYPEMAP(double, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double),
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(throws) char *
|
||||
{
|
||||
if ($1 == NULL) {
|
||||
SWIG_Chicken_ThrowException(C_SCHEME_FALSE);
|
||||
} else {
|
||||
int string_len = strlen($1);
|
||||
C_word *string_space = C_alloc(C_SIZEOF_STRING(string_len));
|
||||
SWIG_Chicken_ThrowException(C_string(&string_space, string_len, (char *) $1));
|
||||
}
|
||||
}
|
||||
|
||||
/* Void */
|
||||
%typemap(out) void
|
||||
%{
|
||||
|
|
@ -416,7 +455,7 @@ $result = C_SCHEME_UNDEFINED;
|
|||
/* --- Constants --- */
|
||||
|
||||
%typemap(constcode) char *
|
||||
"static const char *$result = \"$value\";"
|
||||
"static const char *$result = $value;"
|
||||
|
||||
%typemap(constcode) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []
|
||||
"static const void *$result = (void*) $value;"
|
||||
|
|
@ -513,11 +552,61 @@ $result = C_SCHEME_UNDEFINED;
|
|||
$1 = !SWIG_ConvertPtr($input, &ptr, 0, 0);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE &
|
||||
{
|
||||
void *ptr = 0;
|
||||
if (SWIG_ConvertPtr($input, &ptr, $descriptor, 0)) {
|
||||
/* error */
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = (ptr != 0);
|
||||
}
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE
|
||||
{
|
||||
void *ptr = 0;
|
||||
if (SWIG_ConvertPtr($input, &ptr, $&descriptor, 0)) {
|
||||
/* error */
|
||||
$1 = 0;
|
||||
} else {
|
||||
$1 = (ptr != 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Exception handling
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
/* TODO */
|
||||
/* ------------------------------------------------------------
|
||||
* --- Exception handling ---
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%typemap(throws) SWIGTYPE {
|
||||
$<ype temp = new $ltype($1);
|
||||
C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
|
||||
C_word ptr = SWIG_NewPointerObj(temp, $&descriptor,1);
|
||||
SWIG_Chicken_ThrowException(ptr);
|
||||
}
|
||||
|
||||
%typemap(throws) SWIGTYPE * {
|
||||
C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
|
||||
C_word ptr = SWIG_NewPointerObj((void *) $1, $descriptor, 0);
|
||||
SWIG_Chicken_ThrowException(ptr);
|
||||
}
|
||||
|
||||
%typemap(throws) SWIGTYPE [ANY] {
|
||||
C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
|
||||
C_word ptr = SWIG_NewPointerObj((void *) $1, $descriptor, 0);
|
||||
SWIG_Chicken_ThrowException(ptr);
|
||||
}
|
||||
|
||||
%typemap(throws) SWIGTYPE & {
|
||||
C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
|
||||
C_word ptr = SWIG_NewPointerObj((void *)&($1),$descriptor,0);
|
||||
SWIG_Chicken_ThrowException(ptr);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Overloaded operator support
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ extern "C" {
|
|||
#define C_swig_is_ptr(x) (C_truep (C_blockp (x)) && C_truep (C_pointerp (x)))
|
||||
#define C_swig_is_swigpointer(x) (C_truep (C_blockp(x)) && C_truep (C_swigpointerp(x)))
|
||||
#define C_swig_is_closurep(x) (C_truep (C_blockp(x)) && C_truep(C_closurep(x)))
|
||||
#define C_swig_is_long(x) (C_swig_is_fixnum(x) || C_swig_is_flonum(x))
|
||||
|
||||
#define SWIG_APPEND_VALUE(object) \
|
||||
if (resultobj == C_SCHEME_UNDEFINED) \
|
||||
|
|
@ -178,6 +179,21 @@ SWIG_Chicken_Barf(int code, C_char *msg, ...)
|
|||
}
|
||||
}
|
||||
|
||||
static void SWIG_Chicken_ThrowException(C_word value) C_noret;
|
||||
static void SWIG_Chicken_ThrowException(C_word value)
|
||||
{
|
||||
char *aborthook = C_text("\003sysabort");
|
||||
C_word *a = C_alloc(C_SIZEOF_STRING(strlen(aborthook)));
|
||||
C_word abort = C_intern2(&a, aborthook);
|
||||
|
||||
abort = C_block_item(abort, 0);
|
||||
if (C_immediatep(abort))
|
||||
SWIG_Chicken_Panic(C_text("`##sys#abort' is not defiend"));
|
||||
|
||||
C_save(value);
|
||||
C_do_apply(1, abort, C_SCHEME_UNDEFINED);
|
||||
}
|
||||
|
||||
static void
|
||||
SWIG_Chicken_Finalizer(C_word argc, C_word closure, C_word continuation, C_word s)
|
||||
{
|
||||
|
|
@ -251,6 +267,8 @@ SWIG_Chicken_ConvertPtr(C_word s, void **result, swig_type_info *type, int flags
|
|||
if (flags & SWIG_POINTER_DISOWN) {
|
||||
C_do_unregister_finalizer(s);
|
||||
}
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
58
Lib/chicken/std_string.i
Normal file
58
Lib/chicken/std_string.i
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
// SWIG typemaps for std::string
|
||||
// copied from the guile std_string.i and modified
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
||||
class string;
|
||||
|
||||
%typemap(typecheck) string = char *;
|
||||
%typemap(typecheck) const string & = char *;
|
||||
|
||||
%typemap(in) string (char* tempptr) {
|
||||
if ($input == C_SCHEME_FALSE) {
|
||||
$1 = std::string();
|
||||
} else {
|
||||
if (!C_swig_is_string ($input)) {
|
||||
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE,
|
||||
"Argument #$argnum is not a string");
|
||||
}
|
||||
tempptr = SWIG_MakeString($input);
|
||||
$1 = std::string(tempptr);
|
||||
if (tempptr) SWIG_free(tempptr);
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(in) const string& (std::string temp,
|
||||
char* tempptr) {
|
||||
|
||||
if ($input == C_SCHEME_FALSE) {
|
||||
temp = std::string();
|
||||
$1 = &temp;
|
||||
} else {
|
||||
if (!C_swig_is_string ($input)) {
|
||||
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE,
|
||||
"Argument #$argnum is not a string");
|
||||
}
|
||||
tempptr = SWIG_MakeString($input);
|
||||
temp = std::string(tempptr);
|
||||
if (tempptr) SWIG_free(tempptr);
|
||||
$1 = &temp;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(out) string {
|
||||
int size = $1.size();
|
||||
C_word *space = C_alloc (C_SIZEOF_STRING (size));
|
||||
$result = C_string (&space, size, (char *) $1.c_str());
|
||||
}
|
||||
|
||||
%typemap(out) const string& {
|
||||
int size = $1->size();
|
||||
C_word *space = C_alloc (C_SIZEOF_STRING (size));
|
||||
$result = C_string (&space, size, (char *) $1->c_str());
|
||||
}
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ output values, in reverse order.
|
|||
%{ if (!checker ($input)) {
|
||||
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'type_'");
|
||||
}
|
||||
temp = from_scheme ($input);
|
||||
temp = ($*1_ltype) from_scheme ($input);
|
||||
$1 = &temp; %}
|
||||
|
||||
%typemap(typecheck) type_ *INPUT = type_;
|
||||
|
|
@ -166,12 +166,12 @@ output values, in reverse order.
|
|||
INOUT_TYPEMAP(int, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
|
||||
INOUT_TYPEMAP(enum SWIGTYPE, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
|
||||
INOUT_TYPEMAP(short, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
|
||||
INOUT_TYPEMAP(long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), C_SIZEOF_FLOWNUM);
|
||||
INOUT_TYPEMAP(long long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), C_SIZEOF_FLONUM);
|
||||
INOUT_TYPEMAP(long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM);
|
||||
INOUT_TYPEMAP(long long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM);
|
||||
INOUT_TYPEMAP(unsigned int, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
|
||||
INOUT_TYPEMAP(unsigned short, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
|
||||
INOUT_TYPEMAP(unsigned long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), C_SIZEOF_FLONUM);
|
||||
INOUT_TYPEMAP(unsigned long long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), C_SIZEOF_FLONUM);
|
||||
INOUT_TYPEMAP(unsigned long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM);
|
||||
INOUT_TYPEMAP(unsigned long long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM);
|
||||
INOUT_TYPEMAP(unsigned char, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
|
||||
INOUT_TYPEMAP(signed char, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
|
||||
INOUT_TYPEMAP(char, C_character_code, C_make_character, C_swig_is_char, (char), 0);
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ CHICKEN::functionWrapper(Node *n)
|
|||
Parm *p;
|
||||
int i;
|
||||
String *wname;
|
||||
char source[64];
|
||||
String *source;
|
||||
Wrapper *f;
|
||||
String *mangle = NewString("");
|
||||
String *get_pointers;
|
||||
|
|
@ -399,7 +399,7 @@ CHICKEN::functionWrapper(Node *n)
|
|||
String *ln = Getattr(p,"lname");
|
||||
SwigType *pb = SwigType_typedef_resolve_all(SwigType_base(pt));
|
||||
|
||||
sprintf(source,"scm%d",i+1);
|
||||
source = NewStringf("scm%d",i+1);
|
||||
|
||||
Printf(f->def, ", C_word scm%d", i+1);
|
||||
Printf(declfunc,",C_word");
|
||||
|
|
@ -421,7 +421,7 @@ CHICKEN::functionWrapper(Node *n)
|
|||
}
|
||||
|
||||
if (i >= num_required)
|
||||
Printv(get_pointers, "if (argc-2>", i, " && (", source, ")) {\n", NIL);
|
||||
Printf(get_pointers, "if (argc-2>%i && (%s)) {\n", i, source);
|
||||
Printv(get_pointers,tm,"\n", NIL);
|
||||
if (i >= num_required)
|
||||
Printv(get_pointers, "}\n", NIL);
|
||||
|
|
@ -457,6 +457,7 @@ CHICKEN::functionWrapper(Node *n)
|
|||
|
||||
} else {
|
||||
}
|
||||
|
||||
|
||||
p = Getattr(p,"tmap:in:next");
|
||||
continue;
|
||||
|
|
@ -466,6 +467,8 @@ CHICKEN::functionWrapper(Node *n)
|
|||
SwigType_str(pt,0));
|
||||
break;
|
||||
}
|
||||
|
||||
Delete(source);
|
||||
p = nextSibling(p);
|
||||
}
|
||||
|
||||
|
|
@ -708,7 +711,7 @@ CHICKEN::variableWrapper(Node *n) {
|
|||
|
||||
Wrapper_add_local(f, "resultobj", "C_word resultobj");
|
||||
|
||||
Printf(f->code, "if (argc!=2||argc!=3) C_bad_argc(argc,2);\n");
|
||||
Printf(f->code, "if (argc!=2 && argc!=3) C_bad_argc(argc,2);\n");
|
||||
|
||||
/* Check for a setting of the variable value */
|
||||
if (!Getattr(n,"feature:immutable")) {
|
||||
|
|
@ -726,13 +729,19 @@ CHICKEN::variableWrapper(Node *n) {
|
|||
}
|
||||
Printf(f->code, "}\n");
|
||||
}
|
||||
|
||||
String *varname;
|
||||
if (SwigType_istemplate((char*)name)) {
|
||||
varname = SwigType_namestr((char *)name);
|
||||
} else {
|
||||
varname = name;
|
||||
}
|
||||
|
||||
// Now return the value of the variable - regardless
|
||||
// of evaluating or setting.
|
||||
if ((tm = Swig_typemap_lookup_new("varout",n,name,0))) {
|
||||
|
||||
Replaceall(tm,"$source",name);
|
||||
Replaceall(tm,"$varname",name);
|
||||
Replaceall(tm,"$source",varname);
|
||||
Replaceall(tm,"$varname",varname);
|
||||
Replaceall(tm,"$target","resultobj");
|
||||
Replaceall(tm,"$result","resultobj");
|
||||
Printf(f->code, "%s\n", tm);
|
||||
|
|
@ -805,6 +814,8 @@ CHICKEN::constantWrapper(Node *n)
|
|||
Wrapper *f;
|
||||
String *overname = 0;
|
||||
String *scmname;
|
||||
String *rvalue;
|
||||
SwigType *nctype;
|
||||
|
||||
int num_required;
|
||||
int num_arguments;
|
||||
|
|
@ -812,10 +823,11 @@ CHICKEN::constantWrapper(Node *n)
|
|||
scmname = NewString(iname);
|
||||
Replaceall(scmname, "_", "-");
|
||||
|
||||
Printf(mangle, "\"%s\"", SwigType_manglestr(t));
|
||||
Printf(source, "swig_const_%s", name);
|
||||
Printf(source, "swig_const_%s", iname);
|
||||
Replaceall(source, "::", "__");
|
||||
|
||||
Printf(mangle, "\"%s\"", SwigType_manglestr(t));
|
||||
|
||||
if (Getattr(n,"sym:overloaded")) {
|
||||
overname = Getattr(n,"sym:overname");
|
||||
} else {
|
||||
|
|
@ -827,16 +839,29 @@ CHICKEN::constantWrapper(Node *n)
|
|||
Append(wname, overname);
|
||||
}
|
||||
|
||||
nctype = NewString(t);
|
||||
if (SwigType_isconst(nctype)) {
|
||||
Delete(SwigType_pop(nctype));
|
||||
}
|
||||
|
||||
if (SwigType_type(nctype) == T_STRING) {
|
||||
rvalue = NewStringf("\"%s\"", value);
|
||||
} else if (SwigType_type(nctype) == T_CHAR) {
|
||||
rvalue = NewStringf("\'%s\'", value);
|
||||
} else {
|
||||
rvalue = NewString(value);
|
||||
}
|
||||
|
||||
/* Special hook for member pointer */
|
||||
if (SwigType_type(t) == T_MPOINTER) {
|
||||
Printf(f_header, "static %s = %s;\n", SwigType_str(t,wname), value);
|
||||
Printf(f_header, "static %s = %s;\n", SwigType_str(t,wname), rvalue);
|
||||
value = wname;
|
||||
}
|
||||
if ((tm = Swig_typemap_lookup_new("constcode", n, name, 0))) {
|
||||
Replaceall(tm,"$source",value);
|
||||
Replaceall(tm,"$source",rvalue);
|
||||
Replaceall(tm,"$target",source);
|
||||
Replaceall(tm,"$result",source);
|
||||
Replaceall(tm,"$value",value);
|
||||
Replaceall(tm,"$value",rvalue);
|
||||
Printf(f_header, "%s\n", tm);
|
||||
}
|
||||
else {
|
||||
|
|
@ -920,12 +945,14 @@ CHICKEN::constantWrapper(Node *n)
|
|||
}
|
||||
|
||||
Delete(wname);
|
||||
Delete(nctype);
|
||||
Delete(proc_name);
|
||||
Delete(argnum);
|
||||
Delete(arg);
|
||||
Delete(tm2);
|
||||
Delete(mangle);
|
||||
Delete(source);
|
||||
Delete(rvalue);
|
||||
DelWrapper(f);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue