[Synopsis-changes] Synopsis/Synopsis/include/Synopsis Interpreter.hh,1.1,1.2 Object.hh,1.2,1.3
Stefan Seefeld stefan at synopsis.fresco.orgSun Jan 11 19:46:31 UTC 2004
- Previous message: [Synopsis-changes] Synopsis/Synopsis/tests/Cxx-API/Synopsis/AST Guard.hh,NONE,1.1 Makefile,NONE,1.1 SourceFile.cc,NONE,1.1 SourceFile.py,NONE,1.1
- Next message: [Synopsis-changes] Synopsis/Synopsis/include/Synopsis/AST AST.hh,1.1,1.2 Declaration.hh,1.1,1.2 SourceFile.hh,1.1,1.2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /cvs/synopsis/Synopsis/include/Synopsis
In directory frida:/tmp/cvs-serv6573/include/Synopsis
Modified Files:
Interpreter.hh Object.hh
Log Message:
refinements
Index: Interpreter.hh
===================================================================
RCS file: /cvs/synopsis/Synopsis/include/Synopsis/Interpreter.hh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -d -r1.1 -r1.2
--- Interpreter.hh 9 Jan 2004 20:03:25 -0000 1.1
+++ Interpreter.hh 11 Jan 2004 19:46:29 -0000 1.2
@@ -18,37 +18,41 @@ namespace Synopsis
class Interpreter
{
public:
+ struct Exception
+ {
+ Exception() {}
+ };
- enum Mode { EVAL = Py_eval_input,
- FILE = Py_file_input,
- SINGLE = Py_single_input};
+ enum Mode { EVAL = Py_eval_input,
+ FILE = Py_file_input,
+ SINGLE = Py_single_input};
- Interpreter() {}
- ~Interpreter() {}
+ Interpreter() {}
+ ~Interpreter() {}
- Object run_string(const std::string &, Mode, Object, Object);
- Object run_file(const std::string &, Mode, Object, Object);
+ Object run_string(const std::string &, Mode, Object, Object);
+ Object run_file(const std::string &, Mode, Object, Object);
private:
};
inline Object Interpreter::run_string(const std::string &code,
Mode m, Object globals, Object locals)
{
- Object retn = PyRun_String(const_cast<char *>(code.c_str()), m,
- globals.my_impl, locals.my_impl);
- if (!retn) PyErr_Print();
- return retn;
+ PyObject *retn = PyRun_String(const_cast<char *>(code.c_str()), m,
+ globals.my_impl, locals.my_impl);
+ if (!retn) throw Exception();
+ return retn;
}
inline Object Interpreter::run_file(const std::string &script,
Mode m, Object globals, Object locals)
{
- ::FILE *file = fopen(script.c_str(), "r");
- Object retn = PyRun_File(file, const_cast<char *>(script.c_str()),
- m, globals.my_impl, locals.my_impl);
- fclose(file);
- if (!retn) PyErr_Print();
- return retn;
+ ::FILE *file = fopen(script.c_str(), "r");
+ PyObject *retn = PyRun_File(file, const_cast<char *>(script.c_str()),
+ m, globals.my_impl, locals.my_impl);
+ fclose(file);
+ if (!retn) throw Exception();
+ return retn;
}
}
Index: Object.hh
===================================================================
RCS file: /cvs/synopsis/Synopsis/include/Synopsis/Object.hh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -p -d -r1.2 -r1.3
--- Object.hh 10 Jan 2004 22:50:34 -0000 1.2
+++ Object.hh 11 Jan 2004 19:46:29 -0000 1.3
@@ -58,9 +58,10 @@ public:
Object &operator = (Object o);
int hash() const { return PyObject_Hash(my_impl);}
- operator bool () const { return PyObject_IsTrue(my_impl);}
+ operator bool () const { return my_impl != Py_None;}
Object repr() const { return PyObject_Repr(my_impl);}
Object str() const { return PyObject_Str(my_impl);}
+ Object boolean() const { return PyObject_IsTrue(my_impl);}
bool is_instance(Object) const;
void assert_type(const char *module,
const char *type) const
@@ -72,62 +73,6 @@ public:
Object attr(const char *name) const;
- Object call(const char *name);
- Object call(const char *name,
- Object);
- Object call(const char *name,
- Object,
- Object);
- Object call(const char *name,
- Object,
- Object,
- Object);
- Object call(const char *name,
- Object,
- Object,
- Object,
- Object);
- Object call(const char *name,
- Object,
- Object,
- Object,
- Object,
- Object);
- Object call(const char *name,
- Object,
- Object,
- Object,
- Object,
- Object,
- Object);
- Object call(const char *name,
- Object,
- Object,
- Object,
- Object,
- Object,
- Object,
- Object);
- Object call(const char *name,
- Object,
- Object,
- Object,
- Object,
- Object,
- Object,
- Object,
- Object);
- Object call(const char *name,
- Object,
- Object,
- Object,
- Object,
- Object,
- Object,
- Object,
- Object,
- Object);
-
PyObject *ref() { Py_INCREF(my_impl); return my_impl;}
private:
PyObject *my_impl;
@@ -184,155 +129,6 @@ inline Object Object::attr(const char *n
else return Object(retn);
}
-inline Object Object::call(const char *name)
-{
- return PyObject_CallMethod(my_impl, const_cast<char *>(name), 0);
-}
-
-inline Object Object::call(const char *name,
- Object o1)
-{
- return PyObject_CallMethod(my_impl, const_cast<char *>(name),
- "O",
- o1.my_impl);
-}
-
-inline Object Object::call(const char *name,
- Object o1,
- Object o2)
-{
- return PyObject_CallMethod(my_impl, const_cast<char *>(name),
- "OO",
- o1.my_impl,
- o2.my_impl);
-}
-
-inline Object Object::call(const char *name,
- Object o1,
- Object o2,
- Object o3)
-{
- return PyObject_CallMethod(my_impl, const_cast<char *>(name),
- "OOO",
- o1.my_impl,
- o2.my_impl,
- o3.my_impl);
-}
-
-inline Object Object::call(const char *name,
- Object o1,
- Object o2,
- Object o3,
- Object o4)
-{
- return PyObject_CallMethod(my_impl, const_cast<char *>(name),
- "OOOO",
- o1.my_impl,
- o2.my_impl,
- o3.my_impl,
- o4.my_impl);
-}
-
-inline Object Object::call(const char *name,
- Object o1,
- Object o2,
- Object o3,
- Object o4,
- Object o5)
-{
- return PyObject_CallMethod(my_impl, const_cast<char *>(name),
- "OOOOO",
- o1.my_impl,
- o2.my_impl,
- o3.my_impl,
- o4.my_impl,
- o5.my_impl);
-}
-
-inline Object Object::call(const char *name,
- Object o1,
- Object o2,
- Object o3,
- Object o4,
- Object o5,
- Object o6)
-{
- return PyObject_CallMethod(my_impl, const_cast<char *>(name),
- "OOOOOO",
- o1.my_impl,
- o2.my_impl,
- o3.my_impl,
- o4.my_impl,
- o5.my_impl,
- o6.my_impl);
-}
-
-inline Object Object::call(const char *name,
- Object o1,
- Object o2,
- Object o3,
- Object o4,
- Object o5,
- Object o6,
- Object o7)
-{
- return PyObject_CallMethod(my_impl, const_cast<char *>(name),
- "OOOOOOO",
- o1.my_impl,
- o2.my_impl,
- o3.my_impl,
- o4.my_impl,
- o5.my_impl,
- o6.my_impl,
- o7.my_impl);
-}
-
-inline Object Object::call(const char *name,
- Object o1,
- Object o2,
- Object o3,
- Object o4,
- Object o5,
- Object o6,
- Object o7,
- Object o8)
-{
- return PyObject_CallMethod(my_impl, const_cast<char *>(name),
- "OOOOOOOO",
- o1.my_impl,
- o2.my_impl,
- o3.my_impl,
- o4.my_impl,
- o5.my_impl,
- o6.my_impl,
- o7.my_impl,
- o8.my_impl);
-}
-
-inline Object Object::call(const char *name,
- Object o1,
- Object o2,
- Object o3,
- Object o4,
- Object o5,
- Object o6,
- Object o7,
- Object o8,
- Object o9)
-{
- return PyObject_CallMethod(my_impl, const_cast<char *>(name),
- "OOOOOOOOO",
- o1.my_impl,
- o2.my_impl,
- o3.my_impl,
- o4.my_impl,
- o5.my_impl,
- o6.my_impl,
- o7.my_impl,
- o8.my_impl,
- o9.my_impl);
-}
-
template <typename T>
inline T Object::narrow(Object o) throw(Object::TypeError)
{
- Previous message: [Synopsis-changes] Synopsis/Synopsis/tests/Cxx-API/Synopsis/AST Guard.hh,NONE,1.1 Makefile,NONE,1.1 SourceFile.cc,NONE,1.1 SourceFile.py,NONE,1.1
- Next message: [Synopsis-changes] Synopsis/Synopsis/include/Synopsis/AST AST.hh,1.1,1.2 Declaration.hh,1.1,1.2 SourceFile.hh,1.1,1.2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Synopsis-changes mailing list