Skip to content

Commit 2275892

Browse files
committed
Re-organized project's source.
Removed "GIT." prefix from error codes.
1 parent d0a3b0a commit 2275892

22 files changed

+82
-97
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ set(LUA_GIT2_SRC
6161
)
6262

6363
if(${USE_PRE_GENERATED_BINDINGS})
64-
set(LUA_GIT2_SRC pre_generated-git2.nobj.c)
64+
set(LUA_GIT2_SRC src/pre_generated-git2.nobj.c)
6565
else()
6666
# Generate Lua bindings.
6767
GenLuaNativeObjects(LUA_GIT2_SRC)

git2.nobj.lua

+17-18
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ hide_meta_info = false, --true,
66

77
include "git2.h",
88

9-
package "GIT" {
9+
-- Error codes
1010
const "SUCCESS" { 0 },
1111
const "ERROR" { -1 },
1212
const "ENOTOID" { -2 },
@@ -23,25 +23,24 @@ const "EFLOCKFAIL" { -12 },
2323
const "EZLIB" { -13 },
2424
const "EBUSY" { -14 },
2525
const "EBAREINDEX" { -15 },
26-
},
2726

2827
subfiles {
29-
"repository.nobj.lua",
30-
"rawobject.nobj.lua",
31-
"oid.nobj.lua",
32-
"database.nobj.lua",
33-
"database_backend.nobj.lua",
34-
"index.nobj.lua",
35-
"index_entry.nobj.lua",
36-
"error.nobj.lua",
37-
"object.nobj.lua",
38-
"blob.nobj.lua",
39-
"signature.nobj.lua",
40-
"commit.nobj.lua",
41-
"tree.nobj.lua",
42-
"tree_entry.nobj.lua",
43-
"tag.nobj.lua",
44-
"revwalk.nobj.lua",
28+
"src/repository.nobj.lua",
29+
"src/rawobject.nobj.lua",
30+
"src/oid.nobj.lua",
31+
"src/database.nobj.lua",
32+
"src/database_backend.nobj.lua",
33+
"src/index.nobj.lua",
34+
"src/index_entry.nobj.lua",
35+
"src/error.nobj.lua",
36+
"src/object.nobj.lua",
37+
"src/blob.nobj.lua",
38+
"src/signature.nobj.lua",
39+
"src/commit.nobj.lua",
40+
"src/tree.nobj.lua",
41+
"src/tree_entry.nobj.lua",
42+
"src/tag.nobj.lua",
43+
"src/revwalk.nobj.lua",
4544
},
4645
}
4746

blob.nobj.lua src/blob.nobj.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
-- THE SOFTWARE.
2020

21-
c_source [[
22-
typedef git_blob Blob;
23-
]]
24-
2521
object "Blob" {
22+
c_source [[
23+
typedef git_blob Blob;
24+
]],
2625
extends "Object",
2726
constructor "new" {
2827
var_in{"Repository *", "repo"},

commit.nobj.lua src/commit.nobj.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
-- THE SOFTWARE.
2020

21-
c_source [[
22-
typedef git_commit Commit;
23-
]]
24-
2521
object "Commit" {
22+
c_source [[
23+
typedef git_commit Commit;
24+
]],
2625
extends "Object",
2726
constructor "new" {
2827
var_in{"Repository *", "repo"},

database.nobj.lua src/database.nobj.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
-- THE SOFTWARE.
2020

21-
c_source [[
22-
typedef git_odb Database;
23-
]]
24-
2521
object "Database" {
22+
c_source [[
23+
typedef git_odb Database;
24+
]],
2625
constructor "new" {
2726
var_out{"GitError", "err"},
2827
c_source [[

database_backend.nobj.lua src/database_backend.nobj.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
-- THE SOFTWARE.
2020

21-
c_source [[
21+
object "DatabaseBackend" {
22+
c_source [[
2223
//typedef struct RawObject RawObject;
2324
#include <git2/odb_backend.h>
2425
@@ -161,9 +162,7 @@ static void database_backend_free_cb(git_odb_backend *backend)
161162
DatabaseBackend_unref(lua_backend);
162163
}
163164
164-
]]
165-
166-
object "DatabaseBackend" {
165+
]],
167166
constructor {
168167
var_in{"lua_State *", "L"},
169168
c_source [[

error.nobj.lua src/error.nobj.lua

File renamed without changes.

index.nobj.lua src/index.nobj.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
-- THE SOFTWARE.
2020

21-
c_source [[
22-
typedef git_index Index;
23-
]]
24-
2521
object "Index" {
22+
c_source [[
23+
typedef git_index Index;
24+
]],
2625
constructor "bare" {
2726
var_in{"const char *", "index_path"},
2827
var_out{"GitError", "err"},

index_entry.nobj.lua src/index_entry.nobj.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
-- THE SOFTWARE.
2020

21-
c_source [[
22-
typedef git_index_entry IndexEntry;
23-
]]
24-
2521
object "IndexEntry" {
22+
c_source [[
23+
typedef git_index_entry IndexEntry;
24+
]],
2625
const "NAMEMASK" { 0x0fff },
2726
const "STAGEMASK" { 0x3000 },
2827
const "EXTENDED" { 0x4000 },

object.nobj.lua src/object.nobj.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
-- THE SOFTWARE.
2020

21-
c_source [[
22-
typedef git_object Object;
23-
]]
24-
2521
object "Object" {
22+
c_source [[
23+
typedef git_object Object;
24+
]],
2625
dyn_caster {
2726
caster_type = "switch",
2827
value_function = "git_object_type",

oid.nobj.lua src/oid.nobj.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
-- THE SOFTWARE.
2020

21-
c_source [[
22-
typedef git_oid OID;
23-
]]
24-
2521
object "OID" {
22+
c_source [[
23+
typedef git_oid OID;
24+
]],
2625
userdata_type = 'simple',
2726
constructor "str" {
2827
var_in{"const char *", "hex"},
File renamed without changes.

rawobject.nobj.lua src/rawobject.nobj.lua

+10-11
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
-- THE SOFTWARE.
2020

21-
c_source [[
21+
object "RawObject" {
22+
c_source [[
2223
typedef struct RawObject {
2324
git_rawobj git;
2425
int ref;
@@ -54,32 +55,30 @@ static void RawObject_from_git_rawobj(lua_State *L, RawObject *raw, git_rawobj *
5455
}
5556
}
5657
57-
]]
58-
59-
object "RawObject" {
58+
]],
6059
userdata_type = 'embed',
6160
default = 'NULL',
62-
constructor "header" {
61+
constructor "new" {
6362
var_in{"const char *", "type"},
64-
var_in{"size_t", "len"},
63+
var_in{"const char *", "data"},
6564
c_source [[
6665
RawObject raw; /* temp. storage, this gets copied. */
6766
${this} = &(raw);
68-
raw.git.data = NULL;
69-
raw.git.len = ${len};
7067
raw.git.type = git_object_string2type(${type});
7168
raw.ref = LUA_REFNIL;
69+
RawObject_set_data_and_ref(L, &raw, ${data}, ${data}_len, ${data::idx});
7270
]],
7371
},
74-
constructor "new" {
72+
constructor "header" {
7573
var_in{"const char *", "type"},
76-
var_in{"const char *", "data"},
74+
var_in{"size_t", "len"},
7775
c_source [[
7876
RawObject raw; /* temp. storage, this gets copied. */
7977
${this} = &(raw);
78+
raw.git.data = NULL;
79+
raw.git.len = ${len};
8080
raw.git.type = git_object_string2type(${type});
8181
raw.ref = LUA_REFNIL;
82-
RawObject_set_data_and_ref(L, &raw, ${data}, ${data}_len, ${data::idx});
8382
]],
8483
},
8584
destructor "close" {

repository.nobj.lua src/repository.nobj.lua

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
-- THE SOFTWARE.
2020

21-
c_source [[
22-
typedef git_repository Repository;
23-
24-
]]
25-
2621
object "Repository" {
22+
c_source [[
23+
typedef git_repository Repository;
24+
]],
2725
constructor "open" {
2826
var_in{"const char *", "path"},
2927
var_out{"GitError", "err"},

revwalk.nobj.lua src/revwalk.nobj.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
-- THE SOFTWARE.
2020

21-
c_source [[
22-
typedef git_revwalk RevWalk;
23-
]]
24-
2521
object "RevWalk" {
22+
c_source [[
23+
typedef git_revwalk RevWalk;
24+
]],
2625
extends "Object",
2726
const "SORT_NONE" { 0x00 },
2827
const "SORT_TOPOLOGICAL" { 0x01 },

signature.nobj.lua src/signature.nobj.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
-- THE SOFTWARE.
2020

21-
c_source [[
22-
typedef git_signature Signature;
23-
]]
24-
2521
object "Signature" {
22+
c_source [[
23+
typedef git_signature Signature;
24+
]],
2625
constructor {
2726
c_call "Signature *" "git_signature_new"
2827
{ "const char *", "name", "const char *", "email", "time_t", "time", "int", "offset" },

tag.nobj.lua src/tag.nobj.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
-- THE SOFTWARE.
2020

21-
c_source [[
22-
typedef git_tag Tag;
23-
]]
24-
2521
object "Tag" {
22+
c_source [[
23+
typedef git_tag Tag;
24+
]],
2625
extends "Object",
2726
constructor "new" {
2827
var_in{"Repository *", "repo"},

tree.nobj.lua src/tree.nobj.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
-- THE SOFTWARE.
2020

21-
c_source [[
22-
typedef git_tree Tree;
23-
]]
24-
2521
object "Tree" {
22+
c_source [[
23+
typedef git_tree Tree;
24+
]],
2625
extends "Object",
2726
constructor "new" {
2827
var_in{"Repository *", "repo"},

tree_entry.nobj.lua src/tree_entry.nobj.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
-- THE SOFTWARE.
2020

21-
c_source [[
22-
typedef git_tree_entry TreeEntry;
23-
]]
24-
2521
object "TreeEntry" {
22+
c_source [[
23+
typedef git_tree_entry TreeEntry;
24+
]],
2625
method "name" {
2726
c_call "const char *" "git_tree_entry_name" {}
2827
},

0 commit comments

Comments
 (0)