From d7cc40e5ddc21a01f2094330710c0d0adb34f4fd Mon Sep 17 00:00:00 2001 From: Brandon Dyck Date: Sun, 27 Nov 2022 15:14:52 -0700 Subject: [PATCH] Wrapped ph7_value_is_X functions --- ph7.go | 60 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/ph7.go b/ph7.go index 560dac2..9f55559 100644 --- a/ph7.go +++ b/ph7.go @@ -290,18 +290,54 @@ func (v *Value) CompareStrict(v2 *Value) int { // TODO (*Value).ObjectWalk // TODO (*Value).ObjectFetchAttr // TODO (*Value).ObjectGetClassName -// TODO (*Value).IsInt -// TODO (*Value).IsFloat -// TODO (*Value).IsBool -// TODO (*Value).IsString -// TODO (*Value).IsNull -// TODO (*Value).IsNumeric -// TODO (*Value).IsCallable -// TODO (*Value).IsScalar -// TODO (*Value).IsArray -// TODO (*Value).IsObject -// TODO (*Value).IsResource -// TODO (*Value).IsEmpty + +func (v *Value) IsInt() bool { + return C.ph7_value_is_int((*C.ph7_value)(v)) != 0 +} + +func (v *Value) IsFloat() bool { + return C.ph7_value_is_float((*C.ph7_value)(v)) != 0 +} + +func (v *Value) IsBool() bool { + return C.ph7_value_is_bool((*C.ph7_value)(v)) != 0 +} + +func (v *Value) IsString() bool { + return C.ph7_value_is_string((*C.ph7_value)(v)) != 0 +} + +func (v *Value) IsNull() bool { + return C.ph7_value_is_null((*C.ph7_value)(v)) != 0 +} + +func (v *Value) IsNumeric() bool { + return C.ph7_value_is_numeric((*C.ph7_value)(v)) != 0 +} + +func (v *Value) IsCallable() bool { + return C.ph7_value_is_callable((*C.ph7_value)(v)) != 0 +} + +func (v *Value) IsScalar() bool { + return C.ph7_value_is_scalar((*C.ph7_value)(v)) != 0 +} + +func (v *Value) IsArray() bool { + return C.ph7_value_is_array((*C.ph7_value)(v)) != 0 +} + +func (v *Value) IsObject() bool { + return C.ph7_value_is_object((*C.ph7_value)(v)) != 0 +} + +func (v *Value) IsResource() bool { + return C.ph7_value_is_resource((*C.ph7_value)(v)) != 0 +} + +func (v *Value) IsEmpty() bool { + return C.ph7_value_is_empty((*C.ph7_value)(v)) != 0 +} // ph7_lib_init is unnecessary when single-threaded, and possibly always. // TODO Config