I have now created a separate script plugin class and manage all events from there.
I added the possibility to use c::b events in scripts.
I had some difficulties with the menu events not getting handled. But after updating my compiler from 4.7 to 4.8 all works. I don't know if this had do do with a "hard" rebuild, or with the compiler version.
Can please someone test this build with a different compiler then 4.8.1 and look if the menu and c::b events work? Of course all others are also invited to test...
procedure to test:
1) Compile all
2) Run C::B sqrat port
3) Open scripting console
4) In the script console open "scripts\test\script-test-plugin.script"
5) Run Menu->Plugins->Test scripting
6) Check scripting console for output (The Volume test fails)
7) In the script console open "scripts\test\event-test-plugin.script"
8) Run Menu->Plugins->Test Event scripting
9) Open and close random project and files -> Check in the console for errors
10) Reload a plugin (repeat step 4->9 or 7->9)
thank you
greetings
Hi!
i have found a bug. A very strange bug. Can please someone review this code, if it is right:
template<>
struct Var<const wxString&> {
const wxString& value;
wxString tmp_value;
Var(HSQUIRRELVM v, SQInteger idx) : value(tmp_value){
if (!Sqrat::Error::Instance().Occurred(v)) {
wxString* ptr = ClassType<wxString>::GetInstance(v, idx);
if (ptr != NULL) {
tmp_value.Append((*ptr).c_str());
} else {
Sqrat::Error::Instance().Clear(v);
const SQChar* str;
sq_tostring(v, idx);
sq_getstring(v, -1, &str);
tmp_value = wxString::FromUTF8(str);
sq_pop(v, 1);
}
}
}
static void push(HSQUIRRELVM v, const wxString& value) {
ClassType<wxString>::PushInstanceCopy(v, value);
}
};
i need the member value to be a const ref to a wxString.
On linux this code works without problems on windows it worked with gcc 4.7 but with 4.8 the value overwrites some other variables in the code.
You can reproduce it with this steps:
1. Compile c::b from my git hub repo
2. Set breakpoint at "include/scripting/sqrat/sqrat/sqratGlobalMethodes.h" at line 184 and 185
3. Start the debugger
4. load the script "scripts/ConvertOldToNewScript.script"
5. run the script from menu plugins->Convert Scripts
5b. if a messagebox pops up press ok
6. The debugger will now stop on breakpoint 1: Look at the variable "method". It will hold the right address for the function "wx_GetFileFromUser"
7. Continue the debugger one line, it will stop on breakpoint 2
8. The pointer "method" does not point anymore to a valid function....
after investigating i found the error in the source posted previously. The address gets changed at the initialization of the reference in the first line of the constructor...
i have no clue why, or how i should fix this, because for me the code looks ugly but right...
greetings
* Add more controls. Now implemented:
wxEvent, wxTextCtrl, wxButton, wxAnimationCtrl, wxCommandLinkButton, wxCheckBox, wxChoice, wxCollapsiblePane, wxComboBox, wxRadioBox, wxGauge, wxHyperlinkCtrl, wxRadioButton, wxListBox, wxCheckListBox, wxStaticText, wxSlider, wxToggleButton, wxSearchCtrl, wxColourPickerCtrl, wxDirPickerCtrl, wxFilePickerCtrl, wxTimer, wxSpinButton, wxSpinCtrl
i haven't exported all functions, only the important one.(Almost) All functions are documented with doxygen (markdown). The controls can't be created on "runtime", only imported from xrc files.
You can test the implemented controls with the xrc-test-plugin.
instruction:
1.a) Download https://github.com/bluehazzard/codeblocks_sf and compile it
1) Open Script console
2) Open "scripts/test/xrc-test-plugin.script"
3) Start test with Plugins->Test scripting-> Test XRC
4) open "scripts/test/xrc_test.xrc
5) test the controls and discover the gimmicks/bugs ;)
my plan for the future:
* implement wxPropertyGrid (next main goal)
* implement the possibility to install script plugins with the Plugin->Manage Plugins-> install
* encapsulate script plugins in .cbplugin container (for delivering xrc and script files ins one container)
* implement wxFrame
* implement wxTreeCtrl
i think the main controls are implemented now. I don't know if tabs and ScrollBars are necessary...
greetings
Two patches, so far:
http://cmpt.benbmp.org/codeblocks/patches/sqrat/0001-scripting-no-pch-build-fix.patch
http://cmpt.benbmp.org/codeblocks/patches/sqrat/0002-scripting-Fix-compilation-it-seems-that-Play-doesn-t.patch
I'm trying to make the thing to compile with autotools and noPCH.
And I'm hitting a road block:
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../../../../../src/sdk/scripting/bindings -I../../../../src/include -I/usr/lib64/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -I../../../../../src/include -I../../../../../src/sdk/wxscintilla/include -I../../../../../src/include/scripting/squirrel -I../../../../../src/include/scripting/bindings -I../../../../../src/include/scripting/sqrat -ansi -DTIXML_USE_STL -O2 -ffast-math -DCB_AUTOCONF -fPIC -DPIC -fexceptions -MT sq_wx/sq_wxBaseControls.lo -MD -MP -MF sq_wx/.deps/sq_wxBaseControls.Tpo -c ../../../../../src/sdk/scripting/bindings/sq_wx/sq_wxBaseControls.cpp -fPIC -DPIC -o sq_wx/.libs/sq_wxBaseControls.o
In file included from ../../../../../src/include/scripting/sqrat/sqrat/sqratTypes.h:39:0,
from ../../../../../src/include/scripting/sqrat/sqrat/sqratAllocator.h:35,
from ../../../../../src/include/scripting/sqrat/sqrat/sqratObject.h:34,
from ../../../../../src/include/scripting/sqrat/sqrat/sqratTable.h:34,
from ../../../../../src/include/scripting/sqrat/sqrat.h:33,
from ../../../../../src/include/scripting/bindings/sq_wx/sq_wx_type_handler.h:5,
from ../../../../../src/include/scripting/bindings/sq_wx/sq_wxBaseControls.h:4,
from ../../../../../src/sdk/scripting/bindings/sq_wx/sq_wxBaseControls.cpp:2:
../../../../../src/include/scripting/sqrat/sqrat/sqratClassType.h: In instantiation of ‘void* Sqrat::ClassTypeData<C, B>::Cast(SQUserPointer, SQUserPointer) [with C = wxSpinCtrl; B = wxSpinButton; SQUserPointer = void*]’:
../../../../../src/sdk/scripting/bindings/sq_wx/sq_wxBaseControls.cpp:1104:1: required from here
../../../../../src/include/scripting/sqrat/sqrat/sqratClassType.h:64:13: error: invalid static_cast from type ‘wxSpinCtrl*’ to type ‘wxSpinButton*’
../../../../../src/include/scripting/sqrat/sqrat/sqratClassType.h: In instantiation of ‘void* Sqrat::ClassTypeData<C, B>::Cast(SQUserPointer, SQUserPointer) [with C = wxGauge; B = wxGaugeBase; SQUserPointer = void*]’:
../../../../../src/sdk/scripting/bindings/sq_wx/sq_wxBaseControls.cpp:1104:1: required from here
../../../../../src/include/scripting/sqrat/sqrat/sqratClassType.h:64:13: error: invalid static_cast from type ‘wxGauge*’ to type ‘wxGaugeBase*’
../../../../../src/include/scripting/sqrat/sqrat/sqratClassType.h: In instantiation of ‘void* Sqrat::ClassTypeData<C, B>::Cast(SQUserPointer, SQUserPointer) [with C = wxComboBox; B = wxChoice; SQUserPointer = void*]’:
../../../../../src/sdk/scripting/bindings/sq_wx/sq_wxBaseControls.cpp:1104:1: required from here
../../../../../src/include/scripting/sqrat/sqrat/sqratClassType.h:64:13: error: invalid static_cast from type ‘wxComboBox*’ to type ‘wxChoice*’
Makefile:477: recipe for target 'sq_wx/sq_wxBaseControls.lo' failed
make[4]: *** [sq_wx/sq_wxBaseControls.lo] Error 1
Is there any real reason you have to bind the wxXXXBase class? This is an implementation detail the wx user shouldn't care!
Other notes:
1. There is an include for sqplus in a lot of places, still.
2. sqrat/sqrat looks ugly, I'd prefer if you remove one of the levels.
3. It will be good if all public headers for scripting could be included without the need of additional paths
4. Please keep filename only with lower case letters and underscores.
/home/obfuscated/projects/codeblocks/git/src/sdk/menuitemsmanager.cpp|118|warning: deleting object of abstract class type ‘Menu_point_base’ which has non-virtual destructor will cause undefined behaviour [-Wdelete-non-virtual-dtor]|
This is pretty bad warning/error, please fix!
Edit:
/home/obfuscated/projects/codeblocks/git/src/sdk/menuitemsmanager.cpp|201|warning: unused variable ‘sub_menu’ [-Wunused-variable]|
This one seems like a bug, too.
FYI: For proper Windows PCH creation sdk.h needs moved to src.
diff --git a/src/CodeBlocks.cbp b/src/CodeBlocks.cbp
index 1e6f409..090715d 100644
--- a/src/CodeBlocks.cbp
+++ b/src/CodeBlocks.cbp
@@ -1322,7 +1322,7 @@
<Unit filename="include/sdk.h">
<Option compile="1" />
<Option weight="1" />
- <Option target="sdk" />
+ <Option target="src" />
</Unit>
<Unit filename="include/sdk_common.h">
<Option target="sdk" />
Tim S.
Patch to get Win32 wx30 cbp to build.
diff --git a/src/CodeBlocks_wx30.cbp b/src/CodeBlocks_wx30.cbp
index 72a5a0e..aaf47e5 100644
--- a/src/CodeBlocks_wx30.cbp
+++ b/src/CodeBlocks_wx30.cbp
@@ -1154,6 +1154,9 @@
<Unit filename="include/scripting/bindings/sq_wx/sq_wx_dialog.h">
<Option target="sdk" />
</Unit>
+ <Unit filename="include/scripting/bindings/sq_wx/sq_wx_propgrid.h">
+ <Option target="sdk" />
+ </Unit>
<Unit filename="include/scripting/bindings/sq_wx/sq_wx_type_handler.h">
<Option target="sdk" />
</Unit>
@@ -3158,6 +3161,9 @@
<Unit filename="sdk/scripting/bindings/sq_wx/sq_wx_base_controls.cpp">
<Option target="sdk" />
</Unit>
+ <Unit filename="sdk/scripting/bindings/sq_wx/sq_wx_propgrid.cpp">
+ <Option target="sdk" />
+ </Unit>
<Unit filename="sdk/scripting/bindings/sq_wx/sq_wx_constants.cpp">
<Option target="sdk" />
</Unit>
Tim S.
@BlueHazzard:
What version of Squirrel are you using in this branch?
Also have you seen this problem:
a<-_T("Test");
b<-_T("Test");
print(a==b); //<-- this one here prints false, instead of the expected true.
?
If you have seen it, then have you solved it?
I can see that other people have reported this problem and it has not been fixed.
There is also a patch that modifies the VM, see here: http://forum.squirrel-lang.org/mainsite/forums/default.aspx?g=posts&m=4084#post4084
@devs: What do you think of applying this patch to our VM?
What version of Squirrel are you using in this branch?
At the moment i'm using 3.0.4, but i will update to 3.0.6 after Alberto (fagiano) will release his bugfix, becaues there are two (non common) bugs that hopefully will get fixed.
Also have you seen this problem:
a<-_T("Test");
b<-_T("Test");
print(a==b); //<-- this one here prints false, instead of the expected true.
This is nor a bug nor a problem... This is how squirrel works with user pointers... You have to use a cmp function to compare the content of user pointers. In my version of the squirrel port this won't be a big problem, because you can work with native strings:
a<-"Test";
b<-"Test";
print(a==b);
FunctionThatOnlyCanUseWxString(a); // This will work...
c <- wxString("fail");
d <- "faile";
print(c==d); // This won't work...
It is not a intuitive thing, but if speed is what you want, this is the obvious way to deal with user pointers (and tables and strings and so on).
At the beginning i wanted to implement this patch, (or use the mingobad version of squirrel, because he has a few interesting features) but then i thought the base version of the language is used in a lot big projects, well tested and some kind of well maintained, so why use a patched untested version... I'm open for discussions on this...
In two weeks i will continue my work on this port...
greetings
You miss wxpropgrid from the link-libraries in the linux project-file.
In sc_plugin.cpp you miss "()" afgter GetName in line 77.
But with all that I get:
/home/jens/codeblocks-build/codeblocks.bluehazzard/src/sdk/scripting/bindings/sq_wx/sq_wx_base_controls.cpp:1221: undefined reference to `ScriptBindings::sq_wx_propgrid_wrapper::GetLabelEditor()'
/home/jens/codeblocks-build/codeblocks.bluehazzard/src/sdk/scripting/bindings/sq_wx/sq_wx_base_controls.cpp:1220: undefined reference to `ScriptBindings::sq_wx_propgrid_wrapper::GetEntry(wxString)'
/home/jens/codeblocks-build/codeblocks.bluehazzard/src/sdk/scripting/bindings/sq_wx/sq_wx_base_controls.cpp:1219: undefined reference to `ScriptBindings::sq_wx_propgrid_wrapper::GetRoot()'
/home/jens/codeblocks-build/codeblocks.bluehazzard/src/sdk/scripting/bindings/sq_wx/sq_wx_base_controls.cpp:1218: undefined reference to `ScriptBindings::sq_wx_propgrid_wrapper::GetSelectedProperty()'
/home/jens/codeblocks-build/codeblocks.bluehazzard/src/sdk/scripting/bindings/sq_wx/sq_wx_base_controls.cpp:1217: undefined reference to `ScriptBindings::sq_wx_propgrid_wrapper::Populate(Sqrat::Table)'
/home/jens/codeblocks-build/codeblocks.bluehazzard/src/sdk/scripting/bindings/sq_wx/sq_wx_base_controls.cpp:1215: undefined reference to `ScriptBindings::sq_wx_propgrid_wrapper_constructor(SQVM*)'
as error while linking.