mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 04:16:28 +00:00
Pass around the TSRM
This commit is contained in:
+65
-65
@@ -136,7 +136,7 @@ int TWIG_INSTANCE_OF_USERLAND(zval *object, char *interface TSRMLS_DC)
|
|||||||
return instanceof_function(Z_OBJCE_P(object), *pce TSRMLS_CC);
|
return instanceof_function(Z_OBJCE_P(object), *pce TSRMLS_CC);
|
||||||
}
|
}
|
||||||
|
|
||||||
zval *TWIG_GET_ARRAYOBJECT_ELEMENT(zval *object, zval *offset)
|
zval *TWIG_GET_ARRAYOBJECT_ELEMENT(zval *object, zval *offset TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zend_class_entry *ce = Z_OBJCE_P(object);
|
zend_class_entry *ce = Z_OBJCE_P(object);
|
||||||
zval *retval;
|
zval *retval;
|
||||||
@@ -159,7 +159,7 @@ zval *TWIG_GET_ARRAYOBJECT_ELEMENT(zval *object, zval *offset)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TWIG_ISSET_ARRAYOBJECT_ELEMENT(zval *object, zval *offset)
|
int TWIG_ISSET_ARRAYOBJECT_ELEMENT(zval *object, zval *offset TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zend_class_entry *ce = Z_OBJCE_P(object);
|
zend_class_entry *ce = Z_OBJCE_P(object);
|
||||||
zval *retval;
|
zval *retval;
|
||||||
@@ -194,7 +194,7 @@ char *TWIG_STRTOLOWER_ZVAL(zval *item)
|
|||||||
return item_dup;
|
return item_dup;
|
||||||
}
|
}
|
||||||
|
|
||||||
zval *TWIG_CALL_USER_FUNC_ARRAY(zval *object, char *function, zval *arguments)
|
zval *TWIG_CALL_USER_FUNC_ARRAY(zval *object, char *function, zval *arguments TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zend_fcall_info fci;
|
zend_fcall_info fci;
|
||||||
zval ***args = NULL;
|
zval ***args = NULL;
|
||||||
@@ -237,7 +237,7 @@ zval *TWIG_CALL_USER_FUNC_ARRAY(zval *object, char *function, zval *arguments)
|
|||||||
if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE) {
|
if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE) {
|
||||||
zval_dtor(zfunction);
|
zval_dtor(zfunction);
|
||||||
efree(zfunction);
|
efree(zfunction);
|
||||||
zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Could not execute %s::%s()", zend_get_class_entry(object)->name, function);
|
zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 0 TSRMLS_CC, "Could not execute %s::%s()", zend_get_class_entry(object TSRMLS_CC)->name, function);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args) {
|
if (args) {
|
||||||
@@ -248,18 +248,18 @@ zval *TWIG_CALL_USER_FUNC_ARRAY(zval *object, char *function, zval *arguments)
|
|||||||
return retval_ptr;
|
return retval_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TWIG_CALL_BOOLEAN(zval *object, char *functionName)
|
int TWIG_CALL_BOOLEAN(zval *object, char *functionName TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zval *ret;
|
zval *ret;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
ret = TWIG_CALL_USER_FUNC_ARRAY(object, functionName, NULL);
|
ret = TWIG_CALL_USER_FUNC_ARRAY(object, functionName, NULL TSRMLS_CC);
|
||||||
res = Z_LVAL_P(ret);
|
res = Z_LVAL_P(ret);
|
||||||
zval_ptr_dtor(&ret);
|
zval_ptr_dtor(&ret);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
zval *TWIG_GET_STATIC_PROPERTY(zval *class, char *prop_name)
|
zval *TWIG_GET_STATIC_PROPERTY(zval *class, char *prop_name TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zval **tmp_zval;
|
zval **tmp_zval;
|
||||||
zend_class_entry *ce;
|
zend_class_entry *ce;
|
||||||
@@ -268,7 +268,7 @@ zval *TWIG_GET_STATIC_PROPERTY(zval *class, char *prop_name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ce = zend_get_class_entry(class);
|
ce = zend_get_class_entry(class TSRMLS_CC);
|
||||||
#if PHP_VERSION_ID >= 50400
|
#if PHP_VERSION_ID >= 50400
|
||||||
tmp_zval = zend_std_get_static_property(ce, prop_name, strlen(prop_name), 0, NULL TSRMLS_CC);
|
tmp_zval = zend_std_get_static_property(ce, prop_name, strlen(prop_name), 0, NULL TSRMLS_CC);
|
||||||
#else
|
#else
|
||||||
@@ -277,15 +277,15 @@ zval *TWIG_GET_STATIC_PROPERTY(zval *class, char *prop_name)
|
|||||||
return *tmp_zval;
|
return *tmp_zval;
|
||||||
}
|
}
|
||||||
|
|
||||||
zval *TWIG_GET_ARRAY_ELEMENT_ZVAL(zval *class, zval *prop_name)
|
zval *TWIG_GET_ARRAY_ELEMENT_ZVAL(zval *class, zval *prop_name TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zval **tmp_zval;
|
zval **tmp_zval;
|
||||||
char *tmp_name;
|
char *tmp_name;
|
||||||
|
|
||||||
if (class == NULL || Z_TYPE_P(class) != IS_ARRAY || Z_TYPE_P(prop_name) != IS_STRING) {
|
if (class == NULL || Z_TYPE_P(class) != IS_ARRAY || Z_TYPE_P(prop_name) != IS_STRING) {
|
||||||
if (class != NULL && Z_TYPE_P(class) == IS_OBJECT && TWIG_INSTANCE_OF(class, zend_ce_arrayaccess)) {
|
if (class != NULL && Z_TYPE_P(class) == IS_OBJECT && TWIG_INSTANCE_OF(class, zend_ce_arrayaccess TSRMLS_CC)) {
|
||||||
// array access object
|
// array access object
|
||||||
return TWIG_GET_ARRAYOBJECT_ELEMENT(class, prop_name);
|
return TWIG_GET_ARRAYOBJECT_ELEMENT(class, prop_name TSRMLS_CC);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -298,7 +298,7 @@ zval *TWIG_GET_ARRAY_ELEMENT_ZVAL(zval *class, zval *prop_name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
zval *TWIG_GET_ARRAY_ELEMENT(zval *class, char *prop_name, int prop_name_length)
|
zval *TWIG_GET_ARRAY_ELEMENT(zval *class, char *prop_name, int prop_name_length TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zval **tmp_zval;
|
zval **tmp_zval;
|
||||||
|
|
||||||
@@ -306,14 +306,14 @@ zval *TWIG_GET_ARRAY_ELEMENT(zval *class, char *prop_name, int prop_name_length)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class != NULL && Z_TYPE_P(class) == IS_OBJECT && TWIG_INSTANCE_OF(class, zend_ce_arrayaccess)) {
|
if (class != NULL && Z_TYPE_P(class) == IS_OBJECT && TWIG_INSTANCE_OF(class, zend_ce_arrayaccess TSRMLS_CC)) {
|
||||||
// array access object
|
// array access object
|
||||||
zval *tmp_name_zval;
|
zval *tmp_name_zval;
|
||||||
zval *tmp_ret_zval;
|
zval *tmp_ret_zval;
|
||||||
|
|
||||||
ALLOC_INIT_ZVAL(tmp_name_zval);
|
ALLOC_INIT_ZVAL(tmp_name_zval);
|
||||||
ZVAL_STRING(tmp_name_zval, prop_name, 1);
|
ZVAL_STRING(tmp_name_zval, prop_name, 1);
|
||||||
tmp_ret_zval = TWIG_GET_ARRAYOBJECT_ELEMENT(class, tmp_name_zval);
|
tmp_ret_zval = TWIG_GET_ARRAYOBJECT_ELEMENT(class, tmp_name_zval TSRMLS_CC);
|
||||||
zval_dtor(tmp_name_zval);
|
zval_dtor(tmp_name_zval);
|
||||||
efree(tmp_name_zval);
|
efree(tmp_name_zval);
|
||||||
return tmp_ret_zval;
|
return tmp_ret_zval;
|
||||||
@@ -325,19 +325,19 @@ zval *TWIG_GET_ARRAY_ELEMENT(zval *class, char *prop_name, int prop_name_length)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
zval *TWIG_PROPERTY(zval *object, zval *propname)
|
zval *TWIG_PROPERTY(zval *object, zval *propname TSRMLS_DC)
|
||||||
{
|
{
|
||||||
char *prot_name;
|
char *prot_name;
|
||||||
int prot_name_length;
|
int prot_name_length;
|
||||||
zval *tmp = NULL;
|
zval *tmp = NULL;
|
||||||
|
|
||||||
tmp = TWIG_GET_ARRAY_ELEMENT(object, Z_STRVAL_P(propname), Z_STRLEN_P(propname));
|
tmp = TWIG_GET_ARRAY_ELEMENT(object, Z_STRVAL_P(propname), Z_STRLEN_P(propname) TSRMLS_CC);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
zend_mangle_property_name(&prot_name, &prot_name_length, "*", 1, Z_STRVAL_P(propname), Z_STRLEN_P(propname), 0);
|
zend_mangle_property_name(&prot_name, &prot_name_length, "*", 1, Z_STRVAL_P(propname), Z_STRLEN_P(propname), 0);
|
||||||
tmp = TWIG_GET_ARRAY_ELEMENT(object, prot_name, prot_name_length);
|
tmp = TWIG_GET_ARRAY_ELEMENT(object, prot_name, prot_name_length TSRMLS_CC);
|
||||||
efree(prot_name);
|
efree(prot_name);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
return tmp;
|
return tmp;
|
||||||
@@ -358,7 +358,7 @@ zval *TWIG_PROPERTY(zval *object, zval *propname)
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TWIG_HAS_PROPERTY(zval *object, zval *propname)
|
int TWIG_HAS_PROPERTY(zval *object, zval *propname TSRMLS_DC)
|
||||||
{
|
{
|
||||||
if (Z_OBJ_HT_P(object)->has_property) {
|
if (Z_OBJ_HT_P(object)->has_property) {
|
||||||
#if PHP_VERSION_ID >= 50400
|
#if PHP_VERSION_ID >= 50400
|
||||||
@@ -370,13 +370,13 @@ int TWIG_HAS_PROPERTY(zval *object, zval *propname)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
zval *TWIG_PROPERTY_CHAR(zval *object, char *propname)
|
zval *TWIG_PROPERTY_CHAR(zval *object, char *propname TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zval *tmp_name_zval, *tmp;
|
zval *tmp_name_zval, *tmp;
|
||||||
|
|
||||||
ALLOC_INIT_ZVAL(tmp_name_zval);
|
ALLOC_INIT_ZVAL(tmp_name_zval);
|
||||||
ZVAL_STRING(tmp_name_zval, propname, 1);
|
ZVAL_STRING(tmp_name_zval, propname, 1);
|
||||||
tmp = TWIG_PROPERTY(object, tmp_name_zval);
|
tmp = TWIG_PROPERTY(object, tmp_name_zval TSRMLS_CC);
|
||||||
zval_dtor(tmp_name_zval);
|
zval_dtor(tmp_name_zval);
|
||||||
efree(tmp_name_zval);
|
efree(tmp_name_zval);
|
||||||
return tmp;
|
return tmp;
|
||||||
@@ -387,7 +387,7 @@ int TWIG_CALL_B_0(zval *object, char *method)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
zval *TWIG_CALL_S(zval *object, char *method, char *arg0)
|
zval *TWIG_CALL_S(zval *object, char *method, char *arg0 TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zend_fcall_info fci;
|
zend_fcall_info fci;
|
||||||
zval **args[1];
|
zval **args[1];
|
||||||
@@ -426,12 +426,12 @@ zval *TWIG_CALL_S(zval *object, char *method, char *arg0)
|
|||||||
return retval_ptr;
|
return retval_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TWIG_CALL_SB(zval *object, char *method, char *arg0)
|
int TWIG_CALL_SB(zval *object, char *method, char *arg0 TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zval *retval_ptr;
|
zval *retval_ptr;
|
||||||
int success;
|
int success;
|
||||||
|
|
||||||
retval_ptr = TWIG_CALL_S(object, method, arg0);
|
retval_ptr = TWIG_CALL_S(object, method, arg0 TSRMLS_CC);
|
||||||
success = (retval_ptr && (Z_TYPE_P(retval_ptr) == IS_BOOL) && Z_LVAL_P(retval_ptr));
|
success = (retval_ptr && (Z_TYPE_P(retval_ptr) == IS_BOOL) && Z_LVAL_P(retval_ptr));
|
||||||
|
|
||||||
if (retval_ptr) {
|
if (retval_ptr) {
|
||||||
@@ -441,7 +441,7 @@ int TWIG_CALL_SB(zval *object, char *method, char *arg0)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TWIG_CALL_Z(zval *object, char *method, zval *arg1)
|
int TWIG_CALL_Z(zval *object, char *method, zval *arg1 TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zend_fcall_info fci;
|
zend_fcall_info fci;
|
||||||
zval **args[1];
|
zval **args[1];
|
||||||
@@ -487,7 +487,7 @@ int TWIG_CALL_Z(zval *object, char *method, zval *arg1)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TWIG_CALL_ZZ(zval *object, char *method, zval *arg1, zval *arg2)
|
int TWIG_CALL_ZZ(zval *object, char *method, zval *arg1, zval *arg2 TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zend_fcall_info fci;
|
zend_fcall_info fci;
|
||||||
zval **args[2];
|
zval **args[2];
|
||||||
@@ -534,7 +534,7 @@ int TWIG_CALL_ZZ(zval *object, char *method, zval *arg1, zval *arg2)
|
|||||||
# define Z_UNSET_ISREF_P(pz) pz->is_ref = 0
|
# define Z_UNSET_ISREF_P(pz) pz->is_ref = 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void TWIG_NEW(zval *object, char *class, zval *value)
|
void TWIG_NEW(zval *object, char *class, zval *value TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zend_class_entry **pce;
|
zend_class_entry **pce;
|
||||||
|
|
||||||
@@ -547,7 +547,7 @@ void TWIG_NEW(zval *object, char *class, zval *value)
|
|||||||
Z_SET_REFCOUNT_P(object, 1);
|
Z_SET_REFCOUNT_P(object, 1);
|
||||||
Z_UNSET_ISREF_P(object);
|
Z_UNSET_ISREF_P(object);
|
||||||
|
|
||||||
TWIG_CALL_Z(object, "__construct", value);
|
TWIG_CALL_Z(object, "__construct", value TSRMLS_CC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void twig_add_array_key_to_string(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
|
static void twig_add_array_key_to_string(zval **zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
|
||||||
@@ -576,7 +576,7 @@ static void twig_add_array_key_to_string(zval **zv TSRMLS_DC, int num_args, va_l
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *TWIG_IMPLODE_ARRAY_KEYS(char *joiner, zval *array)
|
char *TWIG_IMPLODE_ARRAY_KEYS(char *joiner, zval *array TSRMLS_DC)
|
||||||
{
|
{
|
||||||
smart_str collector = { 0, 0, 0 };
|
smart_str collector = { 0, 0, 0 };
|
||||||
|
|
||||||
@@ -587,7 +587,7 @@ char *TWIG_IMPLODE_ARRAY_KEYS(char *joiner, zval *array)
|
|||||||
return collector.c;
|
return collector.c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TWIG_THROW_EXCEPTION(char *exception_name, char *message, ...)
|
static void TWIG_THROW_EXCEPTION(char *exception_name, char *message TSRMLS_DC, ...)
|
||||||
{
|
{
|
||||||
char *buffer;
|
char *buffer;
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -606,7 +606,7 @@ static void TWIG_THROW_EXCEPTION(char *exception_name, char *message, ...)
|
|||||||
zend_throw_exception_ex(*pce, 0 TSRMLS_CC, buffer);
|
zend_throw_exception_ex(*pce, 0 TSRMLS_CC, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *TWIG_GET_CLASS_NAME(zval *object)
|
char *TWIG_GET_CLASS_NAME(zval *object TSRMLS_DC)
|
||||||
{
|
{
|
||||||
char *class_name;
|
char *class_name;
|
||||||
zend_uint class_name_len;
|
zend_uint class_name_len;
|
||||||
@@ -662,12 +662,12 @@ static int twig_add_dyn_property_to_class(zval **pptr TSRMLS_DC, int num_args, v
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void twig_add_class_to_cache(zval *cache, zval *object, char *class_name)
|
static void twig_add_class_to_cache(zval *cache, zval *object, char *class_name TSRMLS_DC)
|
||||||
{
|
{
|
||||||
zval *class_info, *class_methods, *class_properties;
|
zval *class_info, *class_methods, *class_properties;
|
||||||
zend_class_entry *class_ce;
|
zend_class_entry *class_ce;
|
||||||
|
|
||||||
class_ce = zend_get_class_entry(object);
|
class_ce = zend_get_class_entry(object TSRMLS_CC);
|
||||||
|
|
||||||
ALLOC_INIT_ZVAL(class_info);
|
ALLOC_INIT_ZVAL(class_info);
|
||||||
ALLOC_INIT_ZVAL(class_methods);
|
ALLOC_INIT_ZVAL(class_methods);
|
||||||
@@ -729,7 +729,7 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|||||||
if (strcmp("method", type) != 0) {
|
if (strcmp("method", type) != 0) {
|
||||||
// printf("XXXmethod: %s\n", type);
|
// printf("XXXmethod: %s\n", type);
|
||||||
if ((TWIG_ARRAY_KEY_EXISTS(object, item))
|
if ((TWIG_ARRAY_KEY_EXISTS(object, item))
|
||||||
|| (TWIG_INSTANCE_OF(object, zend_ce_arrayaccess) && TWIG_ISSET_ARRAYOBJECT_ELEMENT(object, item))
|
|| (TWIG_INSTANCE_OF(object, zend_ce_arrayaccess TSRMLS_CC) && TWIG_ISSET_ARRAYOBJECT_ELEMENT(object, item TSRMLS_CC))
|
||||||
) {
|
) {
|
||||||
zval *ret;
|
zval *ret;
|
||||||
|
|
||||||
@@ -737,7 +737,7 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|||||||
RETURN_TRUE;
|
RETURN_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = TWIG_GET_ARRAY_ELEMENT(object, Z_STRVAL_P(item), Z_STRLEN_P(item));
|
ret = TWIG_GET_ARRAY_ELEMENT(object, Z_STRVAL_P(item), Z_STRLEN_P(item) TSRMLS_CC);
|
||||||
RETVAL_ZVAL(ret, 1, 0);
|
RETVAL_ZVAL(ret, 1, 0);
|
||||||
if (free_ret) {
|
if (free_ret) {
|
||||||
zval_ptr_dtor(&ret);
|
zval_ptr_dtor(&ret);
|
||||||
@@ -757,7 +757,7 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|||||||
if (isDefinedTest) {
|
if (isDefinedTest) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env"), "isStrictVariables")) {
|
if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "isStrictVariables" TSRMLS_CC)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -771,9 +771,9 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (Z_TYPE_P(object) == IS_OBJECT) {
|
if (Z_TYPE_P(object) == IS_OBJECT) {
|
||||||
TWIG_THROW_EXCEPTION("Twig_Error_Runtime", "Key \"%s\" in object (with ArrayAccess) of type \"%s\" does not exist", Z_STRVAL_P(item), TWIG_GET_CLASS_NAME(object));
|
TWIG_THROW_EXCEPTION("Twig_Error_Runtime", "Key \"%s\" in object (with ArrayAccess) of type \"%s\" does not exist" TSRMLS_CC, Z_STRVAL_P(item), TWIG_GET_CLASS_NAME(object TSRMLS_CC));
|
||||||
} else {
|
} else {
|
||||||
TWIG_THROW_EXCEPTION("Twig_Error_Runtime", "Key \"%s\" for array with keys \"%s\" does not exist", Z_STRVAL_P(item), TWIG_IMPLODE_ARRAY_KEYS(", ", object));
|
TWIG_THROW_EXCEPTION("Twig_Error_Runtime", "Key \"%s\" for array with keys \"%s\" does not exist" TSRMLS_CC, Z_STRVAL_P(item), TWIG_IMPLODE_ARRAY_KEYS(", ", object TSRMLS_CC));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -797,10 +797,10 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|||||||
throw new Twig_Error_Runtime(sprintf('Item "%s" for "%s" does not exist', $item, implode(', ', array_keys($object))));
|
throw new Twig_Error_Runtime(sprintf('Item "%s" for "%s" does not exist', $item, implode(', ', array_keys($object))));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env"), "isStrictVariables")) {
|
if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "isStrictVariables" TSRMLS_CC)) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
TWIG_THROW_EXCEPTION("Twig_Error_Runtime", "Item \"%s\" for \"%s\" does not exist", Z_STRVAL_P(item), TWIG_IMPLODE_ARRAY_KEYS(", ", object));
|
TWIG_THROW_EXCEPTION("Twig_Error_Runtime", "Item \"%s\" for \"%s\" does not exist" TSRMLS_CC, Z_STRVAL_P(item), TWIG_IMPLODE_ARRAY_KEYS(", ", object TSRMLS_CC));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -821,11 +821,11 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|||||||
if (Z_TYPE_P(object) == IS_OBJECT) {
|
if (Z_TYPE_P(object) == IS_OBJECT) {
|
||||||
char *class_name = NULL;
|
char *class_name = NULL;
|
||||||
|
|
||||||
class_name = TWIG_GET_CLASS_NAME(object);
|
class_name = TWIG_GET_CLASS_NAME(object TSRMLS_CC);
|
||||||
tmp_self_cache = TWIG_GET_STATIC_PROPERTY(template, "cache");
|
tmp_self_cache = TWIG_GET_STATIC_PROPERTY(template, "cache" TSRMLS_CC);
|
||||||
|
|
||||||
if (!TWIG_GET_ARRAY_ELEMENT(tmp_self_cache, class_name, strlen(class_name))) {
|
if (!TWIG_GET_ARRAY_ELEMENT(tmp_self_cache, class_name, strlen(class_name) TSRMLS_CC)) {
|
||||||
twig_add_class_to_cache(tmp_self_cache, object, class_name);
|
twig_add_class_to_cache(tmp_self_cache, object, class_name TSRMLS_CC);
|
||||||
}
|
}
|
||||||
efree(class_name);
|
efree(class_name);
|
||||||
}
|
}
|
||||||
@@ -851,27 +851,27 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|||||||
zval *tmp_class, *tmp_properties, *tmp_item;
|
zval *tmp_class, *tmp_properties, *tmp_item;
|
||||||
char *class_name = NULL;
|
char *class_name = NULL;
|
||||||
|
|
||||||
class_name = TWIG_GET_CLASS_NAME(object);
|
class_name = TWIG_GET_CLASS_NAME(object TSRMLS_CC);
|
||||||
tmp_class = TWIG_GET_ARRAY_ELEMENT(tmp_self_cache, class_name, strlen(class_name));
|
tmp_class = TWIG_GET_ARRAY_ELEMENT(tmp_self_cache, class_name, strlen(class_name) TSRMLS_CC);
|
||||||
tmp_properties = TWIG_GET_ARRAY_ELEMENT(tmp_class, "properties", strlen("properties"));
|
tmp_properties = TWIG_GET_ARRAY_ELEMENT(tmp_class, "properties", strlen("properties") TSRMLS_CC);
|
||||||
tmp_item = TWIG_GET_ARRAY_ELEMENT_ZVAL(tmp_properties, item);
|
tmp_item = TWIG_GET_ARRAY_ELEMENT_ZVAL(tmp_properties, item TSRMLS_CC);
|
||||||
|
|
||||||
efree(class_name);
|
efree(class_name);
|
||||||
|
|
||||||
if (tmp_item || TWIG_HAS_PROPERTY(object, item) || TWIG_ARRAY_KEY_EXISTS(object, item) // FIXME: Array key? is that array access here?
|
if (tmp_item || TWIG_HAS_PROPERTY(object, item TSRMLS_CC) || TWIG_ARRAY_KEY_EXISTS(object, item) // FIXME: Array key? is that array access here?
|
||||||
) {
|
) {
|
||||||
if (isDefinedTest) {
|
if (isDefinedTest) {
|
||||||
RETURN_TRUE;
|
RETURN_TRUE;
|
||||||
}
|
}
|
||||||
if (TWIG_CALL_SB(TWIG_PROPERTY_CHAR(template, "env"), "hasExtension", "sandbox")) {
|
if (TWIG_CALL_SB(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "hasExtension", "sandbox" TSRMLS_CC)) {
|
||||||
TWIG_CALL_ZZ(TWIG_CALL_S(TWIG_PROPERTY_CHAR(template, "env"), "getExtension", "sandbox"), "checkPropertyAllowed", object, item);
|
TWIG_CALL_ZZ(TWIG_CALL_S(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "getExtension", "sandbox" TSRMLS_CC), "checkPropertyAllowed", object, item TSRMLS_CC);
|
||||||
}
|
}
|
||||||
if (EG(exception)) {
|
if (EG(exception)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
convert_to_string(item);
|
convert_to_string(item);
|
||||||
ret = TWIG_PROPERTY(object, item);
|
ret = TWIG_PROPERTY(object, item TSRMLS_CC);
|
||||||
RETURN_ZVAL(ret, 1, 0);
|
RETURN_ZVAL(ret, 1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -896,7 +896,7 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|||||||
zval *tmp_class, *tmp_methods;
|
zval *tmp_class, *tmp_methods;
|
||||||
char *class_name = NULL;
|
char *class_name = NULL;
|
||||||
|
|
||||||
class_name = TWIG_GET_CLASS_NAME(object);
|
class_name = TWIG_GET_CLASS_NAME(object TSRMLS_CC);
|
||||||
lcItem_length = strlen(lcItem);
|
lcItem_length = strlen(lcItem);
|
||||||
tmp_method_name_get = emalloc(4 + lcItem_length);
|
tmp_method_name_get = emalloc(4 + lcItem_length);
|
||||||
tmp_method_name_is = emalloc(3 + lcItem_length);
|
tmp_method_name_is = emalloc(3 + lcItem_length);
|
||||||
@@ -904,17 +904,17 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|||||||
sprintf(tmp_method_name_get, "get%s", lcItem);
|
sprintf(tmp_method_name_get, "get%s", lcItem);
|
||||||
sprintf(tmp_method_name_is, "is%s", lcItem);
|
sprintf(tmp_method_name_is, "is%s", lcItem);
|
||||||
|
|
||||||
tmp_class = TWIG_GET_ARRAY_ELEMENT(tmp_self_cache, class_name, strlen(class_name));
|
tmp_class = TWIG_GET_ARRAY_ELEMENT(tmp_self_cache, class_name, strlen(class_name) TSRMLS_CC);
|
||||||
tmp_methods = TWIG_GET_ARRAY_ELEMENT(tmp_class, "methods", strlen("methods"));
|
tmp_methods = TWIG_GET_ARRAY_ELEMENT(tmp_class, "methods", strlen("methods") TSRMLS_CC);
|
||||||
efree(class_name);
|
efree(class_name);
|
||||||
|
|
||||||
if (TWIG_GET_ARRAY_ELEMENT(tmp_methods, lcItem, lcItem_length)) {
|
if (TWIG_GET_ARRAY_ELEMENT(tmp_methods, lcItem, lcItem_length TSRMLS_CC)) {
|
||||||
method = Z_STRVAL_P(item);
|
method = Z_STRVAL_P(item);
|
||||||
} else if (TWIG_GET_ARRAY_ELEMENT(tmp_methods, tmp_method_name_get, lcItem_length + 3)) {
|
} else if (TWIG_GET_ARRAY_ELEMENT(tmp_methods, tmp_method_name_get, lcItem_length + 3 TSRMLS_CC)) {
|
||||||
method = tmp_method_name_get;
|
method = tmp_method_name_get;
|
||||||
} else if (TWIG_GET_ARRAY_ELEMENT(tmp_methods, tmp_method_name_is, lcItem_length + 2)) {
|
} else if (TWIG_GET_ARRAY_ELEMENT(tmp_methods, tmp_method_name_is, lcItem_length + 2 TSRMLS_CC)) {
|
||||||
method = tmp_method_name_is;
|
method = tmp_method_name_is;
|
||||||
} else if (TWIG_GET_ARRAY_ELEMENT(tmp_methods, "__call", 6)) {
|
} else if (TWIG_GET_ARRAY_ELEMENT(tmp_methods, "__call", 6 TSRMLS_CC)) {
|
||||||
method = Z_STRVAL_P(item);
|
method = Z_STRVAL_P(item);
|
||||||
/*
|
/*
|
||||||
} else {
|
} else {
|
||||||
@@ -934,10 +934,10 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|||||||
if (isDefinedTest) {
|
if (isDefinedTest) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env"), "isStrictVariables")) {
|
if (ignoreStrictCheck || !TWIG_CALL_BOOLEAN(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "isStrictVariables" TSRMLS_CC)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TWIG_THROW_EXCEPTION("Twig_Error_Runtime", "Method \"%s\" for object \"%s\" does not exist", Z_STRVAL_P(item), TWIG_GET_CLASS_NAME(object));
|
TWIG_THROW_EXCEPTION("Twig_Error_Runtime", "Method \"%s\" for object \"%s\" does not exist" TSRMLS_CC, Z_STRVAL_P(item), TWIG_GET_CLASS_NAME(object TSRMLS_CC));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isDefinedTest) {
|
if (isDefinedTest) {
|
||||||
@@ -951,8 +951,8 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|||||||
$this->env->getExtension('sandbox')->checkMethodAllowed($object, $method);
|
$this->env->getExtension('sandbox')->checkMethodAllowed($object, $method);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (TWIG_CALL_SB(TWIG_PROPERTY_CHAR(template, "env"), "hasExtension", "sandbox")) {
|
if (TWIG_CALL_SB(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "hasExtension", "sandbox" TSRMLS_CC)) {
|
||||||
TWIG_CALL_ZZ(TWIG_CALL_S(TWIG_PROPERTY_CHAR(template, "env"), "getExtension", "sandbox"), "checkMethodAllowed", object, item);
|
TWIG_CALL_ZZ(TWIG_CALL_S(TWIG_PROPERTY_CHAR(template, "env" TSRMLS_CC), "getExtension", "sandbox" TSRMLS_CC), "checkMethodAllowed", object, item TSRMLS_CC);
|
||||||
}
|
}
|
||||||
if (EG(exception)) {
|
if (EG(exception)) {
|
||||||
return;
|
return;
|
||||||
@@ -961,7 +961,7 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|||||||
$ret = call_user_func_array(array($object, $method), $arguments);
|
$ret = call_user_func_array(array($object, $method), $arguments);
|
||||||
*/
|
*/
|
||||||
if (Z_TYPE_P(object) == IS_OBJECT) {
|
if (Z_TYPE_P(object) == IS_OBJECT) {
|
||||||
ret = TWIG_CALL_USER_FUNC_ARRAY(object, method, arguments);
|
ret = TWIG_CALL_USER_FUNC_ARRAY(object, method, arguments TSRMLS_CC);
|
||||||
free_ret = 1;
|
free_ret = 1;
|
||||||
}
|
}
|
||||||
efree(tmp_method_name_get);
|
efree(tmp_method_name_get);
|
||||||
@@ -973,8 +973,8 @@ PHP_FUNCTION(twig_template_get_attributes)
|
|||||||
return new Twig_Markup($ret);
|
return new Twig_Markup($ret);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (TWIG_INSTANCE_OF_USERLAND(object, "Twig_TemplateInterface")) {
|
if (TWIG_INSTANCE_OF_USERLAND(object, "Twig_TemplateInterface" TSRMLS_CC)) {
|
||||||
TWIG_NEW(return_value, "Twig_Markup", ret);
|
TWIG_NEW(return_value, "Twig_Markup", ret TSRMLS_CC);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
zval_ptr_dtor(&ret);
|
zval_ptr_dtor(&ret);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user