Cleanly pass 'copy_const_reference' for getValueAsString methods (hooping it will solve a big bug in python binding.
DO NOT SUPPRESS TARGET_LINK_LIBRARIES in CMakeLists.txt for ADD_LIBRARY since it is mandotory under man osx (at least under version 10.6.3)
This commit is contained in:
parent
5fb64e6da5
commit
b0b3d50c3e
|
@ -3,24 +3,28 @@ INCLUDE_DIRECTORIES(${VLSISAPD_SOURCE_DIR}/src/dtr/src ${LIBXML2_INCLUDE_DIR} ${
|
||||||
SET ( hpps vlsisapd/dtr/Techno.h
|
SET ( hpps vlsisapd/dtr/Techno.h
|
||||||
vlsisapd/dtr/Rules.h
|
vlsisapd/dtr/Rules.h
|
||||||
vlsisapd/dtr/Name.h
|
vlsisapd/dtr/Name.h
|
||||||
vlsisapd/dtr/DTRException.h )
|
vlsisapd/dtr/DTRException.h
|
||||||
|
)
|
||||||
|
|
||||||
SET ( cpps Techno.cpp
|
SET ( cpps Techno.cpp
|
||||||
Name.cpp )
|
Name.cpp
|
||||||
|
)
|
||||||
|
|
||||||
SET ( pycpps PyDtr.cpp ${cpps})
|
SET ( pycpps PyDtr.cpp ${cpps}
|
||||||
|
)
|
||||||
|
|
||||||
ADD_LIBRARY(dtr ${cpps})
|
ADD_LIBRARY(dtr ${cpps})
|
||||||
TARGET_LINK_LIBRARIES(dtr ${LIBXML2_LIBRARIES})
|
TARGET_LINK_LIBRARIES(dtr ${LIBXML2_LIBRARIES})
|
||||||
INSTALL(TARGETS dtr DESTINATION lib${LIB_SUFFIX})
|
INSTALL(TARGETS dtr DESTINATION lib${LIB_SUFFIX})
|
||||||
|
|
||||||
IF (Boost_FOUND)
|
IF (Boost_FOUND)
|
||||||
ADD_LIBRARY(pyDTR MODULE ${pycpps})
|
ADD_LIBRARY(pyDTR MODULE ${pycpps})
|
||||||
SET_TARGET_PROPERTIES(pyDTR PROPERTIES
|
SET_TARGET_PROPERTIES(pyDTR PROPERTIES
|
||||||
COMPILE_FLAGS "${COMPILE_FLAGS} -D__PYTHON_MODULE__=1"
|
COMPILE_FLAGS "${COMPILE_FLAGS} -D__PYTHON_MODULE__=1"
|
||||||
PREFIX ""
|
PREFIX ""
|
||||||
)
|
)
|
||||||
INSTALL(TARGETS pyDTR DESTINATION ${PYTHON_SITE_PACKAGES})
|
TARGET_LINK_LIBRARIES(pyDTR dtr ${LIBXML2_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
|
||||||
|
INSTALL(TARGETS pyDTR DESTINATION ${PYTHON_SITE_PACKAGES})
|
||||||
ENDIF(Boost_FOUND)
|
ENDIF(Boost_FOUND)
|
||||||
|
|
||||||
INSTALL(FILES ${hpps} DESTINATION include/vlsisapd/dtr)
|
INSTALL(FILES ${hpps} DESTINATION include/vlsisapd/dtr)
|
||||||
|
|
|
@ -20,7 +20,7 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getValueAsString_overloads, getValueAsStr
|
||||||
// specify that Techno::addRule method has optional arguments
|
// specify that Techno::addRule method has optional arguments
|
||||||
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(addRule_overloads, addRule, 3, 5);
|
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(addRule_overloads, addRule, 3, 5);
|
||||||
|
|
||||||
BOOST_PYTHON_MODULE(pyDTR) {
|
BOOST_PYTHON_MODULE(DTR) {
|
||||||
// class DTR::Name
|
// class DTR::Name
|
||||||
class_<Name>("Name", init<std::string>())
|
class_<Name>("Name", init<std::string>())
|
||||||
.def("getString", &Name::getString, return_value_policy<copy_const_reference>()) // return_value_policy because this method return a refenrce on string
|
.def("getString", &Name::getString, return_value_policy<copy_const_reference>()) // return_value_policy because this method return a refenrce on string
|
||||||
|
@ -37,7 +37,7 @@ BOOST_PYTHON_MODULE(pyDTR) {
|
||||||
.def("getName" , &Rule::getName )
|
.def("getName" , &Rule::getName )
|
||||||
.def("getType" , &Rule::getType )
|
.def("getType" , &Rule::getType )
|
||||||
.def("getValue" , &Rule::getValue )
|
.def("getValue" , &Rule::getValue )
|
||||||
.def("getValueAsString", &Rule::getValueAsString)
|
.def("getValueAsString", &Rule::getValueAsString, return_value_policy<copy_const_reference>())
|
||||||
.def("getRef" , &Rule::getRef )
|
.def("getRef" , &Rule::getRef )
|
||||||
.def("getLayer1" , &Rule::getLayer1 )
|
.def("getLayer1" , &Rule::getLayer1 )
|
||||||
.def("getLayer2" , &Rule::getLayer2 )
|
.def("getLayer2" , &Rule::getLayer2 )
|
||||||
|
@ -57,7 +57,7 @@ BOOST_PYTHON_MODULE(pyDTR) {
|
||||||
.def("getUnit" , &Techno::getUnit)
|
.def("getUnit" , &Techno::getUnit)
|
||||||
.def("getRule" , &Techno::getRule , getRule_overloads()[return_value_policy<reference_existing_object>()])
|
.def("getRule" , &Techno::getRule , getRule_overloads()[return_value_policy<reference_existing_object>()])
|
||||||
.def("getValue" , &Techno::getValue , getValue_overloads())
|
.def("getValue" , &Techno::getValue , getValue_overloads())
|
||||||
.def("getValueAsString", &Techno::getValueAsString, getValueAsString_overloads())
|
.def("getValueAsString", &Techno::getValueAsString, getValueAsString_overloads()[return_value_policy<copy_const_reference>()])
|
||||||
|
|
||||||
// modifiers
|
// modifiers
|
||||||
.def("addRule" , &Techno::addRule , addRule_overloads()[return_value_policy<reference_existing_object>()])
|
.def("addRule" , &Techno::addRule , addRule_overloads()[return_value_policy<reference_existing_object>()])
|
||||||
|
|
|
@ -82,7 +82,7 @@ double Techno::getValue(Name name, Name layer1, Name layer2) {
|
||||||
return getRule(name, layer1, layer2)->getValue();
|
return getRule(name, layer1, layer2)->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
string Techno::getValueAsString(Name name, Name layer1, Name layer2) {
|
const string& Techno::getValueAsString(Name name, Name layer1, Name layer2) {
|
||||||
return getRule(name, layer1, layer2)->getValueAsString();
|
return getRule(name, layer1, layer2)->getValueAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class Rule {
|
||||||
inline Name getName();
|
inline Name getName();
|
||||||
inline Name getType();
|
inline Name getType();
|
||||||
inline double getValue();
|
inline double getValue();
|
||||||
inline std::string getValueAsString();
|
inline const std::string& getValueAsString();
|
||||||
inline Name getRef();
|
inline Name getRef();
|
||||||
inline Name getLayer1();
|
inline Name getLayer1();
|
||||||
virtual inline Name getLayer2(); // add virtual so the Rule object is polymorphic
|
virtual inline Name getLayer2(); // add virtual so the Rule object is polymorphic
|
||||||
|
@ -63,7 +63,7 @@ inline double Rule::getValue() { return _value; };
|
||||||
inline Name Rule::getRef() { return _ref; };
|
inline Name Rule::getRef() { return _ref; };
|
||||||
inline Name Rule::getLayer1() { return _layer1; };
|
inline Name Rule::getLayer1() { return _layer1; };
|
||||||
inline Name Rule::getLayer2() { return _layer2; };
|
inline Name Rule::getLayer2() { return _layer2; };
|
||||||
inline std::string Rule::getValueAsString() { return _valueStr.getString(); };
|
inline const std::string& Rule::getValueAsString() { return _valueStr.getString(); };
|
||||||
|
|
||||||
inline void Rule::setType(Name type) { _type = type; };
|
inline void Rule::setType(Name type) { _type = type; };
|
||||||
} // namespace DTR
|
} // namespace DTR
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Techno {
|
||||||
|
|
||||||
Rule* getRule(Name name, Name layer1=Name(""), Name layer2=Name(""));
|
Rule* getRule(Name name, Name layer1=Name(""), Name layer2=Name(""));
|
||||||
double getValue(Name name, Name layer1=Name(""), Name layer2=Name(""));
|
double getValue(Name name, Name layer1=Name(""), Name layer2=Name(""));
|
||||||
std::string getValueAsString(Name name, Name layer1=Name(""), Name layer2=Name(""));
|
const std::string& getValueAsString(Name name, Name layer1=Name(""), Name layer2=Name(""));
|
||||||
|
|
||||||
bool writeToFile(std::string filePath);
|
bool writeToFile(std::string filePath);
|
||||||
static Techno* readFromFile(const std::string filePath);
|
static Techno* readFromFile(const std::string filePath);
|
||||||
|
|
Loading…
Reference in New Issue