com gtk/php-gtk: Override for AtkRelation constructor (sorry, couldn't resist that one) - thanks Andrei: ext/gtk+/atk.overrides
[email protected] (David Soria Parra)
| Newsgroups | php.gtk.cvs |
|---|---|
| Message-ID | <[email protected]> |
Commit: 9e301bcc79a2e245718a01061ccd3e1ba064ea81 Author: Steph Fox <[email protected]> Fri, 23 Jun 2006 17:25:51 +0000 Parents: d1d1b0171bb9f345dd971a51956ebb99d13ee0c3 Branches: master Link: http://git.php.net/?p=gtk/php-gtk.git;a=commitdiff;h=9e301bcc79a2e245718a01061ccd3e1ba064ea81 Log: Override for AtkRelation constructor (sorry, couldn't resist that one) - thanks Andrei Changed paths: M ext/gtk+/atk.overrides Diff: 9e301bcc79a2e245718a01061ccd3e1ba064ea81 diff --git a/ext/gtk+/atk.overrides b/ext/gtk+/atk.overrides index 5a7d9d0..2b25a1e 100644 --- a/ext/gtk+/atk.overrides +++ b/ext/gtk+/atk.overrides @@ -9,3 +9,54 @@ headers %% ignore-glob *_get_type + +%% {{{ AtkRelation + +%% +add-arginfo AtkRelation __construct +static +ZEND_BEGIN_ARG_INFO(ARGINFO_NAME, 0) + ZEND_ARG_INFO(0, targets) + ZEND_ARG_INFO(0, n_targets) + ZEND_ARG_INFO(0, relationship) +ZEND_END_ARG_INFO(); + +%% +override atk_relation_new +PHP_METHOD +{ + zval *php_targets, *php_relationship = NULL; + gint n_targets, i = 0; + AtkRelationType relationship; + AtkObject **targets = NULL; + zval **temp_target; + GObject *wrapped_obj = NULL; + + if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "aV", &php_targets, &php_relationship)) { + PHPG_THROW_CONSTRUCT_EXCEPTION(AtkRelationObject); + } + + if (php_relationship && phpg_gvalue_get_enum(ATK_TYPE_RELATION_TYPE, php_relationship, (gint *)&relationship) == FAILURE) { + PHPG_THROW_CONSTRUCT_EXCEPTION(AtkRelationObject); + } + + n_targets = zend_hash_num_elements(Z_ARRVAL_P(php_targets)); + targets = safe_emalloc(n_targets+1, sizeof(AtkObject *), 0); + + zend_hash_internal_pointer_reset(Z_ARRVAL_P(php_targets)); + while (zend_hash_get_current_data(Z_ARRVAL_P(php_targets), (void **)&temp_target) == SUCCESS) { + targets[i] = ATK_OBJECT(PHPG_GOBJECT(*temp_target)); + zend_hash_move_forward(Z_ARRVAL_P(php_targets)); + i++; + } + + wrapped_obj = (GObject *) atk_relation_new(targets, n_targets, relationship); + efree(targets); + + if (!wrapped_obj) { + PHPG_THROW_CONSTRUCT_EXCEPTION(AtkRelationObject); + } + phpg_gobject_set_wrapper(this_ptr, wrapped_obj TSRMLS_CC); +} + +%% }}}