Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion - make exposing Delphi objects to python painless by utilizing the new RTTI feature in D2010 (and above) #17

Open
GoogleCodeExporter opened this issue May 13, 2015 · 8 comments

Comments

@GoogleCodeExporter
Copy link

Hi,

I've a suggestion - make exposing Delphi objects to python painless by 
utilizing the new RTTI (runtime type information) feature in D2010 (and above).

Currently exposing a class to the hosted Python code needs to you to write too 
much code (check demo06), I guess if we take advantage of the new RTTI feature 
in the newer versions of Delphi, the process can be improved a lot.

For example, check out the Delphi chromium embedded project, all you have to do 
to expose the interface of any Delphi class to the JavaScript environment, is 
to register the class:

// this is your class exposed to JS 
  Test = class 
    class procedure doit(const v: string); 
  end; 

initialization 
// Register your class 
  TCefRTTIExtension.Register('app', Test);

// and in JavaScript code to call that class above:
app.doit(''foo'')', '', 0); 

Cool! Isn't it?

The above code was extracted from: 
http://groups.google.com/group/delphichromiumembedded/browse_thread/thread/1793e
7ca66012f0c/8ab31a5ecdb6bf48?lnk=gst&q=JavaScript+return+#

Some intro about RTTI introduced since D2010:
http://robstechcorner.blogspot.com/2009/09/delphi-2010-rtti-basics.html

Original issue reported on code.google.com by edwin....@innovationgear.com on 29 Oct 2011 at 8:50

@GoogleCodeExporter
Copy link
Author

Issue 18 has been merged into this issue.

Original comment by pyscripter on 2 Nov 2011 at 1:45

@GoogleCodeExporter
Copy link
Author

Have you looked into WrapDelphi and the relevant demos?  This is exactly what 
WrapDelphi does, although it does not use the improvements in RTTI since Delphi 
2009.  However it does make it very easy to expose Delphi objects to Python.

Original comment by pyscripter on 8 Nov 2011 at 9:27

@GoogleCodeExporter
Copy link
Author

Thanks for the hint! It's much easier then Demo08.

Original comment by edwin....@innovationgear.com on 10 Nov 2011 at 1:21

@GoogleCodeExporter
Copy link
Author

I've changed wrapdelphi.pas to use TRttiContext when delphi version is 
DELPHIXE_OR_HIGHER. How I can contribute with this project?

Original comment by alexandre@katrid.com on 28 Jan 2012 at 4:52

Attachments:

@GoogleCodeExporter
Copy link
Author

Thanks, I will review the changes and merge them.

Original comment by pyscripter on 28 Jan 2012 at 4:43

@GoogleCodeExporter
Copy link
Author

Now, python code like "Form1.Memo1.Lines.Add('New line')" is working!
But "print Form1.Memo1.Text" is not working.
Please add 'tkUString' to line 1551.

Original comment by cho...@gmail.com on 4 Feb 2012 at 10:12

@GoogleCodeExporter
Copy link
Author

Sounds great!

Original comment by edwin....@innovationgear.com on 5 Mar 2012 at 9:00

@GoogleCodeExporter
Copy link
Author

@ pyscripter, 

Have you merged WrapDelphi.pas by Alexandre into the python4delphi project 
already? Thanks!

Original comment by edwin....@innovationgear.com on 26 May 2012 at 8:53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant