Fix a few bugs in the chicken module
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7073 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
7285eb6667
commit
99db8b33b2
3 changed files with 30 additions and 11 deletions
|
|
@ -377,17 +377,21 @@ $result = C_SCHEME_UNDEFINED;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
%typemap(varin) char [] {
|
||||||
|
swig_barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "C/C++ variable '$name' is read-only");
|
||||||
|
}
|
||||||
|
|
||||||
/* Special case for string array variables */
|
/* Special case for string array variables */
|
||||||
%typemap(varin) char [ANY] {
|
%typemap(varin) char [ANY] {
|
||||||
if ($input == C_SCHEME_FALSE) {
|
if ($input == C_SCHEME_FALSE) {
|
||||||
$1 = NULL;
|
memset($1,0,$1_dim0*sizeof(char));
|
||||||
}
|
}
|
||||||
else if (!C_swig_is_string ($input)) {
|
else if (!C_swig_is_string ($input)) {
|
||||||
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'");
|
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char *temp = C_c_string ($input);
|
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 */
|
/* Special typemap for character array return values */
|
||||||
%typemap(varout) char [ANY], const char [ANY]
|
%typemap(varout) char [ANY], const char [ANY]
|
||||||
%{ if ($varname == C_SCHEME_FALSE) {
|
%{ if ($varname == NULL) {
|
||||||
$result = NULL;
|
$result = C_SCHEME_FALSE;
|
||||||
}
|
|
||||||
else if (C_swig_is_string ($varname)) {
|
|
||||||
$result = SWIG_MakeString ($varname);
|
|
||||||
}
|
}
|
||||||
else {
|
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 --- */
|
/* --- Constants --- */
|
||||||
|
|
@ -578,7 +582,7 @@ $result = C_SCHEME_UNDEFINED;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
/* Chicken initialization function */
|
/* 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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -590,6 +594,9 @@ SWIGEXPORT(void) SWIG_init(int, C_word, C_word) C_noret;
|
||||||
|
|
||||||
%insert(init) %{
|
%insert(init) %{
|
||||||
/* CHICKEN initialization function */
|
/* CHICKEN initialization function */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
SWIGEXPORT(void)
|
SWIGEXPORT(void)
|
||||||
SWIG_init(C_word argc, C_word closure, C_word continuation) {
|
SWIG_init(C_word argc, C_word closure, C_word continuation) {
|
||||||
int i;
|
int i;
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,9 @@ extern "C" {
|
||||||
SWIG_Chicken_NewPointerObj((void*)ptr, type, owner, &known_space)
|
SWIG_Chicken_NewPointerObj((void*)ptr, type, owner, &known_space)
|
||||||
#define swig_barf SWIG_Chicken_Barf
|
#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 */
|
/* Runtime API */
|
||||||
#define SWIG_GetModule(clientdata) SWIG_Chicken_GetModule()
|
#define SWIG_GetModule(clientdata) SWIG_Chicken_GetModule()
|
||||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Chicken_SetModule(pointer)
|
#define SWIG_SetModule(clientdata, pointer) SWIG_Chicken_SetModule(pointer)
|
||||||
|
|
@ -64,7 +67,8 @@ extern "C" {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SWIG_BARF1_BAD_ARGUMENT_TYPE /* 1 arg */,
|
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);
|
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;
|
barfval = C_BAD_ARGUMENT_TYPE_ERROR;
|
||||||
c = 1;
|
c = 1;
|
||||||
break;
|
break;
|
||||||
|
case SWIG_BARF1_CONTRACT_ASSERT:
|
||||||
|
barfval = C_OUT_OF_RANGE_ERROR;
|
||||||
|
c = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
SWIG_Chicken_Panic (C_text (msg));
|
SWIG_Chicken_Panic (C_text (msg));
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -238,6 +238,10 @@ CHICKEN::top(Node *n)
|
||||||
Printf(f_init, "C_kontinue (continuation, ret);\n");
|
Printf(f_init, "C_kontinue (continuation, ret);\n");
|
||||||
Printf(f_init, "}\n\n");
|
Printf(f_init, "}\n\n");
|
||||||
|
|
||||||
|
Printf(f_init,"#ifdef __cplusplus\n");
|
||||||
|
Printf(f_init,"}\n");
|
||||||
|
Printf(f_init,"#endif\n");
|
||||||
|
|
||||||
Printf(chicken_filename,"%s%s.scm", SWIG_output_directory(), module);
|
Printf(chicken_filename,"%s%s.scm", SWIG_output_directory(), module);
|
||||||
if ((f_scm = NewFile(chicken_filename,"w")) == 0) {
|
if ((f_scm = NewFile(chicken_filename,"w")) == 0) {
|
||||||
Printf(stderr,"Unable to open %s\n", chicken_filename);
|
Printf(stderr,"Unable to open %s\n", chicken_filename);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue