Xcode and Ruby function menu
-
I use XCode as my development IDE which works great as my project has Ruby, C, C++, Javascript and HTML files (for that special "syntax-overload" feeling!). However, for Ruby only, XCode is generating madly indented function-menu pop-ups.
I just spent some time figuring out what is going on and it turns out to be just that it gets confused by loop constructs which have an optional "do" keyword. (Guess the parser for syntax coloring is too picky).
eg:
for faces in container do
blah
endcauses the function menu pop-up to be wrong. Removing the (unneccessary) "do" fixes it.
Anyway, hope this tidbit helps others.
-
Thanks for the tidbit. For Ruby, I currently use TextWrangler (free), but might be moving to TextMate (fee).
I use XCode a lot for C, C++ and Java. It has some quirks, but is basically a pretty good editor. I just recently figured out how to turn on code completion. That sure is nice.
Todd
-
Has anybody tried the Netbeans 6.1 IDE (there also is a Ruby-only IDE)? Till now I haven't had any breaks in syntax highlighting with that IDE (you know Scite? ^^).
One year ago I tried XCode, but it wasn't good for me. I also tried TextMate - seemed to have a good syntax highlighting (but is it really free? I don't think so.)
azuby
-
I use Scite occasionally too - on Windows, when I need line numbers. I said "fee" for TextMate, not "free".
Last year, I went to a Ruby conference and Sun demonstrated NetBeans 6.0. It looked good, but I have yet to download it. I really liked the interactive debugger built into it, but alas, that won't work for SU. I told Sun I would pay $1,000 for an interactive debugger that works in SU.
Todd
-
It's possible to hook into all methods like all Ruby debugger are doing. And we also need to change $STDOUT, $STDIN and $STDERR. So it would be possible to have an own console. But a debugger talking to NetBeans hm ... And all still works for XCode and TextMate?
Don't know, why Ruby programmers use "for" statements - they aren't "the Ruby way" Ruby provides iterators and the "each" (each_index, each_with_index, reverse_each, to, upto, downto, times) method.
azuby
-
Hmm. When I first came across Ruby I was enamored with these constructs. However, there is no such thing as a free lunch and the fact is that they are all slow. For my stuff, significantly slower than plain old simple for-loops - now you can argue they're semantically identical until your blue in the face.. Not as sexy, I know, but I'm old and wise and detest fancy language features that have hidden costs almost as much as I detest feats-of-engineering for engineering's sake. Been there, done that, got the t-shirt. Move on.
Adam
-
Hehe, blue? OK, maybe you really need half of a second. Time is money. But sex sells
azuby
-
Well perhaps I was just grumpy last night. But that link shows what I know, which is a simple for-loop is around 10% faster for pretty much zero loss in readability. I'll take the 10% thanks.
There is a real danger with Ruby of not understanding how much work you're asking for in using these cool constructs. Look at the Struct stuff - obscenely slow. Ditto expressions in which one is making Ruby do a lot of copying behind the scenes. It might look nice and compact on the outside, but... And some of the self-serving arguments you hear about "hardware is cheap" are a bit, well, self serving!
</rant_off>
Bon weekend!
-
Hi,
I'm extremely unknowledgeable about scripting in general, and SU ruby in particular, but have a need (more a desire) to go through and Mac'ify any of my ruby set that give me Console(system) messages on start-up and in use,
It seems the main error (that I see) lies within SU itself and is there as soon as I load a clean instal of SU, before adding any additional rubies. It may or may not be a problem, but it generates pages of reports, which can't be good.
[0x0-0x45045].com.google.sketchupfree7[548] SketchUp(548,0xa015e720) malloc: *** error for object 0xa03eb6d8: Non-aligned pointer being freed
[0x0-0x45045].com.google.sketchupfree7[548] *** set a breakpoint in malloc_error_break to debugas soon as I start adding rubies, I get additional error messages mostly like the examples below, usually telling me what line in which script, is at 'fault'
[0x0-0x3b03b].com.google.sketchupfree7[373] /Library/Application Support/Google SketchUp 7/SketchUp/Plugins/Xyz/Abc.rb:218: warning: parenthesize argument(s) for future ver
[0x0-0x45045].com.google.sketchupfree7[548] (eval):4632: warning: don't put space before argument parentheses
[0x0-0x45045].com.google.sketchupfree7[548] (eval):27: warning: already initialized constant ZERO_TOL
[0x0-0x45045].com.google.sketchupfree7[548] #<NoMethodError: undefined method `rendering_options' for nil:NilClass>from time to time I send these reports to Google (to no avail) and to individual authors who have then, tidied up the code.
I have also used Xcode to clean some scripts, and solve some glitches, so I know it all helps.
My first question is, On a script by script basis, can Xcode be set-up to 'find all>repair all' for these types of errors?
john
-
@driven said:
[0x0-0x45045].com.google.sketchupfree7[548] SketchUp(548,0xa015e720) malloc: *** error for object 0xa03eb6d8: Non-aligned pointer being freed
[0x0-0x45045].com.google.sketchupfree7[548] *** set a breakpoint in malloc_error_break to debugSketchup has always emitted these (scary) messages. I've never figured out why.
@driven said:
0x0-0x3b03b].com.google.sketchupfree7[373] /Library/Application Support/Google SketchUp 7/SketchUp/Plugins/Xyz/Abc.rb:218: warning: parenthesize argument(s) for future ver
You'd have to write a prtty sophisticated regular expression to catch and change all these. You'd be running the risk of screwing up the scripts if you get anything wrong..
@driven said:
[0x0-0x45045].com.google.sketchupfree7[548] (eval):4632: warning: don't put space before argument parentheses
A simple search and replace of " (" with "(" should work.
@driven said:
[0x0-0x45045].com.google.sketchupfree7[548] (eval):27: warning: already initialized constant ZERO_TOL
A script is being required/loaded twice.
@driven said:
[0x0-0x45045].com.google.sketchupfree7[548] #<NoMethodError: undefined method `rendering_options' for nil:NilClass>
This is just an error in the script. My total guess would be a script that is reading the rendering_options when there is no active_model and thus getting nil as the result.
-
@adamb said:
My total guess would be a script that is reading the rendering_options when there is no active_model and thus getting nil as the result.
That's a mac thing? Or does SU load scripts before a model is ready?
-
AdamB,
cheers for the reply, before attempting to write any rubies myself I'm trying to analyze what I can and can't see using Xcode and Console (in combination)
it appears (to me) that if a ruby or it's loader.rb and subfolder reside in SU Plugin folder they will be initiated on start-up whether required or not and generate error reports if they have a prerequisite for "xxx" which is not available/selected prior to start-up(which, of course it's not)
This type of error does't seem to be generated for rubies that are placed inside their own sub-folder with a non-automatic step in their path i.e. rudy console, or a separate toolbar ruby that has it's own sub-folder that contains a on/off-button for an in-folder loader ruby that opens/closes the desired ruby.
Not even sure I follow that myself, but main lightup ruby (for example) appears to have to a degree of separation (for activation at least) and cannot generate errors and cause conflicts, unless it's actually being used and there's a problem.
What I think I'm after is a way to active/de-active any ruby, from within SU using a single(per ruby) external action.
Do you know if that's even realistic en-mass?
Which Xcode template is appropriate for SU rubies? or is there an importable or custom layout that's preferable?
cheers
john
Advertisement