exposing C structs

From: Date: Tue, 24 May 2011 17:06:58 +0000
Subject: exposing C structs
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-8295@lists.php.net to get a copy of this message
hello, i'm wrapping a 3rd-party shared library as an extension, and i'd like to expose some structs as PHP classes. nothing complicated: typedef struct DapiDate { short year; short month; short day; } DapiDate; typedef struct DapiTime { short hour; short minute; short second; } DapiTime; typedef struct DapiDateTime { DapiDate date; DapiTime time; } DapiDateTime; i have some experience with extensions, but never needed to expose data members. the PHP classes corresponding to these structs, as well as their instances, must support reflection. so, let's say i have this C++ code: struct dapic_DapiDate { zend_object std; DapiDate impl; }; PHP_MINIT_FUNCTION(dapic) { zend_class_entry ce; INIT_CLASS_ENTRY(ce, "DapiDate", dapic_no_methods); dapic_DapiDate_ce = zend_register_internal_class(&ce TSRMLS_CC); dapic_DapiDate_ce.create_object = dapic_create_handler<dapic_DapiDate>; ... } what's the minimum required to 1) expose the dapic_DapiDate->impl members in userspace (r/w)? 2) make them visible to ReflectionClass? thanks! -- roman

« previous php.pecl.dev (#8295) next »