[Geany-Devel] Python question

Lex Trotman elextr at xxxxx
Sat Apr 26 08:06:56 UTC 2014


On 26 April 2014 17:50, Pavel Roschin <roshin at scriptumplus.ru> wrote:
>> It should be in the "current" library (not sure correct term), like if
>> it was C, you would call `dlopen(NULL, ...)`. I'm not familiar enough
>> with ctypes to say exactly but if it had a function like
>> `load_library()` I'd expect you would pass `None` where it expects a
>> filename. Alternatively, you might try `geany.document.__file__` to
>> pickup the C module's filename where the symbol lives, if that works.
>
> It works great, now I can access to all internal geany binary functions. But I
> can't access to geanypy.so functions :(
>
> e.g.
>>>> lib.utils_remove_ext_from_filename
> <_FuncPtr object at 0x27dc120>
>>>> lib.Document_create_new_from_geany_document
> Traceback (most recent call last):
>   File "<input>", line 1, in <module>
>   File "/usr/lib64/python2.7/ctypes/__init__.py", line 378, in __getattr__
>     func = self.__getitem__(name)
>   File "/usr/lib64/python2.7/ctypes/__init__.py", line 383, in __getitem__
>     func = self._FuncPtr((name_or_ordinal, self))
> AttributeError: ./src/geany: undefined symbol:
> Document_create_new_from_geany_document
>
> I tried another way: using document_close from geany binary:
>
>         def doc_close(self, doc):
>                 ptrValue = int(str(doc)[13:-1], 16)

***VERY*** evil >:-D

Is int the same size as pointer on your system? On windows in
particular int can be 32 bit and pointer 64 bit.

Cheers
Lex

>                 lib.document_close(ctypes.cast(ptrValue, ctypes.c_void_p).value)
>
> Now I have segfault :)
>
> --
> Best regards,
> Pavel Roschin aka RPG
> _______________________________________________
> Devel mailing list
> Devel at lists.geany.org
> https://lists.geany.org/cgi-bin/mailman/listinfo/devel


More information about the Devel mailing list