csjark module
Peter Otten
__peter__ at web.de
Thu Sep 22 03:39:06 EDT 2016
bezenchu at gmail.com wrote:
> On Thursday, September 22, 2016 at 5:51:43 AM UTC+3, beze... at gmail.com
> wrote:
>> On Wednesday, September 21, 2016 at 10:09:25 PM UTC+3, Peter Otten wrote:
>> > bezenchu at gmail.com wrote:
>> >
>> > > On Wednesday, September 21, 2016 at 5:15:38 PM UTC+3, Peter Otten
>> > > wrote:
>> > >> bezenchu at gmail.com wrote:
>> > >>
>> > >> > On Wednesday, September 21, 2016 at 3:17:11 PM UTC+3, Peter Otten
>> > >> > wrote:
>> > >> >> bezenchu at gmail.com wrote:
>> > >> >>
>> > >> >> > On Wednesday, September 21, 2016 at 1:14:14 PM UTC+3, Peter
>> > >> >> > Otten wrote:
>> > >> >> >> bezenchu at gmail.com wrote:
>> > >> >> >>
>> > >> >> >> > After setting up csjark (http://csjark.readthedocs.io/), I'm
>> > >> >> >> > trying to test on of my C header files which has following
>> > >> >> >> > statements:
>> > >> >> >> >
>> > >> >> >> > typedef struct {
>> > >> >> >> > unsigned long X;
>> > >> >> >> > __int64 Y;
>> > >> >> >> > } abc;
>> > >> >> >> >
>> > >> >> >> >
>> > >> >> >> > If I'm changing __int64 to unsigned long I'm not getting
>> > >> >> >> > this error For the __int64 i'm getting the mention error. Am
>> > >> >> >> > I missing something?
>> > >> >> >> >
>> > >> >> >> >
>> > >> >> >> > In addition, I'm getting following error:
>> > >> >> >> > Attribute error("'tuple object has no attibute 'children'",)
>> > >> >> >> >
>> > >> >> >> > I'd be glad to have some assistance.
>> > >> >> >>
>> > >> >> >> It looks like development of csjark has stopped in 2011. Try
>> > >> >> >> installing a pycparser version from that time frame -- 2.05
>> > >> >> >> should be a good candidate according to
>> > >> >> >> <https://github.com/eliben/pycparser/blob/master/CHANGES> so
>> > >> >> >> if you are using pip after
>> > >> >> >>
>> > >> >> >> $ pip install pycparser==2.05
>> > >> >> >>
>> > >> >> >> csjark might work.
>> > >> >> >
>> > >> >> > I've installed all the required SW, but still getting the same
>> > >> >> > error
>> > >> >>
>> > >> >> When you invoke the interactive interpreter what does
>> > >> >>
>> > >> >> >>> import pycparser
>> > >> >> >>> pycparser.__version__
>> > >> >> '2.05'
>> > >> >>
>> > >> >> produce on your system?
>> > >> >
>> > >> > I have version 2.07 (which is the one used for the development)
>> > >>
>> > >> For cjshark to work (or at least not fail in the way you observed)
>> > >> you need 2.5.
>> > >>
>> > >> 2.7 returns 2-tuples where 2.5 does not. Compare for example:
>> > >>
>> > >>
>> >
https://github.com/eliben/pycparser/blob/release_v2.07/pycparser/c_ast.py#L149
>> > >>
>> > >> def children(self):
>> > >> nodelist = []
>> > >> if self.name is not None: nodelist.append(("name",
>> > >> self.name)) if self.subscript is not None:
>> > >> nodelist.append(("subscript",
>> > >> self.subscript))
>> > >> return tuple(nodelist)
>> > >>
>> > >> and
>> > >>
>> > >>
>> >
https://github.com/eliben/pycparser/blob/release_v2.05/pycparser/c_ast.py#L136
>> > >>
>> > >> def children(self):
>> > >> nodelist = []
>> > >> if self.name is not None: nodelist.append(self.name)
>> > >> if self.subscript is not None:
>> > >> nodelist.append(self.subscript) return tuple(nodelist)
>> > >>
>> > >> I wonder why you didn't just try what I suggested...
>> > >
>> > > Thanks,
>> > > This one solved the 2nd problem.
>> > >
>> > > Do you have any suggestions for the 1st one?
>> >
>> > Here's what I see from your original post:
>> >
>> > https://mail.python.org/pipermail/python-list/2016-September/714323.html
>> >
>> > So I have no idea what your "1st problem" might be. Can you restate it?
>> >
>> > You have to use text, pictures are removed.
>>
>> Clarification with example:
>>
>> I'm taking the complex_union_test.h file (which is one of the test files
>> of csjark) and changing on line 8 from int to __int64 so the code is
>>
>> #include "union_test.h"
>> #include "cenum_test.h"
>>
>> typedef signed int BOOL;
>> typedef enum {TRUE, FALSE} bool_t;
>>
>> typedef union {
>> __int64 int_member;
>> struct cenum_test cenum_test_member;
>> long long long_long_member;
>> BOOL bool_member;
>> bool_t bool_t_member;
>> short short_member;
>> } complex_union;
>>
>> struct struct_with_complex_union {
>> complex_union complex_union_member;
>> bool_t bool_t_member;
>> union union_test union_test_member;
>> };
>>
>> Now trying to execute the parsing and getting following error:
>> Skipped "headers\complex_union_test.":Win32 as it raised
>> ParseError('headers\\complex_union_test.h:8: before: __int64',)
>>
>> I have similar error with my .h file.
>
> seems that I have a solution for it:
> instead of __int64 to use "long long" statement
That seems to be a complaint of the C compiler, e. g.
$ cat tmp.h
typedef struct {
unsigned long X;
__int64 Y;
} abc;
$ gcc tmp.h
tmp.h:3:4: error: unknown type name ‘__int64’
__int64 Y;
^
You can fix that with a
typedef long long __int_64;
assuming long long is the correct replacement for __int_64, or include the
header file where __int_64 is defined if such a header file exists.
More information about the Python-list
mailing list