Reflection - Parsing a class

Posted by jmls on 01-Apr-2011 12:06

I know that the current version (10.2B04) does not support reflection yet, but was wondering how the architect parses the code to identify the properties and methods of a class in order to provide the "helpers" when you press ctrl-space.

Does it compile and parse the xref ? Or xref-xml ?

Does anyone know if that code is 4GL or java ?

All Replies

Posted by Peter Judge on 01-Apr-2011 12:11

My understanding is Java and it reads the rcode. I know that OEUnit (testing tool) uses xml-xref. I have an idea that ABHack has similar functionality and it's all ABL.

Are you providing ABL editing capabilities inside your app?

-- peter

Posted by jmls on 01-Apr-2011 12:21

I looked at the xml-xref, but it seems kinda weird - the reference to

methods point to the line of the "END METHOD"

Don't suppose that the r-code java reader is available for other

usage, is it ? Or is the r-code structure documented somewhere ?

No, not providing and editor, but I am building code generators and I

want to be able to read classes back in and maintain custom methods

and properties so that the code is not lost.

I know that the good Doctor and I have had lots of discussions about this

I currently use annotations but I know that you don't like this

Posted by Peter Judge on 01-Apr-2011 12:41

Don't suppose that the r-code java reader is available for other

usage, is it ? Or is the r-code structure documented somewhere ?

No, I don't believe so, for both cases. Although certainly the stuff you're interested in in this case falls under the rubric of reflection and thus would, I guess, be addressed in that way.

No, not providing and editor, but I am building code generators and I

want to be able to read classes back in and maintain custom methods

and properties so that the code is not lost.

I currently use annotations but I know that you don't like this

Oof. Ouch.

I'm not globally opposed to annotations, but in this case I still think that the custom stuff should be in a derived class.

-- peter

Posted by Thomas Mercer-Hursh on 01-Apr-2011 12:44

Hint:  The piece of OEA that provides the information for syntax coloring, hints, the outline, etc. is doing exactly the same job done by Proparse.

But, it is a good opportunity for me to plug http://www.cintegrity.com/content/Model-Code-ABL

Posted by jmls on 01-Apr-2011 12:46

hah. When I suggested that, I was shot down

One of the other problems is that I want to allow some custom code

inside the generated methods, to cater for the odd circumstance where

a generic generator does not provide all the code required. Yes, yes,

I know. One day the generator will provide all code. But, one day the

sun will also die ..

Posted by Thomas Mercer-Hursh on 01-Apr-2011 13:00

Understand, Peter, that what Julian is trying to do is *not* a standard base class and then some variations ... where a derived class or delegation or something would be the right answer.  Instead, what he has is hundreds of classes which follow the same basic template ... but where there is a need for instance to instance variation to some degree.  Rather than doing what I want him to do, i.e., get those variations into the model and generate from that, Julian wants to generate the standard form, do some manual modifications, and then in essence "reverse engineer" those into the next generation cycle ... except, since he has no model, there is nowhere to parse and place the modifications and he thus has to do it on the fly in the next generation cycle.

Posted by jmls on 01-Apr-2011 13:01

meh. After all the time you, I, John and Jurjen put into "playing"

with the oo-proparse (http://www.oehive.org/node/1250) how could have

I forgotten that one ! Doh!

Thanks

On 1 April 2011 18:44, Thomas Mercer-Hursh

Posted by jmls on 01-Apr-2011 13:16

and one of the reasons that I'm not doing what you want is that I need

to get code out there tomorrow, not next year

Dr Mercer-Hursh shudders

On 1 April 2011 19:01, Thomas Mercer-Hursh

Posted by Peter Judge on 01-Apr-2011 13:24

jmls wrote:

meh. After all the time you, I, John and Jurjen put into "playing"

with the oo-proparse (http://www.oehive.org/node/1250) how could have

I forgotten that one ! Doh!

Thanks

On 1 April 2011 18:44, Thomas Mercer-Hursh


We use AutoDox2 for the new AutoEdge stuff, which is based on ProParse (and it works like a charm), and I saw an extension to AutoDox on the OEHive which writes XML, which may make your life easier.

-- peter

Posted by Thomas Mercer-Hursh on 01-Apr-2011 13:26

Understood ... as long as you aspire to better yourself in the future!

Posted by Peter Judge on 01-Apr-2011 13:29

jmls wrote:

hah. When I suggested that, I was shot down

One of the other problems is that I want to allow some custom code

inside the generated methods, to cater for the odd circumstance where

a generic generator does not provide all the code required. Yes, yes,

I know. One day the generator will provide all code. But, one day the

sun will also die ..

There are ways around this (abstract methods, events, callbacks etc), but I remember now that you wanted a single type per object (ie no hierarchy).

How much customisation do you expect there to be to the generated code?

-- peter

Posted by Thomas Mercer-Hursh on 01-Apr-2011 13:38

I think all those approaches are making something far more complicated than it needs to be ... and, worse yet, they are making the actual run time code complicated when the problem is really one of generation.  One can make an argument in some cases for programming an entirely generic class instead, but again this requires a massively complex run-time compared to what one would have if one could just tailor the generator.  In comparable efforts (going back to 1990), I was looking to get about 90% of the code out of the generator and only have to manually supply the stuff that was unique to an instance.  Julian is using a somewhat simpler approach than my old Specification-Driven Development tool so he probably can't aim that high, but could do fine for simple cases ... which is all I think he is trying to tackle at this point.

Posted by jmls on 01-Apr-2011 13:51

I want to be able to have the flexibility to add code where the

generator does not provide such circumstances, until the time that I

can modify the generator to cater for such things.

For example, one of my "crud" classes needs to delete an operating

system file when the object is destroyed, so I need to have a custom

destructor. I can create a super-class that contains a destructor

override, or I can type in the code into the destructor of the class

in question. At some stage if I find the time, I will then build

that special case into the generator by adding another property to the

generation options of that class

Posted by jmls on 01-Apr-2011 13:51

that's twice this year we've agreed on something

On 1 April 2011 19:38, Thomas Mercer-Hursh

Posted by Thomas Mercer-Hursh on 01-Apr-2011 14:13

I'm sure the date is significant!

Posted by jankeir on 04-Apr-2011 03:09

This is done with ANTLR, you can actually use the same classes used by OE Architect (it requires a bit of work but I am 100% sure it can be done ;-) ). You may even be able to use them from ABL with ikvm. The advantage of the OE Architect ANTLR parser over the proparse.NET ANTLR parser is that it works to some extent even for sources that don't compile (yet).

The advantage of the proparse parser is that it provides a documented API and more information (and you're not doing something that you're not supposed to do and may not be able to do in the future.)

Posted by jmls on 04-Apr-2011 03:31

Interesting. Thanks.

This thread is closed