For Programmers: Free Programming Magazines  


Home > Archive > Prolog > June 2007 > [SWI-Prolog] Possible to register a foreign function dynamically?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author [SWI-Prolog] Possible to register a foreign function dynamically?
yuce

2007-05-29, 7:06 pm

Hello,

I am writing a Python package to interface SWI-Prolog's foreign
language API. The package uses SWI-Prolog as a shared library;
currently I can query it using PL_open_query just fine, the package is
at (for interested people):
http://code.google.com/p/pyswip

I've converted atom_checksum example at:
http://gollem.science.uva.nl/SWI-Pr...igninclude.html to
Python, there's no problem in the initialization, and
PL_register_foreign works somehow , but when I run a query such as `X
is 10, atom_checksum(X, Y)`, i get a "ERROR: atom_checksum/2: Caught
signal 11 (segv)".

Here's my question: Is it possible to register a foreign function
dynamically without requiring a compilation step? I ask this because
all the examples I've found about it requires to have a function
called `install` which is calling `PL_register_foreign`.

Here's the Python code, I've changed `atom_checksum` so it always
returns false (the longer version is also problematic).

# ...
def atom_checksum(a0, arity, context):
return False

funtype = CFUNCTYPE(foreign_t, term_t, c_int, c_void_p)
PL_register_foreign("atom_checksum", 2, funtype(atom_checksum),
PL_FA_VARARGS)
list( prolog.query("X is 10, atom_checksum(X, Y)",
catcherrors=False) )

Thanks,

Yuce Tekol

Jan Wielemaker

2007-05-29, 7:06 pm

On 2007-05-29, yuce <yucetekol@gmail.com> wrote:
> Hello,
>
> I am writing a Python package to interface SWI-Prolog's foreign
> language API. The package uses SWI-Prolog as a shared library;
> currently I can query it using PL_open_query just fine, the package is
> at (for interested people):
> http://code.google.com/p/pyswip
>
> I've converted atom_checksum example at:
> http://gollem.science.uva.nl/SWI-Pr...igninclude.html to
> Python, there's no problem in the initialization, and
> PL_register_foreign works somehow , but when I run a query such as `X
> is 10, atom_checksum(X, Y)`, i get a "ERROR: atom_checksum/2: Caught
> signal 11 (segv)".
>
> Here's my question: Is it possible to register a foreign function
> dynamically without requiring a compilation step? I ask this because
> all the examples I've found about it requires to have a function
> called `install` which is calling `PL_register_foreign`.


Thats because load_foreign_library/1 loads a DLL/so file, looks for
install() in there and calls it. Anything else that can get hold of a
pointer to function of the right signature can call PL_register_foreign
without problems.

> Here's the Python code, I've changed `atom_checksum` so it always
> returns false (the longer version is also problematic).
>
> # ...
> def atom_checksum(a0, arity, context):
> return False
>
> funtype = CFUNCTYPE(foreign_t, term_t, c_int, c_void_p)
> PL_register_foreign("atom_checksum", 2, funtype(atom_checksum),
> PL_FA_VARARGS)
> list( prolog.query("X is 10, atom_checksum(X, Y)",
> catcherrors=False) )


You definitely have a problem returning False. Does that make the
function actually return 0? Maybe you can run it under a debugger
and get a clue?

Success --- Jan

P.s. There is already an interface called pyprolog. Rumours say
that isn't very complete nor maintained. I have no clue.
Lesbian

2007-06-06, 6:39 am

Jessica Simpson and Alyssa Milano Pussy Licking & Fighting!
http://www.theillegalsite.com/Media...mv?watch=726071
Eedes7

2007-06-07, 9:28 am

Nice girls, big boobs :)
http://nice-females-dicked.org/video?id=218571
Ytttttttt

2007-06-09, 11:08 pm

Angelina Jolie and Pamela Anderson , Satisfying Her Lesbian Girlfriend!
http://www.hiltonraped.com/Player.asp?vid=1673286

Jessica Simpson and Sarah M. Gellar Liks Pussy On Yacht!
http://www.hiltonraped.com/WindowsM...cgi?vid=1673286

Heather Locklear and Cameron Diaz Lesbians Doing In Jacuzzi!
http://www.hiltonraped.com/WatchMovie?id=1673286

Christina Aguilera and Pamela Anderson Big Tits Mature Lesbian Sex!
http://www.hiltonraped.com/PlayMovie?clip=1673286

Ashlee Simpson and Jessica Simpson Lesbian XXXXing!
http://www.hiltonraped.com/WindowsM....asp?id=1673286

sex toy uk mallu sex movie anal image sex anal danger sex female version of viagra
http://slw7pl0p.t35.com/teen-sex/teen-sex-vids.html http://yhqbl1u3.t35.com/world-sex/free-world-sex.html http://slw7pl0p.t35.com/teen-sex/sexy-teen-sex.html http://ss6cnhgd.t35.com/gay-sex-movie/gay-bear-sex.html http://slw7pl0p.t35.com/teen-sex/web-cam-teen-sex.html
Zerone

2007-06-14, 5:47 am

http://www.freedutchmovies.com/player.php?q=1673286
Teddicktard7

2007-06-17, 9:24 pm

Lindsay Lohan and Cameron Diaz Vibrating In Slits!

brooke busty movie filme porn download gratis he man tube video chat de sexo gratis porn movie xxx
country free music video free online sex video clip video sex porn gratis free porn video download adult scaleable video
juegos porn gratis mature sex movie adult video pay per view porn movie download jocuri gratis download
britney hair lock spear extrait gratuit porn video lego star war video game 2007 movie picture transformer free latina porn video

http://play-home-video.info/warner-home-video-logo.html
http://dvdsclip.com/funny-picture-and-clip.html
http://bestskivideo.com/music-usher-video.html
http://free-video-wefd.org/download-free-psp-video.html
http://bestskivideo.com/60-gb-ipod-video.html
http://video-porn-gratis-dsg.org/gratis-sex-video.html
http://moremoviesonline.com/clip-great-hair-salon.html
http://video-porn-gratis-dsg.org/pu...nas-gratis.html
http://run-video-gratis.info/de-gra...iple-video.html
http://yeah-paris-hilton-sex-tape.o...lton-movie.html
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com