-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify object prototype system (#850)
This commit simplifies some of the implementation details of object prototypes, as well as renames the (internal) functions for actually using prototypes. The main renames are as follows: - CreateFromPrototype -> AllocateObject - CreateAndInitFromPrototype -> CreateObject - ApplyPrototypeToObject -> SetObjectPrototype Additional functions have been added for initializing an allocated object (ConstructObject) and querying the prototype of an object (GetObjectPrototype). Additionally, the '__init' method is now fully optional and may be omitted. In terms of implementation details, the creation of metatables for prototypes no longer takes a shallow copy of the prototype, and instead just connects objects to their prototypes directly via '__index'. This means that changes to any fields in prototypes are made visible to objects that inherit the prototype, and don't become stuck. For metamethods, we no longer support the '__index', '__newindex', or '__le' fields being defined. These are unused and are weird enough to generally just be worth avoiding for objects anyway. Finally, allocation of objects can now be customized. If a prototype defines an '__allocate' method then it will be invoked (with the prototype passed as 'self') and is expected to return a table for the object to live inside. Like '__init' this method is fully optional; if not defined then the default is to just create an empty table.
- Loading branch information
Showing
10 changed files
with
163 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.