summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slicer/slicer/modelPartsTypes.h16
-rw-r--r--slicer/tool/parser.cpp20
2 files changed, 19 insertions, 17 deletions
diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h
index 02af753..363891d 100644
--- a/slicer/slicer/modelPartsTypes.h
+++ b/slicer/slicer/modelPartsTypes.h
@@ -112,17 +112,18 @@ namespace Slicer {
};
typedef IceUtil::Handle<HookBase> HookPtr;
- template <typename MT, typename CT, MT CT::*M, typename MP>
+ template <typename MT, typename CT, typename MP>
class DLL_PRIVATE Hook : public HookBase {
public:
- Hook(const std::string & n) :
+ Hook(MT CT::* m, const std::string & n) :
+ member(m),
name(n)
{
}
ModelPartPtr Get(T * t) const override
{
- return t ? new MP(const_cast<typename std::remove_const<MT>::type &>(t->*M)) : NULL;
+ return t ? new MP(const_cast<typename std::remove_const<MT>::type &>(t->*member)) : NULL;
}
std::string PartName() const override
@@ -131,14 +132,15 @@ namespace Slicer {
}
private:
+ const MT CT::* member;
const std::string name;
};
- template <typename MT, typename CT, MT CT::*M, typename MP>
- class DLL_PRIVATE HookMetadata : public Hook<MT, CT, M, MP> {
+ template <typename MT, typename CT, typename MP>
+ class DLL_PRIVATE HookMetadata : public Hook<MT, CT, MP> {
public:
- HookMetadata(const std::string & n, const Metadata & md) :
- Hook<MT, CT, M, MP>(n),
+ HookMetadata(MT CT::* member, const std::string & n, const Metadata & md) :
+ Hook<MT, CT, MP>(member, n),
metadata(md)
{
}
diff --git a/slicer/tool/parser.cpp b/slicer/tool/parser.cpp
index e880d1c..5aa5f5c 100644
--- a/slicer/tool/parser.cpp
+++ b/slicer/tool/parser.cpp
@@ -275,9 +275,8 @@ namespace Slicer {
}
fprintbf(cpp, " %s",
Slice::typeToString(type, dm->optional()));
- fprintbf(cpp, ", %s, &%s, ",
- boost::algorithm::trim_right_copy_if(dm->container()->thisScope(), ispunct),
- dm->scoped());
+ fprintbf(cpp, ", %s, ",
+ boost::algorithm::trim_right_copy_if(dm->container()->thisScope(), ispunct));
if (dm->optional()) {
fprintbf(cpp, "ModelPartForOptional< ");
}
@@ -285,7 +284,8 @@ namespace Slicer {
if (dm->optional()) {
fprintbf(cpp, " > ");
}
- fprintbf(cpp, " >(\"%s\"",
+ fprintbf(cpp, " >(&%s, \"%s\"",
+ dm->scoped(),
name ? *name : dm->name());
if (hasMetadata(dm->getMetaData())) {
fprintbf(cpp, ", ");
@@ -411,22 +411,22 @@ namespace Slicer {
auto vname = metaDataValue("slicer:value:", d->getMetaData());
fprintbf(cpp, "\t\t");
auto ktype = d->keyType();
- fprintbf(cpp, "new ModelPartForComplex< %s::value_type >::Hook< const %s, %s::value_type, &%s::value_type::first, ",
+ fprintbf(cpp, "new ModelPartForComplex< %s::value_type >::Hook< const %s, %s::value_type, ",
d->scoped(),
Slice::typeToString(ktype),
- d->scoped(),
d->scoped());
createNewModelPartPtrFor(ktype);
- fprintbf(cpp, " >(\"%s\"),\n\t\t",
+ fprintbf(cpp, " >(&%s::value_type::first, \"%s\"),\n\t\t",
+ d->scoped(),
kname ? *kname : "key");
auto vtype = d->valueType();
- fprintbf(cpp, "new ModelPartForComplex< %s::value_type >::Hook< %s, %s::value_type, &%s::value_type::second, ",
+ fprintbf(cpp, "new ModelPartForComplex< %s::value_type >::Hook< %s, %s::value_type, ",
d->scoped(),
Slice::typeToString(vtype),
- d->scoped(),
d->scoped());
createNewModelPartPtrFor(vtype);
- fprintbf(cpp, " >(\"%s\"),\n",
+ fprintbf(cpp, " >(&%s::value_type::second, \"%s\"),\n",
+ d->scoped(),
vname ? *vname : "value");
fprintbf(cpp, "\t};\n");
fprintbf(cpp, "\n");