groue / GRMustache

Flexible and production-ready Mustache templates for MacOS Cocoa and iOS
http://mustache.github.com/
MIT License
1.44k stars 190 forks source link

Garbage Collection support #40

Closed KosmicTask closed 11 years ago

KosmicTask commented 11 years ago

What is the status of GC support? I read somewhere that it is was supported, but that may have been some time ago.

Thanks

groue commented 11 years ago

Hi Jonathan.

Actually, I don't have the slightest idea. GRMustache has always been developed in the traditional reference-counted way, and I have a total lack of experience in GC.

How can I help you?

KosmicTask commented 11 years ago

Hi Gwendal

I was looking to replace MGTemplateEngine as it is behaving oddly when operating with similarly named keys. eg: @"task-input" and @"task-input-index-1-based" don't get replaced reliably.

The following mentions that GRMustache worked ok with GC (it was some time ago): http://gentlebytes.com/2010/11/mgtemplateengine-alternative/

An RC app can be compiled to run under GC without much intervention as long as all variables are reachable from a root. As ever, however, there can be demons in the long grass!

I will try building the library for GC and see how I get on.

Regards

Jonathan Mitchell Mugginsoft LLP

On 10 Jan 2013, at 21:46, Gwendal Roué notifications@github.com wrote:

Hi Jonathan.

Actually, I don't have the slightest idea. GRMustache has always been developed in the traditional reference-counted way, and I have a total lack of experience in GC.

How can I help you?

— Reply to this email directly or view it on GitHub.

groue commented 11 years ago

GRMustache has evolved a lot since this blog post.

Some features and caches are now backed on globals variables that may harm GC support. Look for static in the code.

I'll help the best I can: your hints for GC support will be appreciated.

KosmicTask commented 11 years ago

GC can be enabled simply by adding GCC_ENABLE_OBJC_GC : supported as a user defined build option in Xcode 4. This produces a working library as far as my simple template usage goes.

The problem is that the tests cannot be run under GC as JSONKit does not support GC. JSONKit usage seems restricted to loading the serialised test data such as:

NSDictionary *testSuite = [testSuiteData objectFromJSONDataWithParseOptions:JKParseOptionComments error:&error];

Without working tests it will of course be hard to proclaim that the library supports GC. What are your thoughts on this?

groue commented 11 years ago

JSONKit provides JSON decoding of the test suites. We should switch to NSJSONSerialization now that it exists.

KosmicTask commented 11 years ago

NSJSONSerialization is OS X 10.7 and above only. The GRMustache6-MacOS deployment target is currently 10.6 (the project level setting is 10.7). Is dropping 10.6 compatibility acceptable?

groue commented 11 years ago

No, dropping 10.6 would not be acceptable.

However the JSON lib is only used by tests. It does not ship in the product. NSJSONSerialization could be used for testing against the 10.7 and 10.8 SDK. Testing against 10.6 would require another GC-compatible JSON parsing library.

KosmicTask commented 11 years ago

OK.

I will probably end up having to configure a GC only test target to force the test bundle to run as GC. I will use NSJSONSerialization to test 10.7 +.