Bläddra i källkod

new method from JeffH and Marauder: getClassHierarchy(classname). dumps a list of the class inhericance in reverse ancestor order (so that class first, next parent, *it's* parent, ect

AzaezelX 4 år sedan
förälder
incheckning
313466f57c
1 ändrade filer med 25 tillägg och 0 borttagningar
  1. 25 0
      Engine/source/console/simObject.cpp

+ 25 - 0
Engine/source/console/simObject.cpp

@@ -3185,6 +3185,31 @@ DefineEngineMethod( SimObject, getField, const char*, ( S32 index ),,
    return "";
 }
 
+DefineEngineFunction(getClassHierarchy, const char*, (const char* name), ,
+   "Returns the inheritance hierarchy for a given class.")
+{
+   AbstractClassRep* pRep = AbstractClassRep::findClassRep(name);
+   if (!pRep)
+   {
+      //Con::errorf("%s does not exist", name);
+      return StringTable->EmptyString();
+   }
+
+   StringBuilder buffer;
+
+   while (pRep != NULL)
+   {
+      StringTableEntry className = pRep->getClassName();
+      buffer.append(className);
+      buffer.append(" ");
+      pRep = pRep->getParentClass();
+   }
+
+   String result = buffer.end().trim();
+   //Con::printf("getClassHierarchy for %s=%s", name, result.c_str());
+   return Con::getReturnBuffer(result.c_str());
+
+}
 //-----------------------------------------------------------------------------
 
 #ifdef TORQUE_DEBUG