1
0
mirror of https://github.com/deuill/go-php.git synced 2024-09-21 00:40:45 +00:00
go-php/value/value.c
Alex Palaistras 8a2ce468e2 Add documentation blocks.
Added documentation blocks and licence headers to all files.
2015-10-04 19:28:44 +01:00

67 lines
1.1 KiB
C

// Copyright 2015 Alexander Palaistras. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
#include <errno.h>
#include <stdbool.h>
#include <main/php.h>
#include "value.h"
void *value_create_long(long int value) {
zval *v;
MAKE_STD_ZVAL(v);
ZVAL_LONG(v, value);
return (void *) v;
}
void *value_create_double(double value) {
zval *v;
MAKE_STD_ZVAL(v);
ZVAL_DOUBLE(v, value);
return (void *) v;
}
void *value_create_bool(bool value) {
zval *v;
MAKE_STD_ZVAL(v);
ZVAL_BOOL(v, value);
return (void *) v;
}
void *value_create_string(char *value) {
zval *v;
MAKE_STD_ZVAL(v);
ZVAL_STRING(v, value, 1);
return (void *) v;
}
void *value_create_array(unsigned int size) {
zval *v;
MAKE_STD_ZVAL(v);
array_init_size(v, size);
return (void *) v;
}
void value_array_set_index(void *arr, unsigned long idx, void *val) {
add_index_zval((zval *) arr, idx, (zval *) val);
}
void value_array_set_key(void *arr, const char *key, void *val) {
add_assoc_zval((zval *) arr, key, (zval *) val);
}
void value_destroy(void *zvalptr) {
zval_dtor((zval *) zvalptr);
}