Page 1 of 2

Squirrel static lib

Posted: Sat Oct 06, 2012 11:56 am
by grabiller
Hi,

For the raafal project I'm looking for someone who would be kind enough to compile Squirrel as a 64bit static library for Mac OS/X so I could use it with an Import statement in PB. I already have it for Windows and Linux.

Squirrel is a small and fast scripting language (based on Lua code) with Javascript like syntax but with native classes instead of prototypes.
http://www.squirrel-lang.org/

The latest source package can be downloaded here:
http://code.google.com/p/squirrel/
(squirrel_3_0_3_stable.tar.gz)

raafal will use Squirrel as its official scripting language (others like Python,.. may be added in the future) for a lot of things including expressions evaluation inside numeric input fields.

As I'm working on the UI Widgets, I've already done the numeric/slider input widget and I just need to finish it with expressions evaluation for which I need Squirrel.

My Mac setup is not very 'academic' to say the least and it's a pain to use so any help on this would be appreciated.

On a side note the raafal project is still looking for its first Mac OS/X support team member :wink:
If you are interested, do not hesitate to contact me.

Cheers,
Guy.

Re: Squirrel static lib

Posted: Sun Oct 07, 2012 7:56 am
by wilbert
I don't know if everything was compiled properly but you can try if it works.
http://www.w73.nl/pb/squirrel.zip

Re: Squirrel static lib

Posted: Sun Oct 07, 2012 10:43 pm
by grabiller
Awesome. Thanks wilbert!

I just did a quick test and it seems to work as expected. I'll do more extensive tests this week.

Thanks again!

Cheers

Re: Squirrel static lib

Posted: Tue Oct 09, 2012 11:02 am
by grabiller
After more extensive tests, everything appears to work properly.

However, and this is my fault, I forgot to mention the SQUSEDOUBLE preprocessor definition to compile Squirrel with SQFloat as double instead of float.

Could it be possible for you to recompile the libraries with the SQUSEDOUBLE defined ?

Re: Squirrel static lib

Posted: Tue Oct 09, 2012 11:27 am
by wilbert
Maybe a silly question but how do I set that flag ?

Re: Squirrel static lib

Posted: Tue Oct 09, 2012 11:37 am
by grabiller
It depends on how you compile the library. If you just do a "make sq64" then you will have to add the -DSQUSEDOUBLE to the gcc command lines in the squirrel and sqstdlib makefiles.

Once compiled you can check the result with the "sq" executable from the bin folder and type "print(_floatsize_)" in the console. It should print 8 instead of 4.

Re: Squirrel static lib

Posted: Tue Oct 09, 2012 12:02 pm
by wilbert
Try again, same download location.

Re: Squirrel static lib

Posted: Tue Oct 09, 2012 12:51 pm
by grabiller
Yep, that's it.

Thank you again very much, wilbert.

You can test it here:
http://www.raafal.org/download/raafal.x ... macosx.zip

I would be interested to know the result on a 'real' Mac :wink:

The last widget (slider/numeric) on the dialog is where you can enter expressions evaluated with Squirrel. You have to right click on it to enter edit mode. You can preview the result of an expression by SHIFT+ENTER, and go back to the expression with CMD+Z. ESC will undo everything since you entered edit mode. ENTER to validate.

Aside the usual operators (+,-,/,*,%) here are the usable functions:
abs(x), acos(x), asin(x), atan(x), atan2(x,y), ceil(x), cos(x), exp(x), fabs(x), floor(x), log(x), log10(x), pow(x,y), rand(x), sin(x), sqrt(x), srand(seed), tan(x), PI or pi, RAND_MAX.

You can use variables too and separate expressions with commas, the last expression on the right is the one returned:
x=0.1,y=0.2,x+y
should returns 0.3

Bitwise operators are also supported:
&,^,|,~,>>,<<,>>>

Logical operators are supported as well but I made a little mistake and they wont work properly with '=' because normaly, in Squirrel, when you create a new variable, if it's not local to a function, you have to create a new 'slot':
x <- 5.0
Is equivalent to x = 5.0 except it will create 'x' in the context environment. For convenience I replace '=' with '<-' before compiling but I forgot the logical operators '==', '!=', '<==>' so they wont work properly for now. (as well as '+=', '-=', '/=' and '*='. I'll fix that later.

A message requester is shown (for now, later one it will use the framework logging system) on compile error or on runtime error.

Re: Squirrel static lib

Posted: Tue Oct 09, 2012 2:00 pm
by wilbert
It seems to work fine.
Didn't you compile with PB 5.0 beta 4 ?
I thought the problem of the wrong colors for stretched images was solved with beta 4 but I still see it in your application.

Re: Squirrel static lib

Posted: Tue Oct 09, 2012 2:18 pm
by grabiller
Oops, I didn't paid attention the beta 4 was available.
Downloading now.

Re: Squirrel static lib

Posted: Tue Oct 09, 2012 3:41 pm
by grabiller
Ok I got it working.

Here is the version compiled with PB 5.00 beta4:
http://www.raafal.org/download/raafal.x ... macosx.zip

From what I can see here, the problem is still present.

Is it on your side ?

Re: Squirrel static lib

Posted: Tue Oct 09, 2012 4:08 pm
by wilbert
For the box with 'subscription' inside it, the problem indeed still exists.
The other controls are looking better now. I don't know if that one is drawn in another way.

Re: Squirrel static lib

Posted: Tue Oct 09, 2012 4:14 pm
by grabiller
That's interesting.

No, that one is drawn exactly the same way as the other ones. It renders correctly on Windows and Linux.

Odd.

Re: Squirrel static lib

Posted: Tue Oct 09, 2012 9:08 pm
by grabiller
Btw, out of curiosity, what did you do to compile the lib on Mac ?

Just a "make sq64" ? Or did you use XCode or something ?

Re: Squirrel static lib

Posted: Wed Oct 10, 2012 5:59 am
by wilbert
I didn't see any .xcodeproj file so I just used the make command that compiled everything with gcc.
That worked fine :)