Reflection filter broken

Monkey Forums/Monkey Bug Reports/Reflection filter broken

ziggy(Posted 2015) [#1]
Hello, form version 82 (and 83 too) the reflection filter is broken, which breaks the whole JungleGui events system, and quite a bit of my programs... :(

This small sample replicates the issue:
Import reflection
#REFLECTION_FILTER+="${MODPATH}"
Function Main()
	Print "Listing..."
	For Local func:FunctionInfo = EachIn GetFunctions
		Print func.Name
	Next
	Print "Done!"
End

Function Dummy:String()
	Return "Hello world!"
End

It should list "at last" Function Main and Dummy, but it does not list a single function.


Samah(Posted 2015) [#2]
I had issues getting JungleGui to recognise my classes, actually. Maybe this was the reason...


ImmutableOctet(SKNG)(Posted 2015) [#3]
The reflection filter is not broken, you just made a mistake with your own code. Move the filter assignment to before your import of the 'reflection' module. You're setting a preprocessor variable after it has already been used in another module.

This works just fine:


Output:



ziggy(Posted 2015) [#4]
The reflection filter is not broken, you just made a mistake with your own code. Move the filter assignment to before your import of the 'reflection' module

Well, current new implementation breaks the += operator logi. ,This operator is expected to be used when the directive has already been set anywhere else.

Also, it makes it impossible to modify the reflection filter on any module when it is not used before any other module imports the reflection filter, which makes modules unable to rely on it!

In short, If you use 2 modules that import the reflection module, the last one can't work. The second module can't add what it needs to the reflection filter. So, it's broken, or requires redesign, but it's currently quite useless as it is!


marksibly(Posted 2015) [#5]
Can you explain the problem a bit more clearly Ziggy? Been a while since I looked at the reflection stuff...


marksibly(Posted 2015) [#6]
OK, think I've found it - preprocessor isn't pushing/popping ${CD} or ${MODPATH}.


k.o.g.(Posted 2015) [#7]
Yea, i found the problem weeks before and i was thinking, its my fault...


ziggy(Posted 2015) [#8]
Can you explain the problem a bit more clearly Ziggy?
OK, think I've found it - preprocessor isn't pushing/popping ${CD} or ${MODPATH}.

I think you answered yourlself? The problem is that most of JungleGui modules import reflection and add themselves to the reflection filter by using the += operator, but it was failing to work.

By the way, did you ever found the time to look at this? http://www.monkey-x.com/Community/posts.php?topic=8140&post=81614&view=all#81614


marksibly(Posted 2015) [#9]
Ok, just committed a bunch of stuff including a fix for this - and hopefully for the 'have to import superclass modules' issue too.

Needs more testing before I build a release, but have a go at the github version if you can.


ziggy(Posted 2015) [#10]
Thanks! I'll give it a try during this week with Jungle Gui, which uses reflection very extensively. Also, I could test the Friend and Private keywords too that seems to be added. Not sure how their syntax work... ?


ziggy(Posted 2015) [#11]
Hello,
I've been testing this and been unable to make reflection work with JungleGui. the different JungleGui modules import reflection when they needed and use the REFLECTION_FILTER+= to register themselves into the filter.
If I do a small smaple with 2 files or the like, the latest changes seem to fix the reflection filter issue, but when using the whole junglegui module, it does not work and none of the samples are able to register event listeners due missing reflection registration... I'm a bit lost, if anyone can lend a hand to locate the issue...
that's the JungleGui repository: https://github.com/ziggybcn/junglegui