コード例 #1
0
ファイル: browsermain.go プロジェクト: henrylee2cn/tardisgo
// Main allows code that might be targeted to broser-based JS code to schedule TARDISgo code periodically, separate from call-backs.
// For non-JS targets it simply calls the given mainFN.
// This should be the last function called in main.main()
func BrowserMain(mainFN func(), msInvocationInterval, runLimit int) {
	if runtime.GOARCH == "js" { // probably only want to do this in a browser
		JScallbackOK = true
		ht := hx.New("js", "haxe.Timer", 1, msInvocationInterval)
		go func() { // put the main program into a goroutine
			mainFN()
			hx.Meth("js", ht, "haxe.Timer", "stop", 0)
		}()
		hx.SetInt("js", "Scheduler.runLimit", runLimit)
		hx.Code("js", "_a.param(0).val.run=Scheduler.timerEventHandler;", ht)
	} else {
		mainFN()
	}
}
コード例 #2
0
ファイル: tgotypes.go プロジェクト: henrylee2cn/tardisgo
func AddHaxeType(ptr unsafe.Pointer) {
	TypeTable = append(TypeTable, (*rtype)(ptr))
	hx.SetInt("", "TypeInfo.nextTypeID", len(TypeTable))
}