Author Topic: My wizard doesn't work anymore!  (Read 5946 times)

Trikko

  • Guest
My wizard doesn't work anymore!
« on: August 31, 2006, 02:11:41 pm »
I wrote a custom wxWidgets wizard to support 5 different compilers i use. Recently i've updated code::blocks and it doesn't work anymore. I've registered plugin on global config.script. Errors:

1) All declarations of functions and vars are broken (fixed changing local vars type to local and using "function" on function declaration)
2) When i start the wizard it tells me: "GetInstance : invalid argument type".

How can i solve error #2 ?

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: My wizard doesn't work anymore!
« Reply #1 on: August 31, 2006, 02:14:00 pm »
Quote
Recently i've updated code::blocks and it doesn't work anymore.

What was the previous revision, where your scripts worked? Scripts-related code hasn't been touched for many revisions now, AFAIK.
With that info missing, I don't think anyone can help you.
Be patient!
This bug will be fixed soon...

Trikko

  • Guest
Re: My wizard doesn't work anymore!
« Reply #2 on: August 31, 2006, 02:18:22 pm »
Quote
Recently i've updated code::blocks and it doesn't work anymore.

What was the previous revision, where your scripts worked? Scripts-related code hasn't been touched for many revisions now, AFAIK.
With that info missing, I don't think anyone can help you.


Eh, i don't remember. It was before august, maybe july too... It was a long time ago when wizard and old template exist togheter.

By the way function was declared in this way:

void myfunc(wxString @test)
instead of
function myfunc(test)

But the error #2 seems to be a runtime error. If not it should report me the line where the error is found.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: My wizard doesn't work anymore!
« Reply #3 on: August 31, 2006, 02:38:00 pm »
Quote
By the way function was declared in this way:

void myfunc(wxString @test)
instead of
function myfunc(test)

That's why I 'm asking. It must be much earlier than July.
The syntax of your scripts declares that they were written for Angelscript. We have converted to using Squirrel for quite some time now, somewhere around March IIRC.

Luckily, conversion is not *too* much of a hassle.

  • Squirrel is typeless: remove all function return types and replace them with "function". Also remove all function arguments' types and leave just the arguments vars.
  • Squirrel doesn't have autohandles (the @ symbol). Remove that too.


You can also check one of the existing scripts to see how they 're written.
Documentation for Squirrel is at its site: http://www.squirrel-lang.org

If you still have problems, post your script here.
Be patient!
This bug will be fixed soon...

Trikko

  • Guest
Re: My wizard doesn't work anymore!
« Reply #4 on: August 31, 2006, 02:47:56 pm »

That's why I 'm asking. It must be much earlier than July.
The syntax of your scripts declares that they were written for Angelscript. We have converted to using Squirrel for quite some time now, somewhere around March IIRC.


Probably i wrote script on march and i've created some project, then i didn't create any project but i've just worked on old ones so i've never noticed the problem.

Quote
Luckily, conversion is not *too* much of a hassle.

LOL. Probably i can't explain better the problem. I've just realized this. I've just converted syntax where needed. But now there's a strange "GetInstance : etc... etc... " (as reported before), that seems not to be a syntax-convertion error...

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: My wizard doesn't work anymore!
« Reply #5 on: August 31, 2006, 03:07:26 pm »
Quote from: Trikko
LOL. Probably i can't explain better the problem. I've just realized this. I've just converted syntax where needed. But now there's a strange "GetInstance : etc... etc... " (as reported before), that seems not to be a syntax-convertion error...

Quote from: mandrav
If you still have problems, post your script here.
Be patient!
This bug will be fixed soon...

Trikko

  • Guest
Re: My wizard doesn't work anymore!
« Reply #6 on: August 31, 2006, 03:19:55 pm »
Code
function BeginWizard() {
    Wizard.AddProjectPathPage();
    Wizard.AddPage("OptSelection");
}

// Base Directory Selection
function OnEnter_OptSelection(fwd) {

    local value;

    value = Wizard.GetTextControlValue("m_txtBasePath");

    if (value.length() == 0) {
        value = ConfigManager.Read("/wx_multi_target/BasePath", "");
        Wizard.SetTextControlValue("m_txtBasePath", value);
    }

    value = Wizard.GetTextControlValue("m_txtVersion");

    if (value.length() == 0) {
        value = ConfigManager.Read("/wx_multi_target/Version", "26");
        Wizard.SetTextControlValue("m_txtVersion", value);
    }

   return true;
}

function OnLeave_OptSelection(fwd) {

    ConfigManager.Write("/wx_multi_target/BasePath", Wizard.GetTextControlValue("m_txtBasePath"),true);
    ConfigManager.Write("/wx_multi_target/Version", Wizard.GetTextControlValue("m_txtVersion"),true);

    return true;
}

function OnClick_m_cmdBrowse() {

    local dir = Wizard.GetTextControlValue("m_txtBasePath");
    dir = IO.SelectDirectory("Please select wxWidgets' top-level folder", dir, false);

    if (IO.DirectoryExists(dir))
        Wizard.SetTextControlValue("m_txtBasePath", dir);

}


// setup the already created project
function SetupProject(project) {

    local basePath = ConfigManager.Read("/wx_multi_target/BasePath", "");
    local version = ConfigManager.Read("/wx_multi_target/Version", "");
    local custom_lib_dir;

    local compilers_count = 5;
    local i,k;

    // Include dir is the same for all compilers
    project.AddIncludeDir(basePath + "\\include");
    project.RemoveBuildTarget("default");

    for (i = 0; i<compilers_count; i++) {
        local compilerWxSign, compilerCbSign, compilerName, libPrefix, libSuff;

        switch (i) {


        case 0:
            libPrefix = "";
            libSuff = ".lib";
            compilerCbSign = "dmc";
            compilerWxSign = "dmc";
            compilerName = "Digital Mars";
            break;
        case 1:
            libPrefix = "lib";
            libSuff = ".a";
            compilerCbSign = "gcc";
            compilerWxSign = "gcc";
            compilerName = "GCC/MingW";
            break;
      case 2:
            libPrefix = "";
            libSuff = ".lib";
            compilerCbSign = "msvc8";
            compilerWxSign = "vc";
            compilerName = "VC++";
            break;

        case 3:
            libPrefix = "";
            libSuff = ".lib";
            compilerCbSign = "ow";
            compilerWxSign = "wat";
            compilerName = "Open Watcom";
            break;
        case 4:
            libPrefix = "";
            libSuff = ".lib";
            compilerCbSign = "bcc";
            compilerWxSign = "bcc";
            compilerName = "Borland CC";
            break;
        }

        for (k = 0; k < 2 ; k++) {

            local debugFlag;
            local targetTitle;

            if (k != 0) {
                debugFlag = "d";
                targetTitle = "Debug - ";
            } else {
                debugFlag = "";
                targetTitle = "Release - ";
            }
            custom_lib_dir = basePath + "\\lib\\" + compilerWxSign + debugFlag + "_lib";

            if (IO.DirectoryExists(custom_lib_dir)) {

                // New target for our compiler
                local target = project.AddBuildTarget(targetTitle + compilerName);
                if (target != null) {
                    local tmp;

                    target.AddIncludeDir(custom_lib_dir + "\\msw" + debugFlag);
                    target.AddLibDir(custom_lib_dir);
                    target.SetCompilerID(compilerCbSign);
                    target.SetTargetType(ttExecutable);

                    tmp = ".\\";
                    target.SetObjectOutput(tmp + "_" + compilerWxSign + "_objs");

                    if (k==0)
                        target.SetOutputFilename(tmp + "RELEASE/output_" + compilerWxSign + ".exe");
                    else
                        target.SetOutputFilename(tmp + "DEBUG/output_" + compilerWxSign + ".exe");

                    tmp = "";
                    // Add Libraries
                    target.AddLinkLib(custom_lib_dir + "\\" + libPrefix + "wxmsw" + debugFlag + version + libSuff);
                    target.AddLinkLib(custom_lib_dir + "\\" + libPrefix + "wxtiff" + debugFlag + libSuff);
                    target.AddLinkLib(custom_lib_dir + "\\" + libPrefix  + "wxpng" + debugFlag + libSuff);
                    target.AddLinkLib(custom_lib_dir + "\\" + libPrefix  + "wxjpeg" + debugFlag + libSuff);
                    target.AddLinkLib(custom_lib_dir + "\\" + libPrefix  + "wxzlib" + debugFlag + libSuff );
                    target.AddLinkLib(custom_lib_dir + "\\" + libPrefix  + "wxregex" + debugFlag + libSuff );
                    target.AddLinkLib(custom_lib_dir + "\\" + libPrefix  + "wxexpat" + debugFlag + libSuff);

                    target.AddLinkLib("kernel32");
                    target.AddLinkLib("user32");
                    target.AddLinkLib("gdi32");
                    target.AddLinkLib("comdlg32");
                    target.AddLinkLib("winspool");
                    target.AddLinkLib("winmm");
                    target.AddLinkLib("shell32");
                    target.AddLinkLib("comctl32");
                    target.AddLinkLib("ole32");
                    target.AddLinkLib("oleaut32");
                    target.AddLinkLib("uuid");
                    target.AddLinkLib("rpcrt4");
                    target.AddLinkLib("advapi32");
                    target.AddLinkLib("wsock32");
                    target.AddLinkLib("odbc32");


                    // Compiler dependent settings
                    local compOpts;
                    local linkOpts;

                    switch (i) {

                        // DMARS
                    case 0:
                        compOpts = "-mn -cpp -Ae -Ar -o -w- -6 -D_WIN32_WINNT=0x0400 -D__WXMSW__ -DNOPCH -D__WIN32__";
                        linkOpts = "/NOLOGO /SILENT /NOI /DELEXECUTABLE /EXETYPE:NT /su:windows:4.0";
                        if (k==1) compOpts += "-g -D__WXDEBUG__";
                        break;
                        // GCC
                    case 1:
                        compOpts = "-s -O3 -Os -mthreads -W -Wall -DNOPCH  -D__WXMSW__ -Wno-ctor-dtor-privacy -DHAVE_W32API_H -MD";
                        linkOpts = "-s -mthreads -Wl,--subsystem,windows -mwindows";
                        if (k==1) compOpts += "-g -D__WXDEBUG__";
                        break;
                        // OW
                    case 2:
                        compOpts = "/MT /W4 /O2 /Ot /GR /GRR /EHsc /GA /DWIN32 /DNOPCH /D_WINDOWS /D__WXMSW__ /D__WIN32__";
                        linkOpts = "/SUBSYSTEM:WINDOWS";
                        if (k==1) compOpts += "-zi /D_DEBUG /D__WXDEBUG__";
                        break;
                    case 3:
                        compOpts = "-bw -br -bn -ot -d -d0 -zw -bt=nt -fp6 -wcd=549 -wcd=656 -wcd=657 -wcd=667 -wcd=726 -d_WXMSW_";
                        linkOpts = "-\"system nt_win\"";
                        if (k==1) compOpts += "-g";
                        break;

                    case 4:
                        break;

                    }

                    target.AddLinkerOption(linkOpts);
                    target.AddCompilerOption(compOpts);
                    target.SetIncludeInTargetAll(true);

                }
            }

        }

    }

    for (i = 0; i<project.GetBuildTargetsCount(); i++) {
        project.AddFile(i,"app.cpp",true,true,50);
        project.AddFile(i,"frmMain.cpp",true,true,50);
        project.AddFile(i,"wx.rc",true,true,50);
        project.AddFile(i,"frmMain.h",false,false,50);
        project.AddFile(i,"_wx_intellisense.h",false,false,50);
    }

    return true;
}

function GetFilesDir() {

    local result = "wxWidgets-multi/files";
    return result;
}

This is the code...

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: My wizard doesn't work anymore!
« Reply #7 on: August 31, 2006, 03:53:30 pm »
Oh, I forgot to tell you the last thing you should do :).

  • All literal strings in Squirrel which will be passed to SDK-bound functions, must be enclosed in _T(). So, Wizard.GetTextControlValue("m_txtBasePath"); would become Wizard.GetTextControlValue(_T("m_txtBasePath"));, etc.
Be patient!
This bug will be fixed soon...

Trikko

  • Guest
Re: My wizard doesn't work anymore!
« Reply #8 on: August 31, 2006, 04:13:08 pm »
Oh, I forgot to tell you the last thing you should do :).

  • All literal strings in Squirrel which will be passed to SDK-bound functions, must be enclosed in _T(). So, Wizard.GetTextControlValue("m_txtBasePath"); would become Wizard.GetTextControlValue(_T("m_txtBasePath"));, etc.
Good it works now. But there's a wizard-related problem. (This problem exists in old version too...).

Take a look:
Code
    for (i = 0; i<project.GetBuildTargetsCount(); i++) {
        project.AddFile(i,_T("app.cpp"),true,true,50);
        project.AddFile(i,_T("frmMain.cpp"),true,true,50);
        project.AddFile(i,_T("wx.rc"),true,true,50);
        project.AddFile(i,_T("frmMain.h"),false,false,50);
        project.AddFile(i,_T("_wx_intellisense.h"),false,false,50);
    }

I add these files to project for each target. But when i compile the new project it won't works becouse on project "properties -> targets -> selected build target files"  static box all items are unchecked. How can i "check" them from script?

Thanks in advance!