Example #1
0
func (o *OsMod) Run(_ ...runtime.Val) (v runtime.Val, err error) {
	defer runtime.PanicToError(&err)
	if o.ob == nil {
		// Prepare the object
		o.ob = runtime.NewObject()
		o.ob.Set(runtime.String("TempDir"), runtime.String(os.TempDir()))
		o.ob.Set(runtime.String("PathSeparator"), runtime.String(os.PathSeparator))
		o.ob.Set(runtime.String("PathListSeparator"), runtime.String(os.PathListSeparator))
		o.ob.Set(runtime.String("DevNull"), runtime.String(os.DevNull))
		o.ob.Set(runtime.String("Exec"), runtime.NewNativeFunc(o.ctx, "os.Exec", o.os_Exec))
		o.ob.Set(runtime.String("Exit"), runtime.NewNativeFunc(o.ctx, "os.Exit", o.os_Exit))
		o.ob.Set(runtime.String("Getenv"), runtime.NewNativeFunc(o.ctx, "os.Getenv", o.os_Getenv))
		o.ob.Set(runtime.String("Getwd"), runtime.NewNativeFunc(o.ctx, "os.Getwd", o.os_Getwd))
		o.ob.Set(runtime.String("ReadFile"), runtime.NewNativeFunc(o.ctx, "os.ReadFile", o.os_ReadFile))
		o.ob.Set(runtime.String("WriteFile"), runtime.NewNativeFunc(o.ctx, "os.WriteFile", o.os_WriteFile))
		o.ob.Set(runtime.String("Open"), runtime.NewNativeFunc(o.ctx, "os.Open", o.os_Open))
		o.ob.Set(runtime.String("TryOpen"), runtime.NewNativeFunc(o.ctx, "os.TryOpen", o.os_TryOpen))
		o.ob.Set(runtime.String("Mkdir"), runtime.NewNativeFunc(o.ctx, "os.Mkdir", o.os_Mkdir))
		o.ob.Set(runtime.String("Remove"), runtime.NewNativeFunc(o.ctx, "os.Remove", o.os_Remove))
		o.ob.Set(runtime.String("RemoveAll"), runtime.NewNativeFunc(o.ctx, "os.RemoveAll", o.os_RemoveAll))
		o.ob.Set(runtime.String("Rename"), runtime.NewNativeFunc(o.ctx, "os.Rename", o.os_Rename))
		o.ob.Set(runtime.String("ReadDir"), runtime.NewNativeFunc(o.ctx, "os.ReadDir", o.os_ReadDir))
	}
	return o.ob, nil
}
Example #2
0
func (t *TimeMod) Run(_ ...runtime.Val) (v runtime.Val, err error) {
	defer runtime.PanicToError(&err)
	if t.ob == nil {
		// Prepare the object
		t.ob = runtime.NewObject()
		t.ob.Set(runtime.String("Date"), runtime.NewNativeFunc(t.ctx, "time.Date", t.time_Date))
		t.ob.Set(runtime.String("Now"), runtime.NewNativeFunc(t.ctx, "time.Now", t.time_Now))
		t.ob.Set(runtime.String("Sleep"), runtime.NewNativeFunc(t.ctx, "time.Sleep", t.time_Sleep))
	}
	return t.ob, nil
}
Example #3
0
func (f *FmtMod) Run(_ ...runtime.Val) (v runtime.Val, err error) {
	defer runtime.PanicToError(&err)
	if f.ob == nil {
		// Prepare the object
		f.ob = runtime.NewObject()
		f.ob.Set(runtime.String("Print"), runtime.NewNativeFunc(f.ctx, "fmt.Print", f.fmt_Print))
		f.ob.Set(runtime.String("Println"), runtime.NewNativeFunc(f.ctx, "fmt.Println", f.fmt_Println))
		f.ob.Set(runtime.String("Scanln"), runtime.NewNativeFunc(f.ctx, "fmt.Scanln", f.fmt_Scanln))
		f.ob.Set(runtime.String("Scanint"), runtime.NewNativeFunc(f.ctx, "fmt.Scanint", f.fmt_Scanint))
	}
	return f.ob, nil
}
Example #4
0
// Not interested in any argument in this case. Note the named return values.
func (lm *LogModule) Run(_ ...runtime.Val) (v runtime.Val, err error) {
	// Handle the panics, convert to an error
	defer runtime.PanicToError(&err)
	// Check the cache, create the return value if unavailable
	if lm.ob == nil {
		// Prepare the object
		lm.ob = runtime.NewObject()
		// Export some functions...
		lm.ob.Set(runtime.String("Printf"), runtime.NewNativeFunc(lm.ctx, "log.Printf", lm.Printf))
	}
	return lm.ob, nil
}
Example #5
0
func (fp *FilepathMod) Run(_ ...runtime.Val) (v runtime.Val, err error) {
	defer runtime.PanicToError(&err)
	if fp.ob == nil {
		// Prepare the object
		fp.ob = runtime.NewObject()
		fp.ob.Set(runtime.String("Abs"), runtime.NewNativeFunc(fp.ctx, "filepath.Abs", fp.filepath_Abs))
		fp.ob.Set(runtime.String("Base"), runtime.NewNativeFunc(fp.ctx, "filepath.Base", fp.filepath_Base))
		fp.ob.Set(runtime.String("Dir"), runtime.NewNativeFunc(fp.ctx, "filepath.Dir", fp.filepath_Dir))
		fp.ob.Set(runtime.String("Ext"), runtime.NewNativeFunc(fp.ctx, "filepath.Ext", fp.filepath_Ext))
		fp.ob.Set(runtime.String("IsAbs"), runtime.NewNativeFunc(fp.ctx, "filepath.IsAbs", fp.filepath_IsAbs))
		fp.ob.Set(runtime.String("Join"), runtime.NewNativeFunc(fp.ctx, "filepath.Join", fp.filepath_Join))
	}
	return fp.ob, nil
}
Example #6
0
// Not interested in any argument in this case. Note the named return values.
func (jm *JotaModule) Run(_ ...runtime.Val) (v runtime.Val, err error) {
	// Handle the panics, convert to an error
	defer runtime.PanicToError(&err)
	// Check the cache, create the return value if unavailable
	if jm.ob == nil {
		// Prepare the object
		jm.ob = runtime.NewObject()
		// Export some functions...
		jm.ob.Set(runtime.String("Me"), runtime.NewNativeFunc(jm.ctx, "jota.Me", jm.Me))
		jm.ob.Set(runtime.String("Move"), runtime.NewNativeFunc(jm.ctx, "jota.Move", jm.Move))
		jm.ob.Set(runtime.String("MoveTowards"), runtime.NewNativeFunc(jm.ctx, "jota.MoveTowards", jm.MoveTowards))
		jm.ob.Set(runtime.String("Turn"), runtime.NewNativeFunc(jm.ctx, "jota.Turn", jm.Turn))
		jm.ob.Set(runtime.String("UseAbility"), runtime.NewNativeFunc(jm.ctx, "jota.UseAbility", jm.UseAbility))
		jm.ob.Set(runtime.String("Param"), runtime.NewNativeFunc(jm.ctx, "jota.Param", jm.Param))
		jm.ob.Set(runtime.String("NearestEnt"), runtime.NewNativeFunc(jm.ctx, "jota.NearestEnt", jm.NearestEnt))
		jm.ob.Set(runtime.String("ControlPoints"), runtime.NewNativeFunc(jm.ctx, "jota.ControlPoints", jm.ControlPoints))
		jm.ob.Set(runtime.String("NearbyEnts"), runtime.NewNativeFunc(jm.ctx, "jota.NearbyEnts", jm.NearbyEnts))
		jm.ob.Set(runtime.String("PathDir"), runtime.NewNativeFunc(jm.ctx, "jota.PathDir", jm.PathDir))
	}
	return jm.ob, nil
}
Example #7
0
func (s *StringsMod) Run(_ ...runtime.Val) (v runtime.Val, err error) {
	defer runtime.PanicToError(&err)
	if s.ob == nil {
		// Prepare the object
		s.ob = runtime.NewObject()
		s.ob.Set(runtime.String("ToLower"), runtime.NewNativeFunc(s.ctx, "strings.ToLower", s.strings_ToLower))
		s.ob.Set(runtime.String("ToUpper"), runtime.NewNativeFunc(s.ctx, "strings.ToUpper", s.strings_ToUpper))
		s.ob.Set(runtime.String("HasPrefix"), runtime.NewNativeFunc(s.ctx, "strings.HasPrefix", s.strings_HasPrefix))
		s.ob.Set(runtime.String("HasSuffix"), runtime.NewNativeFunc(s.ctx, "strings.HasSuffix", s.strings_HasSuffix))
		s.ob.Set(runtime.String("Matches"), runtime.NewNativeFunc(s.ctx, "strings.Matches", s.strings_Matches))
		s.ob.Set(runtime.String("ByteAt"), runtime.NewNativeFunc(s.ctx, "strings.ByteAt", s.strings_ByteAt))
		s.ob.Set(runtime.String("Concat"), runtime.NewNativeFunc(s.ctx, "strings.Concat", s.strings_Concat))
		s.ob.Set(runtime.String("Contains"), runtime.NewNativeFunc(s.ctx, "strings.Contains", s.strings_Contains))
		s.ob.Set(runtime.String("Index"), runtime.NewNativeFunc(s.ctx, "strings.Index", s.strings_Index))
		s.ob.Set(runtime.String("LastIndex"), runtime.NewNativeFunc(s.ctx, "strings.LastIndex", s.strings_LastIndex))
		s.ob.Set(runtime.String("Slice"), runtime.NewNativeFunc(s.ctx, "strings.Slice", s.strings_Slice))
		s.ob.Set(runtime.String("Split"), runtime.NewNativeFunc(s.ctx, "strings.Split", s.strings_Split))
		s.ob.Set(runtime.String("Join"), runtime.NewNativeFunc(s.ctx, "strings.Join", s.strings_Join))
		s.ob.Set(runtime.String("Replace"), runtime.NewNativeFunc(s.ctx, "strings.Replace", s.strings_Replace))
		s.ob.Set(runtime.String("Repeat"), runtime.NewNativeFunc(s.ctx, "strings.Repeat", s.strings_Repeat))
		s.ob.Set(runtime.String("Trim"), runtime.NewNativeFunc(s.ctx, "strings.Trim", s.strings_Trim))
	}
	return s.ob, nil
}
Example #8
0
func (m *MathMod) Run(_ ...runtime.Val) (v runtime.Val, err error) {
	defer runtime.PanicToError(&err)
	if m.ob == nil {
		// Prepare the object
		m.ob = runtime.NewObject()
		m.ob.Set(runtime.String("Pi"), runtime.Number(math.Pi))
		m.ob.Set(runtime.String("Abs"), runtime.NewNativeFunc(m.ctx, "math.Abs", m.math_Abs))
		m.ob.Set(runtime.String("Acos"), runtime.NewNativeFunc(m.ctx, "math.Acos", m.math_Acos))
		m.ob.Set(runtime.String("Acosh"), runtime.NewNativeFunc(m.ctx, "math.Acosh", m.math_Acosh))
		m.ob.Set(runtime.String("Asin"), runtime.NewNativeFunc(m.ctx, "math.Asin", m.math_Asin))
		m.ob.Set(runtime.String("Asinh"), runtime.NewNativeFunc(m.ctx, "math.Asinh", m.math_Asinh))
		m.ob.Set(runtime.String("Atan"), runtime.NewNativeFunc(m.ctx, "math.Atan", m.math_Atan))
		m.ob.Set(runtime.String("Atan2"), runtime.NewNativeFunc(m.ctx, "math.Atan2", m.math_Atan2))
		m.ob.Set(runtime.String("Atanh"), runtime.NewNativeFunc(m.ctx, "math.Atanh", m.math_Atanh))
		m.ob.Set(runtime.String("Ceil"), runtime.NewNativeFunc(m.ctx, "math.Ceil", m.math_Ceil))
		m.ob.Set(runtime.String("Cos"), runtime.NewNativeFunc(m.ctx, "math.Cos", m.math_Cos))
		m.ob.Set(runtime.String("Cosh"), runtime.NewNativeFunc(m.ctx, "math.Cosh", m.math_Cosh))
		m.ob.Set(runtime.String("Exp"), runtime.NewNativeFunc(m.ctx, "math.Exp", m.math_Exp))
		m.ob.Set(runtime.String("Floor"), runtime.NewNativeFunc(m.ctx, "math.Floor", m.math_Floor))
		m.ob.Set(runtime.String("Inf"), runtime.NewNativeFunc(m.ctx, "math.Inf", m.math_Inf))
		m.ob.Set(runtime.String("IsInf"), runtime.NewNativeFunc(m.ctx, "math.IsInf", m.math_IsInf))
		m.ob.Set(runtime.String("IsNaN"), runtime.NewNativeFunc(m.ctx, "math.IsNaN", m.math_IsNaN))
		m.ob.Set(runtime.String("Max"), runtime.NewNativeFunc(m.ctx, "math.Max", m.math_Max))
		m.ob.Set(runtime.String("Min"), runtime.NewNativeFunc(m.ctx, "math.Min", m.math_Min))
		m.ob.Set(runtime.String("NaN"), runtime.NewNativeFunc(m.ctx, "math.NaN", m.math_NaN))
		m.ob.Set(runtime.String("Pow"), runtime.NewNativeFunc(m.ctx, "math.Pow", m.math_Pow))
		m.ob.Set(runtime.String("Sin"), runtime.NewNativeFunc(m.ctx, "math.Sin", m.math_Sin))
		m.ob.Set(runtime.String("Sinh"), runtime.NewNativeFunc(m.ctx, "math.Sinh", m.math_Sinh))
		m.ob.Set(runtime.String("Sqrt"), runtime.NewNativeFunc(m.ctx, "math.Sqrt", m.math_Sqrt))
		m.ob.Set(runtime.String("Tan"), runtime.NewNativeFunc(m.ctx, "math.Tan", m.math_Tan))
		m.ob.Set(runtime.String("Tanh"), runtime.NewNativeFunc(m.ctx, "math.Tanh", m.math_Tanh))
		m.ob.Set(runtime.String("RandSeed"), runtime.NewNativeFunc(m.ctx, "math.RandSeed", m.math_RandSeed))
		m.ob.Set(runtime.String("Rand"), runtime.NewNativeFunc(m.ctx, "math.Rand", m.math_Rand))
	}
	return m.ob, nil
}