Game Development Community

How to tell if a Namespace has a "native" method/function ?

by Orion Elenzil · in Torque Game Engine · 02/11/2008 (10:29 am) · 3 replies

Howdy folks -

i've written an improved version of "dump()",
which lists the methods of a given class or object broken down by namespace inheritance.

ie,
you get nice dumps like:

33 methods from Player:
   foo()
   bar()

10 method from AIPlayer:
   bim()
   bam()

but i just realized a slight bug with my code,
which is that if a child namespace implements a method which is also in the parent namespace,
my code doesn't display the method as being native to the child.
for example, if AIPlayer also implements foo() in the above example,
i would like to get:
33 methods from Player:
   foo()
   bar()

11 method from AIPlayer:
   bim()
   bam()
   foo()
.. but don't. my code only counts 10 methods from AIPlayer.

this is because i'm checking for method "nativity" by testing if the method is also implemented by the parent class. but there has to be a better way. any suggestions ?

as an example of the area of code i'm in,
here's the stock code which returns a list of all the methods available in a given namespace:
void Namespace::getEntryList(Vector<Entry *> *vec)
{
   if(mHashSequence != mCacheSequence)
      buildHashTable();
   for(U32 i = 0; i < mHashSize; i++)
      if(mHashTable[i])
         vec->push_back(mHashTable[i]);
 	dQsort(vec->address(),vec->size(),sizeof(Namespace::Entry *),compareEntries);
}

#1
02/12/2008 (12:45 am)
Orion, you're a stud, man.
#2
02/12/2008 (8:23 am)
That's what i was fishin' for! Yeah !