[C++-sig] boost python extensions & on HPUX/AIX ?

2011-06-30 Thread Avi Bahra
I have built boost python  extension. I have used the 
to embed the path to boost python shared library.
This avoids users of my extension from having to set
LD_LIBRARY_PATH when using my extension

python-extension ecflow : [ glob src/*.cpp ]

:   $(PYTHON_INSTALL_DIR)
;

In my Jamroot.jam:

install install-py
: Pyext//ecflow
: on
  PYTHON_EXTENSION
  SHARED_LIB
  $(PYTHON_INSTALL_DIR)
  $(PYTHON_INSTALL_DIR)
;


This all works like a charm on Linux:

However on HPUX, I find that embedded path, is always the development path
and not $(PYTHON_INSTALL_DIR)
On AIX it seems to be ignored.

Does any one know if  feature is known to work on HPUX/AIX ?

   Best regards,
Ta,
Avi
___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig


[C++-sig] Boost Python - Implementing a Cloning function

2011-06-30 Thread Jay Riley

I'm trying to implement a Cloning function for one of my classes I want to 
extend to Python. Extending the classes in C++ is easy as I can just override 
the Clone function, but it's definitely not working like that for Python. 
Here's the code, with unimportant detail ommitted.

template
class Cloneable
{
public:
typedef boost::shared_ptr ClonePtr;
virtual ClonePtr Clone() = 0;
};
   

class Action : public Cloneable
{
public:
virtual ClonePtr Clone() override;
}

Action::ClonePtr Action::Clone()
{
return ClonePtr(new Action(*this));
}

class Attack : public Action
{
public:
   virtual ClonePtr Clone() override;
}

Attack::ClonePtr Attack::Clone()
{
return Attack::ClonePtr(new Attack(*this));
}

struct AttackWrapper : Game::Battles::Actions::Attack
{
 Cloneable::ClonePtr AttackWrapper::Clone()
 {
   return call_method::ClonePtr>(self, "Clone");
 }
 Cloneable::ClonePtr AttackWrapper::CloneDefault()
 {
   return this->Action::Clone();
 }
}

I expose it like follows:

class_, std::auto_ptr,  
bases >("Attack")
.def(init<>())
.def(init())
.def("Clone", &Attack::Clone, &AttackWrapper::CloneDefault)
;

In my python file:

class ScriptedAttack(Attack):
def __init__(self, Type, ID, Name, Flags, Power, MPCost = 0, SPCost = 
0, Accuracy = 0.9, CritChance = 0.1, DefineOwnUse = False, EleWeights = None, 
StatusEffectChances = None):
  #initialization logic
def Clone(self):
  #return ScriptedAttack(self)
  #what to put here?

Fire = ScriptedAttack(ActionType.MagicAction, PrimaryEngine.GetUID(), 
"Fire", AttackFlags.Projectile | AttackFlags.Elemental, 32, 14, 0, 1.0, 0.1, 
False, {Elements.Fire: 1.0})
Fire2 = Fire.Clone()
ActLibrary.AddAttack(Fire)
ActLibrary.AddAttack(Fire2)

I'm really not sure how to do this - I'm stuck on what I need to put under def 
Clone. I know I can't have multiple inits, and I can't define a copy 
constructor. I know about the copy function in python, but the Action class 
(base of Attack) has a custom copy constructor I need to be called.

Can someone help me out with how to do this?

Thanks in advance ___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig