func allocObject(cobj *C.git_object) Object { switch ObjectType(C.git_object_type(cobj)) { case ObjectCommit: commit := &Commit{ gitObject: gitObject{cobj}, cast_ptr: (*C.git_commit)(cobj), } runtime.SetFinalizer(commit, (*Commit).Free) return commit case ObjectTree: tree := &Tree{ gitObject: gitObject{cobj}, cast_ptr: (*C.git_tree)(cobj), } runtime.SetFinalizer(tree, (*Tree).Free) return tree case ObjectBlob: blob := &Blob{ gitObject: gitObject{cobj}, cast_ptr: (*C.git_blob)(cobj), } runtime.SetFinalizer(blob, (*Blob).Free) return blob } return nil }
func allocObject(cobj *C.git_object, repo *Repository) Object { obj := gitObject{ ptr: cobj, repo: repo, } switch ObjectType(C.git_object_type(cobj)) { case ObjectCommit: commit := &Commit{ gitObject: obj, cast_ptr: (*C.git_commit)(cobj), } runtime.SetFinalizer(commit, (*Commit).Free) return commit case ObjectTree: tree := &Tree{ gitObject: obj, cast_ptr: (*C.git_tree)(cobj), } runtime.SetFinalizer(tree, (*Tree).Free) return tree case ObjectBlob: blob := &Blob{ gitObject: obj, cast_ptr: (*C.git_blob)(cobj), } runtime.SetFinalizer(blob, (*Blob).Free) return blob case ObjectTag: tag := &Tag{ gitObject: obj, cast_ptr: (*C.git_tag)(cobj), } runtime.SetFinalizer(tag, (*Tag).Free) return tag } return nil }
func allocObject(cobj *C.git_object) Object { switch ObjectType(C.git_object_type(cobj)) { case OBJ_COMMIT: commit := &Commit{gitObject{cobj}} runtime.SetFinalizer(commit, (*Commit).Free) return commit case OBJ_TREE: tree := &Tree{gitObject{cobj}} runtime.SetFinalizer(tree, (*Tree).Free) return tree case OBJ_BLOB: blob := &Blob{gitObject{cobj}} runtime.SetFinalizer(blob, (*Blob).Free) return blob } return nil }
func (obj *Object) Type() ObjectType { return ObjectType(C.git_object_type(obj.git_object)) }
func (o gitObject) Type() ObjectType { return ObjectType(C.git_object_type(o.ptr)) }
func (o Object) Type() string { return C.GoString(C.git_object_type2string(C.git_object_type(o.obj))) }