Skip to content

Commit 29662d8

Browse files
committed
Fix compile bug with LuaJIT 2.1
1 parent 2e1978e commit 29662d8

File tree

1 file changed

+51
-50
lines changed

1 file changed

+51
-50
lines changed

src/pre_generated-git2.nobj.c

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020
#define luaL_Reg luaL_reg
2121
#endif
2222

23-
/* some Lua 5.1 compatibility support. */
24-
#if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM == 501)
2523
/*
26-
** Adapted from Lua 5.2.0
24+
** Adapted from Lua 5.2.0 luaL_setfuncs.
2725
*/
28-
static void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
26+
static void nobj_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
2927
luaL_checkstack(L, nup, "too many upvalues");
3028
for (; l->name != NULL; l++) { /* fill the table with given functions */
3129
int i;
@@ -38,6 +36,9 @@ static void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
3836
lua_pop(L, nup); /* remove upvalues */
3937
}
4038

39+
/* some Lua 5.1 compatibility support. */
40+
#if !defined(LUA_VERSION_NUM) || (LUA_VERSION_NUM == 501)
41+
4142
#define lua_load_no_mode(L, reader, data, source) \
4243
lua_load(L, reader, data, source)
4344

@@ -1209,7 +1210,7 @@ static void obj_type_register_package(lua_State *L, const reg_sub_module *type_r
12091210
/* create public functions table. */
12101211
if(reg_list != NULL && reg_list[0].name != NULL) {
12111212
/* register functions */
1212-
luaL_setfuncs(L, reg_list, 0);
1213+
nobj_setfuncs(L, reg_list, 0);
12131214
}
12141215

12151216
obj_type_register_constants(L, type_reg->constants, -1, type_reg->bidirectional_consts);
@@ -1224,17 +1225,17 @@ static void obj_type_register_meta(lua_State *L, const reg_sub_module *type_reg)
12241225
reg_list = type_reg->pub_funcs;
12251226
if(reg_list != NULL && reg_list[0].name != NULL) {
12261227
/* register functions */
1227-
luaL_setfuncs(L, reg_list, 0);
1228+
nobj_setfuncs(L, reg_list, 0);
12281229
}
12291230

12301231
obj_type_register_constants(L, type_reg->constants, -1, type_reg->bidirectional_consts);
12311232

12321233
/* register methods. */
1233-
luaL_setfuncs(L, type_reg->methods, 0);
1234+
nobj_setfuncs(L, type_reg->methods, 0);
12341235

12351236
/* create metatable table. */
12361237
lua_newtable(L);
1237-
luaL_setfuncs(L, type_reg->metas, 0); /* fill metatable */
1238+
nobj_setfuncs(L, type_reg->metas, 0); /* fill metatable */
12381239
/* setmetatable on meta-object. */
12391240
lua_setmetatable(L, -2);
12401241

@@ -1259,7 +1260,7 @@ static void obj_type_register(lua_State *L, const reg_sub_module *type_reg, int
12591260
reg_list = type_reg->pub_funcs;
12601261
if(reg_list != NULL && reg_list[0].name != NULL) {
12611262
/* register "constructors" as to object's public API */
1262-
luaL_setfuncs(L, reg_list, 0); /* fill public API table. */
1263+
nobj_setfuncs(L, reg_list, 0); /* fill public API table. */
12631264

12641265
/* make public API table callable as the default constructor. */
12651266
lua_newtable(L); /* create metatable */
@@ -1289,7 +1290,7 @@ static void obj_type_register(lua_State *L, const reg_sub_module *type_reg, int
12891290
#endif
12901291
}
12911292

1292-
luaL_setfuncs(L, type_reg->methods, 0); /* fill methods table. */
1293+
nobj_setfuncs(L, type_reg->methods, 0); /* fill methods table. */
12931294

12941295
luaL_newmetatable(L, type->name); /* create metatable */
12951296
lua_pushliteral(L, ".name");
@@ -1307,7 +1308,7 @@ static void obj_type_register(lua_State *L, const reg_sub_module *type_reg, int
13071308
lua_pushvalue(L, -2); /* dup metatable. */
13081309
lua_rawset(L, priv_table); /* priv_table["<object_name>"] = metatable */
13091310

1310-
luaL_setfuncs(L, type_reg->metas, 0); /* fill metatable */
1311+
nobj_setfuncs(L, type_reg->metas, 0); /* fill metatable */
13111312

13121313
/* add obj_bases to metatable. */
13131314
while(base->id >= 0) {
@@ -3484,18 +3485,18 @@ static int Object__string2type__func(lua_State *L) {
34843485
static void dyn_caster_Object(void **obj, obj_type **type) {
34853486
Object * base_obj = (Object *)*obj;
34863487
switch(git_object_type(base_obj)) {
3487-
case GIT_OBJ_BLOB:
3488-
*type = &(obj_type_Blob);
3489-
break;
3490-
case GIT_OBJ_TREE:
3491-
*type = &(obj_type_Tree);
3492-
break;
34933488
case GIT_OBJ_TAG:
34943489
*type = &(obj_type_Tag);
34953490
break;
34963491
case GIT_OBJ_COMMIT:
34973492
*type = &(obj_type_Commit);
34983493
break;
3494+
case GIT_OBJ_BLOB:
3495+
*type = &(obj_type_Blob);
3496+
break;
3497+
case GIT_OBJ_TREE:
3498+
*type = &(obj_type_Tree);
3499+
break;
34993500
default:
35003501
break;
35013502
}
@@ -4503,14 +4504,14 @@ static const obj_field obj_OID_fields[] = {
45034504
};
45044505

45054506
static const obj_const obj_OID_constants[] = {
4507+
#ifdef GIT_OID_MINPREFIXLEN
4508+
{"MINPREFIXLEN", NULL, GIT_OID_MINPREFIXLEN, CONST_NUMBER},
4509+
#endif
45064510
#ifdef GIT_OID_RAWSZ
45074511
{"RAWSZ", NULL, GIT_OID_RAWSZ, CONST_NUMBER},
45084512
#endif
45094513
#ifdef GIT_OID_HEXSZ
45104514
{"HEXSZ", NULL, GIT_OID_HEXSZ, CONST_NUMBER},
4511-
#endif
4512-
#ifdef GIT_OID_MINPREFIXLEN
4513-
{"MINPREFIXLEN", NULL, GIT_OID_MINPREFIXLEN, CONST_NUMBER},
45144515
#endif
45154516
{NULL, NULL, 0.0 , 0}
45164517
};
@@ -4715,10 +4716,10 @@ static const obj_field obj_IndexEntry_fields[] = {
47154716

47164717
static const obj_const obj_IndexEntry_constants[] = {
47174718
{"EXTENDED", NULL, 16384, CONST_NUMBER},
4718-
{"NAMEMASK", NULL, 4095, CONST_NUMBER},
47194719
{"STAGEMASK", NULL, 12288, CONST_NUMBER},
47204720
{"VALID", NULL, 32768, CONST_NUMBER},
47214721
{"STAGESHIFT", NULL, 12, CONST_NUMBER},
4722+
{"NAMEMASK", NULL, 4095, CONST_NUMBER},
47224723
{NULL, NULL, 0.0 , 0}
47234724
};
47244725

@@ -4804,10 +4805,10 @@ static const luaL_Reg obj_Blob_pub_funcs[] = {
48044805
};
48054806

48064807
static const luaL_Reg obj_Blob_methods[] = {
4807-
{"owner", Object__owner__meth},
4808-
{"id", Object__id__meth},
48094808
{"type", Object__type__meth},
48104809
{"free", Object__free__meth},
4810+
{"id", Object__id__meth},
4811+
{"owner", Object__owner__meth},
48114812
{"rawcontent", Blob__rawcontent__meth},
48124813
{"rawsize", Blob__rawsize__meth},
48134814
{NULL, NULL}
@@ -4880,9 +4881,9 @@ static const luaL_Reg obj_Commit_pub_funcs[] = {
48804881
};
48814882

48824883
static const luaL_Reg obj_Commit_methods[] = {
4883-
{"owner", Object__owner__meth},
48844884
{"type", Object__type__meth},
48854885
{"free", Object__free__meth},
4886+
{"owner", Object__owner__meth},
48864887
{"id", Commit__id__meth},
48874888
{"message_encoding", Commit__message_encoding__meth},
48884889
{"message", Commit__message__meth},
@@ -4926,10 +4927,10 @@ static const luaL_Reg obj_Tree_pub_funcs[] = {
49264927
};
49274928

49284929
static const luaL_Reg obj_Tree_methods[] = {
4929-
{"owner", Object__owner__meth},
4930-
{"id", Object__id__meth},
49314930
{"type", Object__type__meth},
49324931
{"free", Object__free__meth},
4932+
{"id", Object__id__meth},
4933+
{"owner", Object__owner__meth},
49334934
{"entrycount", Tree__entrycount__meth},
49344935
{"entry_byname", Tree__entry_byname__meth},
49354936
{"entry_byindex", Tree__entry_byindex__meth},
@@ -5000,10 +5001,10 @@ static const luaL_Reg obj_Tag_pub_funcs[] = {
50005001
};
50015002

50025003
static const luaL_Reg obj_Tag_methods[] = {
5003-
{"owner", Object__owner__meth},
5004-
{"id", Object__id__meth},
50055004
{"type", Object__type__meth},
50065005
{"free", Object__free__meth},
5006+
{"id", Object__id__meth},
5007+
{"owner", Object__owner__meth},
50075008
{"target", Tag__target__meth},
50085009
{"name", Tag__name__meth},
50095010
{"tagger", Tag__tagger__meth},
@@ -5067,10 +5068,10 @@ static const obj_field obj_RevWalk_fields[] = {
50675068
};
50685069

50695070
static const obj_const obj_RevWalk_constants[] = {
5071+
{"SORT_REVERSE", NULL, 4, CONST_NUMBER},
50705072
{"SORT_NONE", NULL, 0, CONST_NUMBER},
5071-
{"SORT_TOPOLOGICAL", NULL, 1, CONST_NUMBER},
50725073
{"SORT_TIME", NULL, 2, CONST_NUMBER},
5073-
{"SORT_REVERSE", NULL, 4, CONST_NUMBER},
5074+
{"SORT_TOPOLOGICAL", NULL, 1, CONST_NUMBER},
50745075
{NULL, NULL, 0.0 , 0}
50755076
};
50765077

@@ -5124,35 +5125,35 @@ static const luaL_Reg git2_function[] = {
51245125
};
51255126

51265127
static const obj_const git2_constants[] = {
5127-
{"REF_OID", NULL, 1, CONST_NUMBER},
5128-
#ifdef GIT_OK
5129-
{"OK", NULL, GIT_OK, CONST_NUMBER},
5130-
#endif
5131-
#ifdef GIT_EEXISTS
5132-
{"EEXISTS", NULL, GIT_EEXISTS, CONST_NUMBER},
5133-
#endif
5134-
{"REF_PACKED", NULL, 4, CONST_NUMBER},
5135-
{"REF_SYMBOLIC", NULL, 2, CONST_NUMBER},
5128+
{"REF_INVALID", NULL, 0, CONST_NUMBER},
51365129
{"REF_HAS_PEEL", NULL, 8, CONST_NUMBER},
5137-
#ifdef GIT_ERROR
5138-
{"ERROR", NULL, GIT_ERROR, CONST_NUMBER},
5139-
#endif
5140-
#ifdef GIT_ENOTFOUND
5141-
{"ENOTFOUND", NULL, GIT_ENOTFOUND, CONST_NUMBER},
5130+
#ifdef GIT_REVWALKOVER
5131+
{"REVWALKOVER", NULL, GIT_REVWALKOVER, CONST_NUMBER},
51425132
#endif
51435133
#ifdef GIT_EBUFS
51445134
{"EBUFS", NULL, GIT_EBUFS, CONST_NUMBER},
51455135
#endif
5146-
{"REF_INVALID", NULL, 0, CONST_NUMBER},
5147-
#ifdef GIT_REVWALKOVER
5148-
{"REVWALKOVER", NULL, GIT_REVWALKOVER, CONST_NUMBER},
5136+
#ifdef GIT_ENOTFOUND
5137+
{"ENOTFOUND", NULL, GIT_ENOTFOUND, CONST_NUMBER},
51495138
#endif
5150-
#ifdef GIT_EAMBIGUOUS
5151-
{"EAMBIGUOUS", NULL, GIT_EAMBIGUOUS, CONST_NUMBER},
5139+
{"REF_PACKED", NULL, 4, CONST_NUMBER},
5140+
#ifdef GIT_EEXISTS
5141+
{"EEXISTS", NULL, GIT_EEXISTS, CONST_NUMBER},
5142+
#endif
5143+
#ifdef GIT_OK
5144+
{"OK", NULL, GIT_OK, CONST_NUMBER},
51525145
#endif
51535146
{"REF_LISTALL", NULL, 7, CONST_NUMBER},
5147+
{"REF_OID", NULL, 1, CONST_NUMBER},
51545148
#ifdef GIT_PASSTHROUGH
51555149
{"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},
51565157
#endif
51575158
{NULL, NULL, 0.0 , 0}
51585159
};
@@ -5244,7 +5245,7 @@ LUA_NOBJ_API int luaopen_git2(lua_State *L) {
52445245
luaL_register(L, "git2", git2_function);
52455246
#else
52465247
lua_newtable(L);
5247-
luaL_setfuncs(L, git2_function, 0);
5248+
nobj_setfuncs(L, git2_function, 0);
52485249
#endif
52495250

52505251
/* register module constants. */

0 commit comments

Comments
 (0)