From 8b2abc1ca731bfaff4290a386f86e7f49b1c1b39 Mon Sep 17 00:00:00 2001 From: Nico von Geyso Date: Sun, 10 Mar 2013 14:21:26 +0100 Subject: [PATCH] added missing remote header file and fixed instance creation --- include/pygit2/remote.h | 38 ++++++++++++++++++++++++++++++++++++++ src/remote.c | 7 ++++--- src/repository.c | 12 ++++++++---- 3 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 include/pygit2/remote.h diff --git a/include/pygit2/remote.h b/include/pygit2/remote.h new file mode 100644 index 0000000..726a52a --- /dev/null +++ b/include/pygit2/remote.h @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2013 The pygit2 contributors + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, + * as published by the Free Software Foundation. + * + * In addition to the permissions in the GNU General Public License, + * the authors give you unlimited permission to link the compiled + * version of this file into combinations with other programs, + * and to distribute those combinations without any restriction + * coming from the use of this file. (The General Public License + * restrictions do apply in other respects; for example, they cover + * modification of the file, and distribution when not linked into + * a combined executable.) + * + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDE_pygit2_remote_h +#define INCLUDE_pygit2_remote_h + +#define PY_SSIZE_T_CLEAN +#include +#include + +PyObject* Remote_init(Remote *self, PyObject *args, PyObject *kwds); +PyObject* Remote_fetch(Remote *self, PyObject *args); + +#endif diff --git a/src/remote.c b/src/remote.c index 42288e7..ccf7e55 100644 --- a/src/remote.c +++ b/src/remote.c @@ -31,12 +31,13 @@ #include #include #include +#include extern PyObject *GitError; extern PyTypeObject RepositoryType; PyObject * -Remote_call(Remote *self, PyObject *args, PyObject *kwds) +Remote_init(Remote *self, PyObject *args, PyObject *kwds) { Repository* py_repo = NULL; char *name = NULL; @@ -239,7 +240,7 @@ PyTypeObject RemoteType = { 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ - (ternaryfunc) Remote_call, /* tp_call */ + 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ @@ -260,7 +261,7 @@ PyTypeObject RemoteType = { 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - 0, /* tp_init */ + (initproc)Remote_init, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ }; diff --git a/src/repository.c b/src/repository.c index 4fb5309..bba47e3 100644 --- a/src/repository.c +++ b/src/repository.c @@ -34,6 +34,7 @@ #include #include #include +#include extern PyObject *GitError; @@ -1049,20 +1050,23 @@ PyObject * Repository_remotes__get__(Repository *self) { git_strarray remotes; - PyObject* py_list = NULL, *py_tmp; + PyObject* py_list = NULL, *py_args = NULL; + Remote *py_remote; size_t i; git_remote_list(&remotes, self->repo); py_list = PyList_New(remotes.count); for (i=0; i < remotes.count; ++i) { - py_tmp = INSTANCIATE_CLASS(RemoteType, Py_BuildValue("Os", self, remotes.strings[i])); - PyList_SetItem(py_list, i, py_tmp); + py_remote = PyObject_New(Remote, &RemoteType); + py_args = Py_BuildValue("Os", self, remotes.strings[i]); + Remote_init(py_remote, py_args, NULL); + PyList_SetItem(py_list, i, (PyObject*) py_remote); } git_strarray_free(&remotes); - return py_list; + return (PyObject*) py_list; }