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

Brian Hall bhall at gamers-fix.com
Sun Jul 11 22:36:44 CEST 2004


Here is a simple project that shows the problem...

There is cPythonScriptedAction class which is a wrapper for the
cScriptedAction class which is derived from cAction.  cAction holds a
reference to a cState.  All of the constructors of the various cAction
classes take a reference to a cState object upon construction which they
store.

The python script derives a new type from the exposed cScriptedAction,
obtains the cState reference via the State() accessor, and makes
modifications to the value the state contains.

The output expected is:

State Value: 10
Hello from Python!
State Value 10
State Value 5
State Value 5

The output received is:

State Value: 10
Hello from Python!
State Value 10
State Value 5
State Value 10

This shows the state value on the C++ side isn't changing, and therefore the
python derived action class has its own copy of the state rather that using
the reference.

I hope this helps explain what's going on!

Brian

-----Original Message-----
From: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] On
Behalf Of David Abrahams
Sent: Sunday, July 11, 2004 1:30 PM
To: c++-sig at python.org
Subject: [C++-sig] Re: Type Exception of type Argument Error

"Brian Hall" <bhall at gamers-fix.com> writes:

> Alright, I've modified my code to use the object class to create python
> objects, and all is going well now aside from the object being passed into
> the constructor being copied rather than used as a reference...

??  What constructor ??

>
> How do can I ensure that any constructor parameters are not copied but are
> actually treated as the correct type of constructor parameters?

I'm lost.  Can you post a small piece of code that illustrates your
question?

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

_______________________________________________
C++-sig mailing list
C++-sig at python.org
http://mail.python.org/mailman/listinfo/c++-sig
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PythonSandbox.zip
Type: application/x-zip-compressed
Size: 9391 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040711/63f31626/attachment.bin>


More information about the Cplusplus-sig mailing list