summaryrefslogtreecommitdiff
path: root/src/object.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-04-29 14:22:06 -0700
committerRussell Belfer <rb@github.com>2013-04-29 14:22:06 -0700
commitd77611022c4a43d5e67cf52ce2bc2b11ee5bcdc0 (patch)
treed59b9eb5648f5603db6e68c0cefd14ce7049e8e5 /src/object.h
parentb7f167da29effa125663b143d3daf79a6ad88d2e (diff)
downloadlibgit2-d77611022c4a43d5e67cf52ce2bc2b11ee5bcdc0.tar.gz
Standardize cast versions of git_object accessors
This removes the GIT_INLINE versions of the simple git_object accessors and standardizes them with a helper macro in src/object.h to build the function bodies.
Diffstat (limited to 'src/object.h')
-rw-r--r--src/object.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/object.h b/src/object.h
index d187c55b7..906d40736 100644
--- a/src/object.h
+++ b/src/object.h
@@ -28,4 +28,16 @@ int git_oid__parse(git_oid *oid, const char **buffer_out, const char *buffer_end
void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid);
+#define GIT_OBJ_WRAPPER(TYPE,OBJTYPE) \
+ int TYPE##_lookup(TYPE **out, git_repository *repo, const git_oid *id) { \
+ return git_object_lookup((git_object **)out, repo, id, OBJTYPE); } \
+ int TYPE##_lookup_prefix(TYPE **out, git_repository *repo, const git_oid *id, size_t len) { \
+ return git_object_lookup_prefix((git_object **)out, repo, id, len, OBJTYPE); } \
+ void TYPE##_free(TYPE *obj) { \
+ git_object_free((git_object *)obj); } \
+ const git_oid *TYPE##_id(const TYPE *obj) { \
+ return git_object_id((const git_object *)obj); } \
+ git_repository *TYPE##_owner(const TYPE *obj) { \
+ return git_object_owner((const git_object *)obj); }
+
#endif