Different reflection on HTML5 and iOS (XCode 4.5)

Monkey Forums/Monkey Programming/Different reflection on HTML5 and iOS (XCode 4.5)

Anatol(Posted 2012) [#1]
Hi,

[EDIT] solved, see post http://www.monkeycoder.co.nz/Community/post.php?topic=3698&post=40323

Something is wrong that used to work before. I use reflection to cycle through all fields of a few classes in order to save the state of some of these fields.

I notice now that in my project iOS seems to only detect fields in classes but not in classes that extend other classes. As a result the fields I get through reflection in HTML5 and iOS are different (HTML5 comes up with a lot more from the extending classes).

I use the same filter for both builds
#REFLECTION_FILTER="monkey.map*|book*|pages*"

This used to work, and I have a hunch that it stopped working since I updated to XCode 4.5 very recently. I tested it with older versions of Monkey of which I am certain that they worked but get the same disappointing result, hence I think it's the updated XCode.

Some more details about the project setup: the Book Class Extends IntMap<Page> (it's basically a better container for pages); and then there are classes like Page001 Extends Page, Page002 Extends Page, etc.

So all I get on iOS are Fields from the Page Class, but none from the extending classes Book, Page001, Page002, etc.

Does anyone have any ideas? I would appreciate any help - I've tried for a couple of hours but to no avail.

Thanks,
Anatol


Anatol(Posted 2012) [#2]
Sometimes it helps just to have a weekend and not worry about things for a while - I recommend it.

My issue above is resolved, but I haven't really changed much. All I did was to build my project with
#REFLECTION_FILTER="*"
which pointed out some issues in my code (mostly wrong return values of methods that I never call). A great way to double-check code though.

And I installed Command Line Tools in Xcode (under Xcode > Preferences > Downloads > Components).

I then tried to build and run in Xcode but due to including everything in the reflection it took probably about 15 minutes to build and didn't run at all in the end. I then reverted to
#REFLECTION_FILTER="monkey.map*|book*|pages*"
and it all works well just as before.

I'm not certain what really fixed it, but these two approaches are worth trying for anyone who experiences similar problems. Are Command Line Tools a requirement for Monkey on iOS?


Anatol(Posted 2012) [#3]
Hm, I have the same problem now again as described above. The same Monkeycode creates different reflection results in HTML5 and iOS.

Here's a download link of a very simplified version of the actual project: http://attic.nugob.org/communities/monkeycoder.co.nz/forum/attachments/reflectionTest.zip

Code snippet for reflection
[monkeycode]
Class Book Extends IntMap<Page>

Field myBookField01:Int
Field myBookField02:Int

Method AddPage:Void(page:Page)
Set(Count()+1,page)
End

Method PrintFieldNames:Void()
Local classInfo:=GetClass(Self)
Print("--- CLASS " + classInfo.Name + " ---")
For Local fieldInfo:=Eachin classInfo.GetFields(True)
Print(fieldInfo.Name)
Next

For Local page:= Eachin Values()
Local classInfo:=GetClass(page)
Print("--- CLASS " + classInfo.Name + " ---")
For Local fieldInfo:=Eachin classInfo.GetFields(True)
Print(fieldInfo.Name)
Next
Next
End

End
[/monkeycode]

(Note that there's also a class EnhancedBook Extends Book)

Print() results:

HTML5
--- CLASS book.enhancedBook.EnhancedBook ---
root
myBookField01
myBookField02
myEnhancedBookField01
myEnhancedBookField02
--- CLASS pages.page001.Page001 ---
myPageField01
myPageField02
myPage001Field01
myPage001Field02


iOS (Xcode 4.5)
--- CLASS monkey.map.IntMap<book.page.Page> ---
root
--- CLASS pages.page001.Page001 ---
myPageField01
myPageField02
myPage001Field01
myPage001Field02


To me HTML5 shows the 'correct' result that I'm after. iOS seems to ignore some class extensions and I think this may be also because extensions aren't necessarily located in the same module or sub-module.

The project has the following file/module structure:
main.monkey
book
   book.monkey
   enhancedBook.monkey
   page.monkey
pages
   pages.monkey
   page001.monkey


I'm just not sure what I'm doing wrong or if it's a Monkey/Xcode issue.

Also, this definitely used to work and results were identical in HTML5 and iOS; I'm quite certain that it stopped working after an update to Xcode 4.5.

If anyone has any ideas, please let me know. I spent a lot of time searching for bugs but to no avail. Thank you!


Anatol(Posted 2012) [#4]
In short and for lack of a better word: AAAAAaaaaaaaahhhhhh!

In detail: forget all of the posts above. It seems it's neither a Monkey nor a Xcode issue. Something in my project files must have been corrupted. I'm developing on Windows with Jungle IDE and sync everything except the build folder to a Mac via Sugarsync. As a test I copied over the entire project in the traditional way via external HDD, and it worked. Now I resynced the project on the Mac from scratch, and it works just as it should.

I really have no idea why this happened or where the synced files were different because all changes I made on Windows appeared when running it on the Mac. Just the reflection misbehaved.

I'm quite relieved about this outcome, but I really wish I hadn't wasted so much time on it. Strange, though, that the simplified sample project that I posted above came up with similar issues, and also only when I synced it. Maybe the reflection module is simply more "sensitive"...