// interfaceToDynamic - limited runtime conversion of Go->Haxe types // TODO consider making public func interfaceToDynamic(a interface{}) uintptr { //fmt.Printf("DEBUG interfaceToDynamic a= %v:%T\n", a, a) if a == nil { return hx.Null() } switch a.(type) { case []interface{}: //println("DEBUG []interface{}") ret := hx.New("", "Array<Dynamic>", 0) for _, aa := range a.([]interface{}) { //fmt.Printf("DEBUG aa= %v:%T\n", aa, aa) val := interfaceToDynamic(aa) //fmt.Println("DEBUG val=" + hx.CallString("", "Std.string", 1, val)) hx.Code("", "_a.param(0).val.push(_a.param(1).val);", ret, val) } return ret case bool, string, int, float64: return hx.CodeDynamic("", "_a.param(0).val;", a) case []byte: return hx.CodeDynamic("", "Slice.toBytes(cast(_a.param(0).val,Slice));", a) default: panic("Unhandled Go interface{} to Haxe Dynamic: " + hx.CallString("", "Std.string", 1, a)) } return hx.Null() }
func HaxeTimer(up unsafe.Pointer) { rt := (*runtimeTimer)(up) defer func() { rt.haxeRuning = false rt.seq = hx.Null() }() rt.seq = 0 rt.haxeRuning = true again: HaxeWait(&rt.when, &rt.haxeRuning) // rt.when is in nanoseconds if rt.haxeRuning { rt.f(rt.arg, rt.seq) rt.seq++ if rt.period > 0 { rt.when += rt.period goto again } } }