This repository has been archived by the owner on Sep 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from vmarkovtsev/master
Wrap more objects with CGo
- Loading branch information
Showing
10 changed files
with
498 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// +build ignore | ||
package main | ||
|
||
import ( | ||
"C" | ||
|
||
"gopkg.in/src-d/go-git.v3" | ||
) | ||
|
||
//export c_Blame_get_Path | ||
func c_Blame_get_Path(b uint64) *C.char { | ||
obj, ok := GetObject(Handle(b)) | ||
if !ok { | ||
return nil | ||
} | ||
blame := obj.(*git.Blame) | ||
return C.CString(blame.Path) | ||
} | ||
|
||
//export c_Blame_get_Rev | ||
func c_Blame_get_Rev(b uint64) *C.char { | ||
obj, ok := GetObject(Handle(b)) | ||
if !ok { | ||
return nil | ||
} | ||
blame := obj.(*git.Blame) | ||
return CBytes(blame.Rev[:]) | ||
} | ||
|
||
|
||
//export c_Blame_get_Lines_len | ||
func c_Blame_get_Lines_len(b uint64) int { | ||
obj, ok := GetObject(Handle(b)) | ||
if !ok { | ||
return 0 | ||
} | ||
blame := obj.(*git.Blame) | ||
return len(blame.Lines) | ||
} | ||
|
||
//export c_Blame_get_Lines_item | ||
func c_Blame_get_Lines_item(b uint64, i int) { | ||
obj, ok := GetObject(Handle(b)) | ||
if !ok { | ||
return | ||
} | ||
blame := obj.(*git.Blame) | ||
line := blame.Lines[i] | ||
_ = line | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package main | ||
|
||
import ( | ||
"C" | ||
|
||
"gopkg.in/src-d/go-git.v3" | ||
) | ||
|
||
//export c_File_get_Name | ||
func c_File_get_Name(f uint64) *C.char { | ||
obj, ok := GetObject(Handle(f)) | ||
if !ok { | ||
return nil | ||
} | ||
file := obj.(*git.File) | ||
return C.CString(file.Name) | ||
} | ||
|
||
//export c_File_get_Mode | ||
func c_File_get_Mode(f uint64) uint32 { | ||
obj, ok := GetObject(Handle(f)) | ||
if !ok { | ||
return 0 | ||
} | ||
file := obj.(*git.File) | ||
return uint32(file.Mode) | ||
} | ||
|
||
//export c_NewFileIter | ||
func c_NewFileIter(r uint64, t uint64) uint64 { | ||
obj, ok := GetObject(Handle(r)) | ||
if !ok { | ||
return IH | ||
} | ||
repo := obj.(*git.Repository) | ||
obj, ok = GetObject(Handle(t)) | ||
if !ok { | ||
return IH | ||
} | ||
tree := obj.(*git.Tree) | ||
iter := git.NewFileIter(repo, tree) | ||
return uint64(RegisterObject(iter)) | ||
} | ||
|
||
//export c_FileIter_Next | ||
func c_FileIter_Next(i uint64) (uint64, int, *C.char) { | ||
obj, ok := GetObject(Handle(i)) | ||
if !ok { | ||
return IH, ErrorCodeNotFound, C.CString(MessageNotFound) | ||
} | ||
iter := obj.(*git.FileIter) | ||
file, err := iter.Next() | ||
if err != nil { | ||
return IH, ErrorCodeInternal, C.CString(err.Error()) | ||
} | ||
return uint64(RegisterObject(file)), ErrorCodeSuccess, nil | ||
} | ||
|
||
//export c_FileIter_Close | ||
func c_FileIter_Close(i uint64) { | ||
obj, ok := GetObject(Handle(i)) | ||
if !ok { | ||
return | ||
} | ||
iter := obj.(*git.FileIter) | ||
iter.Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.