package Objectsimport ("fmt")/**** @author Liu Weiyi* @date 2020年4月25日 1:19 下午*/type PyIntObject struct {PyObject_HEADvalue int}type PyIntType tagPyTypeObjectvar PyInt_Type = PyIntType{name: "int",PyObject_HEAD: PyObject_HEAD_INIT((*tagPyTypeObject)(&PyType_Type)),PyTypeFunc: &PyIntType{},}func PyInt_Create(value int) PyObject {object := PyIntObject{}object.refCount = 1object.TagPyTypeObject = (*tagPyTypeObject)(&PyInt_Type)object.value = valuereturn &object}func (PyType PyIntType) AddFun(left, right PyObject) PyObject {intLeft := left.(*PyIntObject)intRight := right.(*PyIntObject)return PyInt_Create(intLeft.value + intRight.value)}func (PyType PyIntType) PrintFun(object PyObject) {fmt.Println(object.(*PyIntObject).value)}func (PyType PyIntType) HashFun(object PyObject) int32 {return int32(object.(*PyIntObject).value)}func (obj PyIntObject) GetType() *tagPyTypeObject {return obj.TagPyTypeObject}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。