diff --git a/SWIG/Lib/clisp/clisp.swg b/SWIG/Lib/clisp/clisp.swg new file mode 100644 index 000000000..7f00f71f8 --- /dev/null +++ b/SWIG/Lib/clisp/clisp.swg @@ -0,0 +1,28 @@ +/* Define a C preprocessor symbol that can be used in interface files + to distinguish between the SWIG language modules. */ + +#define SWIG_CLISP + +/* Typespecs for basic types. */ + +%typemap(ffitype) void "NIL"; +%typemap(ffitype) void * "(ffi:c-pointer NIL)"; +%typemap(ffitype) char "character"; +%typemap(ffitype) char * "ffi:c-string"; +%typemap(ffitype) unsigned char "ffi:uchar"; +%typemap(ffitype) signed char "ffi:char"; +%typemap(ffitype) short "ffi:short"; +%typemap(ffitype) signed short "ffi:short"; +%typemap(ffitype) unsigned short "ffi:ushort"; +%typemap(ffitype) int "ffi:int"; +%typemap(ffitype) int * "(ffi:c-pointer ffi:int)"; +%typemap(ffitype) signed int "ffi:int"; +%typemap(ffitype) unsigned int "ffi:uint"; +%typemap(ffitype) long "ffi:long"; +%typemap(ffitype) signed long "ffi:long"; +%typemap(ffitype) unsigned long "ffi:ulong"; +%typemap(ffitype) float "SINGLE-FLOAT"; +%typemap(ffitype) float * "(ffi:c-pointer SINGLE-FLOAT)"; +%typemap(ffitype) double "DOUBLE_FLOAT"; +%typemap(ffitype) double * "(ffi:c-pointer DOUBLE-FLOAT)"; + diff --git a/SWIG/Source/Modules/clisp.cxx b/SWIG/Source/Modules/clisp.cxx new file mode 100644 index 000000000..a0784188e --- /dev/null +++ b/SWIG/Source/Modules/clisp.cxx @@ -0,0 +1,318 @@ +/* ----------------------------------------------------------------------------- + * python.cxx + * + * Python module. + * + * Author(s) : Surendra Singhi (surendra@asu.edu) + * + * Copyright (C) 2005 Surendra Singhi + * See the file LICENSE for information on usage and redistribution. + * ----------------------------------------------------------------------------- */ + + + +char cvsroot_clisp_cxx[] = "$Header$"; + +#include "swigmod.h" + +class CLISP : public Language { +public: + File *f_cl; + String *module; + virtual void main(int argc, char *argv[]); + virtual int top(Node *n); + virtual int functionWrapper(Node *n); + virtual int constantWrapper(Node *n); + virtual int classDeclaration(Node *n); + +private: + String* get_ffi_type(SwigType *ty, const String_or_char *name); + String* convert_literal(String *num_param, String *type); + String* strip_parens(String *string); +}; + + +void CLISP :: main(int argc, char *argv[]) { + int i; + + SWIG_library_directory("clisp"); + SWIG_config_file("clisp.swg"); + + for(i=1; i 1) { + Printf(stderr, "Weird!! number %s looks invalid.\n", num); + SWIG_exit(EXIT_FAILURE); + } + Delete(num); + return updated; + } + + if (SwigType_type(type) == T_CHAR) { + /* Use CL syntax for character literals */ + return NewStringf("#\\%s", num_param); + } + else if (SwigType_type(type) == T_STRING) { + /* Use CL syntax for string literals */ + return NewStringf("\"%s\"", num_param); + } + + if (Len(num) < 2 || s[0] != '0') { + return num; + } + + /* octal or hex */ + + res=NewStringf("#%c%s", + s[1] == 'x' ? 'x' : 'o', + s+2); + Delete(num); + + return res; +} + +String* CLISP::get_ffi_type(SwigType *ty, const String_or_char *name) { + Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0); + if (typemap) { + String *typespec = Getattr(typemap, "code"); + return NewString(typespec); + } + else { + SwigType *tr=SwigType_typedef_resolve_all(ty); + char *type_reduced=Char(tr); + // int i; + + //Printf(stdout,"convert_type %s\n", ty); + if (SwigType_isconst(tr)) { + SwigType_pop(tr); + type_reduced=Char(tr); + } + + if (SwigType_ispointer(type_reduced) || SwigType_isarray(ty) || + !strncmp(type_reduced, "p.f", 3)) { +#if 1 + return NewString("(* :void)"); +#else + return NewString(":foreign-address"); +#endif + } + + // for(i=0; i