func newRtype(size uintptr, align, fieldAlign, kind uint8, comprable bool, str string, uncommonType unsafe.Pointer, ptrToThis unsafe.Pointer) rtype { var alg *typeAlg if comprable { alg = &typeAlg{equal: equal} } return rtype{ size: size, align: align, fieldAlign: fieldAlign, kind: Kind(kind), alg: alg, string: addrString(str), uncommonType: uncommonType, ptrToThis: ptrToThis, zero: hx.Malloc(size), } }
func haxe2go(ret *emptyInterface, i interface{}) { if ret == nil { i = interface{}(nil) return } /* if ret.typ == nil { // HELP! assume dynamic? panic("DEBUG reflect.haxe2go() nil Go type") //println("DEBUG reflect.haxe2go() nil Go type, using uintptr") //uip := hx.CodeIface("", "uintptr", "null;") //ret.typ = createHaxeType(hx.CodeInt("", "_a.param(0).typ;", uip)) } */ ret.word = hx.Malloc(ret.typ.size) switch ret.typ.Kind() & kindMask { case Bool: *(*bool)(ret.word) = hx.CodeBool("", "_a.param(0).val;", i) case Int: *(*int)(ret.word) = hx.CodeInt("", "_a.param(0).val;", i) case Int8: *(*int8)(ret.word) = int8(hx.CodeInt("", "_a.param(0).val;", i)) case Int16: *(*int16)(ret.word) = int16(hx.CodeInt("", "_a.param(0).val;", i)) case Int32: *(*int32)(ret.word) = int32(hx.CodeInt("", "_a.param(0).val;", i)) case Int64: *(*int64)(ret.word) = hx.Int64(hx.CodeDynamic("", "_a.param(0).val;", i)) case Uint: *(*uint)(ret.word) = uint(hx.CodeInt("", "_a.param(0).val;", i)) case Uint8: *(*uint8)(ret.word) = uint8(hx.CodeInt("", "_a.param(0).val;", i)) case Uint16: *(*uint16)(ret.word) = uint16(hx.CodeInt("", "_a.param(0).val;", i)) case Uint32: *(*uint32)(ret.word) = uint32(hx.CodeInt("", "_a.param(0).val;", i)) case Uint64: *(*uint64)(ret.word) = uint64(hx.Int64(hx.CodeDynamic("", "_a.param(0).val;", i))) case Uintptr: *(*uintptr)(ret.word) = uintptr(hx.CodeDynamic("", "_a.param(0).val;", i)) case Float32: *(*float32)(ret.word) = float32(hx.CodeFloat("", "_a.param(0).val;", i)) case Float64: *(*float64)(ret.word) = float64(hx.CodeFloat("", "_a.param(0).val;", i)) case Complex64: *(*complex64)(ret.word) = complex64(hx.Complex(hx.CodeDynamic("", "_a.param(0).val;", i))) case Complex128: *(*complex128)(ret.word) = hx.Complex(hx.CodeDynamic("", "_a.param(0).val;", i)) case UnsafePointer, Ptr: //*(*unsafe.Pointer)(ret.word) = unsafe.Pointer(hx.CodeDynamic("", "_a.param(0).val;", i)) ret.word = unsafe.Pointer(hx.CodeDynamic("", "_a.param(0).val;", i)) case String: *(*string)(ret.word) = hx.CodeString("", "_a.param(0).val;", i) case Array, Struct: hx.Code("", "_a.param(1).val.store_object(_a.param(2).val,_a.param(0).val);", i, ret.word, ret.typ.size) case Slice, Interface, Map, Func, Chan: val := hx.CodeDynamic("", "_a.param(0).val;", i) *(*uintptr)(ret.word) = val /* htyp := "null" if !hx.IsNull(val) { htyp = hx.CallString("", "Type.getClassName", 1, val) } println("DEBUG unpack haxe type=", htyp, " Go type=", ret.typ.Kind().String(), "val=", val, "encoded=", ret) */ } }
func haxeUnsafeNew(rtp *rtype) unsafe.Pointer { return hx.Malloc(rtp.size) }