Fixes the placement of swig-lisp code, and also makes sure that
literals are properly converted for enums. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8731 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
24404e25aa
commit
70c1bd07a4
2 changed files with 20 additions and 15 deletions
|
|
@ -96,7 +96,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%insert("lisphead") %{
|
%insert("swiglisp") %{
|
||||||
;;;SWIG wrapper code starts here
|
;;;SWIG wrapper code starts here
|
||||||
|
|
||||||
(defmacro defanonenum (&body enums)
|
(defmacro defanonenum (&body enums)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ char cvsroot_cffi_cxx[] = "$Header$";
|
||||||
//#define CFFI_DEBUG
|
//#define CFFI_DEBUG
|
||||||
class CFFI : public Language {
|
class CFFI : public Language {
|
||||||
public:
|
public:
|
||||||
File *f_cl;
|
String *f_cl;
|
||||||
String *f_clhead;
|
String *f_clhead;
|
||||||
String *f_clwrap;
|
String *f_clwrap;
|
||||||
bool CWrap; // generate wrapper file for C code?
|
bool CWrap; // generate wrapper file for C code?
|
||||||
|
|
@ -95,6 +95,7 @@ void CFFI :: main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
f_clhead = NewString("");
|
f_clhead = NewString("");
|
||||||
f_clwrap = NewString("");
|
f_clwrap = NewString("");
|
||||||
|
f_cl = NewString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
int CFFI :: top(Node *n) {
|
int CFFI :: top(Node *n) {
|
||||||
|
|
@ -104,8 +105,8 @@ int CFFI :: top(Node *n) {
|
||||||
String *lisp_filename=NewString("");
|
String *lisp_filename=NewString("");
|
||||||
|
|
||||||
Printf(lisp_filename, "%s%s.lisp", SWIG_output_directory(), module);
|
Printf(lisp_filename, "%s%s.lisp", SWIG_output_directory(), module);
|
||||||
f_cl=NewFile(lisp_filename, "w");
|
File *f_lisp=NewFile(lisp_filename, "w");
|
||||||
if (!f_cl) {
|
if (!f_lisp) {
|
||||||
FileErrorDisplay(lisp_filename);
|
FileErrorDisplay(lisp_filename);
|
||||||
SWIG_exit(EXIT_FAILURE);
|
SWIG_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +114,7 @@ int CFFI :: top(Node *n) {
|
||||||
if (CPlusPlus || CWrap) {
|
if (CPlusPlus || CWrap) {
|
||||||
f_cxx=NewFile(cxx_filename, "w");
|
f_cxx=NewFile(cxx_filename, "w");
|
||||||
if (!f_cxx) {
|
if (!f_cxx) {
|
||||||
Close(f_cl); Delete(f_cl);
|
Close(f_lisp); Delete(f_lisp);
|
||||||
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
|
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
|
||||||
SWIG_exit(EXIT_FAILURE);
|
SWIG_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
@ -127,17 +128,18 @@ int CFFI :: top(Node *n) {
|
||||||
Swig_register_filebyname("header",f_cxx_header);
|
Swig_register_filebyname("header",f_cxx_header);
|
||||||
Swig_register_filebyname("wrapper",f_cxx_wrapper);
|
Swig_register_filebyname("wrapper",f_cxx_wrapper);
|
||||||
Swig_register_filebyname("runtime",f_cxx);
|
Swig_register_filebyname("runtime",f_cxx);
|
||||||
Swig_register_filebyname("lisp", f_clwrap);
|
Swig_register_filebyname("lisphead", f_clhead);
|
||||||
Swig_register_filebyname("lisphead", f_cl);
|
Swig_register_filebyname("swiglisp", f_cl);
|
||||||
|
|
||||||
Language::top(n);
|
Language::top(n);
|
||||||
|
Printf(f_lisp, "%s\n", f_clhead);
|
||||||
Printf(f_cl, "%s\n", f_clhead);
|
Printf(f_lisp, "%s\n", f_cl);
|
||||||
Printf(f_cl, "%s\n", f_clwrap);
|
Printf(f_lisp, "%s\n", f_clwrap);
|
||||||
|
|
||||||
Printf(stderr, "All done now!\n");
|
Printf(stderr, "All done now!\n");
|
||||||
Close(f_cl);
|
Close(f_lisp);
|
||||||
Delete(f_cl); // Deletes the handle, not the file
|
Delete(f_lisp); // Deletes the handle, not the file
|
||||||
|
Delete(f_cl);
|
||||||
Delete(f_clhead);
|
Delete(f_clhead);
|
||||||
Delete(f_clwrap);
|
Delete(f_clwrap);
|
||||||
Close(f_cxx);
|
Close(f_cxx);
|
||||||
|
|
@ -443,9 +445,12 @@ int CFFI :: enumDeclaration(Node *n) {
|
||||||
|
|
||||||
if(!value)
|
if(!value)
|
||||||
Printf(f_cl,"\n\t%s%s",slot_name_prefix, slot_name);
|
Printf(f_cl,"\n\t%s%s",slot_name_prefix, slot_name);
|
||||||
else
|
else {
|
||||||
Printf(f_cl,"\n\t(%s%s %s)",slot_name_prefix, slot_name,value);
|
String *type=Getattr(c, "type");
|
||||||
|
String *converted_value=convert_literal(value, type);
|
||||||
|
Printf(f_cl,"\n\t(%s%s %s)",slot_name_prefix, slot_name,converted_value);
|
||||||
|
Delete(converted_value);
|
||||||
|
}
|
||||||
Delete(value);
|
Delete(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue