Permalink
Browse files

Reverting constructor changes

  • Loading branch information...
1 parent 818ad90 commit 12dd3d4a1ec49b3548f11e93e18c8e9a95d1e5e5 @mahcuz mahcuz committed Dec 2, 2010
Showing with 16 additions and 182 deletions.
  1. +9 −28 cairo_context.c
  2. +2 −44 cairo_font.c
  3. +1 −2 cairo_font_face.c
  4. +4 −32 cairo_font_options.c
  5. +0 −76 php_cairo.h
View
@@ -35,9 +35,6 @@ zend_class_entry *cairo_ce_cairolinecap;
zend_class_entry *cairo_ce_cairolinejoin;
zend_class_entry *cairo_ce_cairooperator;
-static zend_object_handlers object_handlers;
-static zend_function ctor_wrapper_func;
-
/* Basic Context */
ZEND_BEGIN_ARG_INFO(CairoContext___construct_args, ZEND_SEND_BY_VAL)
/* ZEND_ARG_OBJ_INFO(0, surface, CairoSurface, 0) */
@@ -230,8 +227,7 @@ PHP_METHOD(CairoContext, __construct)
surface_object = (cairo_surface_object *)zend_object_store_get_object(surface_zval TSRMLS_CC);
context_object = (cairo_context_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
- context_object->context = cairo_create(surface_object->surface);
- context_object->is_constructed = 1;
+ context_object->context = cairo_create(surface_object->surface);
php_cairo_throw_exception(cairo_status(context_object->context) TSRMLS_CC);
/* we need to be able to get this zval out later, so ref and store */
@@ -2934,14 +2930,6 @@ static void cairo_context_object_destroy(void *object TSRMLS_DC)
efree(object);
}
-static zend_function * get_constructor(zval *object TSRMLS_DC)
-{
- if (Z_OBJCE_P(object) == cairo_ce_cairocontext)
- return zend_get_std_object_handlers()->get_constructor(object TSRMLS_CC);
- else
- return &ctor_wrapper_func;
-}
-
static zend_object_value cairo_context_object_new(zend_class_entry *ce TSRMLS_DC)
{
zend_object_value retval;
@@ -2950,14 +2938,13 @@ static zend_object_value cairo_context_object_new(zend_class_entry *ce TSRMLS_DC
context = ecalloc(1, sizeof(cairo_context_object));
- context->std.ce = ce;
- context->surface = NULL;
- context->matrix = NULL;
- context->pattern = NULL;
- context->font_face = NULL;
- context->font_matrix = NULL;
- context->scaled_font = NULL;
- context->is_constructed = 0;
+ context->std.ce = ce;
+ context->surface = NULL;
+ context->matrix = NULL;
+ context->pattern = NULL;
+ context->font_face = NULL;
+ context->font_matrix = NULL;
+ context->scaled_font = NULL;
ALLOC_HASHTABLE(context->std.properties);
zend_hash_init(context->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
@@ -2967,7 +2954,7 @@ static zend_object_value cairo_context_object_new(zend_class_entry *ce TSRMLS_DC
object_properties_init(&context->std, ce);
#endif
retval.handle = zend_objects_store_put(context, NULL, (zend_objects_free_object_storage_t)cairo_context_object_destroy, NULL TSRMLS_CC);
- retval.handlers = &object_handlers;
+ retval.handlers = &cairo_std_object_handlers;
return retval;
}
@@ -2990,12 +2977,6 @@ PHP_MINIT_FUNCTION(cairo_context)
cairo_ce_cairocontext = zend_register_internal_class(&ce TSRMLS_CC);
cairo_ce_cairocontext->create_object = cairo_context_object_new;
- memcpy(&object_handlers, zend_get_std_object_handlers(),
- sizeof object_handlers);
- object_handlers.get_constructor = get_constructor;
-
- PHP_CAIRO_CTOR_WRAPPER_FUNC_INIT(cairo_ce_cairocontext);
-
INIT_CLASS_ENTRY(antialias_ce, "CairoAntialias", NULL);
cairo_ce_cairoantialias = zend_register_internal_class(&antialias_ce TSRMLS_CC);
cairo_ce_cairoantialias->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_FINAL_CLASS;
View
@@ -32,9 +32,6 @@ zend_class_entry *cairo_ce_cairofontslant;
zend_class_entry *cairo_ce_cairofontweight;
zend_class_entry *cairo_ce_cairotoyfontface;
-static zend_object_handlers object_handlers;
-static zend_function ctor_wrapper_func;
-
ZEND_BEGIN_ARG_INFO_EX(CairoToyFontFace___construct_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
ZEND_ARG_INFO(0, family)
ZEND_ARG_INFO(0, slant)
@@ -77,15 +74,6 @@ PHP_METHOD(CairoToyFontFace, __construct)
long family_len, slant = CAIRO_FONT_SLANT_NORMAL, weight = CAIRO_FONT_WEIGHT_NORMAL;
cairo_font_face_object *fontface_object;
- PHP_CAIRO_ERROR_HANDLING(TRUE);
- if (zend_parse_parameters_none() == FAILURE)
- {
- PHP_CAIRO_RESTORE_ERRORS(TRUE);
- return;
- }
- PHP_CAIRO_RESTORE_ERRORS(TRUE);
-
- /*
PHP_CAIRO_ERROR_HANDLING(TRUE)
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll",
&family, &family_len,
@@ -96,10 +84,8 @@ PHP_METHOD(CairoToyFontFace, __construct)
PHP_CAIRO_RESTORE_ERRORS(TRUE)
fontface_object = (cairo_font_face_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
- fontface_object->font_face = cairo_toy_font_face_create((const char *)family, slant, weight);
- fontface_object->is_constructed = 1;
+ fontface_object->font_face = cairo_toy_font_face_create((const char *)family, slant, weight);
php_cairo_throw_exception(cairo_font_face_status(fontface_object->font_face) TSRMLS_CC);
- */
}
/* {{{ proto string cairo_toy_font_face_get_family(CairoToyFontFace object)
@@ -176,28 +162,6 @@ const zend_function_entry cairo_toy_font_face_methods[] = {
};
/* }}} */
-/* We need to override the object handlers */
-static zend_object_value cairo_font_object_new(zend_class_entry *ce TSRMLS_DC)
-{
- zend_object_value object = cairo_font_face_object_new(ce TSRMLS_CC);
-
- object.handlers = &object_handlers;
-
- return object;
-}
-
-static zend_function * get_constructor(zval * object TSRMLS_DC)
-{
- if (Z_OBJCE_P(object) == cairo_ce_cairotoyfontface)
- {
- return zend_get_std_object_handlers()->get_constructor(object TSRMLS_CC);
- }
- else
- {
- return &ctor_wrapper_func;
- }
-}
-
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(cairo_font)
{
@@ -207,13 +171,7 @@ PHP_MINIT_FUNCTION(cairo_font)
INIT_CLASS_ENTRY(toyfont_ce, "CairoToyFontFace", cairo_toy_font_face_methods);
cairo_ce_cairotoyfontface = zend_register_internal_class_ex(&toyfont_ce, cairo_ce_cairofontface, "CairoFontFace" TSRMLS_CC);
- cairo_ce_cairotoyfontface->create_object = cairo_font_object_new;
-
- memcpy(&object_handlers, zend_get_std_object_handlers(),
- sizeof object_handlers);
- object_handlers.get_constructor = get_constructor;
-
- PHP_CAIRO_CTOR_WRAPPER_FUNC_INIT(cairo_ce_cairotoyfontface);
+ cairo_ce_cairotoyfontface->create_object = cairo_font_face_object_new;
INIT_CLASS_ENTRY(fontslant_ce, "CairoFontSlant", NULL);
cairo_ce_cairofontslant = zend_register_internal_class(&fontslant_ce TSRMLS_CC);
View
@@ -120,8 +120,7 @@ zend_object_value cairo_font_face_object_new(zend_class_entry *ce TSRMLS_DC)
font_face = ecalloc(1, sizeof(cairo_font_face_object));
- font_face->std.ce = ce;
- font_face->is_constructed = 0;
+ font_face->std.ce = ce;
ALLOC_HASHTABLE(font_face->std.properties);
zend_hash_init(font_face->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
View
@@ -33,9 +33,6 @@ zend_class_entry *cairo_ce_subpixelorder;
zend_class_entry *cairo_ce_hintstyle;
zend_class_entry *cairo_ce_hintmetrics;
-static zend_object_handlers object_handlers;
-static zend_function ctor_wrapper_func;
-
ZEND_BEGIN_ARG_INFO(CairoFontOptions_fontoptions_args, ZEND_SEND_BY_VAL)
/* ZEND_ARG_OBJ_INFO(0, other, CairoFontOptions, 0) - dang E_RECOVERABLE_ERROR */
ZEND_ARG_INFO(0, other)
@@ -80,9 +77,8 @@ static zend_object_value cairo_font_options_object_new(zend_class_entry *ce TSRM
zval *temp;
font_options = ecalloc(1, sizeof(cairo_font_options_object));
- font_options->font_options = NULL;
- font_options->std.ce = ce;
- font_options->is_constructed = 0;
+ font_options->font_options = NULL;
+ font_options->std.ce = ce;
ALLOC_HASHTABLE(font_options->std.properties);
zend_hash_init(font_options->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
@@ -92,7 +88,7 @@ static zend_object_value cairo_font_options_object_new(zend_class_entry *ce TSRM
object_properties_init(&font_options->std, ce);
#endif
retval.handle = zend_objects_store_put(font_options, NULL, (zend_objects_free_object_storage_t)cairo_font_options_object_destroy, NULL TSRMLS_CC);
- retval.handlers = &object_handlers;
+ retval.handlers = zend_get_std_object_handlers();
return retval;
}
/* }}} */
@@ -106,19 +102,13 @@ PHP_METHOD(CairoFontOptions, __construct)
PHP_CAIRO_ERROR_HANDLING(TRUE)
if (zend_parse_parameters_none() == FAILURE) {
- /* For some reason zend_parse_parameters_none() DOES return FAILURE,
- * but DOESN'T throw an exception. No idea why - I believe this may
- * be the reason for the later segfault after we return from this
- * function.
- */
PHP_CAIRO_RESTORE_ERRORS(TRUE)
return;
}
PHP_CAIRO_RESTORE_ERRORS(TRUE)
font_options_object = (cairo_font_options_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
- font_options_object->font_options = cairo_font_options_create();
- font_options_object->is_constructed = 1;
+ font_options_object->font_options = cairo_font_options_create();
php_cairo_throw_exception(cairo_font_options_status(font_options_object->font_options) TSRMLS_CC);
}
@@ -432,18 +422,6 @@ const zend_function_entry cairo_font_options_methods[] = {
/* }}} */
-static zend_function * get_constructor (zval * object TSRMLS_DC)
-{
- if (Z_OBJCE_P(object) == cairo_ce_cairofontoptions)
- {
- return zend_get_std_object_handlers()->get_constructor(object TSRMLS_CC);
- }
- else
- {
- return &ctor_wrapper_func;
- }
-}
-
/* Helper Functions */
PHP_CAIRO_API zend_class_entry * php_cairo_get_fontoptions_ce()
{
@@ -470,12 +448,6 @@ PHP_MINIT_FUNCTION(cairo_font_options)
cairo_ce_cairofontoptions = zend_register_internal_class(&fontoptions_ce TSRMLS_CC);
cairo_ce_cairofontoptions->create_object = cairo_font_options_object_new;
- memcpy(&object_handlers, zend_get_std_object_handlers(),
- sizeof object_handlers);
- object_handlers.get_constructor = get_constructor;
-
- PHP_CAIRO_CTOR_WRAPPER_FUNC_INIT(cairo_ce_cairofontoptions);
-
INIT_CLASS_ENTRY(hintstyle_ce, "CairoHintStyle", NULL);
cairo_ce_hintstyle = zend_register_internal_class(&hintstyle_ce TSRMLS_CC);
cairo_ce_hintstyle->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_FINAL_CLASS;
Oops, something went wrong. Retry.

0 comments on commit 12dd3d4

Please sign in to comment.