Fix a few bugs in the chicken module
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7073 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
151658c377
commit
61330651b0
3 changed files with 30 additions and 11 deletions
|
|
@ -377,17 +377,21 @@ $result = C_SCHEME_UNDEFINED;
|
|||
}
|
||||
#endif
|
||||
|
||||
%typemap(varin) char [] {
|
||||
swig_barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "C/C++ variable '$name' is read-only");
|
||||
}
|
||||
|
||||
/* Special case for string array variables */
|
||||
%typemap(varin) char [ANY] {
|
||||
if ($input == C_SCHEME_FALSE) {
|
||||
$1 = NULL;
|
||||
memset($1,0,$1_dim0*sizeof(char));
|
||||
}
|
||||
else if (!C_swig_is_string ($input)) {
|
||||
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'");
|
||||
}
|
||||
else {
|
||||
char *temp = C_c_string ($input);
|
||||
strncpy($1,temp,$1_dim0);
|
||||
strncpy($1,temp,$1_dim0*sizeof(char));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -398,15 +402,15 @@ $result = C_SCHEME_UNDEFINED;
|
|||
|
||||
/* Special typemap for character array return values */
|
||||
%typemap(varout) char [ANY], const char [ANY]
|
||||
%{ if ($varname == C_SCHEME_FALSE) {
|
||||
$result = NULL;
|
||||
}
|
||||
else if (C_swig_is_string ($varname)) {
|
||||
$result = SWIG_MakeString ($varname);
|
||||
%{ if ($varname == NULL) {
|
||||
$result = C_SCHEME_FALSE;
|
||||
}
|
||||
else {
|
||||
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'string'");
|
||||
} %}
|
||||
const int string_len = strlen ($varname);
|
||||
C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len));
|
||||
$result = C_string (&string_space, string_len, (char *) $varname);
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
/* --- Constants --- */
|
||||
|
|
@ -578,7 +582,7 @@ $result = C_SCHEME_UNDEFINED;
|
|||
extern "C" {
|
||||
#endif
|
||||
/* Chicken initialization function */
|
||||
SWIGEXPORT(void) SWIG_init(int, C_word, C_word) C_noret;
|
||||
SWIGEXPORT(void) SWIG_init(C_word, C_word, C_word) C_noret;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -590,6 +594,9 @@ SWIGEXPORT(void) SWIG_init(int, C_word, C_word) C_noret;
|
|||
|
||||
%insert(init) %{
|
||||
/* CHICKEN initialization function */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
SWIGEXPORT(void)
|
||||
SWIG_init(C_word argc, C_word closure, C_word continuation) {
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ extern "C" {
|
|||
SWIG_Chicken_NewPointerObj((void*)ptr, type, owner, &known_space)
|
||||
#define swig_barf SWIG_Chicken_Barf
|
||||
|
||||
#define SWIG_contract_assert(expr, message) if (!(expr)) { \
|
||||
SWIG_Chicken_Barf(SWIG_BARF1_CONTRACT_ASSERT, C_text(message)); } else
|
||||
|
||||
/* Runtime API */
|
||||
#define SWIG_GetModule(clientdata) SWIG_Chicken_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Chicken_SetModule(pointer)
|
||||
|
|
@ -64,7 +67,8 @@ extern "C" {
|
|||
|
||||
enum {
|
||||
SWIG_BARF1_BAD_ARGUMENT_TYPE /* 1 arg */,
|
||||
SWIG_BARF1_ARGUMENT_NULL /* 1 arg */
|
||||
SWIG_BARF1_ARGUMENT_NULL /* 1 arg */,
|
||||
SWIG_BARF1_CONTRACT_ASSERT /* 1 arg */,
|
||||
};
|
||||
|
||||
typedef C_word (*swig_chicken_destructor)(C_word,C_word,C_word,C_word);
|
||||
|
|
@ -136,6 +140,10 @@ SWIG_Chicken_Barf(int code, C_char *msg, ...)
|
|||
barfval = C_BAD_ARGUMENT_TYPE_ERROR;
|
||||
c = 1;
|
||||
break;
|
||||
case SWIG_BARF1_CONTRACT_ASSERT:
|
||||
barfval = C_OUT_OF_RANGE_ERROR;
|
||||
c = 1;
|
||||
break;
|
||||
default:
|
||||
SWIG_Chicken_Panic (C_text (msg));
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue