From: SourceForge.net <no...@so...> - 2011-02-06 19:53:32
|
Bugs item #3161614, was opened at 2011-01-19 12:11 Message generated for change (Comment added) made by michaelkappert You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3161614&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: parsing Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: P.Marek (pmarek) Assigned to: Marcelo Matus (marcelomatus) Summary: CFFI: "-" in #defined strings Initial Comment: Generated string constants with a "-" are wrongly parsed as expressions. svn_ra.h has #define SVN_RA_CAPABILITY_LOG_REVPROPS "log-revprops" but swig makes this: (cl:defconstant SVN_RA_CAPABILITY_LOG_REVPROPS (cl:- "log" "revprops")) which doesn't compile: ; Argument X is not a NUMBER: "log" SBCL. Please see debian bug 607116. ---------------------------------------------------------------------- Comment By: Michael Kappert (michaelkappert) Date: 2011-02-06 20:53 Message: Sorry about this. Please try the appended patch. I ran the cffi test suite this time. It didn't show any regressions. Regards, Michael -- cffi.patch -- --- swig/Source/Modules/cffi.cxx.old 2011-01-19 21:24:36.605421976 +0100 +++ swig/Source/Modules/cffi.cxx.new 2011-02-06 12:20:17.332725627 +0100 @@ -564,7 +564,12 @@ int CFFI::constantWrapper(Node *n) { String *type = Getattr(n, "type"); - String *converted_value = convert_literal(Getattr(n, "value"), type); + String *converted_value; + if (Strcmp(type, "p.char") == 0) { + converted_value = NewString(Getattr(n, "rawval")); + } else { + converted_value = convert_literal(Getattr(n, "value"), type); + } String *name = lispify_name(n, Getattr(n, "sym:name"), "'constant"); if (Strcmp(name, "t") == 0 || Strcmp(name, "T") == 0) ---------------------------------------------------------------------- Comment By: William Fulton (wsfulton) Date: 2011-02-04 08:53 Message: This break other constant wrappers when run through the SWIG test-suite: http://www.swig.org/Doc2.0/Extending.html#Extending_test_suite. For example the array_member, the output in array_member.lisp: (cl:defconstant BUFF_LEN 12) now it is: (cl:defconstant BUFF_LEN ) This patch will need some rework. ---------------------------------------------------------------------- Comment By: Michael Kappert (michaelkappert) Date: 2011-01-19 21:55 Message: I think the attached patch fixes the problem. Only briefly tested with the original input and gtkenums.h. I noticed that the CFFI modules generated keywords for enum constants. This looks dubious?! I don't use CFFI myself, though. -- cffi.patch -- --- swig/Source/Modules/cffi.cxx 2011-01-19 21:24:36.605421976 +0100 +++ swig/Source/Modules/cffi.cxx.new 2011-01-19 21:35:59.217066056 +0100 @@ -564,7 +564,7 @@ int CFFI::constantWrapper(Node *n) { String *type = Getattr(n, "type"); - String *converted_value = convert_literal(Getattr(n, "value"), type); + String *converted_value = convert_literal(Getattr(n, "rawval"), type); String *name = lispify_name(n, Getattr(n, "sym:name"), "'constant"); if (Strcmp(name, "t") == 0 || Strcmp(name, "T") == 0) @@ -961,6 +961,11 @@ try_to_split defaults to true (see stub above). */ String *CFFI::convert_literal(String *literal, String *type, bool try_to_split) { + if ( literal == NULL ) return 0; + if ( *Char(literal) == '\'' || *Char(literal) == '"') { + return NewString(literal); + } + String *num_param = Copy(literal); String *trimmed = trim(num_param); String *num = strip_parens(trimmed), *res = 0; -- cffi.patch end -- Regards Michael ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3161614&group_id=1645 |