コード例 #1
0
ファイル: router.c プロジェクト: hobbit19/zephir
/**
 * Test\Router constructor
 *
 * @param boolean defaultRoutes
 */
PHP_METHOD(Test_Router, __construct) {

    zval *_1, *_4;
    zval *defaultRoutes_param = NULL, *routes, *_0, *_2 = NULL, *_3;
    zend_bool defaultRoutes;

    ZEPHIR_MM_GROW();
    zephir_fetch_params(1, 0, 1, &defaultRoutes_param);

    if (!defaultRoutes_param) {
        defaultRoutes = 1;
    } else {
        defaultRoutes = zephir_get_boolval(defaultRoutes_param);
    }


    ZEPHIR_INIT_VAR(routes);
    array_init(routes);
    if ((defaultRoutes == 1)) {
        ZEPHIR_INIT_VAR(_0);
        object_init_ex(_0, test_router_route_ce);
        ZEPHIR_INIT_VAR(_1);
        array_init_size(_1, 2);
        add_assoc_long_ex(_1, SS("controller"), 1);
        ZEPHIR_INIT_VAR(_2);
        ZVAL_STRING(_2, "#^/([a-zA-Z0-9\\_\\-]+)[/]{0,1}$#", 1);
        zephir_call_method_p2_noret(_0, "__construct", _2, _1);
        zephir_array_append(&routes, _0, PH_SEPARATE);
        ZEPHIR_INIT_VAR(_3);
        object_init_ex(_3, test_router_route_ce);
        ZEPHIR_INIT_VAR(_4);
        array_init_size(_4, 4);
        add_assoc_long_ex(_4, SS("controller"), 1);
        add_assoc_long_ex(_4, SS("action"), 2);
        add_assoc_long_ex(_4, SS("params"), 3);
        ZEPHIR_INIT_NVAR(_2);
        ZVAL_STRING(_2, "#^/([a-zA-Z0-9\\_\\-]+)/([a-zA-Z0-9\\.\\_]+)(/.*)*$#", 1);
        zephir_call_method_p2_noret(_3, "__construct", _2, _4);
        zephir_array_append(&routes, _3, PH_SEPARATE);
    }
    ZEPHIR_INIT_NVAR(_2);
    array_init(_2);
    zephir_update_property_this(this_ptr, SL("_params"), _2 TSRMLS_CC);
    zephir_update_property_this(this_ptr, SL("_routes"), routes TSRMLS_CC);
    ZEPHIR_MM_RESTORE();

}
コード例 #2
0
ファイル: oo.c プロジェクト: OctavioFuenzalida/zephir
PHP_METHOD(Test_Oo, testInstance7) {

	zval *o;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(o);
	object_init_ex(o, test_oo_ooconstructparams_ce);
	zephir_call_method_p2_noret(o, "__construct", ZEPHIR_GLOBAL(global_false), ZEPHIR_GLOBAL(global_true));
	RETURN_CCTOR(o);

}
コード例 #3
0
ファイル: connection.c プロジェクト: dario1985/adodb
PHP_METHOD(ADOdb_Connection, setAttribute) {

    zval *name_param = NULL, *value, *_0, *_1;
    zval *name = NULL;

    ZEPHIR_MM_GROW();
    zephir_fetch_params(1, 2, 0, &name_param, &value);

    zephir_get_strval(name, name_param);


    _0 = zephir_fetch_nproperty_this(this_ptr, SL("connection"), PH_NOISY_CC);
    if (zephir_is_true(_0)) {
        _1 = zephir_fetch_nproperty_this(this_ptr, SL("connection"), PH_NOISY_CC);
        zephir_call_method_p2_noret(_1, "setattribute", name, value);
    }
    _1 = zephir_fetch_nproperty_this(this_ptr, SL("dso"), PH_NOISY_CC);
    zephir_call_method_p2_noret(_1, "setoption", name, value);
    ZEPHIR_MM_RESTORE();

}
コード例 #4
0
ファイル: oo.c プロジェクト: OctavioFuenzalida/zephir
PHP_METHOD(Test_Oo, testInstance5) {

	zval *o, *_0, *_1;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(o);
	object_init_ex(o, test_oo_ooconstructparams_ce);
	ZEPHIR_INIT_VAR(_0);
	ZVAL_STRING(_0, "a", 1);
	ZEPHIR_INIT_VAR(_1);
	ZVAL_STRING(_1, "b", 1);
	zephir_call_method_p2_noret(o, "__construct", _0, _1);
	RETURN_CCTOR(o);

}
コード例 #5
0
ファイル: oo.c プロジェクト: OctavioFuenzalida/zephir
PHP_METHOD(Test_Oo, testInstance4) {

	zval *o, *a, *b;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	ZVAL_STRING(a, "a", 1);
	ZEPHIR_INIT_VAR(b);
	ZVAL_STRING(b, "b", 1);
	ZEPHIR_INIT_VAR(o);
	object_init_ex(o, test_oo_ooconstructparams_ce);
	zephir_call_method_p2_noret(o, "__construct", a, b);
	RETURN_CCTOR(o);

}
コード例 #6
0
ファイル: oo.c プロジェクト: OctavioFuenzalida/zephir
PHP_METHOD(Test_Oo, testInstance11) {

	zval *o, *_0, *_1;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(o);
	object_init_ex(o, test_oo_ooconstructparams_ce);
	if (zephir_has_constructor(o TSRMLS_CC)) {
		ZEPHIR_INIT_VAR(_0);
		ZVAL_LONG(_0, 1);
		ZEPHIR_INIT_VAR(_1);
		ZVAL_LONG(_1, 2);
		zephir_call_method_p2_noret(o, "__construct", _0, _1);
	}
	RETURN_CCTOR(o);

}
コード例 #7
0
ファイル: route.c プロジェクト: hellcore/zephir
/**
 * Test\Router\Route constructor
 *
 * @param string pattern
 * @param array paths
 * @param array|string httpMethods
 */
PHP_METHOD(Test_Router_Route, __construct) {

	zval *pattern, *paths = NULL, *httpMethods = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 2, &pattern, &paths, &httpMethods);

	if (!paths) {
		ZEPHIR_CPY_WRT(paths, ZEPHIR_GLOBAL(global_null));
	}
	if (!httpMethods) {
		ZEPHIR_CPY_WRT(httpMethods, ZEPHIR_GLOBAL(global_null));
	}


	zephir_call_method_p2_noret(this_ptr, "reconfigure", pattern, paths);
	zephir_update_property_this(this_ptr, SL("_methods"), httpMethods TSRMLS_CC);
	ZEPHIR_MM_RESTORE();

}
コード例 #8
0
/**
 * Hash
 *
 * @param string data 
 * @return string
 */
PHP_METHOD(OAuth_V1_Signature, hash) {

	zval *data_param = NULL, *algorithm = NULL, *hash, *signingKey, *_0, _1, *_2;
	zval *data = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &data_param);

		zephir_get_strval(data, data_param);


	ZEPHIR_INIT_VAR(algorithm);
	zephir_call_method(algorithm, this_ptr, "gethashingalgorithm");
	ZEPHIR_INIT_VAR(_0);
	zephir_fast_strtoupper(_0, algorithm);
	ZEPHIR_CPY_WRT(algorithm, _0);
	do {
		if (ZEPHIR_IS_STRING(algorithm, "HMAC-SHA1")) {
			ZEPHIR_INIT_VAR(signingKey);
			zephir_call_method(signingKey, this_ptr, "getsigningkey");
			ZEPHIR_SINIT_VAR(_1);
			ZVAL_STRING(&_1, "sha1", 0);
			ZEPHIR_INIT_VAR(hash);
			zephir_call_func_p4(hash, "hash_hmac", &_1, data, signingKey, ZEPHIR_GLOBAL(global_true));
			break;
		}
		ZEPHIR_INIT_BNVAR(_0);
		object_init_ex(_0, oauth_v1_unsupportedhashalgorithmexception_ce);
		ZEPHIR_INIT_VAR(_2);
		ZEPHIR_CONCAT_SVS(_2, "Unsupported hashing algorithm (", algorithm, ") used.");
		zephir_call_method_p2_noret(_0, "__construct", algorithm, _2);
		zephir_throw_exception(_0 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	} while(0);

	RETURN_CCTOR(hash);

}
コード例 #9
0
ファイル: spectralnorm.c プロジェクト: CyberLine/zephir
PHP_METHOD(Test_SpectralNorm, Au) {

	zend_function *_9 = NULL;
	zend_bool _0, _3;
	zval *n_param = NULL, *u, *v, *_6 = NULL, *_7 = NULL, *_8 = NULL, *_10 = NULL;
	int n, t, i, j, _1, _2, _4, _5;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 3, 0, &n_param, &u, &v);

		n = zephir_get_intval(n_param);


	_2 = (n - 1);
	_1 = 0;
	_0 = 0;
	if ((_1 <= _2)) {
		while (1) {
			if (_0) {
				_1++;
				if (!((_1 <= _2))) {
					break;
				}
			} else {
				_0 = 1;
			}
			i = _1;
			t = 0;
			_5 = (n - 1);
			_4 = 0;
			_3 = 0;
			if ((_4 <= _5)) {
				while (1) {
					if (_3) {
						_4++;
						if (!((_4 <= _5))) {
							break;
						}
					} else {
						_3 = 1;
					}
					j = _4;
					ZEPHIR_INIT_NVAR(_6);
					ZEPHIR_INIT_NVAR(_7);
					ZVAL_LONG(_7, i);
					ZEPHIR_INIT_NVAR(_8);
					ZVAL_LONG(_8, j);
					zephir_call_method_p2_cache(_6, this_ptr, "ax", &_9, _7, _8);
					ZEPHIR_INIT_NVAR(_7);
					ZEPHIR_INIT_NVAR(_8);
					ZVAL_LONG(_8, j);
					zephir_call_method_p1(_7, u, "offsetge", _8);
					ZEPHIR_INIT_LNVAR(_10);
					mul_function(_10, _6, _7 TSRMLS_CC);
					t += zephir_get_numberval(_10);
				}
			}
			ZEPHIR_INIT_NVAR(_6);
			ZVAL_LONG(_6, i);
			ZEPHIR_INIT_NVAR(_7);
			ZVAL_LONG(_7, t);
			zephir_call_method_p2_noret(v, "offsetset", _6, _7);
		}
	}
	ZEPHIR_MM_RESTORE();

}