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?
-
Download the source for Code::Blocks, add Lua bindings, compile, run.Captain Obvlious– Captain Obvlious2013-09-09 22:11:22 +00:00Commented 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 helpfulryyker– ryyker2013-09-09 22:59:27 +00:00Commented Sep 9, 2013 at 22:59
-
6just for the sake of information, code::blocks is an IDE, not the compiler :-) you are probably using gcc as your compilerNatan Streppel– Natan Streppel2013-09-09 23:00:16 +00:00Commented Sep 9, 2013 at 23:00
-
2Regarding @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.ryyker– ryyker2013-09-09 23:04:31 +00:00Commented Sep 9, 2013 at 23:04
-
@ryyker That post doesn't seem to have anything to do with changing the scripting language used in codeblocksgreatwolf– greatwolf2013-09-09 23:05:52 +00:00Commented Sep 9, 2013 at 23:05
1 Answer
It seems doable in theory. Whether it is doable in practice, hard to say. Here is what you would need to do:
- 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
- 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
- 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
- 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)
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!