[Mono-list] Mapping PHP and Mono
Sterling Hughes
sterling@bumblebury.com
01 Feb 2003 17:05:42 -0500
Hi,
I'm working on making mono and php talk with each other, I figure since
PHP# is probably a way off, it should be easy enough to use mono's C api
to create overloaded objects.
I'm currently working on property accesses. In PHP property accesses,
don't quite work the same way. The overloading in Mono (and I'd assume
.NET) overload on a per-property basis. PHP overloads on a per-object
basis.
Therefore, I've come up with the following design, which I figured
someone on this list would be more qualified than I do evaluate:
1) Property accesses are handled as overloaded methods. If you prefix a
method with "get", a property access is assumed. So
$obj = new mono("mystupidtest.test1");
$obj->getTestVariable(); // <- This will perform a property access on
TestVariable
The same applies to setting properties:
$obj->setTestVariable("Some Value");
2) Field accesses are equivalent to property accesses. Meaning you can
do:
$obj = new mono("mystupidtest.test1");
$obj->testField = 10;
And it will be automagically set/getted.
Does this design seem like a good thing?
Second, Are there anythings to consider when mapping objects to base
types? Ie, mapping a mono integer (which is an object) to a PHP
integer. Does anyone have opinions as to whether these should be
directly mapped (faster) or if everything, including base types should
be objects, and then set's and get's would be overloaded (maps to the ms
way, but is slow as all hell). Are there anythings to consider so the
performance degradation would be worthwhile?
-Sterling
--
"A business that makes nothing but money is a poor kind of business."
- Henry Ford