mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
Stop using SWIG for ldb Python bindings.
This commit is contained in:
parent
1f4bd4b82c
commit
28f80dbb7c
3
.gitignore
vendored
3
.gitignore
vendored
@ -348,3 +348,6 @@ librpc/gen_ndr/*_s.c
|
|||||||
librpc/gen_ndr/cli_named_pipe_auth.[ch]
|
librpc/gen_ndr/cli_named_pipe_auth.[ch]
|
||||||
librpc/gen_ndr/srv_named_pipe_auth.[ch]
|
librpc/gen_ndr/srv_named_pipe_auth.[ch]
|
||||||
lib/tevent/Makefile
|
lib/tevent/Makefile
|
||||||
|
lib/tevent/tevent.so
|
||||||
|
lib/tevent/libtevent.so*
|
||||||
|
lib/tevent/libtevent.a
|
||||||
|
@ -22,7 +22,6 @@ SHLD_FLAGS = @SHLD_FLAGS@
|
|||||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||||
PICFLAG = @PICFLAG@
|
PICFLAG = @PICFLAG@
|
||||||
SHLIBEXT = @SHLIBEXT@
|
SHLIBEXT = @SHLIBEXT@
|
||||||
SWIG = swig
|
|
||||||
PYTHON = @PYTHON@
|
PYTHON = @PYTHON@
|
||||||
PYTHON_CONFIG = @PYTHON_CONFIG@
|
PYTHON_CONFIG = @PYTHON_CONFIG@
|
||||||
PYTHON_BUILD_TARGET = @PYTHON_BUILD_TARGET@
|
PYTHON_BUILD_TARGET = @PYTHON_BUILD_TARGET@
|
||||||
|
@ -9,8 +9,6 @@ autoheader $IPATHS || exit 1
|
|||||||
|
|
||||||
rm -rf autom4te.cache
|
rm -rf autom4te.cache
|
||||||
|
|
||||||
swig -O -Wall -python -keyword events.i # Ignore errors for now
|
|
||||||
|
|
||||||
echo "Now run ./configure and then make."
|
echo "Now run ./configure and then make."
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
Unix SMB/CIFS implementation.
|
|
||||||
Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program 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. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
%module(docstring="Event management.",package="samba.events") events;
|
|
||||||
|
|
||||||
%import "../../lib/talloc/talloc.i";
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include "tevent.h"
|
|
||||||
typedef struct event_context event;
|
|
||||||
%}
|
|
||||||
|
|
||||||
typedef struct event_context {
|
|
||||||
%extend {
|
|
||||||
%feature("docstring") event "S.__init__()";
|
|
||||||
event(TALLOC_CTX *mem_ctx) { return event_context_init(mem_ctx); }
|
|
||||||
%feature("docstring") loop_once "S.loop_once() -> int";
|
|
||||||
int loop_once(void);
|
|
||||||
%feature("docstring") loop_wait "S.loop_wait() -> int";
|
|
||||||
int loop_wait(void);
|
|
||||||
}
|
|
||||||
} event;
|
|
||||||
%talloctype(event);
|
|
||||||
|
|
||||||
%typemap(default,noblock=1) struct event_context * {
|
|
||||||
$1 = event_context_init(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(default,noblock=1) struct event_context * {
|
|
||||||
$1 = event_context_init(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char *name);
|
|
||||||
|
|
||||||
%feature("docstring") event_backend_list "event_backend_list() -> list";
|
|
||||||
const char **event_backend_list(TALLOC_CTX *mem_ctx);
|
|
||||||
%feature("docstring") event_set_default_backend "event_set_default_backend(name) -> None";
|
|
||||||
%rename(set_default_backend) event_set_default_backend;
|
|
||||||
void event_set_default_backend(const char *backend);
|
|
@ -1,94 +0,0 @@
|
|||||||
# This file was automatically generated by SWIG (http://www.swig.org).
|
|
||||||
# Version 1.3.36
|
|
||||||
#
|
|
||||||
# Don't modify this file, modify the SWIG interface instead.
|
|
||||||
|
|
||||||
"""
|
|
||||||
Event management.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import _events
|
|
||||||
import new
|
|
||||||
new_instancemethod = new.instancemethod
|
|
||||||
try:
|
|
||||||
_swig_property = property
|
|
||||||
except NameError:
|
|
||||||
pass # Python < 2.2 doesn't have 'property'.
|
|
||||||
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
|
|
||||||
if (name == "thisown"): return self.this.own(value)
|
|
||||||
if (name == "this"):
|
|
||||||
if type(value).__name__ == 'PySwigObject':
|
|
||||||
self.__dict__[name] = value
|
|
||||||
return
|
|
||||||
method = class_type.__swig_setmethods__.get(name,None)
|
|
||||||
if method: return method(self,value)
|
|
||||||
if (not static) or hasattr(self,name):
|
|
||||||
self.__dict__[name] = value
|
|
||||||
else:
|
|
||||||
raise AttributeError("You cannot add attributes to %s" % self)
|
|
||||||
|
|
||||||
def _swig_setattr(self,class_type,name,value):
|
|
||||||
return _swig_setattr_nondynamic(self,class_type,name,value,0)
|
|
||||||
|
|
||||||
def _swig_getattr(self,class_type,name):
|
|
||||||
if (name == "thisown"): return self.this.own()
|
|
||||||
method = class_type.__swig_getmethods__.get(name,None)
|
|
||||||
if method: return method(self)
|
|
||||||
raise AttributeError,name
|
|
||||||
|
|
||||||
def _swig_repr(self):
|
|
||||||
try: strthis = "proxy of " + self.this.__repr__()
|
|
||||||
except: strthis = ""
|
|
||||||
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
|
|
||||||
|
|
||||||
import types
|
|
||||||
try:
|
|
||||||
_object = types.ObjectType
|
|
||||||
_newclass = 1
|
|
||||||
except AttributeError:
|
|
||||||
class _object : pass
|
|
||||||
_newclass = 0
|
|
||||||
del types
|
|
||||||
|
|
||||||
|
|
||||||
def _swig_setattr_nondynamic_method(set):
|
|
||||||
def set_attr(self,name,value):
|
|
||||||
if (name == "thisown"): return self.this.own(value)
|
|
||||||
if hasattr(self,name) or (name == "this"):
|
|
||||||
set(self,name,value)
|
|
||||||
else:
|
|
||||||
raise AttributeError("You cannot add attributes to %s" % self)
|
|
||||||
return set_attr
|
|
||||||
|
|
||||||
|
|
||||||
class event(object):
|
|
||||||
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
|
|
||||||
__repr__ = _swig_repr
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
"""S.__init__()"""
|
|
||||||
_events.event_swiginit(self,_events.new_event(*args, **kwargs))
|
|
||||||
def loop_once(*args, **kwargs):
|
|
||||||
"""S.loop_once() -> int"""
|
|
||||||
return _events.event_loop_once(*args, **kwargs)
|
|
||||||
|
|
||||||
def loop_wait(*args, **kwargs):
|
|
||||||
"""S.loop_wait() -> int"""
|
|
||||||
return _events.event_loop_wait(*args, **kwargs)
|
|
||||||
|
|
||||||
__swig_destroy__ = _events.delete_event
|
|
||||||
event.loop_once = new_instancemethod(_events.event_loop_once,None,event)
|
|
||||||
event.loop_wait = new_instancemethod(_events.event_loop_wait,None,event)
|
|
||||||
event_swigregister = _events.event_swigregister
|
|
||||||
event_swigregister(event)
|
|
||||||
|
|
||||||
event_context_init_byname = _events.event_context_init_byname
|
|
||||||
|
|
||||||
def event_backend_list(*args):
|
|
||||||
"""event_backend_list() -> list"""
|
|
||||||
return _events.event_backend_list(*args)
|
|
||||||
|
|
||||||
def set_default_backend(*args, **kwargs):
|
|
||||||
"""event_set_default_backend(name) -> None"""
|
|
||||||
return _events.set_default_backend(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
110
lib/tevent/pytevent.c
Normal file
110
lib/tevent/pytevent.c
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
Unix SMB/CIFS implementation.
|
||||||
|
Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2008
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Python.h>
|
||||||
|
#include <tevent.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <../talloc/pytalloc.h>
|
||||||
|
#include <tevent_util.h>
|
||||||
|
|
||||||
|
PyAPI_DATA(PyTypeObject) PyEventContext;
|
||||||
|
|
||||||
|
static PyObject *py_set_default_backend(PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "s", &name))
|
||||||
|
return NULL;
|
||||||
|
event_set_default_backend(name);
|
||||||
|
return Py_None;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *py_backend_list(PyObject *self)
|
||||||
|
{
|
||||||
|
const char **backends = event_backend_list(NULL);
|
||||||
|
PyObject *ret;
|
||||||
|
int i, len;
|
||||||
|
|
||||||
|
len = ev_str_list_length(backends);
|
||||||
|
ret = PyList_New(len);
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
PyList_SetItem(ret, i, PyString_FromString(backends[i]));
|
||||||
|
talloc_free(backends);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyMethodDef tevent_methods[] = {
|
||||||
|
{ "set_default_backend", (PyCFunction)py_set_default_backend,
|
||||||
|
METH_VARARGS, "set_default_backend(name) -> None" },
|
||||||
|
{ "backend_list", (PyCFunction)py_backend_list,
|
||||||
|
METH_NOARGS, "backend_list() -> list" },
|
||||||
|
{ NULL },
|
||||||
|
};
|
||||||
|
|
||||||
|
static PyObject *py_event_ctx_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
|
{
|
||||||
|
const char *kwnames[] = { "name", NULL };
|
||||||
|
char *name = NULL;
|
||||||
|
struct event_context *ev_ctx;
|
||||||
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|s", (char **)kwnames, &name))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (name == NULL)
|
||||||
|
ev_ctx = event_context_init(NULL);
|
||||||
|
else
|
||||||
|
ev_ctx = event_context_init_byname(NULL, name);
|
||||||
|
|
||||||
|
return py_talloc_import(&PyEventContext, ev_ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *py_event_ctx_loop_once(py_talloc_Object *self)
|
||||||
|
{
|
||||||
|
return PyInt_FromLong(event_loop_once(self->ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *py_event_ctx_loop_wait(py_talloc_Object *self)
|
||||||
|
{
|
||||||
|
return PyInt_FromLong(event_loop_wait(self->ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyMethodDef py_event_ctx_methods[] = {
|
||||||
|
{ "loop_once", (PyCFunction)py_event_ctx_loop_once, METH_NOARGS,
|
||||||
|
"S.loop_once() -> int" },
|
||||||
|
{ "loop_wait", (PyCFunction)py_event_ctx_loop_wait, METH_NOARGS,
|
||||||
|
"S.loop_wait() -> int" },
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
PyTypeObject PyEventContext = {
|
||||||
|
.tp_name = "EventContext",
|
||||||
|
.tp_methods = py_event_ctx_methods,
|
||||||
|
.tp_basicsize = sizeof(py_talloc_Object),
|
||||||
|
.tp_dealloc = py_talloc_dealloc,
|
||||||
|
.tp_new = py_event_ctx_new,
|
||||||
|
};
|
||||||
|
|
||||||
|
void inittevent(void)
|
||||||
|
{
|
||||||
|
PyObject *m;
|
||||||
|
|
||||||
|
m = Py_InitModule3("tevent", tevent_methods, "Event management.");
|
||||||
|
if (m == NULL)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
@ -37,17 +37,13 @@ clean::
|
|||||||
check-python:: build-python
|
check-python:: build-python
|
||||||
$(LIB_PATH_VAR)=. PYTHONPATH=".:$(teventdir)" $(PYTHON) $(teventdir)/tests.py
|
$(LIB_PATH_VAR)=. PYTHONPATH=".:$(teventdir)" $(PYTHON) $(teventdir)/tests.py
|
||||||
|
|
||||||
install-swig::
|
build-python:: tevent.$(SHLIBEXT)
|
||||||
mkdir -p $(DESTDIR)`$(SWIG) -swiglib`
|
|
||||||
cp tevent.i $(DESTDIR)`$(SWIG) -swiglib`
|
|
||||||
|
|
||||||
build-python:: _events.$(SHLIBEXT)
|
pytevent.o: $(teventdir)/pytevent.c
|
||||||
|
$(CC) $(PICFLAG) -c $(teventdir)/pytevent.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags`
|
||||||
|
|
||||||
events_wrap.o: $(teventdir)/events_wrap.c
|
tevent.$(SHLIBEXT): libtevent.$(SHLIBEXT) pytevent.o
|
||||||
$(CC) $(PICFLAG) -c $(teventdir)/events_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags`
|
$(SHLD) $(SHLD_FLAGS) -o $@ pytevent.o -L. -ltevent `$(PYTHON_CONFIG) --libs`
|
||||||
|
|
||||||
_events.$(SHLIBEXT): libtevent.$(SHLIBEXT) events_wrap.o
|
|
||||||
$(SHLD) $(SHLD_FLAGS) -o $@ events_wrap.o -L. -ltevent `$(PYTHON_CONFIG) --libs`
|
|
||||||
|
|
||||||
install-python:: build-python
|
install-python:: build-python
|
||||||
mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` \
|
mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` \
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
/**
|
/**
|
||||||
return the number of elements in a string list
|
return the number of elements in a string list
|
||||||
*/
|
*/
|
||||||
static size_t str_list_length(const char **list)
|
size_t ev_str_list_length(const char **list)
|
||||||
{
|
{
|
||||||
size_t ret;
|
size_t ret;
|
||||||
for (ret=0;list && list[ret];ret++) /* noop */ ;
|
for (ret=0;list && list[ret];ret++) /* noop */ ;
|
||||||
@ -40,7 +40,7 @@ static size_t str_list_length(const char **list)
|
|||||||
*/
|
*/
|
||||||
const char **ev_str_list_add(const char **list, const char *s)
|
const char **ev_str_list_add(const char **list, const char *s)
|
||||||
{
|
{
|
||||||
size_t len = str_list_length(list);
|
size_t len = ev_str_list_length(list);
|
||||||
const char **ret;
|
const char **ret;
|
||||||
|
|
||||||
ret = talloc_realloc(NULL, list, const char *, len+2);
|
ret = talloc_realloc(NULL, list, const char *, len+2);
|
||||||
|
@ -115,3 +115,4 @@ do { \
|
|||||||
|
|
||||||
const char **ev_str_list_add(const char **list, const char *s);
|
const char **ev_str_list_add(const char **list, const char *s);
|
||||||
int ev_set_blocking(int fd, bool set);
|
int ev_set_blocking(int fd, bool set);
|
||||||
|
size_t ev_str_list_length(const char **list);
|
||||||
|
Loading…
Reference in New Issue
Block a user