Squirrel

The programming language
Welcome to Squirrel Sign in | Join | Help
in Search

Squirrel Visual Studio 2008 Integration

Last post 10-06-2009, 11:42 AM by v_enom. 11 replies.
Sort Posts: Previous Next
  •  03-19-2009, 3:22 AM 3072

    Squirrel Visual Studio 2008 Integration

    Hi All, I while ago I promised I'd write a visual studio plug in for squirrel. I finally had the time and the patience to go though the excruciating process of extending VS2008.

    I wrote a "Integrated mode Package", that means that it will integrate in your VS2008 as C++ or C#. It implents a custom project system (.sqproj) a language service(syntax coloring etc..) and a remote debugger. It is as capable as SQDev(the eclipse plugin) but at the moment I don't support watches in the debugger. The protocol is fully compatible with sqdbg/sqdev so if you were using sqdev now you can switch to Squirrel Studio without changing your app.

    This is a preview release, I haven't tested it for very long but so far everthing seems to be working well enough and if you are used to visual studio you will feel at home(F5 run, F10 step etc...).

    http://wiki.squirrel-lang.org/files/SquirrelStudioIntegrated.msi

    HOW TO INSTALL

    OPTION A) You have visual studio 2008 (Professional or greter) already installed on you machine.
                    *Run the msi installer

    OPTION B) You don't have visual studio 2008 or u have an express vesion.
                   *Download Visual Studio Shell (Integrated Mode) with SP1 [NOTE: Integrated Mode NOT Isolated Mode]
                   *Run the msi Installer

    To check if evething works:
                   *Run Visual Studio 2008
                   *File/New Project
                   *Squirrel/Squirrel Basic Project
                   *Configure the project and u are ready to go

    other notes:
    *The fake autocompletion works like in the eclipse plugin, you can configure it from Tool/Options/Squirrel/General
    *Syntax cheking is always on, if you wait for a second or 2, the editor will show the squiggly line on the error. The error also appears in the Errors tool window(u have to open it).
    *The project configuration for the debugger works pretty much like in sqdev(same options in Project/Properties then "Configuration Properties/Debugger").

    that's it, tell me if you have any problem. I'll make a wiki page or something as soon as I'm confident that everything is stable enough.

    ciao

    Alberto


  •  03-19-2009, 7:18 PM 3075 in reply to 3072

    HI fagiano,i've tried it

    I intall it on my vs2008 professtional,and it works! the setup is easy and F5 and F10,F11 all works,but can you tell me how to setup the autocompletion in
    Tool/Options/Squirrel/General? I see Symbols file1 ,Symbols file2 and Symbols file3 ,what kind of file should i input there?
    And by the way the breakpoint i set doesn't seem to work,and every time i Run the program the Output window says:

    Loaded 'squirrel module'
    Symbols Loaded - nothing
    DEBUGGER EVENT : addbreakpoint<UNHANDLED>
    DEBUGGER EVENT : addbreakpoint<UNHANDLED>
    DEBUGGER EVENT : addbreakpoint<UNHANDLED>
    DEBUGGER EVENT : step


    and sometimes the vs2008 will crash when i press F5


    Thank you for your work!I don't need to use vs and eclipse to debug together anymore!---the eclipse often crash and consume much mem.
  •  03-19-2009, 8:52 PM 3076 in reply to 3075

    I find a weird behavior of the plugin

    When i Add .nut file to the SquirrelProject,it auto copy the .nut files to the squirrel project dirctory!So after that the file i edit with the plugin is not the .nut i Choose to add in,it's the copied one.
    But in C++ project,when i Add files,it just add a reference to it,so diferent projects can share the same file,
    is that a bug ?
  •  03-19-2009, 10:12 PM 3077 in reply to 3076

    Re: I find a weird behavior of the plugin

    Hi, No is not a bug, that's how the MSBuild based projects work. Try a C# project, is going to do the same. There are up and downs on this approach, and the only alternative seems to be revriting your own project file format. So we will have to live with it.

    Alberto

  •  03-19-2009, 10:17 PM 3078 in reply to 3075

    Re: HI fagiano,i've tried it

    The breakpoints will not work if your project structure doesn't reflect the way you load a file in the vm.
    For Instance if you load a script in "data/scripts/thescript.nut" in the sqproj you must have a folder "data" a folder "scripts" and in it a file "thescript.nut".

    The symbol file format is just to have some form of completion on global symbols, is just useful to remeber the name of global methods etc...
    Is an XML, I'll post an example asap.

    Alberto

  •  03-20-2009, 12:17 AM 3079 in reply to 3078

    the breakpoint breaks in main.nut now!but not the second .nut

    My "SquirrelProject.sqproj" file is in "debug"
    I add folder "script" in the sqproj,then move "main.nut"&"ui.nut"to "debug\script",and add them to folder"script" in sqproj

    in c++,I call DoFile(L"script\\main.nut")
    in main.nut :UI.load<-loadfile("script\\UI.nut",true);

    the breakpoint in main.nut works all right,but in UI.nut it doesn't break on the right breakpoint

    I can step into UI.nut

    filesystem:
    debug\
          SquirrelProject.sqproj
          script\
                  main.nut UI.nut
    sqproj structure:
    SquirrelProject
    ------reference
    ------script
           |
            --main.nut
           |
            -UI.nut



         

  •  03-20-2009, 12:52 AM 3081 in reply to 3079

    breakpoint in UI.nut

    in UI.nut:
    print("1");
     print("2");//set breakpoint here
     print("3");

    if i press F5 then the app prints "1" and never go on,just die there
    if i press F10 to step over,then the app can run every line and print
    "1
    2
    3"

    when i press F5 at the beginning ,the Output Windows says:
    Loaded 'squirrel module'
    Symbols Loaded - nothing
    DEBUGGER EVENT : addbreakpoint<UNHANDLED>
    DEBUGGER EVENT : step
    DEBUGGER EVENT : resumed
    DEBUGGER EVENT : breakpoint

    But the breakpoint in main.nut works all right
  •  03-20-2009, 3:54 AM 3084 in reply to 3081

    Re: breakpoint in UI.nut

    how do you load your scripts are you using "dofile()"?

    One thing to notice is that the debugger stores all the paths as lowercase so assuming you are using do file you should do smething like dofile(path.tolower()) when you load a script so that the path is lowercased and the debugger can match it.

    I have a function like this in my system that also prevents to load a script twice

    local loaded_files = {}
    function require(filename):(loaded_files)
    {
     try{
      filename = filename.tolower(); //here in my real code I also flip the slashes to unix slashes
      if(filename in loaded_files)
       return;
      dofile(filename);
      loaded_files[filename] <- 1;
     }catch(e)
     {
      throw "require failed ["+e+"] "+filename;
     }
    }

    I hope tis helps

    Alberto

  •  03-20-2009, 4:29 AM 3086 in reply to 3084

    I change UI.nut to ui.nut ,and it finally works as expect!

    Finally.
    lowercase!?!
    rename UI.nut to ui.nut and in main.nut:
    change UI.load<-loadfile("script\\UI.nut",true); to... "script\\ui.nut"...
    and Finally the breakpoint works in the ui.nut
    Thank you for your help,and expect the stable release of the plugin.
  •  03-21-2009, 3:22 AM 3092 in reply to 3086

    Squirrel Visual Studio 2008 Integration

    Here is an example for the fake autocompletion, it will complete the sqstdlib functions etc... This was hand made by me but a better approach is to autogenerate it with a script. In my company project we have a command line switch for our game that instead of running the game, just loads all out scripts and then traversing the root table generates a similar file. It is extremely useful when you have a very massive script library as we do.

    http://wiki.squirrel-lang.org/files/std_completion.zip

    I Hope this helps

    Alberto

    PS: it also works with the eclipse plugin

     

  •  09-19-2009, 7:18 PM 3516 in reply to 3092

    Re: Squirrel Visual Studio 2008 Integration

     Is there any way to get this working with correct path information..

    My working directory:

    /Kernel/

    Squirrel scripts are at

    /Modules/Squirrel/

     So in C++ I have to do "../Modules/Squirrel/main.nut" which means no debuging happens since I guess it can't find the files or whatever...

    Is there any way to do this that doesn't require me to put my script files inside of /Kernel/ ?

     I noticed the squirrel project has a "working directory" entry but modifying it doesn't seem to do anything..


  •  10-06-2009, 11:42 AM 3545 in reply to 3072

    Re: Squirrel Visual Studio 2008 Integration

    .

    Normal 0 false false false MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Обычная таблица"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}

    Do you have a good tutorial to know how to start working with Squirrel?
    All I saw (http://wiki.squirrel-lang.org/default.aspx/SquirrelWiki/EmbeddingGettingStarted.html) is eversome fake.... No images (how does it work in VS 2008. Becouse if I create new squirrel project even ::print("Hello world") doesn't work and returns an error), no algorithm how to add to the current C++ project... Nothing helpful for the beginner. May you create it first of all? The first steps is the most difficult and the most important part and as I see other have problems with starting and using *.nut scripts too.

    1) this example http://wiki.squirrel-lang.org/default.aspx/SquirrelWiki/SquirrelCallToCpp.html
    show such errors like

    Error    1    error C2664: 'sq_throwerror' : cannot convert parameter 2 from 'const char [14]' to 'const SQChar *' :
        default:   return sq_throwerror(v,"invalid param"); //throws an exception
    Error    2    error C2664: 'sq_pushstring' : cannot convert parameter 2 from 'const char *' to 'const SQChar *' : 
       sq_pushstring(v,fname,-1);
    Error    3    error C2664: 'sq_compilebuffer' : cannot convert parameter 2 from 'char *' to 'const SQChar *': 
     sq_compilebuffer(v,cmd,(int)strlen(cmd)*sizeof(SQChar),"compile",1);



    2) in this example http://wiki.squirrel-lang.org/default.aspx/SquirrelWiki/EmbeddingGettingStarted.html


    I recieve  an    error C2660: 'sq_call' : function does not take 3 arguments   

        sq_call(v,4,0); //calls the function 
    if add 0 to the end - everyhing compiles...but shows nothing. What does it do?
    sq_call(v,4,0,0); //calls the function

    3) and what does integrated Squirrel project main.nut file does I can't understand. What should I recieve if  I  run:
    ::print("Hello World"); (I think I have to see "Hello world" on my screen or in file...or smth.)
    in main.nut by default?
    I press F5 - error, F6 - nothing happened....

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems