@@ -9,38 +9,31 @@ import "C"
99import (
1010 "strings"
1111 "unsafe"
12−
13− "github.com/replit/prybar/utils"
1412)
1513
16−func init() {
17− utils.Register(&Language{})
18−}
14+type Python struct{}
1915
20−type Language struct {
21−}
22−
23−func (p Language) Open() {
16+func (p Python) Open() {
2417 C.Py_Initialize()
2518}
2619
27−func (p Language) Version() string {
20+func (p Python) Version() string {
2821 return "Python " + C.GoString(C.Py_GetVersion()) + " on " + C.GoString(C.Py_GetPlatform())
2922}
3023
31−func (p Language) Eval(code string) {
24+func (p Python) Eval(code string) {
3225 ccode := C.CString(code)
3326 defer C.free(unsafe.Pointer(ccode))
3427 C.GoString(C.pry_eval(ccode, C.Py_file_input))
3528}
3629
37−func (p Language) EvalExpression(code string) string {
30+func (p Python) EvalExpression(code string) string {
3831 ccode := C.CString(code)
3932 defer C.free(unsafe.Pointer(ccode))
4033 return C.GoString(C.pry_eval(ccode, C.Py_eval_input))
4134}
4235
43−func (p Language) EvalFile(file string, args []string) {
36+func (p Python) EvalFile(file string, args []string) {
4437 handle := C.stdin
4538 cfile := C.CString(file)
4639 defer C.free(unsafe.Pointer(cfile))
@@ -58,19 +51,19 @@ func (p Language) EvalFile(file string, args []string) {
5851 C.pry_eval_file(handle, cfile, C.int(len(args)+1), argv)
5952}
6053
61−func (p Language) REPLLikeEval(code string) {
54+func (p Python) REPLLikeEval(code string) {
6255 ccode := C.CString(code)
6356 defer C.free(unsafe.Pointer(ccode))
6457 C.pry_eval(ccode, C.Py_single_input)
6558}
6659
67−func (p Language) LoadModule(mod string) {
60+func (p Python) LoadModule(mod string) {
6861 cmode := C.CString(mod)
6962 defer C.free(unsafe.Pointer(cmode))
7063 C.PyImport_ImportModule(cmode)
7164}
7265
73−func (p Language) REPL() {
66+func (p Python) REPL() {
7467 p.LoadModule("readline")
7568
7669 fn := C.CString("<stdin>")
@@ -78,7 +71,7 @@ func (p Language) REPL() {
7871 C.PyRun_InteractiveLoopFlags(C.stdin, fn, nil)
7972}
8073
81−func (p Language) SetPrompts(ps1, ps2 string) {
74+func (p Python) SetPrompts(ps1, ps2 string) {
8275 cps1 := C.CString(ps1)
8376 defer C.free(unsafe.Pointer(cps1))
8477 cps2 := C.CString(ps2)
@@ -87,6 +80,8 @@ func (p Language) SetPrompts(ps1, ps2 string) {
8780 C.pry_set_prompts(cps1, cps2)
8881}
8982
90−func (p Language) Close() {
83+func (p Python) Close() {
9184 C.Py_Finalize()
9285}
86+
87+var Instance = Python{}