Domanda

I have a program written in Free Pascal. It imports functions from a DLL selected at runtime. They are imported with the pascal; keyword. I want to extend this program using python code. As I found out shedskin could be helpful for me in this situation. How do I need to proceed? In fact I want to "compile python code to a DLL". Additional to any free or open source tool/compiler I can use Microsoft Visual Studio 2012 and VC++ to solve my problem.

È stato utile?

Soluzione 2

The pascal modifier is a statement of a calling convention. Parameters are pushed onto the stack left to right. Compare to the cdecl calling convention where the parameters are pushed right to left to support variadic functions in C. The stdcall modifier is another right to left calling convention.

Free Pascal supports both calling conventions. Here is cdecl, stdcall and pascal for Free Pascal. The calling conventions are definitely NOT compatible. If you call a function expected it arguments in a certain order with the stack arranged in the other order -- bad things will happen.

You will probably need to use cdecl to extend Free Pascal with Python that has been compiled into C++ code with shedskin. I think all Windows DLL's use the pascal conversion regardless of the language the DLL was written in however.

So make sure you use the right calling convention -- depending where you are using the code.

Altri suggerimenti

Assuming Pascal can use c foreign functions, using the python c-api directly is possible. I think your first step though, is understanding the api python exposes for embedding cpython in other applications.

http://docs.python.org/2/extending/

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top