Author: juhliarik
Date: Wed Oct 31 10:12:50 2007
New Revision: 41658
URL: http://svn.opensuse.org/viewcvs/yast?rev=41658&view=rev
Log:
-deleted temporary part of code (testing additional parts)
Modified:
trunk/python-bindings/src/Makefile.am
trunk/python-bindings/src/YCP.cc
trunk/python-bindings/src/YCPDeclarations.cc
trunk/python-bindings/src/YCPDeclarations.h
trunk/python-bindings/src/YCPTypes/Code.cc
trunk/python-bindings/src/YCPTypes/Term.cc
trunk/python-bindings/src/YCPTypes/YCPTypesInternal.cc
trunk/python-bindings/src/YPython.cc
trunk/python-bindings/src/YPythonNamespace.cc
Modified: trunk/python-bindings/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/python-bindings/src/Makefile.am?rev=41658&r1=41657&r2=41658&view=diff
==============================================================================
--- trunk/python-bindings/src/Makefile.am (original)
+++ trunk/python-bindings/src/Makefile.am Wed Oct 31 10:12:50 2007
@@ -30,9 +30,7 @@
libYCP_la_SOURCES = \
$(liby2lang_python_la_SOURCES) \
YCP.cc \
- PythonLogger.cc PythonLogger.h \
- YPythonNamespace.cc YPythonNamespace.h \
- YCPDeclarations.cc YCPDeclarations.
+ PythonLogger.cc PythonLogger.h
@@ -54,6 +52,8 @@
-lycp -ly2 \
-Xlinker --no-whole-archive \
-ly2util \
+ -ly2 \
+ -lYCPDeclarations \
-version-info 2:0
libYCP_la_LIBADD = libYCPTypes.la #libYCPDeclarations.la
Modified: trunk/python-bindings/src/YCP.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/python-bindings/src/YCP.cc?rev=41658&r1=41657&r2=41658&view=diff
==============================================================================
--- trunk/python-bindings/src/YCP.cc (original)
+++ trunk/python-bindings/src/YCP.cc Wed Oct 31 10:12:50 2007
@@ -43,8 +43,6 @@
PyObject * SCR_Run (const char *scr_command, PyObject *args);
-PyObject * Py_ycp_code(PyObject *args);
-
void Py_y2logger(PyObject *args);
void init_wfm ();
@@ -129,12 +127,14 @@
return Py_None;
}
+/*
static PyObject * ycp_code (PyObject *self, PyObject *args) {
Py_ycp_code(args);
return Py_None;
}
+*/
/**
* This is needed for importing new module from ycp.
@@ -154,7 +154,6 @@
{"SCR_Execute", ycp_scr_execute, METH_VARARGS, "SCR Execute function"},
{"SCR_Dir", ycp_scr_dir, METH_VARARGS, "SCR Dir function"},
{"y2logger", ycp_y2logger, METH_VARARGS, "Logging error, debug messages and milestones in python"},
- {"ycp_code", ycp_code, METH_VARARGS, "Convert Python function call to YCP Code"},
{NULL, NULL, 0, NULL} /* Sentinel */
};
@@ -349,40 +348,6 @@
}
-PyObject * Py_ycp_code(PyObject *args) {
-
- Parser *parser;
- PyObject *temp;
- string command;
- YCodePtr c = 0;
-
- temp = PyTuple_GetItem(args, 0);
-
- if (PyString_Check(temp))
- command = PyString_AsString(temp);
- else
- command = "";
- cout << command << endl;
- parser = new Parser(command.c_str());
-
- //parser->setInput(command.c_str());
- //parser->setBuffered();
- c = parser->parse();
-
- if (c)
- c->evaluate();
- else
- cout << "eee c nejde!" << endl;
-
- cout << c->toString() << endl;
-
- delete(parser);
-
- return Py_None;
-
-}
-
-
PyObject * Import_YCPNameSpace (PyObject *args) {
PyObject* pResult = PyBool_FromLong(0);
Modified: trunk/python-bindings/src/YCPDeclarations.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/python-bindings/src/YCPDeclarations.cc?rev=41658&r1=41657&r2=41658&view=diff
==============================================================================
--- trunk/python-bindings/src/YCPDeclarations.cc (original)
+++ trunk/python-bindings/src/YCPDeclarations.cc Wed Oct 31 10:12:50 2007
@@ -2,10 +2,10 @@
#include <iostream>
using std::string;
using std::vector;
-//#define DBG(str) \
+#define DBG(str) \
std::cerr << __FILE__ << ": " << __LINE__ << ": " << str << std::endl; \
std::cerr.flush()
-#define DBG(str)
+//#define DBG(str)
/********** STATIC MEMBERS **********/
@@ -172,8 +172,9 @@
YCPDeclarations::~YCPDeclarations()
{
+
DBG("YCPDeclarations - destructor");
-
+
int cache_len = _cache.size();
for (int i=0; i < cache_len; i++){
delete _cache[i];
@@ -181,6 +182,8 @@
if (_py_self != NULL)
Py_DECREF(_py_self);
+
+ //_instance = std::auto_ptr<YCPDeclarations>(NULL);
}
Modified: trunk/python-bindings/src/YCPDeclarations.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/python-bindings/src/YCPDeclarations.h?rev=41658&r1=41657&r2=41658&view=diff
==============================================================================
--- trunk/python-bindings/src/YCPDeclarations.h (original)
+++ trunk/python-bindings/src/YCPDeclarations.h Wed Oct 31 10:12:50 2007
@@ -49,13 +49,13 @@
std::vector _cache;
-
/**
* Private construct.
* Call YCPDeclarations::instance() to get pointer to YCPDeclarations
* object.
*/
YCPDeclarations();
+
/**
* Return item from function map which has key key.
Modified: trunk/python-bindings/src/YCPTypes/Code.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/python-bindings/src/YCPTypes/Code.cc?rev=41658&r1=41657&r2=41658&view=diff
==============================================================================
--- trunk/python-bindings/src/YCPTypes/Code.cc (original)
+++ trunk/python-bindings/src/YCPTypes/Code.cc Wed Oct 31 10:12:50 2007
@@ -23,7 +23,7 @@
if (self != NULL){
self->value = Py_None;
if (self->value == NULL){
- Py_DECREF(self);
+ Py_XDECREF(self);
return NULL;
}
Modified: trunk/python-bindings/src/YCPTypes/Term.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/python-bindings/src/YCPTypes/Term.cc?rev=41658&r1=41657&r2=41658&view=diff
==============================================================================
--- trunk/python-bindings/src/YCPTypes/Term.cc (original)
+++ trunk/python-bindings/src/YCPTypes/Term.cc Wed Oct 31 10:12:50 2007
@@ -23,12 +23,12 @@
if (self != NULL){
self->name = PyString_FromString("");
if (self->name == NULL){
- Py_DECREF(self);
+ Py_XDECREF(self);
return NULL;
}
self->value = PyTuple_New(0);
if (self->value == NULL){
- Py_DECREF(self);
+ Py_XDECREF(self);
return NULL;
}
Modified: trunk/python-bindings/src/YCPTypes/YCPTypesInternal.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/python-bindings/src/YCPTypes/YCPTypesInternal.cc?rev=41658&r1=41657&r2=41658&view=diff
==============================================================================
--- trunk/python-bindings/src/YCPTypes/YCPTypesInternal.cc (original)
+++ trunk/python-bindings/src/YCPTypes/YCPTypesInternal.cc Wed Oct 31 10:12:50 2007
@@ -16,7 +16,7 @@
if (self != NULL){
self->value = PyString_FromString("");
if (self->value == NULL){
- Py_DECREF(self);
+ Py_XDECREF(self);
return NULL;
}
@@ -65,7 +65,7 @@
Py_INCREF(value);
if (PyTuple_SetItem(args, 0, value) != 0){
Py_XDECREF(args);
- Py_DECREF(value);
+ Py_XDECREF(value);
}
// create new Path object
Modified: trunk/python-bindings/src/YPython.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/python-bindings/src/YPython.cc?rev=41658&r1=41657&r2=41658&view=diff
==============================================================================
--- trunk/python-bindings/src/YPython.cc (original)
+++ trunk/python-bindings/src/YPython.cc Wed Oct 31 10:12:50 2007
@@ -129,29 +129,20 @@
module_name = module.substr(found+1);
//delete last 3 chars from module name ".py"
module_name.erase(module_name.size()-3); //delete ".py"
- //initialize python and set the path where are python modules
- cout << "Searching path for modules: " << Py_GetPath()<< endl;
+ //initialize python and set the path where are python modules
if (!Py_IsInitialized()) {
- cout <<"path :" << path << endl;
- setenv("PYTHONPATH", path.c_str(), 1);
-
+ setenv("PYTHONPATH", path.c_str(), 1);
Py_Initialize();
YPython::_pMainDicts = PyDict_New();
}
- setenv("PYTHONPATH", path.c_str(), 1);
- cout <<"path :" << path << endl;
if (!YPython::_pMainDicts)
YPython::_pMainDicts = PyDict_New();
//create python string for name of module
pModuleName = PyString_FromString(module_name.c_str());
//check if dictionary contain "dictionary" for module
if ( PyDict_Contains(YPython::_pMainDicts, pModuleName) == 0) {
- cout <<"loadModule name: " << module_name << endl;
- //char * new_path = (char *) path.c_str();
- //PySys_SetPath(new_path);
- cout << "Searching path for modules after init: " << Py_GetPath()<< endl;
pMain = PyImport_ImportModule(module_name.c_str());
if (pMain == NULL){
y2error("Can't import module %s", module_name.c_str());
@@ -628,10 +619,9 @@
char *fun_name = PyString_AsString(((PyCodeObject *) fun_code)->co_name);
string file_path = PyString_AsString(((PyCodeObject *) fun_code)->co_filename);
- //Y2Namespace* name_space = new Y2Namespace();
- printf ("meno funckie %s\n", fun_name);
- printf ("meno suboru %s\n", file_path.c_str());
+ //printf ("meno funckie %s\n", fun_name);
+ //printf ("meno suboru %s\n", file_path.c_str());
//found last "/" in path
size_t found = file_path.find_last_of("/");
@@ -650,16 +640,17 @@
y2error("Finding file where is function %s failed", fun_name);
return YCPNull();
}
+
+ //found last "/" in path
+ found = file_path.find_last_of("/");
+ string path = file_path.substr(0,found+1);
+ setenv("PYTHONPATH", path.c_str(), 1);
YPython::loadModule (file_path);
-
- //found last "/" in path
- found = file_path.find_last_of("/");
//extract module name from path
-
module_name = file_path.substr(found+1);
//delete last 3 chars from module name ".py"
@@ -668,7 +659,6 @@
//found last "/" in path
Y2Namespace *ns = new YPythonNamespace (module_name);
-
if (ns) {
TableEntry *sym_te = ns->table ()->find (fun_name);
if (sym_te == NULL) {
@@ -676,7 +666,7 @@
return YCPNull();
}
SymbolEntryPtr sym_entry = sym_te->sentry();
- cout << "entry" << sym_entry->toString()<< endl;
+ //cout << "entry" << sym_entry->toString()<< endl;
return YCPReference(sym_entry);
} else {
Modified: trunk/python-bindings/src/YPythonNamespace.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/python-bindings/src/YPythonNamespace.cc?rev=41658&r1=41657&r2=41658&view=diff
==============================================================================
--- trunk/python-bindings/src/YPythonNamespace.cc (original)
+++ trunk/python-bindings/src/YPythonNamespace.cc Wed Oct 31 10:12:50 2007
@@ -155,6 +155,7 @@
//Declarations (using YPCDelcarations python module)
YCPDeclarations *decl = YCPDeclarations::instance();
+
FunctionTypePtr sym_tp;
std::vector<constTypePtr> list_of_types;
int tmp;
@@ -171,7 +172,6 @@
return;
}
-
//keys from dictionary
fun_names = PyDict_Keys(pMainDict);
@@ -191,7 +191,8 @@
fun_code = PyFunction_GetCode(pFunc);
num = ((PyCodeObject *) fun_code)->co_argcount;
- if (decl->exists((PyFunctionObject *)pFunc)
+
+ if (decl->exists((PyFunctionObject *)pFunc)
&& decl->numParams((PyFunctionObject *)pFunc) == num){
sym_tp = new FunctionType(decl->returnType((PyFunctionObject *)pFunc));
@@ -222,13 +223,16 @@
// enter it to the symbol table
enterSymbol (fun_se, 0);
}
- } // end of for (int i = 0; i < num_fun_names; i++)
+ } // end of for (int i = 0; i < num_fun_names; i++)
+
y2milestone ("YPythonNamespace finish");
}
YPythonNamespace::~YPythonNamespace ()
{
+
+
}
const string YPythonNamespace::filename () const
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org