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

GC support and test targets #41

Closed KosmicTask closed 11 years ago

KosmicTask commented 11 years ago

Here is my take on adding GC support:

  1. Added GCC_ENABLE_OBJC_GC supported to the main library.
  2. Added a GC only test target (built with GC required) and configured it to run after the existing MacOS test.
  3. Used preprocessor to call either JSONKit or NSJSONSerialization as appropriate.
  4. Removed comments from the JSON test suite data as they cannot be loaded by NSJSONSerialization. Loosing the comments is lamentable and could perhaps be avoided by running the JSON strings through a regex prior to de-serialising.

All tests pass including the iOS ones. In app integration should reveal if there are any issues lurking.

I have not updated the built binary that is included in the repo nor have I commited a version tag.

groue commented 11 years ago

Excellent, Jonathan !

Thank you very much. I'll process with a little tidying up.

It looks like the static libs does not need to be recompiled, since there were no changes in the sources. Do you confirm? Can I assume that GRMustache is GC-compatible as it is?

groue commented 11 years ago

Oh, and can I assume that the MacOSTests-GC target reliably asserts the GC compatibility? I mean, if I change GRMustache, can I be assured of the GC support after those tests pass?

KosmicTask commented 11 years ago

You will need to recompile the library. Even though the source code has not changed the project has been updated so that the library will report that it supports GC.

The MacOSTests-GC target requires GC compatibility so yes, running the target will assert GC compatibility.

I see you have reverted the removal of comments form the JSON files. Will you be removing these prior to processing by NSJSONSerialization? Or perhaps you have another solution in mind.

groue commented 11 years ago

You will need to recompile the library. Even though the source code has not changed the project has been updated so that the library will report that it supports GC.

OK.

I have a doubt: Will Clang honor the GCC_ENABLE_OBJC_GC flag ?

If I may abuse your time, I would ask you to issue a make command in the terminal (in the root of the repo), and link your application against lib/libGRMustache6-MacOS.a

The MacOSTests-GC target requires GC compatibility so yes, running the target will assert GC compatibility.

Cool :-) The README can explicitly claim GC support right after libGRMustache6-MacOS.a has been foolproofed.

I see you have reverted the removal of comments form the JSON files. Will you be removing these prior to processing by NSJSONSerialization? Or perhaps you have another solution in mind.

Yes, it was done in a couple of commits before I put the comments back . Pretty naive processing, actually: I'm removing lines starting with //. But without comments I don't see how JSON test suites could be maintained/improved/etc.

A big thank you, Jonathan. I mostly focus on iOS dev: your help is a really neat contribution for MacOS developers.

groue commented 11 years ago

When I do run the make clean: make command, I see Clang compile .m files with the -fobjc-gc option. This option is not there when I remove the GCC_ENABLE_OBJC_GC setting. So I guess this is it.

Let's recompile, and be happy with GC support :-)

Thank you again

groue commented 11 years ago

GRMustache v1.6.4 is out, with GC support. Update your fork, and happy Mustache!

KosmicTask commented 11 years ago

Thanks for the release and for GRMustache. You have obviously put a lot of work into this codebase.

GC support looks good to go. GC is a deprecated technology but apps using it will be around for a while.

You can, if you wish, add KosmicTask to your list of apps using GRMustache. The current release uses MGTemplateEngine, the next will feature GRMustache.

KosmicTask is an integrated scripting environment for OS X that supports more than 20 scripting languages.

groue commented 11 years ago

GC is a deprecated technology but apps using it will be around for a while.

Yes. I had no doubt GC support would be a nice addition.

You can, if you wish, add KosmicTask to your list of apps using GRMustache

I'm proud to have your application listed on the README :-)

I hope GRMustache will help you having the job done. Should the API lack something, never hesitate opening issues. A good discussion with an actual user in invaluable.

KosmicTask commented 11 years ago

I spent some time investigating GRMustache yesterday and it looks like a good fit for KosmicTask. I use it to generate scripts, like the AppleScript samples shown below. I need to generate a range of scripts, entry points and input arguments, so partials are useful. Users can also insert tags into their own script templates, so ease of use and access to some decent documentation is a plus.

The API seems comprehensive and the implementation seems flexible. So, impressed. I will be sure to open issues if I encounter any.

task-body.mustache:

(*

{{task-function}}

*)
{{> task-entry}}

-- Insert task code here

-- Return result
return {{#task-result?}}{{.}}{{^}}"{{task-result-message}}"{{/}}

end {{task-function}}

task-entry.mustache:

on {{task-function}}({{task-inputs}})

task-input.mustache:

{{task-input}}{{#task-input-id?}} {{.}}{{/}}

task-inputs.mustache:

 {{#task-inputs}}{{task-input}}{{^last-item?}}, {{/}}{{/}}