[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] DLL's






From: Pete Shinners <pete@xxxxxxxxxxxx>
Reply-To: pygame-users@xxxxxxxx
To: pygame-users@xxxxxxxx
Subject: Re: [pygame]  DLL's
Date: Sat, 11 Nov 2006 09:53:19 -0800

On Sat, 2006-11-11 at 19:24 +0200, Jason Ward wrote:
> I want to write program in assembler and put them into dlls.
> Then I want to make python call those dlls for me. How does
> python call up dlls?
>
> Also, if I make a function return a value in the dll and then python
> calls it up. Can I do it like this.
>
> num=dll_function()
>
> THe first question is the most important

You'll want to check out the docs for this, it is referred to as
"extending python".

Python has a complete C API, so you can manipulate and call Python
objects from C. You can make a .dll loadable as a regular python module.
You import these like you do a regular .py file.

If you are just making functions from C/assembly callable by Python this
won't be too hard. The .dll needs a magically named "init" function.
Python will look for this when opening the .dll. That function will
setup an array of function pointers and strings. Python can then call
those functions using the given names.



Will I need to put anything inside of that init function or do I just leave it blank and let
python do the rest for me?
Please explain fully


_________________________________________________________________
See their smiles, hear their laughter with Windows Live Messenger! http://messenger.live.com