-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d38da7a
commit 10d4228
Showing
9 changed files
with
192 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
version: 0.10 | ||
version: 0.01 | ||
date: | ||
changes: | ||
- First Release |
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 |
---|---|---|
@@ -1,13 +1,44 @@ | ||
#include <perl_libgit2.h> | ||
#include "EXTERN.h" | ||
#include "perl.h" | ||
#include "XSUB.h" | ||
#include "ppport.h" | ||
|
||
MODULE = Git::XS::LibGit2 PACKAGE = Git::XS::LibGit2 | ||
#include "git2.h" | ||
#include <helpers.c> | ||
|
||
typedef struct { | ||
git_repository *repo; | ||
} git_t; | ||
|
||
MODULE = Git::XS PACKAGE = Git::XS | ||
PROTOTYPES: DISABLE | ||
VERSIONCHECK: DISABLE | ||
|
||
void | ||
Object () | ||
PPCODE: | ||
PL_markstack_ptr++; | ||
Object(); | ||
return; | ||
_build(self) | ||
SV *self | ||
PREINIT: | ||
git_t *git; | ||
CODE: | ||
Newx(git, sizeof(git_t), git_t); | ||
xs_object_magic_attach_struct(aTHX_ SvRV(self), git); | ||
SV *repo = call_getter(self, "repo"); | ||
if (call_test(self, "repo_exists", repo)) | ||
git_repository_open(&(git->repo), SvPV_nolen(repo)); | ||
|
||
SV * | ||
init(self) | ||
SV *self | ||
PREINIT: | ||
int rc; | ||
git_t *git = xs_object_magic_get_struct_rv(aTHX_ self); | ||
CODE: | ||
RETVAL = self; | ||
SV *repo = call_getter(self, "repo"); | ||
char *path = SvPV_nolen(repo); | ||
git_repository **pptr = &(git->repo); | ||
rc = git_repository_init(pptr, path, 0); | ||
if (rc != GIT_SUCCESS) | ||
croak("git init failed with code: %d", rc); | ||
OUTPUT: | ||
RETVAL |
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,66 @@ | ||
static SV * call_getter(SV *self, char *has) { | ||
dSP; | ||
int count; | ||
|
||
ENTER; | ||
SAVETMPS; | ||
|
||
PUSHMARK(SP); | ||
XPUSHs(self); | ||
PUTBACK; | ||
|
||
count = call_method(has, G_SCALAR); | ||
|
||
SPAGAIN; | ||
|
||
if (SvTRUE(ERRSV)) { | ||
POPs; | ||
croak("Git::XS error - %s\n", SvPV_nolen(ERRSV)); | ||
} | ||
|
||
if (count != 1) | ||
croak("O NOES"); | ||
|
||
SV *ret = SvREFCNT_inc(POPs); | ||
|
||
PUTBACK; | ||
FREETMPS; | ||
LEAVE; | ||
|
||
return ret; | ||
} | ||
|
||
static int call_test(SV *self, char *test, SV* arg) { | ||
dSP; | ||
int count; | ||
|
||
ENTER; | ||
SAVETMPS; | ||
|
||
PUSHMARK(SP); | ||
XPUSHs(self); | ||
XPUSHs(arg); | ||
PUTBACK; | ||
|
||
count = call_method(test, G_SCALAR); | ||
|
||
SPAGAIN; | ||
|
||
if (SvTRUE(ERRSV)) { | ||
POPs; | ||
croak("Git::XS error - %s\n", SvPV_nolen(ERRSV)); | ||
} | ||
|
||
if (count != 1) | ||
croak("O NOES"); | ||
|
||
int ret = POPi; | ||
|
||
PUTBACK; | ||
FREETMPS; | ||
LEAVE; | ||
|
||
return ret; | ||
} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.