Re: default exceptions, interfaces, etc.

php.internals

l0t3k

23 years ago
Sterling, have you thought of public accessors (maybe even macros) for exception properties. this is for the benefit of extension authors who want to subclass. right now i have to basically copy the code for the constructor to my new class, or resort using call_user_function_ex. for my extension classes i usually do something like this : int myclass_init_zval(zval *return_val,int foo, char *bar, void *etc); /* create a myclass obj stored in return_val */ and put it in the header so i can create an instance of the class from anywhere i need to. the constructor function also calls this. another idea is basic macros /* set up the common properties. subclasses can add others. also set EG(exception) to return_zval if not set */ ZEND_RAISE_EXCEPTION_EX(return_zval, exception_or_subclass_ce, code, message, ...) /* for extension authors to handle exceptions in C */ ZEND_LOWER_EXCEPTION() /* just to be less arcane */ ZEND_HAS_EXCEPTION() (NULL != EG(exception))