Drop guilegh interface

All of guile's interface files now use the scm interface.
This should not affect any users. Swig generated code
using the scm interface can be mixed with gh interface
using user code.
It does simplify maintenance of the guile swig code though.
This commit is contained in:
Geert Janssens 2013-04-19 12:19:49 +02:00
commit b819d2a91e
25 changed files with 1283 additions and 1829 deletions

View file

@ -42,23 +42,23 @@ namespace std {
template<class T> class vector {
%typemap(in) vector<T> {
if (gh_vector_p($input)) {
unsigned long size = gh_vector_length($input);
if (scm_is_vector($input)) {
unsigned long size = scm_c_vector_length($input);
$1 = std::vector<T >(size);
for (unsigned long i=0; i<size; i++) {
SCM o = gh_vector_ref($input,gh_ulong2scm(i));
SCM o = scm_vector_ref($input,scm_from_ulong(i));
(($1_type &)$1)[i] =
*((T*) SWIG_MustGetPtr(o,$descriptor(T *),$argnum, 0));
}
} else if (gh_null_p($input)) {
} else if (scm_is_null($input)) {
$1 = std::vector<T >();
} else if (gh_pair_p($input)) {
} else if (scm_is_pair($input)) {
SCM head, tail;
$1 = std::vector<T >();
tail = $input;
while (!gh_null_p(tail)) {
head = gh_car(tail);
tail = gh_cdr(tail);
while (!scm_is_null(tail)) {
head = SCM_CAR(tail);
tail = SCM_CDR(tail);
$1.push_back(*((T*)SWIG_MustGetPtr(head,
$descriptor(T *),
$argnum, 0)));
@ -70,27 +70,27 @@ namespace std {
}
%typemap(in) const vector<T>& (std::vector<T> temp),
const vector<T>* (std::vector<T> temp) {
if (gh_vector_p($input)) {
unsigned long size = gh_vector_length($input);
if (scm_is_vector($input)) {
unsigned long size = scm_c_vector_length($input);
temp = std::vector<T >(size);
$1 = &temp;
for (unsigned long i=0; i<size; i++) {
SCM o = gh_vector_ref($input,gh_ulong2scm(i));
SCM o = scm_vector_ref($input,scm_from_ulong(i));
temp[i] = *((T*) SWIG_MustGetPtr(o,
$descriptor(T *),
$argnum, 0));
}
} else if (gh_null_p($input)) {
} else if (scm_is_null($input)) {
temp = std::vector<T >();
$1 = &temp;
} else if (gh_pair_p($input)) {
} else if (scm_is_pair($input)) {
temp = std::vector<T >();
$1 = &temp;
SCM head, tail;
tail = $input;
while (!gh_null_p(tail)) {
head = gh_car(tail);
tail = gh_cdr(tail);
while (!scm_is_null(tail)) {
head = SCM_CAR(tail);
tail = SCM_CDR(tail);
temp.push_back(*((T*) SWIG_MustGetPtr(head,
$descriptor(T *),
$argnum, 0)));
@ -100,23 +100,23 @@ namespace std {
}
}
%typemap(out) vector<T> {
$result = gh_make_vector(gh_long2scm($1.size()),SCM_UNSPECIFIED);
$result = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED);
for (unsigned int i=0; i<$1.size(); i++) {
T* x = new T((($1_type &)$1)[i]);
gh_vector_set_x($result,gh_long2scm(i),
scm_vector_set_x($result,scm_from_long(i),
SWIG_NewPointerObj(x, $descriptor(T *), 1));
}
}
%typecheck(SWIG_TYPECHECK_VECTOR) vector<T> {
/* native sequence? */
if (gh_vector_p($input)) {
unsigned int size = gh_vector_length($input);
if (scm_is_vector($input)) {
unsigned int size = scm_c_vector_length($input);
if (size == 0) {
/* an empty sequence can be of any type */
$1 = 1;
} else {
/* check the first element only */
SCM o = gh_vector_ref($input,gh_ulong2scm(0));
SCM o = scm_vector_ref($input,scm_from_ulong(0));
T* x;
if (SWIG_ConvertPtr(o,(void**) &x,
$descriptor(T *), 0) != -1)
@ -124,13 +124,13 @@ namespace std {
else
$1 = 0;
}
} else if (gh_null_p($input)) {
} else if (scm_is_null($input)) {
/* again, an empty sequence can be of any type */
$1 = 1;
} else if (gh_pair_p($input)) {
} else if (scm_is_pair($input)) {
/* check the first element only */
T* x;
SCM head = gh_car($input);
SCM head = SCM_CAR($input);
if (SWIG_ConvertPtr(head,(void**) &x,
$descriptor(T *), 0) != -1)
$1 = 1;
@ -149,28 +149,28 @@ namespace std {
%typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&,
const vector<T>* {
/* native sequence? */
if (gh_vector_p($input)) {
unsigned int size = gh_vector_length($input);
if (scm_is_vector($input)) {
unsigned int size = scm_c_vector_length($input);
if (size == 0) {
/* an empty sequence can be of any type */
$1 = 1;
} else {
/* check the first element only */
T* x;
SCM o = gh_vector_ref($input,gh_ulong2scm(0));
SCM o = scm_vector_ref($input,scm_from_ulong(0));
if (SWIG_ConvertPtr(o,(void**) &x,
$descriptor(T *), 0) != -1)
$1 = 1;
else
$1 = 0;
}
} else if (gh_null_p($input)) {
} else if (scm_is_null($input)) {
/* again, an empty sequence can be of any type */
$1 = 1;
} else if (gh_pair_p($input)) {
} else if (scm_is_pair($input)) {
/* check the first element only */
T* x;
SCM head = gh_car($input);
SCM head = SCM_CAR($input);
if (SWIG_ConvertPtr(head,(void**) &x,
$descriptor(T *), 0) != -1)
$1 = 1;
@ -230,24 +230,24 @@ namespace std {
%define specialize_stl_vector(T,CHECK,CONVERT_FROM,CONVERT_TO)
template<> class vector<T> {
%typemap(in) vector<T> {
if (gh_vector_p($input)) {
unsigned long size = gh_vector_length($input);
if (scm_is_vector($input)) {
unsigned long size = scm_c_vector_length($input);
$1 = std::vector<T >(size);
for (unsigned long i=0; i<size; i++) {
SCM o = gh_vector_ref($input,gh_ulong2scm(i));
SCM o = scm_vector_ref($input,scm_from_ulong(i));
if (CHECK(o))
(($1_type &)$1)[i] = (T)(CONVERT_FROM(o));
else
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
}
} else if (gh_null_p($input)) {
} else if (scm_is_null($input)) {
$1 = std::vector<T >();
} else if (gh_pair_p($input)) {
SCM v = gh_list_to_vector($input);
unsigned long size = gh_vector_length(v);
} else if (scm_is_pair($input)) {
SCM v = scm_vector($input);
unsigned long size = scm_c_vector_length(v);
$1 = std::vector<T >(size);
for (unsigned long i=0; i<size; i++) {
SCM o = gh_vector_ref(v,gh_ulong2scm(i));
SCM o = scm_vector_ref(v,scm_from_ulong(i));
if (CHECK(o))
(($1_type &)$1)[i] = (T)(CONVERT_FROM(o));
else
@ -260,27 +260,27 @@ namespace std {
}
%typemap(in) const vector<T>& (std::vector<T> temp),
const vector<T>* (std::vector<T> temp) {
if (gh_vector_p($input)) {
unsigned long size = gh_vector_length($input);
if (scm_is_vector($input)) {
unsigned long size = scm_c_vector_length($input);
temp = std::vector<T >(size);
$1 = &temp;
for (unsigned long i=0; i<size; i++) {
SCM o = gh_vector_ref($input,gh_ulong2scm(i));
SCM o = scm_vector_ref($input,scm_from_ulong(i));
if (CHECK(o))
temp[i] = (T)(CONVERT_FROM(o));
else
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
}
} else if (gh_null_p($input)) {
} else if (scm_is_null($input)) {
temp = std::vector<T >();
$1 = &temp;
} else if (gh_pair_p($input)) {
SCM v = gh_list_to_vector($input);
unsigned long size = gh_vector_length(v);
} else if (scm_is_pair($input)) {
SCM v = scm_vector($input);
unsigned long size = scm_c_vector_length(v);
temp = std::vector<T >(size);
$1 = &temp;
for (unsigned long i=0; i<size; i++) {
SCM o = gh_vector_ref(v,gh_ulong2scm(i));
SCM o = scm_vector_ref(v,scm_from_ulong(i));
if (CHECK(o))
temp[i] = (T)(CONVERT_FROM(o));
else
@ -291,32 +291,32 @@ namespace std {
}
}
%typemap(out) vector<T> {
$result = gh_make_vector(gh_long2scm($1.size()),SCM_UNSPECIFIED);
$result = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED);
for (unsigned int i=0; i<$1.size(); i++) {
SCM x = CONVERT_TO((($1_type &)$1)[i]);
gh_vector_set_x($result,gh_long2scm(i),x);
scm_vector_set_x($result,scm_from_long(i),x);
}
}
%typecheck(SWIG_TYPECHECK_VECTOR) vector<T> {
/* native sequence? */
if (gh_vector_p($input)) {
unsigned int size = gh_vector_length($input);
if (scm_is_vector($input)) {
unsigned int size = scm_c_vector_length($input);
if (size == 0) {
/* an empty sequence can be of any type */
$1 = 1;
} else {
/* check the first element only */
T* x;
SCM o = gh_vector_ref($input,gh_ulong2scm(0));
SCM o = scm_vector_ref($input,scm_from_ulong(0));
$1 = CHECK(o) ? 1 : 0;
}
} else if (gh_null_p($input)) {
} else if (scm_is_null($input)) {
/* again, an empty sequence can be of any type */
$1 = 1;
} else if (gh_pair_p($input)) {
} else if (scm_is_pair($input)) {
/* check the first element only */
T* x;
SCM head = gh_car($input);
SCM head = SCM_CAR($input);
$1 = CHECK(head) ? 1 : 0;
} else {
/* wrapped vector? */
@ -328,24 +328,24 @@ namespace std {
%typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&,
const vector<T>* {
/* native sequence? */
if (gh_vector_p($input)) {
unsigned int size = gh_vector_length($input);
if (scm_is_vector($input)) {
unsigned int size = scm_c_vector_length($input);
if (size == 0) {
/* an empty sequence can be of any type */
$1 = 1;
} else {
/* check the first element only */
T* x;
SCM o = gh_vector_ref($input,gh_ulong2scm(0));
SCM o = scm_vector_ref($input,scm_from_ulong(0));
$1 = CHECK(o) ? 1 : 0;
}
} else if (gh_null_p($input)) {
} else if (scm_is_null($input)) {
/* again, an empty sequence can be of any type */
$1 = 1;
} else if (gh_pair_p($input)) {
} else if (scm_is_pair($input)) {
/* check the first element only */
T* x;
SCM head = gh_car($input);
SCM head = SCM_CAR($input);
$1 = CHECK(head) ? 1 : 0;
} else {
/* wrapped vector? */
@ -394,17 +394,17 @@ namespace std {
};
%enddef
specialize_stl_vector(bool,gh_boolean_p,gh_scm2bool,SWIG_bool2scm);
specialize_stl_vector(char,gh_number_p,gh_scm2long,gh_long2scm);
specialize_stl_vector(int,gh_number_p,gh_scm2long,gh_long2scm);
specialize_stl_vector(long,gh_number_p,gh_scm2long,gh_long2scm);
specialize_stl_vector(short,gh_number_p,gh_scm2long,gh_long2scm);
specialize_stl_vector(unsigned char,gh_number_p,gh_scm2ulong,gh_ulong2scm);
specialize_stl_vector(unsigned int,gh_number_p,gh_scm2ulong,gh_ulong2scm);
specialize_stl_vector(unsigned long,gh_number_p,gh_scm2ulong,gh_ulong2scm);
specialize_stl_vector(unsigned short,gh_number_p,gh_scm2ulong,gh_ulong2scm);
specialize_stl_vector(float,gh_number_p,gh_scm2double,gh_double2scm);
specialize_stl_vector(double,gh_number_p,gh_scm2double,gh_double2scm);
specialize_stl_vector(std::string,gh_string_p,SWIG_scm2string,SWIG_string2scm);
specialize_stl_vector(bool,scm_is_bool,scm_is_true,SWIG_bool2scm);
specialize_stl_vector(char,scm_is_number,scm_to_long,scm_from_long);
specialize_stl_vector(int,scm_is_number,scm_to_long,scm_from_long);
specialize_stl_vector(long,scm_is_number,scm_to_long,scm_from_long);
specialize_stl_vector(short,scm_is_number,scm_to_long,scm_from_long);
specialize_stl_vector(unsigned char,scm_is_number,scm_to_ulong,scm_from_ulong);
specialize_stl_vector(unsigned int,scm_is_number,scm_to_ulong,scm_from_ulong);
specialize_stl_vector(unsigned long,scm_is_number,scm_to_ulong,scm_from_ulong);
specialize_stl_vector(unsigned short,scm_is_number,scm_to_ulong,scm_from_ulong);
specialize_stl_vector(float,scm_is_number,scm_to_double,scm_from_double);
specialize_stl_vector(double,scm_is_number,scm_to_double,scm_from_double);
specialize_stl_vector(std::string,scm_is_string,SWIG_scm2string,SWIG_string2scm);
}