Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
April 19, 2007 Reflection would be really nice | ||||
---|---|---|---|---|
| ||||
A little hello world in SWT is actually bigger then 7 MB. This is due to the generated reflection code, and the need to pull in the whole SWT in the initialization phase. With rudimentary reflection, this would be much better. I also think, there would be many application possible with this kind of stuff. class ClassInfo{ Field[] fields; Method[] methods; Constructors[] constructors; static ClassInfo[] allClasses; // probably the most important } class Field{ uint offset; TypeInfo type; Attribute[] attribs; char[] name; void* getPtr( Object* obj ); } class Parameter{ char[] name; TypeInfo type; Attribute[] attribs; } class Method{ uint offset; TypeInfo ret_type; Attribute[] attribs; char[] name; Parameter[] params; void* getPtr( Object* obj = null ); } class Constructor{ Attribute[] attribs; char[] name; void* getPtr(); Parameter[] params; } |
April 19, 2007 Re: Reflection would be really nice | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frank Benoit (keinfarbton) | Frank Benoit (keinfarbton) wrote:
> class ClassInfo{
> Field[] fields;
> Method[] methods;
> Constructors[] constructors;
> static ClassInfo[] allClasses; // probably the most important
> }
allClasses is already there, see Classinfo.find().
|
April 19, 2007 Re: Reflection would be really nice | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | >
> allClasses is already there, see Classinfo.find().
Didn't know about it :)
Now i can test if "org.eclipse.swt.SWT.SWT" exists.
If so, is there a way to call the static method "static_this()"?
|
April 19, 2007 Re: Reflection would be really nice | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright schrieb: > Frank Benoit (keinfarbton) wrote: >> class ClassInfo{ >> Field[] fields; >> Method[] methods; >> Constructors[] constructors; >> static ClassInfo[] allClasses; // probably the most important >> } > > allClasses is already there, see Classinfo.find(). Where can i find the ClassInfo DDoc? It seems, it disappeared from http://www.digitalmars.com/d/phobos/object.html |
April 19, 2007 Re: Reflection would be really nice | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frank Benoit (keinfarbton) | Frank Benoit (keinfarbton) Wrote (MODIFIED BY ME)
> struct ClassInfo{
> Field[] fields;
> Method[] methods;
> Constructors[] constructors;
> static ClassInfo[] allClasses; // probably the most important
> }
>
> struct Field{
> uint offset;
> TypeInfo type;
> Attribute[] attribs;
> char[] name;
> void* getPtr( Object* obj );
> }
> struct Parameter{
> char[] name;
> TypeInfo type;
> Attribute[] attribs;
> }
> struct Method{
> uint offset;
> TypeInfo ret_type;
> Attribute[] attribs;
> char[] name;
> Parameter[] params;
> void* getPtr( Object* obj = null );
> }
> struct Constructor{
> Attribute[] attribs;
> char[] name;
> void* getPtr();
> Parameter[] params;
> }
That's simpler (inside) : )
|
April 19, 2007 Re: Reflection would be really nice | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frank Benoit (keinfarbton) | Frank Benoit (keinfarbton) wrote:
>> allClasses is already there, see Classinfo.find().
>
> Didn't know about it :)
It was added in 1.011 (IIRC), so that's not surprising :-)
Sean
|
April 19, 2007 Re: Reflection would be really nice | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frank Benoit (keinfarbton) | Frank Benoit (keinfarbton) wrote:
> Walter Bright schrieb:
>> Frank Benoit (keinfarbton) wrote:
>>> class ClassInfo{
>>> Field[] fields;
>>> Method[] methods;
>>> Constructors[] constructors;
>>> static ClassInfo[] allClasses; // probably the most important
>>> }
>>
>> allClasses is already there, see Classinfo.find().
>
> Where can i find the ClassInfo DDoc?
> It seems, it disappeared from
> http://www.digitalmars.com/d/phobos/object.html
It's missing from the 1.010 docs (which are one the web currently), but reappeared in 1.011. So it's probably in your dmd/html folder. ;)
|
April 19, 2007 Re: Reflection would be really nice | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frank Benoit (keinfarbton) | Frank Benoit (keinfarbton) wrote:
>> allClasses is already there, see Classinfo.find().
>
> Didn't know about it :)
>
> Now i can test if "org.eclipse.swt.SWT.SWT" exists.
> If so, is there a way to call the static method "static_this()"?
In the module info, there should be an array of the static constructors.
|
April 19, 2007 Re: Reflection would be really nice | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright schrieb:
> Frank Benoit (keinfarbton) wrote:
>>> allClasses is already there, see Classinfo.find().
>>
>> Didn't know about it :)
>>
>> Now i can test if "org.eclipse.swt.SWT.SWT" exists.
>> If so, is there a way to call the static method "static_this()"?
>
> In the module info, there should be an array of the static constructors.
I cannot use them, because of circular dependencies. This is, why i
"manually" call "static_this()" methods (note the underscore) in a
defined order.
|
April 20, 2007 Re: Reflection would be really nice | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frank Benoit (keinfarbton) | Frank Benoit (keinfarbton) wrote:
> Walter Bright schrieb:
>> Frank Benoit (keinfarbton) wrote:
>>>> allClasses is already there, see Classinfo.find().
>>> Didn't know about it :)
>>>
>>> Now i can test if "org.eclipse.swt.SWT.SWT" exists.
>>> If so, is there a way to call the static method "static_this()"?
>> In the module info, there should be an array of the static constructors.
>
> I cannot use them, because of circular dependencies. This is, why i
> "manually" call "static_this()" methods (note the underscore) in a
> defined order.
There isn't a way to do that with reflection at the moment.
|
Copyright © 1999-2021 by the D Language Foundation