// midgard_query_constraint_group static PHP_METHOD(midgard_query_constraint_group, __construct) { char *type = "AND"; int type_len = 3, num_varargs = 0; zval ***varargs = NULL; #if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 2 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &type, &type_len) == FAILURE) { zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Failed to create constraint group"); return; } #else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s*", &type, &type_len, &varargs, &num_varargs) == FAILURE) { zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Failed to create constraint group"); return; } #endif MidgardQueryConstraintGroup *constraint_group = NULL; if (num_varargs) { MidgardQueryConstraintSimple **constraints = ecalloc(num_varargs, sizeof(MidgardQueryConstraintSimple *)); size_t i; for (i = 0; i < num_varargs; i++) { constraints[i] = MIDGARD_QUERY_CONSTRAINT_SIMPLE(__php_gobject_ptr(*varargs[i])); } efree(varargs); constraint_group = midgard_query_constraint_group_new_with_constraints(type, constraints, num_varargs); efree(constraints); if (!constraint_group) { zend_throw_exception_ex(ce_midgard_error_exception, 0 TSRMLS_CC, "Failed to create constraint group"); return; } } else { constraint_group = midgard_query_constraint_group_new(); if (!constraint_group) { zend_throw_exception_ex(ce_midgard_error_exception, 0 TSRMLS_CC, "Failed to create constraint group"); return; } zend_bool result = midgard_query_constraint_group_set_group_type(constraint_group, type); if (!result) { g_object_unref(constraint_group); zend_throw_exception_ex(ce_midgard_error_exception, 0 TSRMLS_CC, "Failed to create constraint group: couldn't set type"); return; } } MGD_PHP_SET_GOBJECT(getThis(), constraint_group); }
static PHP_METHOD(midgard_query_constraint_group, set_type) { char *type = NULL; int type_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &type, &type_len) == FAILURE) { return; } MidgardQueryConstraintGroup *constraint_group = MIDGARD_QUERY_CONSTRAINT_GROUP(__php_gobject_ptr(getThis())); zend_bool result = midgard_query_constraint_group_set_group_type(constraint_group, type); RETURN_BOOL(result); }
static void __midgard_query_constraint_group_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { MidgardQueryConstraintGroup *self = (MidgardQueryConstraintGroup *) (object); switch (property_id) { case PROPERTY_GROUPTYPE: midgard_query_constraint_group_set_group_type (self, g_value_get_string (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (self, property_id, pspec); break; } }