www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Mangled names

reply Sjoerd van Leent <svanleent gmail.com> writes:
Walter, others,

Would it be possible to store the mangled name of a class/type in to the 
classinfo/typeinfo. This would ease a lot of problems I'm experiencing. 
Since I want to traverse through the classinfo class as follows:

public bool derivesFromIBase(in Interface iface) {
     ClassInfo info = iface.classinfo;
    	if(info == IBase.classinfo) {
		return true;
	} else if(info.interfaces.length > 0) {
		foreach(Interface base; info.interfaces) {
			if(derivesFromIBase(base)) return true;
		}
	}
     return false;
}

public char[] resolve(in ClassInfo clazz) {
	foreach(Interface iface; clazz.interfaces) {
		// should return the mangled name
		if(derivesFromIBase(iface)) return iface.classinfo.name;
	}
	if(clazz.base != Object.classinfo) {
		return resolve(clazz.base);
	}
	return null;
}

Regards,
Sjoerd
May 25 2006
parent Sjoerd van Leent <svanleent gmail.com> writes:
In addition to my previous message, I'd like to have a possibility to 
search for method names as well. I would welcome such a feature. What 
I'm trying to do is to make some general class registry, more or less a 
combination of COM and RMI. I try to make it in such a way that it is 
easily portable (e.g.: not to much calls towards Win32 API).

Problem is that for this to work I need to be able to make interfaces 
visible from the outside, together with their function specifications, 
if possible.

Regards,
Sjoerd

Sjoerd van Leent schreef:
 Walter, others,
 
 Would it be possible to store the mangled name of a class/type in to the 
 classinfo/typeinfo. This would ease a lot of problems I'm experiencing. 
 Since I want to traverse through the classinfo class as follows:
 
 public bool derivesFromIBase(in Interface iface) {
     ClassInfo info = iface.classinfo;
        if(info == IBase.classinfo) {
         return true;
     } else if(info.interfaces.length > 0) {
         foreach(Interface base; info.interfaces) {
             if(derivesFromIBase(base)) return true;
         }
     }
     return false;
 }
 
 public char[] resolve(in ClassInfo clazz) {
     foreach(Interface iface; clazz.interfaces) {
         // should return the mangled name
         if(derivesFromIBase(iface)) return iface.classinfo.name;
     }
     if(clazz.base != Object.classinfo) {
         return resolve(clazz.base);
     }
     return null;
 }
 
 Regards,
 Sjoerd
May 25 2006