unable to wrap an exception that inherits from std:exception (in <exception>)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
PyBindGen |
New
|
Undecided
|
Unassigned |
Bug Description
Hello all,
I am trying to wrap an exception that inherits from std::exception that is found in the standard c++ include file <exception>.
I have reproduced this issue on Linux (Ubuntu 12.04) and Win7x64.
Ubuntu 12.04, Python 2.7.3, gcc 4.6.3, GCC-XML version 0.9.0, pybindgen 0.1.6
Win7x64 under MSVC++ 2008 Express, Python 2.6.6, GCC-XML version 0.9.0, pybindgen 0.1.6
The approach is using pybindgen to generate a script which then generates the wrapper code (Workflow 3).
The errors reported are at the first stage of the workflow.
To reproduce:
1. On Linux, open a terminal in which gccxml and python are accessible at the command line.
2. Cd to a folder that contains MyException.h and exc_module-gen.py as included below.
3. At the prompt, issue the command
4. Examine err.txt and see that it matches what is reported below. Specifically, there is an error
>>> looking at class gdf::exception:
C:\Users\
ored because it uses a base class (::std::exception) which is not declared.
{
There are no special search paths or environment variables set up in the terminal, except that python, and gccxml are available in the path.
It is very possible that I am not using pybindgen in the correct way, but I have tried many things.
The final approach was to reduce the problem to this very minimal example.
Thanks and regards,
Owen
--------- MyException.h ------------------
#ifndef __MYEXCEPTION_
#define __MYEXCEPTION_
#include <exception>
#include <string>
namespace gdf {
/// A general exception
class general : public std::exception
{
public:
virtual ~general( ) throw() { }
const char *what( ) const throw() { return msg.c_str(); }
private:
};
}
#endif
-------- exc_module-gen.py --------------
#! /usr/bin/env python
import sys
import pybindgen
from pybindgen import FileCodeSink
from pybindgen.
import os.path
def my_module_gen():
'''
Generates a script codegen.py to generate a wrapper for MyException.h.
Does not work yet...
'''
inputpath = "/home/
pygen_file = open('codegen.py', "wt")
gccxml_options = {'include_paths':
['.',
module_parser = ModuleParser(
module_
module = module_
std_
general_
module_
module_
module_
module_
pygen_
if __name__ == '__main__':
my_module_gen()
------------ err.txt -------
INFO Parsing source file "/home/
INFO gccxml cmd: /usr/bin/gccxml -I"." -I"." -I"/usr/
INFO GCCXML version - 0.9
/home/user/
{
---------------- end -------