mirror of
https://github.com/laravel-ls/go-php
synced 2026-06-16 03:54:55 +02:00
Initial commit
This commit is contained in:
commit
4cbf7e62b7
19 changed files with 1295 additions and 0 deletions
54
zval.c
Normal file
54
zval.c
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#include <Zend/zend_types.h>
|
||||
#include <Zend/zend_operators.h>
|
||||
#include "zval.h"
|
||||
|
||||
zval new_zval() {
|
||||
zval val;
|
||||
ZVAL_NULL(&val);
|
||||
return val;
|
||||
}
|
||||
|
||||
void zval_destroy(zval *val) {
|
||||
zval_dtor(val);
|
||||
ZVAL_NULL(val);
|
||||
}
|
||||
|
||||
zend_array* zval_get_array(zval *zv) {
|
||||
return Z_ARRVAL_P(zv);
|
||||
}
|
||||
|
||||
// Initialize a hash table traversal
|
||||
void zend_array_init_traverse(zend_array *arr, HashPosition *pos) {
|
||||
zend_hash_internal_pointer_reset_ex(arr, pos);
|
||||
}
|
||||
|
||||
void zval_set_long(zval *val, long int num) {
|
||||
ZVAL_LONG(val, num);
|
||||
}
|
||||
|
||||
// Get the next entry in the hash table
|
||||
int zend_array_get_next(zend_array *arr, HashPosition *pos, hash_table_entry *entry) {
|
||||
zend_string *key_str = NULL;
|
||||
zend_ulong key_long = 0;
|
||||
zval *value = zend_hash_get_current_data_ex(arr, pos);
|
||||
|
||||
if (!value) {
|
||||
return 0; // End of the array
|
||||
}
|
||||
|
||||
if (zend_hash_get_current_key_ex(arr, &key_str, &key_long, pos) == HASH_KEY_IS_STRING) {
|
||||
entry->key_type = HASH_KEY_IS_STRING;
|
||||
entry->key_str = key_str;
|
||||
} else {
|
||||
entry->key_type = HASH_KEY_IS_LONG;
|
||||
entry->key_long = key_long;
|
||||
}
|
||||
|
||||
entry->value = *value;
|
||||
zend_hash_move_forward_ex(arr, pos);
|
||||
return 1; // Entry found
|
||||
}
|
||||
|
||||
char* zend_string_cstr(zend_string *zstr) {
|
||||
return zstr ? ZSTR_VAL(zstr) : NULL;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue