Thread: [php-directfb-cvs] PHP-DirectFB/src php_directfb.h,1.2,1.3 datatypes.c,1.1.1.1,1.2
Status: Pre-Alpha
Brought to you by:
klan
From: Claudio C. <kl...@us...> - 2004-11-13 16:18:04
|
Update of /cvsroot/php-directfb/PHP-DirectFB/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1384 Modified Files: php_directfb.h datatypes.c Log Message: Added a specific constructor for each datatype. Index: php_directfb.h =================================================================== RCS file: /cvsroot/php-directfb/PHP-DirectFB/src/php_directfb.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** php_directfb.h 11 Nov 2004 18:18:57 -0000 1.2 --- php_directfb.h 13 Nov 2004 16:17:54 -0000 1.3 *************** *** 85,89 **** #define DIRECTFB_DATATYPE_DECLARATION( type ) \ ! extern void type##_new( type *obj, zval *ret ); \ extern void type##_translate( zval *obj, type *ret ); \ extern zend_function_entry type##_class_functions[]; \ --- 85,89 ---- #define DIRECTFB_DATATYPE_DECLARATION( type ) \ ! extern void type##_init( type *obj, zval *ret ); \ extern void type##_translate( zval *obj, type *ret ); \ extern zend_function_entry type##_class_functions[]; \ *************** *** 92,101 **** #define DIRECTFB_DATATYPE_DEFINITION( type ) \ static ZEND_FUNCTION( type ) { \ ! zval *this = getThis(); \ ! type obj; \ ! if (!this) \ return; \ ! memset( &obj, 0, sizeof(obj) ); \ ! type##_new( &obj, this ); \ } \ zend_function_entry type##_class_functions[] = { \ --- 92,103 ---- #define DIRECTFB_DATATYPE_DEFINITION( type ) \ static ZEND_FUNCTION( type ) { \ ! if (!getThis()) \ return; \ ! if (!ZEND_NUM_ARGS()) { \ ! type obj; \ ! memset( &obj, 0, sizeof(obj) ); \ ! type##_init( &obj, getThis() ); \ ! } else \ ! type##_ctor( ZEND_NUM_ARGS(), getThis() ); \ } \ zend_function_entry type##_class_functions[] = { \ *************** *** 166,170 **** { \ object_init_ex( (ret), type##_ce ); \ ! type##_new( (data), (ret) ); \ } --- 168,172 ---- { \ object_init_ex( (ret), type##_ce ); \ ! type##_init( (data), (ret) ); \ } Index: datatypes.c =================================================================== RCS file: /cvsroot/php-directfb/PHP-DirectFB/src/datatypes.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** datatypes.c 10 Nov 2004 12:14:25 -0000 1.1.1.1 --- datatypes.c 13 Nov 2004 16:17:54 -0000 1.2 *************** *** 62,74 **** case T_BYTE: convert_to_long_ex( tmp ); ! *((char*) ret) = clamp( Z_LVAL_PP( tmp ), 0, 0xff ); break; case T_SHORT: convert_to_long_ex( tmp ); ! *((short*) ret) = clamp( Z_LVAL_PP( tmp ), 0, 0xffff ); break; case T_LONG: convert_to_long_ex( tmp ); ! *((int*) ret) = Z_LVAL_PP( tmp ); break; case T_FLOAT: --- 62,74 ---- case T_BYTE: convert_to_long_ex( tmp ); ! *((__u8*) ret) = clamp( Z_LVAL_PP( tmp ), 0, 0xff ); break; case T_SHORT: convert_to_long_ex( tmp ); ! *((__u16*) ret) = clamp( Z_LVAL_PP( tmp ), 0, 0xffff ); break; case T_LONG: convert_to_long_ex( tmp ); ! *((__u32*) ret) = Z_LVAL_PP( tmp ); break; case T_FLOAT: *************** *** 124,129 **** /*********************************** DFBPoint ********************************/ void ! DFBPoint_new( DFBPoint *point, zval *ret ) { add_property_long( ret, "x", point->x ); --- 124,138 ---- /*********************************** DFBPoint ********************************/ + static void + DFBPoint_ctor( int ht, zval *this ) + { + DFBPoint point; + + if (zend_parse_parameters( ht, "ll", &point.x, &point.y ) == SUCCESS) + DFBPoint_init( &point, this ); + } + void ! DFBPoint_init( DFBPoint *point, zval *ret ) { add_property_long( ret, "x", point->x ); *************** *** 139,143 **** GET_ENTRY_LONG( y, &ret->y ); } ! DIRECTFB_DATATYPE_DEFINITION( DFBPoint ) --- 148,152 ---- GET_ENTRY_LONG( y, &ret->y ); } ! DIRECTFB_DATATYPE_DEFINITION( DFBPoint ) *************** *** 145,150 **** /********************************** DFBRectangle *****************************/ void ! DFBRectangle_new( DFBRectangle *rect, zval *ret ) { add_property_long( ret, "x", rect->x ); --- 154,169 ---- /********************************** DFBRectangle *****************************/ + static void + DFBRectangle_ctor( int ht, zval *this ) + { + DFBRectangle rect; + + if (zend_parse_parameters( ht, "llll", + &rect.x, &rect.y, &rect.w, &rect.h ) == SUCCESS) + DFBRectangle_init( &rect, this ); + } + void ! DFBRectangle_init( DFBRectangle *rect, zval *ret ) { add_property_long( ret, "x", rect->x ); *************** *** 170,175 **** /********************************** DFBSpan **********************************/ void ! DFBSpan_new( DFBSpan *span, zval *ret ) { add_property_long( ret, "x", span->x ); --- 189,203 ---- /********************************** DFBSpan **********************************/ + static void + DFBSpan_ctor( int ht, zval *this ) + { + DFBSpan span; + + if (zend_parse_parameters( ht, "ll", &span.x, &span.w ) == SUCCESS) + DFBSpan_init( &span, this ); + } + void ! DFBSpan_init( DFBSpan *span, zval *ret ) { add_property_long( ret, "x", span->x ); *************** *** 191,196 **** /***************************** DFBRegion *************************************/ void ! DFBRegion_new( DFBRegion *reg, zval *ret ) { add_property_long( ret, "x1", reg->x1 ); --- 219,234 ---- /***************************** DFBRegion *************************************/ + static void + DFBRegion_ctor( int ht, zval *this ) + { + DFBRegion reg; + + if (zend_parse_parameters( ht, "llll", + ®.x1, ®.y1, ®.x2, ®.y2 ) == SUCCESS) + DFBRegion_init( ®, this ); + } + void ! DFBRegion_init( DFBRegion *reg, zval *ret ) { add_property_long( ret, "x1", reg->x1 ); *************** *** 216,221 **** /**************************** DFBVertex **************************************/ void ! DFBVertex_new( DFBVertex *ve, zval *ret ) { add_property_double( ret, "x", ve->x ); --- 254,272 ---- /**************************** DFBVertex **************************************/ + static void + DFBVertex_ctor( int ht, zval *this ) + { + double x, y, z; + double w, s, t; + + if (zend_parse_parameters( ht, "dddddd", + &x, &y, &z, &w, &s, &t ) == SUCCESS) { + DFBVertex ve = { x, y, z, w, s, t }; + DFBVertex_init( &ve, this ); + } + } + void ! DFBVertex_init( DFBVertex *ve, zval *ret ) { add_property_double( ret, "x", ve->x ); *************** *** 245,250 **** /****************************** DFBColor *************************************/ void ! DFBColor_new( DFBColor *color, zval *ret ) { add_property_long( ret, "a", color->a ); --- 296,312 ---- /****************************** DFBColor *************************************/ + static void + DFBColor_ctor( int ht, zval *this ) + { + int a, r, g, b; + + if (zend_parse_parameters( ht, "llll", &a, &r, &g, &b ) == SUCCESS) { + DFBColor color = { a, r, g, b }; + DFBColor_init( &color, this ); + } + } + void ! DFBColor_init( DFBColor *color, zval *ret ) { add_property_long( ret, "a", color->a ); *************** *** 271,275 **** void ! DFBCardCapabilities_new( DFBCardCapabilities *caps, zval *ret ) { add_property_long( ret, "acceleration_mask", caps->acceleration_mask ); --- 333,337 ---- void ! DFBCardCapabilities_init( DFBCardCapabilities *caps, zval *ret ) { add_property_long( ret, "acceleration_mask", caps->acceleration_mask ); *************** *** 285,289 **** void ! DFBScreenDescription_new( DFBScreenDescription *dsc, zval *ret ) { add_property_long( ret, "caps", dsc->caps ); --- 347,351 ---- void ! DFBScreenDescription_init( DFBScreenDescription *dsc, zval *ret ) { add_property_long( ret, "caps", dsc->caps ); *************** *** 300,304 **** void ! DFBScreenMixerDescription_new( DFBScreenMixerDescription *dsc, zval *ret) { add_property_long( ret, "caps", dsc->caps ); --- 362,366 ---- void ! DFBScreenMixerDescription_init( DFBScreenMixerDescription *dsc, zval *ret) { add_property_long( ret, "caps", dsc->caps ); *************** *** 313,318 **** /************************** DFBScreenMixerConfig *****************************/ void ! DFBScreenMixerConfig_new( DFBScreenMixerConfig *config, zval *ret ) { zval *bg; --- 375,406 ---- /************************** DFBScreenMixerConfig *****************************/ + static void + DFBScreenMixerConfig_ctor( int ht, zval *this ) + { + DFBScreenMixerConfig config; + zval *bg = NULL; + + memset( &config, 0, sizeof(config) ); + + if (zend_parse_parameters( ht, "llllO!", &config.flags, + &config.tree, &config.level, &config.layers, + &bg, DFBScreenMixerConfig_ce ) == SUCCESS) { + if (!bg) { + MAKE_STD_ZVAL( bg ); + object_init_ex( bg, DFBColor_ce ); + DFBColor_init( &config.background, bg ); + } else + ZVAL_ADDREF( bg ); + + add_property_long( this, "flags", config.flags ); + add_property_long( this, "tree", config.tree ); + add_property_long( this, "level", config.level ); + add_property_long( this, "layers", config.layers ); + add_property_zval( this, "background", bg ); + } + } + void ! DFBScreenMixerConfig_init( DFBScreenMixerConfig *config, zval *ret ) { zval *bg; *************** *** 320,324 **** MAKE_STD_ZVAL( bg ); object_init_ex( bg, DFBColor_ce ); ! DFBColor_new( &config->background, bg ); add_property_long( ret, "flags", config->flags ); --- 408,412 ---- MAKE_STD_ZVAL( bg ); object_init_ex( bg, DFBColor_ce ); ! DFBColor_init( &config->background, bg ); add_property_long( ret, "flags", config->flags ); *************** *** 358,362 **** void ! DFBScreenEncoderDescription_new( DFBScreenEncoderDescription *dsc, zval *ret) { add_property_long( ret, "caps", dsc->caps ); --- 446,450 ---- void ! DFBScreenEncoderDescription_init( DFBScreenEncoderDescription *dsc, zval *ret) { add_property_long( ret, "caps", dsc->caps ); *************** *** 370,375 **** /*************************** DFBScreenEncoderConfig **************************/ void ! DFBScreenEncoderConfig_new( DFBScreenEncoderConfig *config, zval *ret ) { add_property_long( ret, "flags", config->flags ); --- 458,473 ---- /*************************** DFBScreenEncoderConfig **************************/ + static void + DFBScreenEncoderConfig_ctor( int ht, zval *this ) + { + DFBScreenEncoderConfig config; + + if (zend_parse_parameters( ht, "llll", &config.flags, &config.tv_standard, + &config.test_picture, &config.mixer ) == SUCCESS) + DFBScreenEncoderConfig_init( &config, this ); + } + void ! DFBScreenEncoderConfig_init( DFBScreenEncoderConfig *config, zval *ret ) { add_property_long( ret, "flags", config->flags ); *************** *** 402,406 **** void ! DFBScreenOutputDescription_new( DFBScreenOutputDescription *dsc, zval *ret ) { add_property_long( ret, "caps", dsc->caps ); --- 500,504 ---- void ! DFBScreenOutputDescription_init( DFBScreenOutputDescription *dsc, zval *ret ) { add_property_long( ret, "caps", dsc->caps ); *************** *** 414,419 **** /************************** DFBScreenOutputConfig ****************************/ void ! DFBScreenOutputConfig_new( DFBScreenOutputConfig *config, zval *ret ) { add_property_long( ret, "flags", config->flags ); --- 512,527 ---- /************************** DFBScreenOutputConfig ****************************/ + static void + DFBScreenOutputConfig_ctor( int ht, zval *this ) + { + DFBScreenOutputConfig config; + + if (zend_parse_parameters( ht, "llll", &config.flags, &config.encoder, + &config.out_signals, &config.out_connectors ) == SUCCESS) + DFBScreenOutputConfig_init( &config, this ); + } + void ! DFBScreenOutputConfig_init( DFBScreenOutputConfig *config, zval *ret ) { add_property_long( ret, "flags", config->flags ); *************** *** 446,450 **** void ! DFBDisplayLayerDescription_new( DFBDisplayLayerDescription *dsc, zval *ret ) { add_property_long( ret, "type", dsc->type ); --- 554,558 ---- void ! DFBDisplayLayerDescription_init( DFBDisplayLayerDescription *dsc, zval *ret ) { add_property_long( ret, "type", dsc->type ); *************** *** 460,465 **** /*********************** DFBDisplayLayerConfig *******************************/ void ! DFBDisplayLayerConfig_new( DFBDisplayLayerConfig *config, zval *ret ) { add_property_long( ret, "flags", config->flags ); --- 568,584 ---- /*********************** DFBDisplayLayerConfig *******************************/ + static void + DFBDisplayLayerConfig_ctor( int ht, zval *this ) + { + DFBDisplayLayerConfig config; + + if (zend_parse_parameters( ht, "llllll", &config.flags, &config.width, + &config.height, &config.pixelformat, + &config.buffermode, &config.options ) == SUCCESS) + DFBDisplayLayerConfig_init( &config, this ); + } + void ! DFBDisplayLayerConfig_init( DFBDisplayLayerConfig *config, zval *ret ) { add_property_long( ret, "flags", config->flags ); *************** *** 498,503 **** /************************ DFBColorAdjustment *********************************/ void ! DFBColorAdjustment_new( DFBColorAdjustment *adj, zval *ret ) { add_property_long( ret, "flags", adj->flags ); --- 617,635 ---- /************************ DFBColorAdjustment *********************************/ + static void + DFBColorAdjustment_ctor( int ht, zval *this ) + { + int flags; + int b, c, h, s; + + if (zend_parse_parameters( ht, "lllll", &flags, + &b, &c, &h, &s ) == SUCCESS) { + DFBColorAdjustment adj = { flags, b, c, h, s }; + DFBColorAdjustment_init( &adj, this ); + } + } + void ! DFBColorAdjustment_init( DFBColorAdjustment *adj, zval *ret ) { add_property_long( ret, "flags", adj->flags ); *************** *** 533,538 **** /**************************** DFBSurfaceDescription **************************/ void ! DFBSurfaceDescription_new( DFBSurfaceDescription *dsc, zval *ret ) { zval *palette; --- 665,709 ---- /**************************** DFBSurfaceDescription **************************/ + static void + DFBSurfaceDescription_ctor( int ht, zval *this ) + { + DFBSurfaceDescription dsc; + zval *palette = NULL; + + if (zend_parse_parameters( ht, "llllla!", &dsc.flags, + &dsc.caps, &dsc.width, &dsc.height, + &dsc.pixelformat, &palette ) == SUCCESS) { + if (palette) { + zval **entry; + int i = 0; + + while (zend_hash_index_find( Z_ARRVAL_P( palette ), + i++, (void**) &entry ) == SUCCESS) { + if (Z_TYPE_PP( entry ) != IS_OBJECT || + Z_OBJCE_PP( entry ) != DFBColor_ce) { + palette = NULL; + break; + } + } + } + + if (!palette) { + MAKE_STD_ZVAL( palette ); + array_init( palette ); + } else + ZVAL_ADDREF( palette ); + + add_property_long( this, "flags", dsc.flags ); + add_property_long( this, "caps", dsc.caps ); + add_property_long( this, "width", dsc.width ); + add_property_long( this, "height", dsc.height ); + add_property_long( this, "pixelformat", dsc.pixelformat ); + /* no preallocated */ + add_property_zval( this, "palette", palette ); + } + } + void ! DFBSurfaceDescription_init( DFBSurfaceDescription *dsc, zval *ret ) { zval *palette; *************** *** 547,551 **** MAKE_STD_ZVAL( entry ); object_init_ex( entry, DFBColor_ce ); ! DFBColor_new( &dsc->palette.entries[i], entry ); add_index_zval( palette, i, entry ); } --- 718,722 ---- MAKE_STD_ZVAL( entry ); object_init_ex( entry, DFBColor_ce ); ! DFBColor_init( &dsc->palette.entries[i], entry ); add_index_zval( palette, i, entry ); } *************** *** 589,593 **** GET_ENTRY_ARRAY( palette, &pal ); ! while(zend_hash_index_find( Z_ARRVAL_P( pal ), i, (void**) &entry ) == SUCCESS) { if (Z_TYPE_PP( entry ) != IS_OBJECT || --- 760,764 ---- GET_ENTRY_ARRAY( palette, &pal ); ! while (zend_hash_index_find( Z_ARRVAL_P( pal ), i, (void**) &entry ) == SUCCESS) { if (Z_TYPE_PP( entry ) != IS_OBJECT || *************** *** 611,616 **** /************************* DFBPaletteDescription *****************************/ void ! DFBPaletteDescription_new( DFBPaletteDescription *dsc, zval *ret ) { zval *entries; --- 782,822 ---- /************************* DFBPaletteDescription *****************************/ + static void + DFBPaletteDescription_ctor( int ht, zval *this ) + { + DFBPaletteDescription dsc; + zval *entries = NULL; + + if (zend_parse_parameters( ht, "llla!", &dsc.flags, &dsc.caps, + &dsc.size, &entries ) == SUCCESS) { + if (entries) { + zval **entry; + int i = 0; + + while (zend_hash_index_find( Z_ARRVAL_P( entries ), + i++, (void**) &entry ) == SUCCESS) { + if (Z_TYPE_PP( entry ) != IS_OBJECT || + Z_OBJCE_PP( entry ) != DFBColor_ce) { + entries = NULL; + break; + } + } + } + + if (!entries) { + MAKE_STD_ZVAL( entries ); + array_init( entries ); + } else + ZVAL_ADDREF( entries ); + + add_property_long( this, "flags", dsc.flags ); + add_property_long( this, "caps", dsc.caps ); + add_property_long( this, "size", dsc.size ); + add_property_zval( this, "entries", entries ); + } + } + void ! DFBPaletteDescription_init( DFBPaletteDescription *dsc, zval *ret ) { zval *entries; *************** *** 625,629 **** MAKE_STD_ZVAL( color ); object_init_ex( color, DFBColor_ce ); ! DFBColor_new( &dsc->entries[i], color ); add_index_zval( entries, i, color ); } --- 831,835 ---- MAKE_STD_ZVAL( color ); object_init_ex( color, DFBColor_ce ); ! DFBColor_init( &dsc->entries[i], color ); add_index_zval( entries, i, color ); } *************** *** 681,686 **** /************************** DFBWindowDescription *****************************/ void ! DFBWindowDescription_new( DFBWindowDescription *dsc, zval *ret ) { add_property_long( ret, "flags", dsc->flags ); --- 887,903 ---- /************************** DFBWindowDescription *****************************/ + static void + DFBWindowDescription_ctor( int ht, zval *this ) + { + DFBWindowDescription dsc; + + if (zend_parse_parameters( ht, "llllllll", &dsc.flags, &dsc.caps, + &dsc.width, &dsc.height, &dsc.pixelformat, + &dsc.posx, &dsc.posy, &dsc.surface_caps ) == SUCCESS) + DFBWindowDescription_init( &dsc, this ); + } + void ! DFBWindowDescription_init( DFBWindowDescription *dsc, zval *ret ) { add_property_long( ret, "flags", dsc->flags ); *************** *** 728,733 **** /********************** DFBFontDescription ***********************************/ void ! DFBFontDescription_new( DFBFontDescription *dsc, zval *ret ) { add_property_long( ret, "flags", dsc->flags ); --- 945,961 ---- /********************** DFBFontDescription ***********************************/ + static void + DFBFontDescription_ctor( int ht, zval *this ) + { + DFBFontDescription dsc; + + if (zend_parse_parameters( ht, "llllll", &dsc.flags, + &dsc.attributes, &dsc.height, &dsc.width, + &dsc.index, &dsc.fixed_advance ) == SUCCESS) + DFBFontDescription_init( &dsc, this ); + } + void ! DFBFontDescription_init( DFBFontDescription *dsc, zval *ret ) { add_property_long( ret, "flags", dsc->flags ); *************** *** 768,772 **** void ! DFBInputDeviceDescription_new( DFBInputDeviceDescription *dsc, zval *ret ) { add_property_long( ret, "type", dsc->type ); --- 996,1000 ---- void ! DFBInputDeviceDescription_init( DFBInputDeviceDescription *dsc, zval *ret ) { add_property_long( ret, "type", dsc->type ); *************** *** 785,790 **** /**************************** DFBInputEvent **********************************/ void ! DFBInputEvent_new( DFBInputEvent *evt, zval *ret ) { add_property_long( ret, "type", evt->type ); --- 1013,1031 ---- /**************************** DFBInputEvent **********************************/ + static void + DFBInputEvent_ctor( int ht, zval *this ) + { + DFBInputEvent evt; + + if (zend_parse_parameters( ht, "lllllllllllll", &evt.type, + &evt.device_id, &evt.flags, &evt.key_code, + &evt.key_id, &evt.key_symbol, &evt.modifiers, + &evt.locks, &evt.button, &evt.buttons, &evt.axis, + &evt.axisabs, &evt.axisrel ) == SUCCESS) + DFBInputEvent_init( &evt, this ); + } + void ! DFBInputEvent_init( DFBInputEvent *evt, zval *ret ) { add_property_long( ret, "type", evt->type ); *************** *** 848,853 **** /******************************** DFBWindowEvent *****************************/ void ! DFBWindowEvent_new( DFBWindowEvent *evt, zval *ret ) { add_property_long( ret, "type", evt->type ); --- 1089,1108 ---- /******************************** DFBWindowEvent *****************************/ + static void + DFBWindowEvent_ctor( int ht, zval *this ) + { + DFBWindowEvent evt; + + if (zend_parse_parameters( ht, "llllllllllllllll", &evt.type, + &evt.window_id, &evt.x, &evt.y, + &evt.cx, &evt.cy, &evt.step, &evt.w, + &evt.h, &evt.key_code, &evt.key_id, + &evt.key_symbol, &evt.modifiers, &evt.locks, + &evt.button, &evt.buttons ) == SUCCESS) + DFBWindowEvent_init( &evt, this ); + } + void ! DFBWindowEvent_init( DFBWindowEvent *evt, zval *ret ) { add_property_long( ret, "type", evt->type ); |