3

I got code::blocks as my C/C++ compiler along with C++ for dummies, but my only problem is with a obscure scripting language that I have never heard of before; "Squirrel". Is it possible to change the scripting language of code::blocks to something more familiar to me, like lua?

6
  • Download the source for Code::Blocks, add Lua bindings, compile, run. Commented Sep 9, 2013 at 22:11
  • I am not sure this will exactly address your question, but I found a three page conversation here that may be helpful Commented Sep 9, 2013 at 22:59
  • 6
    just for the sake of information, code::blocks is an IDE, not the compiler :-) you are probably using gcc as your compiler Commented Sep 9, 2013 at 23:00
  • 2
    Regarding @HappyYellowFace's comment, very true, and commonly forgotten (one up'ed you for that). And leads to the observation that depending on the compiler you choose to use within C::B, just about any scripting language on the planet should work. Commented Sep 9, 2013 at 23:04
  • @ryyker That post doesn't seem to have anything to do with changing the scripting language used in codeblocks Commented Sep 9, 2013 at 23:05

1 Answer 1

1

It seems doable in theory. Whether it is doable in practice, hard to say. Here is what you would need to do:

  1. create a folder src/sdk/scripting/lua in which you put the Lua interpreter (+ Lua libraries like io, math etc) source code and create project file for it
  2. create a folder in src/sdk/scripting/lua_bindings where you put your Lua bindings: the C++ files that allow Lua scripts access to the host application. I recommend you use a tool like SWIG to generate them (codeblocks uses SqPlus). This involves determining what code-blocks functions/classes you want to export, creating one or more .i files, running SWIG on them, put the generated files going into "lua_bindings"; create a DLL project for the bindings
  3. Create a src/lua_scripts in which you put the Lua equivalent of scripts found in src/scripts; or rather, a subset of those scripts, because it is unlikely you will want to export to Lua everything that is available via Squirrel if you're just following examples from a book
  4. Find where Squirrel interpreter is instantiated in codeblocks and where RegisterBindings is called; replace it with instantiation of a Lua interpreter and call your luaopen_codeblocks which you will have created via SWIG (no need for a RegisterLuaBindings if you use SWIG, it does that for you)
  5. Find where the various scripts are called by codeblocks (see http://wiki.codeblocks.org/index.php?title=Scripting_Code::Blocks). Call the equivalent Lua scripts (which are in lua_scripts -- you'll surely have to copy this to the installation folder for code-blocks). For example the startup.script, which is the Squirrel script that codeblocks automatically looks for at startup, is run by the following code in src/src/app.cpp:

    // run startup script
    try
    {
        wxString startup = ConfigManager::LocateDataFile(_T("startup.script"), sdScriptsUser | sdScriptsGlobal);
        if (!startup.IsEmpty())
            Manager::Get()->GetScriptingManager()->LoadScript(startup);
    }
    catch (SquirrelError& exception)
    {
        Manager::Get()->GetScriptingManager()->DisplayErrors(&exception);
    }
    

I think that's about it.

Naturally based on how extensive your scripting is, you may cut some corners, but as you can see, this is not for the faint of heart!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.