summaryrefslogtreecommitdiff
path: root/source4/param
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-12-14 14:28:07 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:50:22 +0100
commitdf8c7da800f75ff45fb48de59d7ce3f0667d375f (patch)
tree65c17e04d7f2e83d2266b6f71ef04c8e79a94d3f /source4/param
parent43ac3d9b44b98d44db9b1550c47e8f96a410d1e9 (diff)
downloadsamba-df8c7da800f75ff45fb48de59d7ce3f0667d375f.tar.gz
samba-df8c7da800f75ff45fb48de59d7ce3f0667d375f.tar.bz2
samba-df8c7da800f75ff45fb48de59d7ce3f0667d375f.zip
r26454: Add simple SWIG macro for wrapping talloced types.
(This used to be commit 760fcc8bfa2a7cd7641465cb3bae889e9e0fbc75)
Diffstat (limited to 'source4/param')
-rw-r--r--source4/param/param.i7
-rw-r--r--source4/param/param.py2
-rw-r--r--source4/param/param_wrap.c112
3 files changed, 60 insertions, 61 deletions
diff --git a/source4/param/param.i b/source4/param/param.i
index ca1bb69184..674c1671e0 100644
--- a/source4/param/param.i
+++ b/source4/param/param.i
@@ -42,13 +42,11 @@ typedef struct param_section param_section;
%rename(LoadParm) loadparm_context;
-%nodefaultctor loadparm_context;
-%nodefaultdtor loadparm_context;
+%talloctype(loadparm_context);
typedef struct loadparm_context {
%extend {
loadparm_context(TALLOC_CTX *mem_ctx) { return loadparm_init(mem_ctx); }
- ~loadparm_context() { talloc_free($self); }
bool load(const char *filename) { return lp_load($self, filename); }
#ifdef SWIGPYTHON
int __len__() { return lp_numservices($self); }
@@ -73,10 +71,10 @@ typedef struct loadparm_service {
%rename(ParamFile) param_context;
+%talloctype(param_context);
typedef struct param_context {
%extend {
param(TALLOC_CTX *mem_ctx) { return param_init(mem_ctx); }
- ~param() { talloc_free($self); }
struct param_section *get_section(const char *name);
struct param_opt *get(const char *section_name, const char *name);
int set_string(const char *section, const char *param, const char *value);
@@ -93,6 +91,7 @@ typedef struct param_context {
}
} param;
+%talloctype(param);
typedef struct param_section {
%extend {
struct param_opt *get(const char *name);
diff --git a/source4/param/param.py b/source4/param/param.py
index 8ac009af96..9c0bac9c07 100644
--- a/source4/param/param.py
+++ b/source4/param/param.py
@@ -87,13 +87,13 @@ class ParamFile(object):
__repr__ = _swig_repr
def __init__(self, *args, **kwargs):
_param.ParamFile_swiginit(self,_param.new_ParamFile(*args, **kwargs))
- __swig_destroy__ = _param.delete_ParamFile
def __getitem__(self, name):
ret = self.get_section(name)
if ret is None:
raise KeyError("No such section %s" % name)
return ret
+ __swig_destroy__ = _param.delete_ParamFile
ParamFile.get_section = new_instancemethod(_param.ParamFile_get_section,None,ParamFile)
ParamFile.get = new_instancemethod(_param.ParamFile_get,None,ParamFile)
ParamFile.set_string = new_instancemethod(_param.ParamFile_set_string,None,ParamFile)
diff --git a/source4/param/param_wrap.c b/source4/param/param_wrap.c
index 704759ad19..ac4a752c7f 100644
--- a/source4/param/param_wrap.c
+++ b/source4/param/param_wrap.c
@@ -2524,7 +2524,6 @@ typedef struct loadparm_service loadparm_service;
typedef struct param_section param_section;
SWIGINTERN loadparm_context *new_loadparm_context(TALLOC_CTX *mem_ctx){ return loadparm_init(mem_ctx); }
-SWIGINTERN void delete_loadparm_context(loadparm_context *self){ talloc_free(self); }
SWIGINTERN swig_type_info*
SWIG_pchar_descriptor(void)
@@ -2640,6 +2639,7 @@ SWIG_FromCharPtr(const char *cptr)
SWIGINTERN bool loadparm_context_is_mydomain(loadparm_context *self,char const *domain){ return lp_is_mydomain(self, domain); }
SWIGINTERN bool loadparm_context_is_myname(loadparm_context *self,char const *name){ return lp_is_myname(self, name); }
+SWIGINTERN void delete_loadparm_context(loadparm_context *self){ talloc_free(self); }
SWIGINTERN char const *loadparm_service_volume_label(loadparm_service *self){ return volume_label(self); }
SWIGINTERN char const *loadparm_service_printername(loadparm_service *self){ return lp_printername(self); }
SWIGINTERN int loadparm_service_maxprintjobs(loadparm_service *self){ return lp_maxprintjobs(self); }
@@ -2665,36 +2665,6 @@ fail:
}
-SWIGINTERN PyObject *_wrap_delete_LoadParm(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- loadparm_context *arg1 = (loadparm_context *) 0 ;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject * obj0 = 0 ;
- char * kwnames[] = {
- (char *) "self", NULL
- };
-
- {
- arg1 = loadparm_init(NULL);
- }
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:delete_LoadParm",kwnames,&obj0)) SWIG_fail;
- if (obj0) {
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, SWIG_POINTER_DISOWN | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_LoadParm" "', argument " "1"" of type '" "loadparm_context *""'");
- }
- arg1 = (loadparm_context *)(argp1);
- }
- delete_loadparm_context(arg1);
-
- resultobj = SWIG_Py_Void();
- return resultobj;
-fail:
- return NULL;
-}
-
-
SWIGINTERN PyObject *_wrap_LoadParm_load(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
loadparm_context *arg1 = (loadparm_context *) 0 ;
@@ -2931,6 +2901,36 @@ fail:
}
+SWIGINTERN PyObject *_wrap_delete_LoadParm(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_context *arg1 = (loadparm_context *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+ char * kwnames[] = {
+ (char *) "self", NULL
+ };
+
+ {
+ arg1 = loadparm_init(NULL);
+ }
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:delete_LoadParm",kwnames,&obj0)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_LoadParm" "', argument " "1"" of type '" "loadparm_context *""'");
+ }
+ arg1 = (loadparm_context *)(argp1);
+ }
+ delete_loadparm_context(arg1);
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *LoadParm_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
@@ -3035,29 +3035,6 @@ fail:
}
-SWIGINTERN PyObject *_wrap_delete_ParamFile(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- param *arg1 = (param *) 0 ;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_context, SWIG_POINTER_DISOWN | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ParamFile" "', argument " "1"" of type '" "param *""'");
- }
- arg1 = (param *)(argp1);
- delete_param(arg1);
-
- resultobj = SWIG_Py_Void();
- return resultobj;
-fail:
- return NULL;
-}
-
-
SWIGINTERN PyObject *_wrap_ParamFile_get_section(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
param *arg1 = (param *) 0 ;
@@ -3313,6 +3290,29 @@ fail:
}
+SWIGINTERN PyObject *_wrap_delete_ParamFile(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param *arg1 = (param *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_context, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ParamFile" "', argument " "1"" of type '" "param *""'");
+ }
+ arg1 = (param *)(argp1);
+ delete_param(arg1);
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *ParamFile_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
@@ -3410,13 +3410,13 @@ SWIGINTERN PyObject *param_section_swiginit(PyObject *SWIGUNUSEDPARM(self), PyOb
static PyMethodDef SwigMethods[] = {
{ (char *)"new_LoadParm", (PyCFunction)_wrap_new_LoadParm, METH_NOARGS, NULL},
- { (char *)"delete_LoadParm", (PyCFunction) _wrap_delete_LoadParm, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"LoadParm_load", (PyCFunction) _wrap_LoadParm_load, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"LoadParm___len__", (PyCFunction) _wrap_LoadParm___len__, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"LoadParm___getitem__", (PyCFunction) _wrap_LoadParm___getitem__, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"LoadParm_configfile", (PyCFunction) _wrap_LoadParm_configfile, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"LoadParm_is_mydomain", (PyCFunction) _wrap_LoadParm_is_mydomain, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"LoadParm_is_myname", (PyCFunction) _wrap_LoadParm_is_myname, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"delete_LoadParm", (PyCFunction) _wrap_delete_LoadParm, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"LoadParm_swigregister", LoadParm_swigregister, METH_VARARGS, NULL},
{ (char *)"LoadParm_swiginit", LoadParm_swiginit, METH_VARARGS, NULL},
{ (char *)"loadparm_service_volume_label", (PyCFunction)_wrap_loadparm_service_volume_label, METH_O, NULL},
@@ -3424,13 +3424,13 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"loadparm_service_maxprintjobs", (PyCFunction)_wrap_loadparm_service_maxprintjobs, METH_O, NULL},
{ (char *)"loadparm_service_swigregister", loadparm_service_swigregister, METH_VARARGS, NULL},
{ (char *)"new_ParamFile", (PyCFunction)_wrap_new_ParamFile, METH_NOARGS, NULL},
- { (char *)"delete_ParamFile", (PyCFunction)_wrap_delete_ParamFile, METH_O, NULL},
{ (char *)"ParamFile_get_section", (PyCFunction) _wrap_ParamFile_get_section, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"ParamFile_get", (PyCFunction) _wrap_ParamFile_get, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"ParamFile_set_string", (PyCFunction) _wrap_ParamFile_set_string, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"ParamFile_read", (PyCFunction) _wrap_ParamFile_read, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"ParamFile_use", (PyCFunction) _wrap_ParamFile_use, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"ParamFile_write", (PyCFunction) _wrap_ParamFile_write, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"delete_ParamFile", (PyCFunction)_wrap_delete_ParamFile, METH_O, NULL},
{ (char *)"ParamFile_swigregister", ParamFile_swigregister, METH_VARARGS, NULL},
{ (char *)"ParamFile_swiginit", ParamFile_swiginit, METH_VARARGS, NULL},
{ (char *)"param_section_get", (PyCFunction) _wrap_param_section_get, METH_VARARGS | METH_KEYWORDS, NULL},