Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

The python wrappers now reflect the Delphi inheritance hierarchy #399

Discussion options

With the fix to #382, tp_base is correctly set for wrappers descending from TPyDelphiObject and registered through the standard RegisterDelphiWrapper mechanism. This means that the isinstance and issubclass builtins will work correctly on wrapped Delphi objects and classes.

It also means that we should not call inherited in RegisterMethods and RegisterGetSets, since python will find the inherited methods and getsets anyway. Calling inherited does not do any harm (it overrides the methods in inherited classes), but it is inefficient speed and memory-wise.

Wrapped classes which do not provide a RegisterMethods and RegisterGetSets override, they should provide an empty one. Otherwise the inherited ones would be created on both the parent and the child class leading to unnecessary duplication.

45ca26c removed the calls to inherited from existing implementations of RegisterMethods and RegisterGetSets. It also changed the implementation of the __dir__ wrapper. However, now, empty RegisterMethods and RegisterGetSets, should be added to the wrappers that do not have these methods.

@lmbelo, @jimmckeeth

You must be logged in to vote

Replies: 1 comment · 7 replies

Comment options

We have this fixed and many other enhancements in the latest "docs" feature branch.

Have a look: https://github.com/Embarcadero/python4delphi/tree/docs

  1. All methods and properties provided by Delphi are now built-in;
  2. It follows the Delphi inheritance until Python object;
  3. Python is now able to refer to class attributes;
  4. The dir method now lists all Delphi attributes available in a class (not instances), categorized by class parents.
  5. Callables are not created on-the-fly anymore;
  6. Doc strings are being read from XML files;
  7. IDE's can use type attributes as stubs for code completion, as they are built-in now;
  8. and more...

@jimmckeeth @pyscripter

You must be logged in to vote
7 replies
@pyscripter
Comment options

pyscripter Dec 31, 2022
Maintainer Author

3. Python is now able to refer to class attributes;

Class methods static or otherwise have been supported for a long time. See for instance https://github.com/pyscripter/python4delphi/blob/master/Tutorials/Webinar%20I/WrapDelphiDemo/MainForm.pas#L49

What is not supported is class fields and properties, but AFAIK (see https://en.delphipraxis.net/topic/8087-access-class-fields-and-properties-with-rtti/) this is not currently possible.

@lmbelo Could you please clarify what is the new functionality in that respect and how it was implemented.

@lmbelo
Comment options

When referred from a given instance of a type, not the type itself, right?

@pyscripter
Comment options

pyscripter Dec 31, 2022
Maintainer Author

Yes. I see. Now you can call class methods from the type?

@lmbelo
Comment options

Yes, exactly. Class and static methods from a type.

@pyscripter
Comment options

pyscripter Dec 31, 2022
Maintainer Author

Good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.