[C++-sig] Type Exception of type Argument Error

Brian Hall bhall at gamers-fix.com
Sun Jul 11 06:26:33 CEST 2004


Hello all,

 

I'm getting really close on my defining derived C++ types in python and
having them instantiated and executed from C++, but I've run into a snag.

 

I have the following module defined:

 

BOOST_PYTHON_MODULE(GI_AISDK)

{

      // Expose the State class to Python

      class_<cState>("State", init<float, std::string>())

            .add_property("value", &cState::Value, &cState::SetValue)

            .add_property("initial_value", &cState::InitialValue,
&cState::SetInitialValue)

            ;

 

      // Expose a base class new scripted actions should derive from

      class_<cPythonScriptedAction>("PythonScriptedAction", init<cState&>())

            .def("state", &cScriptedAction::State,
return_internal_reference<>())

            ;

 

      // Expose a base class new scripted transitions should derive from

      class_<cPythonScriptedTransition>("PythonScriptedTransition",
init<cState&, cState&>())

            .def("source", &cPythonScriptedTransition::Source,
return_internal_reference<>())

            .def("target", &cPythonScriptedTransition::Target,
return_internal_reference<>())

            ;

}

 

The State(), Source(), and Target() methods of the Actions and Transitions
all return a reference to an internally held cState class.

However if I try to call the execute method on the following Action python
script:

 

from GI_AISDK import *

 

class TestAction(PythonScriptedAction):

 

      def __init__(self):

            pass

 

      def execute(self):

            self.state()

 

I get a Type Exception with the annotation Argument Error.  I'm not entirely
sure what could be going on here.  I also tried the
reference_existing_object but to no avail.  If I simply pass in that method,
it executes fine.  In fact I can do whatever I want except call that state()
method.

 

Any ideas?

 

Thanks!

 

Brian Hall

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040710/e32f87c3/attachment.htm>


More information about the Cplusplus-sig mailing list