@@ -9,6 +9,118 @@ import (
99"fmt"
1010)
1111
12+ // Neg the python Object returning an Object
13+ //
14+ // Will raise TypeError if Neg can't be run on this object
15+ func Neg (a Object ) Object {
16+ A , ok := a .(I__neg__ )
17+ if ok {
18+ res := A .M__neg__ ()
19+ if res != NotImplemented {
20+ return res
21+ }
22+ }
23+
24+ // FIXME should be TypeError
25+ panic (fmt .Sprintf ("TypeError: unsupported operand type(s) for -: '%s'" , a .Type ().Name ))
26+ }
27+
28+ // Pos the python Object returning an Object
29+ //
30+ // Will raise TypeError if Pos can't be run on this object
31+ func Pos (a Object ) Object {
32+ A , ok := a .(I__pos__ )
33+ if ok {
34+ res := A .M__pos__ ()
35+ if res != NotImplemented {
36+ return res
37+ }
38+ }
39+
40+ // FIXME should be TypeError
41+ panic (fmt .Sprintf ("TypeError: unsupported operand type(s) for +: '%s'" , a .Type ().Name ))
42+ }
43+
44+ // Abs the python Object returning an Object
45+ //
46+ // Will raise TypeError if Abs can't be run on this object
47+ func Abs (a Object ) Object {
48+ A , ok := a .(I__abs__ )
49+ if ok {
50+ res := A .M__abs__ ()
51+ if res != NotImplemented {
52+ return res
53+ }
54+ }
55+
56+ // FIXME should be TypeError
57+ panic (fmt .Sprintf ("TypeError: unsupported operand type(s) for abs: '%s'" , a .Type ().Name ))
58+ }
59+
60+ // Invert the python Object returning an Object
61+ //
62+ // Will raise TypeError if Invert can't be run on this object
63+ func Invert (a Object ) Object {
64+ A , ok := a .(I__invert__ )
65+ if ok {
66+ res := A .M__invert__ ()
67+ if res != NotImplemented {
68+ return res
69+ }
70+ }
71+
72+ // FIXME should be TypeError
73+ panic (fmt .Sprintf ("TypeError: unsupported operand type(s) for ~: '%s'" , a .Type ().Name ))
74+ }
75+
76+ // MakeComplex the python Object returning an Object
77+ //
78+ // Will raise TypeError if MakeComplex can't be run on this object
79+ func MakeComplex (a Object ) Object {
80+ A , ok := a .(I__complex__ )
81+ if ok {
82+ res := A .M__complex__ ()
83+ if res != NotImplemented {
84+ return res
85+ }
86+ }
87+
88+ // FIXME should be TypeError
89+ panic (fmt .Sprintf ("TypeError: unsupported operand type(s) for complex: '%s'" , a .Type ().Name ))
90+ }
91+
92+ // MakeInt the python Object returning an Object
93+ //
94+ // Will raise TypeError if MakeInt can't be run on this object
95+ func MakeInt (a Object ) Object {
96+ A , ok := a .(I__int__ )
97+ if ok {
98+ res := A .M__int__ ()
99+ if res != NotImplemented {
100+ return res
101+ }
102+ }
103+
104+ // FIXME should be TypeError
105+ panic (fmt .Sprintf ("TypeError: unsupported operand type(s) for int: '%s'" , a .Type ().Name ))
106+ }
107+
108+ // MakeFloat the python Object returning an Object
109+ //
110+ // Will raise TypeError if MakeFloat can't be run on this object
111+ func MakeFloat (a Object ) Object {
112+ A , ok := a .(I__float__ )
113+ if ok {
114+ res := A .M__float__ ()
115+ if res != NotImplemented {
116+ return res
117+ }
118+ }
119+
120+ // FIXME should be TypeError
121+ panic (fmt .Sprintf ("TypeError: unsupported operand type(s) for float: '%s'" , a .Type ().Name ))
122+ }
123+
12124// Add two python objects together returning an Object
13125//
14126// Will raise TypeError if can't be add can't be run on these objects
0 commit comments