Skip to content

Commit

Permalink
list propsync
Browse files Browse the repository at this point in the history
  • Loading branch information
rjkiv committed Jun 1, 2024
1 parent caf9fed commit 8f52d57
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 20 deletions.
31 changes: 15 additions & 16 deletions src/system/obj/Msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,21 @@ DataNode MsgSource::OnRemoveSink(DataArray* da){
return DataNode(0);
}

bool PropSync(MsgSource::Sink& sink, DataNode& node, DataArray* prop, int i, PropOp op){
if(i == prop->Size()) return true;
else {
Symbol sym = prop->Sym(i);
if(sym == obj){
return PropSync<Hmx::Object>(sink.obj, node, prop, i + 1, op);
}
if(sym == mode){
int x = sink.mode;
bool ret = PropSync(x, node, prop, i + 1, op);
sink.mode = (MsgSource::SinkMode)x;
return ret;
}
}
return true;
}
BEGIN_CUSTOM_PROPSYNC(MsgSource::Sink)
SYNC_PROP(obj, (Hmx::Object*&)o.obj)
SYNC_PROP(mode, (int&)o.mode)
END_CUSTOM_PROPSYNC

BEGIN_CUSTOM_PROPSYNC(MsgSource::EventSinkElem)
SYNC_PROP(handler, o.handler)
SYNC_PROP(obj, (Hmx::Object*&)o.obj)
SYNC_PROP(mode, (int&)o.mode)
END_CUSTOM_PROPSYNC

BEGIN_CUSTOM_PROPSYNC(MsgSource::EventSink)
SYNC_PROP(event, o.ev)
SYNC_PROP(sinks, o.sinks)
END_CUSTOM_PROPSYNC

BEGIN_PROPSYNCS(MsgSource)
SYNC_PROP(sinks, mSinks)
Expand Down
28 changes: 24 additions & 4 deletions src/system/obj/PropSync_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,34 @@ template <class T> bool PropSync(ObjPtrList<T, class ObjectDir>& ptr, DataNode&
}
}

template <class T> bool PropSync(std::list<T>& list, DataNode& node, DataArray* prop, int i, PropOp op) {
template <class T> bool PropSync(std::list<T>& pList, DataNode& node, DataArray* prop, int i, PropOp op) {
if((int)op == 0x40) return false;
else {
else if(i == prop->Size()){
MILO_ASSERT(op == kPropSize, 146);
//if(op == kPropGet) node = DataNode(ptr.Ptr());
//else ptr = node.Obj<T>(0);
node = DataNode((int)pList.size());
return true;
}
else {
std::list<T>::iterator it = pList.begin();
for(int count = prop->Int(i++); count > 0; count--){
it++;
}
if(i < prop->Size() || op & 0x13){
return PropSync(*it, node, prop, i, op);
}
else if(op == kPropRemove){
pList.erase(it);
return true;
}
else if(op == kPropInsert){
T item;
if(PropSync(item, node, prop, i, op)){
pList.insert(it, item);
return true;
}
}
return false;
}
}

template <class T, typename T2> bool PropSync(std::vector<T, T2>& vec, DataNode& node, DataArray* prop, int i, PropOp op) {
Expand Down

0 comments on commit 8f52d57

Please sign in to comment.