Overloads not returning appropriate info. [Field reflunkory]

Alex AJ at gmail.com
Thu Apr 4 07:04:21 UTC 2019


Trying to get parameter info of an overloaded method, it doesn't 
return the names. The same code works fine for a free function.


	Id = foo
	TypeName =
	FullName = main.foo
	ModuleName = main
	MangledName = _D4main3fooFiKdfZv
	Protection = public
	Body =
	Uses = []
	Attributes = [
		sAttributeReflection("attr!string(\"test\", 432)", 
"attr!string"),
		sAttributeReflection("4", "int")
	]
	DType = function
	Signature = void(int x, ref double y, float z = 43234.3F)
	NumArgs = 3
	Linkage = D
	ReturnType = void
	Parameters = [
		sParameterReflection("x", "int", "void", "void", 
sStorageClass(false, false, false, false, false, false)),
		sParameterReflection("y", "double", "void", "void", 
sStorageClass(false, false, false, true, false, false)),
		sParameterReflection("z", "float", "43234.3F", "float", 
sStorageClass(false, false, false, false, false, false))
	]



vs





	Methods = [
		Id = foo
		TypeName = int()
		FullName = mModel.cDerived!(int).foo
		ModuleName = mModel
		MangledName = 6mModel__T8cDerivedTiZQm3foo
		Protection = public
		Body =
		Uses = []
		Attributes = [sAttributeReflection("A", "string")]
		Signature = int()
		NumArgs = 0
		Linkage = D
		ReturnType = int
		Parameters = []
		DType = delegate
		Overloads = []
		,
		Id = foo
		TypeName = pure nothrow @nogc @safe int(int, inout(float))
		FullName = mModel.cDerived!(int).foo
		ModuleName = mModel
		MangledName = 6mModel__T8cDerivedTiZQm3foo
		Protection = public
		Body =
		Uses = []
		Attributes = [sAttributeReflection("A", "string")]
		Signature = pure nothrow @nogc @safe int(int, inout(float))
		NumArgs = 2
		Linkage = D
		ReturnType = int
		Parameters = [
			sParameterReflection("", "int", "void", "void", 
sStorageClass(false, false, false, false, false, false)),
			sParameterReflection("", "inout(float)", "void", "void", 
sStorageClass(false, false, false, false, false, false))
		]
		DType = delegate
		Overloads = []
		,




sParameterReflection("z", "float", "43234.3F", "float", 
sStorageClass(false, false, false, false, false, false))

vs

sParameterReflection("", "int", "void", "void", 
sStorageClass(false, false, false, false, false, false)),

notice that some info is field out but not all.

The code is here:
https://github.com/IncipientDesigns/Dlang_Reflect/blob/master/mReflect.d

The Base, Aggregate, Function, and Method classes are the 
appropriate ones to look at. cFunctionReflection does all the 
work though

[Field reflunkory]

Also, with

cFieldReflection I cannot pass the field as a type on to the base 
class to reduce code duplication. Ideally I should be able to 
pass a field around as a type so that reflection can occur on it. 
This seems like a language design issue but maybe there is a 
trick?






More information about the Digitalmars-d-learn mailing list