473,382 Members | 1,362 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Delphi extension

I was given a libxx.so that was probably written in Delphi.
I need to wrap it so that I can call the functions/procedures
of the library from Python. I tried the usual extension
technique compiling a C file. I don't get anything meaningful
back when I call, so it doesn't work, or I am missing some
critical point. I have spent a good deal of time searching
the net, and found one or two comments about doing the job,
but no evidence that anyone has done it.

I would appreciate any suggestions or advice.
Don
Jul 18 '05 #1
4 1886
> I was given a libxx.so that was probably written in Delphi.
I need to wrap it so that I can call the functions/procedures
of the library from Python. I tried the usual extension
technique compiling a C file. I don't get anything meaningful
back when I call, so it doesn't work, or I am missing some
critical point. I have spent a good deal of time searching


I don't know anything about Delphi; it may use a different calling
convention than C (unlikely). If that's the case, however, you're out of
luck unless you can find a Delphi-C or Delphi-Python interface module.

Assuming it uses the C calling convention, you can possibly use the dl
module:

import dl
c=dl.open('/path/to/my/lib.so')
c.call('myfunc',arg1,arg2)

dl is unfortunately limited to passing integers, strings, and NULL, and to
returning integers, so it's likely not to be useful for complex data
structures.

Jul 18 '05 #2
Donald L. Dietmeyer wrote:
I was given a libxx.so that was probably written in Delphi.
I need to wrap it so that I can call the functions/procedures
of the library from Python. I tried the usual extension
technique compiling a C file. I don't get anything meaningful
back when I call, so it doesn't work, or I am missing some
critical point. I have spent a good deal of time searching
the net, and found one or two comments about doing the job,
but no evidence that anyone has done it.

I would appreciate any suggestions or advice.


Would ctypes work for you? http://starship.python.net/crew/theller/ctypes/
Jul 18 '05 #3
Christopher T King <sq******@WPI.EDU> pisze:
I don't know anything about Delphi; it may use a different calling
convention than C (unlikely). If that's the case, however, you're out of
luck unless you can find a Delphi-C or Delphi-Python interface module.


Register is default call convention for libraries written in Delphi, but
one may use any other at will.

--
Jarek Zgoda
http://jpa.berlios.de/
Jul 18 '05 #4
Jarek Zgoda <jz****@gazeta.usun.pl> writes:
Christopher T King <sq******@WPI.EDU> pisze:
I don't know anything about Delphi; it may use a different calling
convention than C (unlikely). If that's the case, however, you're out of
luck unless you can find a Delphi-C or Delphi-Python interface module.


Register is default call convention for libraries written in Delphi, but
one may use any other at will.


A bit of a Delphic utterance...

Googling, it seems 'Register' is what MSVC calls __fastcall.

Not sure how you tell which Delphi functions obey which calling
convention, but (in the absence of a more polished method) I think I'd
attempt to find that out, then write a thin wrapper of the Delphi
interface in C, with explicit calling convention declarations
(eg. __fastcall), then wrap *that* with SWIG.
John
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: PythonMan | last post by:
Any Software can change Python source code to Delphi ? thx --
6
by: Erva | last post by:
Hi, Is there someone who has moved from Delphi to VS.NET? I'am using Delphi currently but seriously considering to moving VS.NET. I would like to hear if someone has already done that, is it...
10
by: Arda Han | last post by:
I am migrating my some applications from Delphi to C#. But... Yes But I don't know C# professionally. I am using DLL in delphi like this : ..... const RFID_103_485IO = 'Cihaz.dll'; ...
3
by: lukeharpin | last post by:
Currently I have been developing applications in Delphi 7. Recently I meet up with a friend of mine who previously developed in Delphi, from version 1 - 7. When Delphi 8 .net was release he found...
7
by: Sanjay Kedare | last post by:
Hi, I am evaluating various alternatives of converting Delphi (Ver 4.0) screens to C# screens. Are there any tools available for such conversion? if yes how much conversion do they achieve? The...
13
by: lukeharpin | last post by:
Hi World, We have been developing Engineering software in Delphi 3,4,5,6,7 for a few years now. This morning we had a discussion about OOP and re-programming the software to which the question...
1
by: Thomas Due | last post by:
Hi, I manage an rather old application in which we have some fairly complex (ugly) Delphi code. This is Delphi 6 we're talking about. Among all this Delphi code there is method for formating a...
4
by: =?Utf-8?B?ZGF2ZWJ5dGhlc2Vh?= | last post by:
Dear List, We have a large application written in Delphi. I am writing a mobile app written in .NET (C#) which reads and writes into the Delphi applications Oracle database via a .NET Web...
11
by: gnuist006 | last post by:
Is there a Delphi equivalent in the C world or Scheme/LISP world ? Recently, Delphi is in resurgence. In Russia people are using like crazy. For example, Bolega has written a free image...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.