Implemented __get and correct object destruction

jgmdev
Created by: jgmdev
Date: 01/30/2012 @ 10:10:35 pm
Views: 767

Today I have committed another set of changes and enabled 2 more classes : wxSystemOptions and wxSystemSettings in order for wxPHP to work better with the generated code of wxFormBuilder.

__get Magic Method

I have introduced the code generation of the magic method __get for wxWidgets classes that contain public or private properties.
So for example, wxPoint has x and y as properties one could do:

$point = new wxPoint(5, 10);

print $point.x . ":" . $point.y;

output: 5:10

Memory Management

Also I have implemented correct handling of objects destruction since on the old code the destruction handler was declared, but not used resulting in a lot of memory leaks. Just deleting the pointer of the deleted objects resulted in a lot of segmentation faults since they were still used by other objects. So I implemented a helper class used by all class wrappers in order to store all zval references they use and once this classes/parent get destroyed the reference of the zval's is decreased and they are garbage collected.  The implementation is not perfect but at least there are fewer memory leaks or none depending on the type of php code written.

TODO list:

So now these is what I have planned for the TODO list:

  • Update config.w32 and configd.w32 to use new wxWidgets 2.9.x
  • Compilation testing and troubleshooting on windows
  • Compilation testing and troubleshooting on mac
  • Implement __set to write to internal wxWidgets class properties.
  • Implement compare_objects handler for wxWidget classes that implement operator== etc...
  • Fix segmentation bug that occurs on shutdown.
  • Preparations for a release
  • Setup file for windows that automatically installs php and wxPHP/wxWidgets in order to start developing GUI applications on that platform.

Special Thanks

Many thanks to the guys at #php.pecl on Efnet especially johannes and ekneuss from which I learned about zval_ptr_dtor and correct declaration of ZEND_ARG_INFO for magic methods that require them :D

Anyone is welcome to checkout svn and compile/test the source code. I hope anyone could make good use of this project besides the ones I intend to ;)

Comments