From d2bd2d13971108079d1907a59d7c9d5db8d6156e Mon Sep 17 00:00:00 2001 From: Diptanshu8 Date: Tue, 11 Jul 2017 11:16:02 +0000 Subject: [PATCH] added basefilename to python_subs --- api/api_testing.py | 4 +-- api/ccextractor.py | 4 +++ api/ccextractor_wrap.c | 63 ++++++++++++++++++++++++++++++++++++++++++ src/ccextractor.c | 5 ++-- src/ccextractor.h | 1 + 5 files changed, 72 insertions(+), 5 deletions(-) diff --git a/api/api_testing.py b/api/api_testing.py index e91e00b4..9f19e364 100644 --- a/api/api_testing.py +++ b/api/api_testing.py @@ -13,7 +13,7 @@ start_ret = cc.api_start(s); #print cc.cvar.python_subs.number_of_lines #print type(cc.cvar.python_subs.subs) -for item in xrange(cc.cc_to_python_get_subs_number_of_lines()): - print item, cc.cc_to_python_get_sub(item) +#for item in xrange(cc.cc_to_python_get_subs_number_of_lines()): +# print item, cc.cc_to_python_get_sub(item) #os.system('clear') diff --git a/api/ccextractor.py b/api/ccextractor.py index 1025733a..9d8f38d4 100644 --- a/api/ccextractor.py +++ b/api/ccextractor.py @@ -151,6 +151,10 @@ class cc_to_python_subs(_object): __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, cc_to_python_subs, name) __repr__ = _swig_repr + __swig_setmethods__["basefilename"] = _ccextractor.cc_to_python_subs_basefilename_set + __swig_getmethods__["basefilename"] = _ccextractor.cc_to_python_subs_basefilename_get + if _newclass: + basefilename = _swig_property(_ccextractor.cc_to_python_subs_basefilename_get, _ccextractor.cc_to_python_subs_basefilename_set) __swig_setmethods__["subs"] = _ccextractor.cc_to_python_subs_subs_set __swig_getmethods__["subs"] = _ccextractor.cc_to_python_subs_subs_get if _newclass: diff --git a/api/ccextractor_wrap.c b/api/ccextractor_wrap.c index c085823b..ba24cbe1 100644 --- a/api/ccextractor_wrap.c +++ b/api/ccextractor_wrap.c @@ -3696,6 +3696,67 @@ SWIGINTERN PyObject *Swig_var_cc608_parity_table_get(void) { } +SWIGINTERN PyObject *_wrap_cc_to_python_subs_basefilename_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct cc_to_python_subs *arg1 = (struct cc_to_python_subs *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"OO:cc_to_python_subs_basefilename_set",&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cc_to_python_subs, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cc_to_python_subs_basefilename_set" "', argument " "1"" of type '" "struct cc_to_python_subs *""'"); + } + arg1 = (struct cc_to_python_subs *)(argp1); + res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "cc_to_python_subs_basefilename_set" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + if (arg1->basefilename) free((char*)arg1->basefilename); + if (arg2) { + size_t size = strlen((const char *)(arg2)) + 1; + arg1->basefilename = (char *)(char *)memcpy(malloc((size)*sizeof(char)), (const char *)(arg2), sizeof(char)*(size)); + } else { + arg1->basefilename = 0; + } + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cc_to_python_subs_basefilename_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + struct cc_to_python_subs *arg1 = (struct cc_to_python_subs *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + char *result = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:cc_to_python_subs_basefilename_get",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cc_to_python_subs, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cc_to_python_subs_basefilename_get" "', argument " "1"" of type '" "struct cc_to_python_subs *""'"); + } + arg1 = (struct cc_to_python_subs *)(argp1); + result = (char *) ((arg1)->basefilename); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_cc_to_python_subs_subs_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; struct cc_to_python_subs *arg1 = (struct cc_to_python_subs *) 0 ; @@ -4317,6 +4378,8 @@ static PyMethodDef SwigMethods[] = { { (char *)"dbg_print", _wrap_dbg_print, METH_VARARGS, NULL}, { (char *)"debug_608_to_ASC", _wrap_debug_608_to_ASC, METH_VARARGS, NULL}, { (char *)"add_cc_sub_text", _wrap_add_cc_sub_text, METH_VARARGS, NULL}, + { (char *)"cc_to_python_subs_basefilename_set", _wrap_cc_to_python_subs_basefilename_set, METH_VARARGS, NULL}, + { (char *)"cc_to_python_subs_basefilename_get", _wrap_cc_to_python_subs_basefilename_get, METH_VARARGS, NULL}, { (char *)"cc_to_python_subs_subs_set", _wrap_cc_to_python_subs_subs_set, METH_VARARGS, NULL}, { (char *)"cc_to_python_subs_subs_get", _wrap_cc_to_python_subs_subs_get, METH_VARARGS, NULL}, { (char *)"cc_to_python_subs_number_of_lines_set", _wrap_cc_to_python_subs_number_of_lines_set, METH_VARARGS, NULL}, diff --git a/src/ccextractor.c b/src/ccextractor.c index 083f7e85..186f4c90 100644 --- a/src/ccextractor.c +++ b/src/ccextractor.c @@ -408,6 +408,8 @@ int api_start(struct ccx_s_options api_options){ curl_easy_cleanup(curl); curl_global_cleanup(); #endif + python_subs.basefilename = ctx->basefilename; + mprint("extension=%s\n",ctx->extension); dinit_libraries(&ctx); if (!ret) @@ -511,8 +513,5 @@ int main(int argc, char* argv[]){ int compile_ret = compile_params(api_options,argc); int start_ret = api_start(*api_options); - printf("Printing python subs \n \n"); - //for(i=0;i