Skip to content

Commit fa62911

Browse files
committed
add some APIs, Fix #10
1 parent dfbaa6a commit fa62911

File tree

2 files changed

+91
-33
lines changed

2 files changed

+91
-33
lines changed

src/index.nobj.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,18 @@ typedef git_index Index;
4747
method "add" {
4848
c_method_call "GitError" "git_index_add" { "IndexEntry *", "source_entry" }
4949
},
50+
method "add_all" {
51+
-- TODO: git_index_matched_path_cb
52+
c_method_call "GitError" "git_index_add_all" { "const StrArray *", "pathspec", "unsigned int", "flags", "void *", "callback", "void *", "payload" }
53+
},
5054
-- TODO: add_conflict?
5155
method "remove" {
5256
c_method_call "GitError" "git_index_remove" { "const char *", "path", "int", "stage" }
5357
},
58+
method "remove_all" {
59+
-- TODO: git_index_matched_path_cb
60+
c_method_call "GitError" "git_index_remove_all" { "const StrArray *", "pathspec", "void *", "callback", "void *", "payload" }
61+
},
5462
method "get_byindex" {
5563
c_method_call "const IndexEntry *" "git_index_get_byindex" { "size_t", "n" }
5664
},

src/pre_generated-git2.nobj.c

Lines changed: 83 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,8 @@ static void obj_type_register_implements(lua_State *L, const reg_impl *impls) {
642642
#define REG_MODULES_AS_GLOBALS 0
643643
#endif
644644

645-
/* For Lua 5.2 don't register modules as globals. */
646-
#if LUA_VERSION_NUM == 502
645+
/* For Lua >=5.2 don't register modules as globals. */
646+
#if LUA_VERSION_NUM >= 502
647647
#undef REG_MODULES_AS_GLOBALS
648648
#define REG_MODULES_AS_GLOBALS 0
649649
#endif
@@ -3047,6 +3047,31 @@ static int Index__add__meth(lua_State *L) {
30473047
return 2;
30483048
}
30493049

3050+
/* method: add_all */
3051+
static int Index__add_all__meth(lua_State *L) {
3052+
Index * this_idx1;
3053+
const StrArray * pathspec_idx2;
3054+
unsigned int flags_idx3;
3055+
void * callback_idx4;
3056+
void * payload_idx5;
3057+
GitError rc_git_index_add_all_idx1 = GIT_OK;
3058+
this_idx1 = obj_type_Index_check(L,1);
3059+
pathspec_idx2 = obj_type_StrArray_check(L,2);
3060+
flags_idx3 = luaL_checkinteger(L,3);
3061+
callback_idx4 = lua_touserdata(L,4);
3062+
payload_idx5 = lua_touserdata(L,5);
3063+
rc_git_index_add_all_idx1 = git_index_add_all(this_idx1, pathspec_idx2, flags_idx3, callback_idx4, payload_idx5);
3064+
/* check for error. */
3065+
if((GIT_OK != rc_git_index_add_all_idx1)) {
3066+
lua_pushnil(L);
3067+
error_code__GitError__push(L, rc_git_index_add_all_idx1);
3068+
} else {
3069+
lua_pushboolean(L, 1);
3070+
lua_pushnil(L);
3071+
}
3072+
return 2;
3073+
}
3074+
30503075
/* method: remove */
30513076
static int Index__remove__meth(lua_State *L) {
30523077
Index * this_idx1;
@@ -3069,6 +3094,29 @@ static int Index__remove__meth(lua_State *L) {
30693094
return 2;
30703095
}
30713096

3097+
/* method: remove_all */
3098+
static int Index__remove_all__meth(lua_State *L) {
3099+
Index * this_idx1;
3100+
const StrArray * pathspec_idx2;
3101+
void * callback_idx3;
3102+
void * payload_idx4;
3103+
GitError rc_git_index_remove_all_idx1 = GIT_OK;
3104+
this_idx1 = obj_type_Index_check(L,1);
3105+
pathspec_idx2 = obj_type_StrArray_check(L,2);
3106+
callback_idx3 = lua_touserdata(L,3);
3107+
payload_idx4 = lua_touserdata(L,4);
3108+
rc_git_index_remove_all_idx1 = git_index_remove_all(this_idx1, pathspec_idx2, callback_idx3, payload_idx4);
3109+
/* check for error. */
3110+
if((GIT_OK != rc_git_index_remove_all_idx1)) {
3111+
lua_pushnil(L);
3112+
error_code__GitError__push(L, rc_git_index_remove_all_idx1);
3113+
} else {
3114+
lua_pushboolean(L, 1);
3115+
lua_pushnil(L);
3116+
}
3117+
return 2;
3118+
}
3119+
30723120
/* method: get_byindex */
30733121
static int Index__get_byindex__meth(lua_State *L) {
30743122
Index * this_idx1;
@@ -3485,12 +3533,12 @@ static int Object__string2type__func(lua_State *L) {
34853533
static void dyn_caster_Object(void **obj, obj_type **type) {
34863534
Object * base_obj = (Object *)*obj;
34873535
switch(git_object_type(base_obj)) {
3488-
case GIT_OBJ_TAG:
3489-
*type = &(obj_type_Tag);
3490-
break;
34913536
case GIT_OBJ_COMMIT:
34923537
*type = &(obj_type_Commit);
34933538
break;
3539+
case GIT_OBJ_TAG:
3540+
*type = &(obj_type_Tag);
3541+
break;
34943542
case GIT_OBJ_BLOB:
34953543
*type = &(obj_type_Blob);
34963544
break;
@@ -4504,14 +4552,14 @@ static const obj_field obj_OID_fields[] = {
45044552
};
45054553

45064554
static const obj_const obj_OID_constants[] = {
4507-
#ifdef GIT_OID_MINPREFIXLEN
4508-
{"MINPREFIXLEN", NULL, GIT_OID_MINPREFIXLEN, CONST_NUMBER},
4509-
#endif
45104555
#ifdef GIT_OID_RAWSZ
45114556
{"RAWSZ", NULL, GIT_OID_RAWSZ, CONST_NUMBER},
45124557
#endif
45134558
#ifdef GIT_OID_HEXSZ
45144559
{"HEXSZ", NULL, GIT_OID_HEXSZ, CONST_NUMBER},
4560+
#endif
4561+
#ifdef GIT_OID_MINPREFIXLEN
4562+
{"MINPREFIXLEN", NULL, GIT_OID_MINPREFIXLEN, CONST_NUMBER},
45154563
#endif
45164564
{NULL, NULL, 0.0 , 0}
45174565
};
@@ -4640,7 +4688,9 @@ static const luaL_Reg obj_Index_methods[] = {
46404688
{"find", Index__find__meth},
46414689
{"add_bypath", Index__add_bypath__meth},
46424690
{"add", Index__add__meth},
4691+
{"add_all", Index__add_all__meth},
46434692
{"remove", Index__remove__meth},
4693+
{"remove_all", Index__remove_all__meth},
46444694
{"get_byindex", Index__get_byindex__meth},
46454695
{"get_bypath", Index__get_bypath__meth},
46464696
{"entrycount", Index__entrycount__meth},
@@ -4715,8 +4765,8 @@ static const obj_field obj_IndexEntry_fields[] = {
47154765
};
47164766

47174767
static const obj_const obj_IndexEntry_constants[] = {
4718-
{"EXTENDED", NULL, 16384, CONST_NUMBER},
47194768
{"STAGEMASK", NULL, 12288, CONST_NUMBER},
4769+
{"EXTENDED", NULL, 16384, CONST_NUMBER},
47204770
{"VALID", NULL, 32768, CONST_NUMBER},
47214771
{"STAGESHIFT", NULL, 12, CONST_NUMBER},
47224772
{"NAMEMASK", NULL, 4095, CONST_NUMBER},
@@ -4805,10 +4855,10 @@ static const luaL_Reg obj_Blob_pub_funcs[] = {
48054855
};
48064856

48074857
static const luaL_Reg obj_Blob_methods[] = {
4808-
{"type", Object__type__meth},
4809-
{"free", Object__free__meth},
48104858
{"id", Object__id__meth},
4859+
{"free", Object__free__meth},
48114860
{"owner", Object__owner__meth},
4861+
{"type", Object__type__meth},
48124862
{"rawcontent", Blob__rawcontent__meth},
48134863
{"rawsize", Blob__rawsize__meth},
48144864
{NULL, NULL}
@@ -4881,9 +4931,9 @@ static const luaL_Reg obj_Commit_pub_funcs[] = {
48814931
};
48824932

48834933
static const luaL_Reg obj_Commit_methods[] = {
4884-
{"type", Object__type__meth},
48854934
{"free", Object__free__meth},
48864935
{"owner", Object__owner__meth},
4936+
{"type", Object__type__meth},
48874937
{"id", Commit__id__meth},
48884938
{"message_encoding", Commit__message_encoding__meth},
48894939
{"message", Commit__message__meth},
@@ -4927,10 +4977,10 @@ static const luaL_Reg obj_Tree_pub_funcs[] = {
49274977
};
49284978

49294979
static const luaL_Reg obj_Tree_methods[] = {
4930-
{"type", Object__type__meth},
4931-
{"free", Object__free__meth},
49324980
{"id", Object__id__meth},
4981+
{"free", Object__free__meth},
49334982
{"owner", Object__owner__meth},
4983+
{"type", Object__type__meth},
49344984
{"entrycount", Tree__entrycount__meth},
49354985
{"entry_byname", Tree__entry_byname__meth},
49364986
{"entry_byindex", Tree__entry_byindex__meth},
@@ -5001,10 +5051,10 @@ static const luaL_Reg obj_Tag_pub_funcs[] = {
50015051
};
50025052

50035053
static const luaL_Reg obj_Tag_methods[] = {
5004-
{"type", Object__type__meth},
5005-
{"free", Object__free__meth},
50065054
{"id", Object__id__meth},
5055+
{"free", Object__free__meth},
50075056
{"owner", Object__owner__meth},
5057+
{"type", Object__type__meth},
50085058
{"target", Tag__target__meth},
50095059
{"name", Tag__name__meth},
50105060
{"tagger", Tag__tagger__meth},
@@ -5070,8 +5120,8 @@ static const obj_field obj_RevWalk_fields[] = {
50705120
static const obj_const obj_RevWalk_constants[] = {
50715121
{"SORT_REVERSE", NULL, 4, CONST_NUMBER},
50725122
{"SORT_NONE", NULL, 0, CONST_NUMBER},
5073-
{"SORT_TIME", NULL, 2, CONST_NUMBER},
50745123
{"SORT_TOPOLOGICAL", NULL, 1, CONST_NUMBER},
5124+
{"SORT_TIME", NULL, 2, CONST_NUMBER},
50755125
{NULL, NULL, 0.0 , 0}
50765126
};
50775127

@@ -5125,35 +5175,35 @@ static const luaL_Reg git2_function[] = {
51255175
};
51265176

51275177
static const obj_const git2_constants[] = {
5128-
{"REF_INVALID", NULL, 0, CONST_NUMBER},
5129-
{"REF_HAS_PEEL", NULL, 8, CONST_NUMBER},
51305178
#ifdef GIT_REVWALKOVER
51315179
{"REVWALKOVER", NULL, GIT_REVWALKOVER, CONST_NUMBER},
51325180
#endif
5133-
#ifdef GIT_EBUFS
5134-
{"EBUFS", NULL, GIT_EBUFS, CONST_NUMBER},
5181+
#ifdef GIT_OK
5182+
{"OK", NULL, GIT_OK, CONST_NUMBER},
51355183
#endif
5184+
{"REF_OID", NULL, 1, CONST_NUMBER},
5185+
#ifdef GIT_ERROR
5186+
{"ERROR", NULL, GIT_ERROR, CONST_NUMBER},
5187+
#endif
5188+
{"REF_PACKED", NULL, 4, CONST_NUMBER},
51365189
#ifdef GIT_ENOTFOUND
51375190
{"ENOTFOUND", NULL, GIT_ENOTFOUND, CONST_NUMBER},
51385191
#endif
5139-
{"REF_PACKED", NULL, 4, CONST_NUMBER},
5192+
{"REF_LISTALL", NULL, 7, CONST_NUMBER},
51405193
#ifdef GIT_EEXISTS
51415194
{"EEXISTS", NULL, GIT_EEXISTS, CONST_NUMBER},
51425195
#endif
5143-
#ifdef GIT_OK
5144-
{"OK", NULL, GIT_OK, CONST_NUMBER},
5196+
{"REF_HAS_PEEL", NULL, 8, CONST_NUMBER},
5197+
#ifdef GIT_EAMBIGUOUS
5198+
{"EAMBIGUOUS", NULL, GIT_EAMBIGUOUS, CONST_NUMBER},
51455199
#endif
5146-
{"REF_LISTALL", NULL, 7, CONST_NUMBER},
5147-
{"REF_OID", NULL, 1, CONST_NUMBER},
5200+
{"REF_SYMBOLIC", NULL, 2, CONST_NUMBER},
5201+
#ifdef GIT_EBUFS
5202+
{"EBUFS", NULL, GIT_EBUFS, CONST_NUMBER},
5203+
#endif
5204+
{"REF_INVALID", NULL, 0, CONST_NUMBER},
51485205
#ifdef GIT_PASSTHROUGH
51495206
{"PASSTHROUGH", NULL, GIT_PASSTHROUGH, CONST_NUMBER},
5150-
#endif
5151-
#ifdef GIT_ERROR
5152-
{"ERROR", NULL, GIT_ERROR, CONST_NUMBER},
5153-
#endif
5154-
{"REF_SYMBOLIC", NULL, 2, CONST_NUMBER},
5155-
#ifdef GIT_EAMBIGUOUS
5156-
{"EAMBIGUOUS", NULL, GIT_EAMBIGUOUS, CONST_NUMBER},
51575207
#endif
51585208
{NULL, NULL, 0.0 , 0}
51595209
};

0 commit comments

Comments
 (0)