Author Topic: Ùpdate Squirrel and replace sqplus with sqrat  (Read 6992 times)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Ùpdate Squirrel and replace sqplus with sqrat
« on: February 17, 2016, 11:32:25 pm »
Hi, i finally got somehow the time to finish a first patch for porting squirrel to the newest version and replace sqplus with sqrat.
i have made a pull request to the repo of obfuscated on github and attached a patch here.

The changes are following:
Quote
general scripting:
 # unified error handling
 # more informative errors and error reporting dialog
 + complete unicode utf8 support
 + Add more test cases
 + Add menu test script
 + Add script to convert old 2.0.8 squirrel scripts to new 3.0.4

script plugins
 # Fix multiple bugs in script Menu Handling
 + Add parameter to OnModuleMenuClicked to distinguish between module
   menus
 + CodeBlocks event handling in scripts

add cb_vm:
 + Prepared to use multiple vms
 + Sand boxing

script binding utility
 + Add StackHandler class for easy squirrel stack handling

wxWidgets binding
 + wxStrings are now handled as native strings: no need of
   _("") or wxT("") to create wxStrings. Calls to wxWidgets functions
   can now handle native strings
 + Add various global bindings

documentation
 + begin squirrel section in doxygen documentation
i forget to mention, that i added also squirrel debugger interface, so you can debug squirrel code running in codeblocks  with codeblocks (you need the squirrel debugger: https://github.com/bluehazzard/cbSquirrelDebugger this debugger should work with the current Codeblocks version). I will post a video how it works probably later this week...

I have tested this patch with wxWidgets 2.8, and git trunk (3.0) on windows 7 and linux with tdm-gcc4.8 and tdm-gcc5.0 and also 64bit on windows. I could not test the PCH because gcc crashed every time i tried to compile it, so this my need some more tweaking. Also missing are the make files. i simply have not the experience to update them.

This is one of more patches. When the rework is finally finished codeblocks scripts can use all base wxWidgets controls and wxWidgets events. Script plugins are as comfortable to install as normal plugins and many more improvements.. It all is working on my local branch, i "just" have to split it up in handy patches and keep them in sync with the trunk.

greetings

PS.: i had to split the patch. You have to rename the files from sqplus_to_sqrat.001.7z -> sqplus_to_sqrat.7z.001 because i could not upload the original file

PSS.  Keeping the "thousand" project (wx2.8 wx3.0 64bit, unix all plugins ecc.)  files in sync is a terrible job...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Ùpdate Squirrel and replace sqplus with sqrat
« Reply #1 on: February 18, 2016, 12:42:11 am »
Do you keep the version with separate commits somewhere?
This one is really massive 17k loc added and only 1.5k loc removed according to github.
I don't think anyone can review such a big commit :(
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Ùpdate Squirrel and replace sqplus with sqrat
« Reply #2 on: February 18, 2016, 01:19:31 am »
Already saw bad staff in the commit.
1. There was a using namespace in a header.
2. Some new classes have been named in non conforming to the naming convention way (Menu_point_item).
3. I don't like the ->GetVM()->GetVM() pattern I see all over the place.
4. The changes in the envvars plugin looks to be mostly cosmetic, but they clutter the diff for no apparent reason.
5. You can remove all the code in the debugger plugin. It is mostly useless.
6. The changes in common_functions.script look to be cosmetic only.
7. The convert script is using camelcase for the name of the file. It is better to stick to lowercase and underscores!
8. Why have you added 2 new scripting extensions?
9. Problems with indents in src/sdk/menuitemsmanager.cpp
10. Using std::list in the same file. Using std::list ist the same as committing a crime against humanity. Vectors are always better. :)
11. Mixing includes with "" and <>, I'd say prefer "".
12. There are changes in wxpropgrid. Why? Why not separate commit?
13. Extremely log line in app.cpp
14. Lots of "FIXME (bluehazzard#1#): squirrel error" left in the code. Why?

I've glanced over the patch only and this is not a thorough review.
The biggest problem is the size of the commit.
So I'd rather prefer if you split it up in parts. I've mentioned this many times on IRC.
And for me the most important part is getting the sq3+sqrat in svn.
After that we can add more features. But I'd prefer if we have a solid base.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Ùpdate Squirrel and replace sqplus with sqrat
« Reply #3 on: February 18, 2016, 01:42:09 am »
About PCH,  you can use the compiler from MinGW-w64 site, such as MinGW-build GCC 5.3, it fixed PCH bug already. TDM GCC 5.1 dose not have such fix.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Ùpdate Squirrel and replace sqplus with sqrat
« Reply #4 on: February 18, 2016, 02:40:03 am »
FYI: Using "wxCHECK_VERSION" without including "wx/version.h" will likely lead to errors on NO PCH builds on Linux.

Edit: This header "wx/wxprec.h" includes "wx/defs.h"; and "wx/defs.h" includes "wx/version.h". Your patch guards "wx/wxprec.h" which will likely result in a NOPCH Build error.

Tim S.

« Last Edit: February 18, 2016, 03:59:20 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Ùpdate Squirrel and replace sqplus with sqrat
« Reply #5 on: February 18, 2016, 03:03:19 am »
I have downloaded the attachments above and I am trying to build CB using parts of the patches.

I am using MinGW GCC 4.7.1; it does NOT appear to have EWOULDBLOCK.
The below patch was done to try to get the code to compile; no idea if it is a valid fix for the problem.
Code
diff --git a/src/sdk/scripting/squirrel/sqrdbg.cpp b/src/sdk/scripting/squirrel/sqrdbg.cpp
index 08da664..0c90b3d 100644
--- a/src/sdk/scripting/squirrel/sqrdbg.cpp
+++ b/src/sdk/scripting/squirrel/sqrdbg.cpp
@@ -103,7 +103,11 @@ SQRESULT sq_rdbg_update(HSQREMOTEDBG rdbg)
  return sq_throwerror(rdbg->_v,_SC("disconnected"));
  case SOCKET_ERROR:
      {
+#ifdef _GLIBCXX_HAVE_EWOULDBLOCK
          if(errno == EAGAIN || errno == EWOULDBLOCK)
+#else
+         if(errno == EAGAIN )
+#endif // _GLIBCXX_HAVE_EWOULDBLOCK
                 {
                     // No bytes received in Linux
                 }

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Ùpdate Squirrel and replace sqplus with sqrat
« Reply #6 on: February 18, 2016, 12:12:14 pm »
Do you keep the version with separate commits somewhere?
This one is really massive 17k loc added and only 1.5k loc removed according to github.
I don't think anyone can review such a big commit :(
Sadly not. This work is nearly 2 years old, and i was a git beginner at that moment. I used git and the main branch to sync my two workstations and so the commit history was cluttered with shit. At one point i squashed them together, without making a branch...

The patch is mainly cluttered because of removing of sqplus, and adding of squirrel and sqrat. You can ignore them in the patch, because the changes there does not  come from me ;)
I can splitt it up more, but i was undecided between posting not compiling patches or one big patch what compiles. The current patch is "mostly" needed for the transfer to sqrat. The additions like C::B event handling or additional bindings are not more than 100 lines of code. I thought that it is more work to remove them, then reviewing them...
Already saw bad staff in the commit.
1. There was a using namespace in a header.
2. Some new classes have been named in non conforming to the naming convention way (Menu_point_item).
3. I don't like the ->GetVM()->GetVM() pattern I see all over the place.
4. The changes in the envvars plugin looks to be mostly cosmetic, but they clutter the diff for no apparent reason.
5. You can remove all the code in the debugger plugin. It is mostly useless.
6. The changes in common_functions.script look to be cosmetic only.
7. The convert script is using camelcase for the name of the file. It is better to stick to lowercase and underscores!
8. Why have you added 2 new scripting extensions?
9. Problems with indents in src/sdk/menuitemsmanager.cpp
10. Using std::list in the same file. Using std::list ist the same as committing a crime against humanity. Vectors are always better. :)
11. Mixing includes with "" and <>, I'd say prefer "".
12. There are changes in wxpropgrid. Why? Why not separate commit?
13. Extremely log line in app.cpp
14. Lots of "FIXME (bluehazzard#1#): squirrel error" left in the code. Why?

So this is something nice, a list i can work on... After all this time i was getting "blind" for the obvious mistakes...

thanks!

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Update Squirrel and replace sqplus with sqrat
« Reply #7 on: February 18, 2016, 12:16:03 pm »
FYI: Using "wxCHECK_VERSION" without including "wx/version.h" will likely lead to errors on NO PCH builds on Linux.

Edit: This header "wx/wxprec.h" includes "wx/defs.h"; and "wx/defs.h" includes "wx/version.h". Your patch guards "wx/wxprec.h" which will likely result in a NOPCH Build error.

Thanks, for the info. They build fine on my system(s), but i will look into it.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Ùpdate Squirrel and replace sqplus with sqrat
« Reply #8 on: February 18, 2016, 07:17:32 pm »
I am using your changes to try once more to learn the correct setting to use Git Under Windows and Linux.
https://github.com/stahta01/codeblocks_https_metadata/tree/port/sqrat

A simple patch the removes the need to define SCRAT_IMPORT in CB Projects. Only tested on Windows 7 32 bit wxWidgets 2.8.
Code
From e90fb7713cd9d8f7da8ecb6593047cd45b22fe14 Mon Sep 17 00:00:00 2001
From: Tim S <stahta01@users.sourceforge.net>
Date: Thu, 18 Feb 2016 12:20:48 -0500
Subject: [PATCH 11/17] * sqrat: Removed the need to define "SCRAT_IMPORT" in
 CB Projects. (Thanks stahta01)

Edited, scripting/sqrat/sqratUtil.h to define SCRAT_IMPORT if SCRAT_EXPORT is not defined.
---
 src/include/scripting/sqrat/sqratUtil.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/include/scripting/sqrat/sqratUtil.h b/src/include/scripting/sqrat/sqratUtil.h
index c076d70..2c8460d 100644
--- a/src/include/scripting/sqrat/sqratUtil.h
+++ b/src/include/scripting/sqrat/sqratUtil.h
@@ -37,6 +37,12 @@
 #include <unordered_map>
 #endif
 
+/* C::B begin */
+#if !defined(SCRAT_EXPORT) && !defined(SCRAT_IMPORT)
+    #define SCRAT_IMPORT
+#endif // !defined(SCRAT_EXPORT) && !defined(SCRAT_IMPORT)
+/* C::B end */
+
 namespace Sqrat {
 
 /// @cond DEV
--
2.7.1.windows.2

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Ùpdate Squirrel and replace sqplus with sqrat
« Reply #9 on: February 18, 2016, 08:15:23 pm »
The current patch is "mostly" needed for the transfer to sqrat.
The patch is full with new features. There are two options - you can separate them or I can separate them. It is up to you to decide :)
Also it will be good if the squirrel upgrade and the switch from sqplus to scrat is done in a single separate commit (no matter if it compiles or not).
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Ùpdate Squirrel and replace sqplus with sqrat
« Reply #10 on: February 18, 2016, 08:34:59 pm »
The current patch is "mostly" needed for the transfer to sqrat.
The patch is full with new features. There are two options - you can separate them or I can separate them. It is up to you to decide :)
Also it will be good if the squirrel upgrade and the switch from sqplus to scrat is done in a single separate commit (no matter if it compiles or not).
i am on it...


Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Ùpdate Squirrel and replace sqplus with sqrat
« Reply #11 on: February 20, 2016, 04:51:57 pm »
Hi, i finally got somehow the time to finish a first patch for porting squirrel to the newest version and replace sqplus with sqrat.
That is certainly nice!!! :)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ