mirror of https://github.com/swig/swig
Guile STRING LENGTH typemap fixes
Fix leak in (char *STRING, size_t LENGTH) family of typemaps. Add (size_t LENGTH, const char *STRING) family of typemaps.
This commit is contained in:
parent
7c478b5e17
commit
29daa0fe34
|
@ -19,10 +19,6 @@ top_builddir = @top_builddir@
|
|||
GUILE = @GUILE@
|
||||
GUILE_RUNTIME=
|
||||
|
||||
FAILING_CPP_TESTS = \
|
||||
char_binary_rev_len \
|
||||
director_binary_string_rev_len \
|
||||
|
||||
C_TEST_CASES = long_long \
|
||||
list_vector \
|
||||
multivalue \
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
;; 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_char_binary_rev_len_module" (dynamic-link "./libchar_binary_rev_len"))
|
||||
(load "testsuite.scm")
|
||||
(load "../schemerunme/char_binary_rev_len.scm")
|
|
@ -0,0 +1,9 @@
|
|||
(define t (new-Test))
|
||||
|
||||
(if (not (= (Test-strlen t "hile") 4))
|
||||
(error "bad multi-arg typemap"))
|
||||
|
||||
(if (not (= (Test-strlen t "hil\x00") 4))
|
||||
(error "bad multi-arg typemap"))
|
||||
|
||||
(exit 0)
|
|
@ -382,15 +382,32 @@ typedef unsigned long SCM;
|
|||
* String & length
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
|
||||
%typemap(in) (const char *STRING, size_t LENGTH)(int must_free = 0) {
|
||||
size_t temp;
|
||||
$1 = ($1_ltype) SWIG_Guile_scm2newstr($input, &temp);
|
||||
$2 = ($2_ltype) temp;
|
||||
must_free = 1;
|
||||
}
|
||||
%typemap(freearg) (const char *STRING, size_t LENGTH) "if (must_free$argnum) SWIG_free($1);"
|
||||
|
||||
%apply (const char *STRING, size_t LENGTH) { (const char *STRING, int LENGTH) }
|
||||
%apply (const char *STRING, size_t LENGTH) { (char *STRING, size_t LENGTH) }
|
||||
%apply (char *STRING, size_t LENGTH) { (char *STRING, int LENGTH) }
|
||||
|
||||
/* Length & string reverse order typemap */
|
||||
|
||||
%typemap(in) (size_t LENGTH, const char *STRING)(int must_free = 0) {
|
||||
size_t temp;
|
||||
$2 = ($2_ltype) SWIG_Guile_scm2newstr($input, &temp);
|
||||
$1 = ($1_ltype) temp;
|
||||
must_free = 1;
|
||||
}
|
||||
%typemap(freearg) (size_t LENGTH, const char *STRING) "if (must_free$argnum) SWIG_free($2);"
|
||||
|
||||
%apply (size_t LENGTH, const char *STRING) { (int LENGTH, const char *STRING) }
|
||||
%apply (size_t LENGTH, const char *STRING) { (size_t LENGTH, char *STRING) }
|
||||
%apply (size_t LENGTH, char *STRING) { (int LENGTH, char *STRING) }
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* CLASS::* (member function pointer) typemaps
|
||||
* taken from typemaps/swigtype.swg
|
||||
|
|
Loading…
Reference in New Issue