コード例 #1
0
ファイル: engine.go プロジェクト: deuill/go-php
//export engineReceiverExists
func engineReceiverExists(rcvr *C.struct__engine_receiver, name *C.char) C.int {
	n := C.GoString(C._receiver_get_name(rcvr))
	if engine == nil || engine.receivers[n].objects[rcvr] == nil {
		return 0
	}

	if engine.receivers[n].objects[rcvr].Exists(C.GoString(name)) {
		return 1
	}

	return 0
}
コード例 #2
0
ファイル: engine.go プロジェクト: deuill/go-php
//export engineReceiverGet
func engineReceiverGet(rcvr *C.struct__engine_receiver, name *C.char) unsafe.Pointer {
	n := C.GoString(C._receiver_get_name(rcvr))
	if engine == nil || engine.receivers[n].objects[rcvr] == nil {
		return nil
	}

	val, err := engine.receivers[n].objects[rcvr].Get(C.GoString(name))
	if err != nil {
		return nil
	}

	return val.Ptr()
}
コード例 #3
0
ファイル: engine.go プロジェクト: deuill/go-php
//export engineReceiverSet
func engineReceiverSet(rcvr *C.struct__engine_receiver, name *C.char, val unsafe.Pointer) {
	n := C.GoString(C._receiver_get_name(rcvr))
	if engine == nil || engine.receivers[n].objects[rcvr] == nil {
		return
	}

	v, err := NewValueFromPtr(val)
	if err != nil {
		return
	}

	engine.receivers[n].objects[rcvr].Set(C.GoString(name), v.Interface())
}
コード例 #4
0
ファイル: engine.go プロジェクト: deuill/go-php
//export engineReceiverCall
func engineReceiverCall(rcvr *C.struct__engine_receiver, name *C.char, args unsafe.Pointer) unsafe.Pointer {
	n := C.GoString(C._receiver_get_name(rcvr))
	if engine == nil || engine.receivers[n].objects[rcvr] == nil {
		return nil
	}

	// Process input arguments.
	va, err := NewValueFromPtr(args)
	if err != nil {
		return nil
	}

	defer va.Destroy()

	val := engine.receivers[n].objects[rcvr].Call(C.GoString(name), va.Slice())
	if val == nil {
		return nil
	}

	return val.Ptr()
}
コード例 #5
0
ファイル: engine.go プロジェクト: deuill/go-php
//export engineReceiverNew
func engineReceiverNew(rcvr *C.struct__engine_receiver, args unsafe.Pointer) C.int {
	n := C.GoString(C._receiver_get_name(rcvr))
	if engine == nil || engine.receivers[n] == nil {
		return 1
	}

	va, err := NewValueFromPtr(args)
	if err != nil {
		return 1
	}

	defer va.Destroy()

	obj, err := engine.receivers[n].NewObject(va.Slice())
	if err != nil {
		return 1
	}

	engine.receivers[n].objects[rcvr] = obj

	return 0
}