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:
parent
81e82bfd1e
commit
00679900c9
8
value.c
8
value.c
@ -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);
|
||||
|
9
value.go
9
value.go
@ -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)
|
||||
}
|
||||
|
8
value.h
8
value.h
@ -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
|
Loading…
Reference in New Issue
Block a user