ducttape / ducttape-engine

Ducttape Engine - A universal game engine

Home Page:http://ducttape-dev.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prefix all signals with "dt::" so we can unambiguously use them from outside

svenstaro opened this issue · comments

Since signals signatures are not compared by type but by name (character by character), we should change all ducttape signal names and prefix them with "dt::".

commented

Are you saying change something like
"void signal(float x)" to "void dt::signal(float x)"
or change
"void signal(meshcomponent mesh)" to "void signal(dt::meshcomponent mesh)"?

void dt::signal because they are actually just strings and when we are outside the engine, they are still just strings. So we would be running into unfixable namespace issues unless we used using namespace dt but I recommend against that.

So in conclusion, all signal names should be prefixed with dt::

commented

But when you connect a signal to a slot you do
dt::SignalClass* Class1(new dt::SignalClass());
SlotClass* Class2(new SlotClass());
connect(Class1, SIGNAL(signal_name), Class2, SLOT(slot_name))
The namespace is used when specifying the containing class, not when specifying the signal. So the string would always be the same. I guess I'm still confused.

The problem is that when you use dt from outside itself, moc will try to find a class by name that matches this connect's parameters and it will not be successful if you don't give it proper names.

In fact, try it yourself and use dt from outside. Try it in the samples, they are pretty much outside.

commented

so, it would actually be the second one of my examples, "void signal(dt::MeshComponent*)". We only have two places in the engine which passes something in the dt namespace, and that's in PhysicsBodyComponent.hpp:108 and NetworkManager.hpp:176 which both already have the dt in the function. That's why I was so puzzled over this issue, because I thought that's what you meant, but it's already fixed in all instances.