diff options
Diffstat (limited to 'ext/tokenizer/tokenizer.c')
-rw-r--r-- | ext/tokenizer/tokenizer.c | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/ext/tokenizer/tokenizer.c b/ext/tokenizer/tokenizer.c index 7567a270af..ed3e8a6eab 100644 --- a/ext/tokenizer/tokenizer.c +++ b/ext/tokenizer/tokenizer.c @@ -89,7 +89,7 @@ static zend_string *php_token_get_text(zval *obj) { return Z_STR_P(text_zval); } -static zend_bool tokenize_common( +static bool tokenize_common( zval *return_value, zend_string *source, zend_long flags, zend_class_entry *token_class); PHP_METHOD(PhpToken, tokenize) @@ -251,37 +251,9 @@ PHP_METHOD(PhpToken, __toString) /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(tokenizer) { - zend_class_entry ce; - zend_string *name; - zval default_val; - ZVAL_UNDEF(&default_val); - tokenizer_register_constants(INIT_FUNC_ARGS_PASSTHRU); tokenizer_token_get_all_register_constants(INIT_FUNC_ARGS_PASSTHRU); - - INIT_CLASS_ENTRY(ce, "PhpToken", class_PhpToken_methods); - php_token_ce = zend_register_internal_class(&ce); - zend_class_implements(php_token_ce, 1, zend_ce_stringable); - - name = zend_string_init("id", sizeof("id") - 1, 1); - zend_declare_typed_property(php_token_ce, name, &default_val, ZEND_ACC_PUBLIC, NULL, - (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(name); - - name = zend_string_init("text", sizeof("text") - 1, 1); - zend_declare_typed_property(php_token_ce, name, &default_val, ZEND_ACC_PUBLIC, NULL, - (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(name); - - name = zend_string_init("line", sizeof("line") - 1, 1); - zend_declare_typed_property(php_token_ce, name, &default_val, ZEND_ACC_PUBLIC, NULL, - (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(name); - - name = zend_string_init("pos", sizeof("pos") - 1, 1); - zend_declare_typed_property(php_token_ce, name, &default_val, ZEND_ACC_PUBLIC, NULL, - (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(name); + php_token_ce = register_class_PhpToken(zend_ce_stringable); return SUCCESS; } @@ -345,7 +317,7 @@ static void add_token( zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &token); } -static zend_bool tokenize(zval *return_value, zend_string *source, zend_class_entry *token_class) +static bool tokenize(zval *return_value, zend_string *source, zend_class_entry *token_class) { zval source_zval; zend_lex_state original_lex_state; @@ -358,7 +330,7 @@ static zend_bool tokenize(zval *return_value, zend_string *source, zend_class_en ZVAL_STR_COPY(&source_zval, source); zend_save_lexical_state(&original_lex_state); - zend_prepare_string_for_scanning(&source_zval, ""); + zend_prepare_string_for_scanning(&source_zval, ZSTR_EMPTY_ALLOC()); LANG_SCNG(yy_state) = yycINITIAL; zend_hash_init(&interned_strings, 0, NULL, NULL, 0); @@ -477,15 +449,15 @@ void on_event( } } -static zend_bool tokenize_parse( +static bool tokenize_parse( zval *return_value, zend_string *source, zend_class_entry *token_class) { zval source_zval; struct event_context ctx; zval token_stream; zend_lex_state original_lex_state; - zend_bool original_in_compilation; - zend_bool success; + bool original_in_compilation; + bool success; ZVAL_STR_COPY(&source_zval, source); @@ -493,7 +465,7 @@ static zend_bool tokenize_parse( CG(in_compilation) = 1; zend_save_lexical_state(&original_lex_state); - zend_prepare_string_for_scanning(&source_zval, ""); + zend_prepare_string_for_scanning(&source_zval, ZSTR_EMPTY_ALLOC()); array_init(&token_stream); ctx.tokens = &token_stream; @@ -523,7 +495,7 @@ static zend_bool tokenize_parse( return success; } -static zend_bool tokenize_common( +static bool tokenize_common( zval *return_value, zend_string *source, zend_long flags, zend_class_entry *token_class) { if (flags & TOKEN_PARSE) { |