1
0
mirror of https://github.com/deuill/go-php.git synced 2024-09-21 00:40:45 +00:00

Rename value methods.

This commit is contained in:
Alex Palaistras 2015-09-26 20:40:41 +01:00
parent 81e82bfd1e
commit 00679900c9
3 changed files with 13 additions and 12 deletions

View File

@ -5,7 +5,7 @@
#include "engine.h"
#include "value.h"
void *value_long(long int value) {
void *value_create_long(long int value) {
zval *v;
MAKE_STD_ZVAL(v);
@ -14,7 +14,7 @@ void *value_long(long int value) {
return_multi((void *) v, 0);
}
void *value_double(double value) {
void *value_create_double(double value) {
zval *v;
MAKE_STD_ZVAL(v);
@ -23,7 +23,7 @@ void *value_double(double value) {
return_multi((void *) v, 0);
}
void *value_bool(bool value) {
void *value_create_bool(bool value) {
zval *v;
MAKE_STD_ZVAL(v);
@ -32,7 +32,7 @@ void *value_bool(bool value) {
return_multi((void *) v, 0);
}
void *value_string(char *value) {
void *value_create_string(char *value) {
zval *v;
MAKE_STD_ZVAL(v);

View File

@ -27,18 +27,19 @@ func NewValue(v interface{}) (*Value, error) {
var ptr unsafe.Pointer
var err error
// Determine value type and create PHP value from the concrete type.
switch v := v.(type) {
case int:
ptr, err = C.value_long(C.long(v))
ptr, err = C.value_create_long(C.long(v))
case float64:
ptr, err = C.value_double(C.double(v))
ptr, err = C.value_create_double(C.double(v))
case bool:
ptr, err = C.value_bool(C.bool(v))
ptr, err = C.value_create_bool(C.bool(v))
case string:
str := C.CString(v)
defer C.free(unsafe.Pointer(str))
ptr, err = C.value_string(str)
ptr, err = C.value_create_string(str)
default:
return nil, fmt.Errorf("Cannot create value of unknown type '%T'", v)
}

View File

@ -1,10 +1,10 @@
#ifndef VALUE_H
#define VALUE_H
void *value_long(long int value);
void *value_double(double value);
void *value_bool(bool value);
void *value_string(char *value);
void *value_create_long(long int value);
void *value_create_double(double value);
void *value_create_bool(bool value);
void *value_create_string(char *value);
void value_destroy(void *zvalptr);
#endif