Squirrel

The programming language
Welcome to Squirrel Sign in | Join | Help
in Search

SqPlus modifications

Last post 01-12-2008, 12:36 PM by ats. 32 replies.
Page 1 of 3 (33 items)   1 2 3 Next >
Sort Posts: Previous Next
  •  08-17-2007, 6:10 AM 2077

    SqPlus modifications

    I've been using SqPlus a bit in my project and done some updates to it.

    Can I submit this to SF project?

    These are some of the changes:
    • Some work arounds for GCC (mainly problems with inline functions, added a define GCC_INLINE_WORKAROUND to activate it.
    • Support for set/get for short/char members
    • Support reading back const SQChar* with get
    • DECLARE_ENUM_TYPE - Allows enums to be used as arguments.
    • Support for more customized Push handlers.
    • A define to disable automatic use of copy constructors (this brings problems when involved classes has protected/private copy constructors): SQPLUS_DISABLE_COPY_INSTANCES
    • Support for automatically generate TypeMasks (a template solution) on function registration.
    • Some cleanup and minor improvements.
    Regards
    // ATS

  •  08-17-2007, 11:22 PM 2080 in reply to 2077

    Re: SqPlus modifications

    Cool.  I've made a branch /branches/ats-r73-updates from /trunk:r73
    at sourceforge SVN.  Please merge your updates here.

    Regards,
    Katsuaki Kawachi
  •  08-18-2007, 3:04 AM 2081 in reply to 2077

    Re: SqPlus modifications

    Checked it out from SF and applied my changes.

    On submitting with svn, I get this error:

    arne# svn commit --username arst -m 'Changes by ATS (gcc-inline, typemask, set/get short/char, ...)'
    Authentication realm: <https://sqplus.svn.sourceforge.net:443> SourceForge Subversion area
    Password for 'arst':
    svn: Commit failed (details follow):
    svn: MKACTIVITY of '/svnroot/sqplus/!svn/act/63bfeed8-65fe-44c8-b821-ceb728a79594': 403 Forbidden (https://sqplus.svn.sourceforge.net)
    I checked out sources with https.

    My username at SourceForge is "arst", while here it is "ats". Maybe that's the source of the problem?


    Regards
    // ATS

  •  08-18-2007, 5:56 AM 2083 in reply to 2081

    Re: SqPlus modifications

    Hi ATS,

    I'm sorry I'd not added you as a SqPlus project member at sourceforge.
    I have fixed it.  Now you can submit your code.

    Regards,
    Kawachi
  •  08-19-2007, 2:55 AM 2089 in reply to 2083

    Re: SqPlus modifications

    Ok, commited and done.

    Thanks for setting it up.

    Regards
    // ATS

  •  08-24-2007, 10:34 PM 2104 in reply to 2089

    Re: SqPlus modifications

    Thanks.  I'm going to merge your code into trunk and create a snapshot.

    Two requrests:
    •  Which version of gcc needs the workaround?
    •  Could you provide short examples of these extensions?
      • Support for set/get for short/char members
      • Support reading back const SQChar* with get
      • DECLARE_ENUM_TYPE - Allows enums to be used as arguments.
      • Support for automatically generate TypeMasks (a template solution) on function registration.
    Regards,
    Kawachi

  •  08-25-2007, 5:02 AM 2105 in reply to 2104

    Re: SqPlus modifications

    Good to hear.

    For GCC, this is what I get as version:

    $ gcc --version
    gcc (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)

    For examples, do you mean something that could go into the source tree?

    Here's an example for set/get with short/char  and SQChar*:
    class AtsTest {
    public:
        AtsTest( short sh=0, SQChar *str="default val" ) : m_sh(sh), m_str(str) { }

        enum Mode { Mode1, Mode2 };
        int FuncWithEnumArg( Mode m ){ return (int)m; }
       
        short m_sh;
        const SQChar *m_str;
    };

    DECLARE_ENUM_TYPE(AtsTest::Mode)
    The function FuncWithEnumArg takes an enum as argument. Without DECLARE_ENUM_TYPE SqPlus does not accept the function.

    And now from a script (I'm using a prompt here):
    sqs@> a <- AtsTest()
    sqs@> a.sh = 4441
    sqs@> print(a.sh)
    4441
    sqs@> print(a.str)
    default val
    sqs@> a.sh = 400000
    sqs@> print(a.sh)
    6784    <--- Its a short, we cannot go beyond 32768
    sqs@>
    For automatic typemasks, it's just that a typemask is added to a Squirrel closure on function registration. In SqPlus.h:
    #ifdef SQPLUS_ENABLE_AUTO_TYPEMASK
      sq_setparamscheck(v,0,sqTypeMask<Func>::Get());
    #endif
    I use it to display type info in the Squirrel prompt:
    sqs@> gfi AtsTest.FuncWithEnumArg
    {type="native", args=["instance", "integer"]}
    sqs@>
    Without the typemask, it's difficult to extract any help about function args. The way I implemented it, Squirrel doesn't use the generated type mask internally, since a type check happens on SqPlus side anyway.

    Hope that clarifies things.

    Regards
    // ATS


  •  08-26-2007, 2:51 AM 2106 in reply to 2105

    Re: SqPlus modifications

    Thanks.  I did some modifications to your branch at SF.

    1.  Deleting const for scsprintf() in constructor (check here please)
    2.  Adding test to testSqPlus2unit/test_Enum.cpp
    I haven't managed to make test_Enum.cpp work well yet.
    I also found this branch fails in testSqPlus2unit/test_PointfBoxf.cpp.

    Could you tell me if you can reproduce them on your host?

    Regards,
    K. Kawachi
  •  08-26-2007, 11:17 AM 2108 in reply to 2106

    Re: SqPlus modifications

    Thanks for putting the test in there.

    I had a look at the problems:
    A - The variables have to be registered with VAR_ACCESS_READ_ONLY. My fault, registration should be:

        SQClassDef<AtsTest>(_T("AtsTest"))
            .func(&AtsTest::FuncWithEnumArg, _T("FuncWithEnumArg"))
            .var(&AtsTest::m_sh, _T("sh"))
            .var(&AtsTest::m_str, _T("str"),VAR_ACCESS_READ_ONLY)
            ;
    For the second problem, there was a SQChar* m_str2 in the class. I only intended to support const SQChar* (I don't think people use raw SQChar* in classes much[danger, danger]). What happened is that without the const there, SqPlus now treated it as a pointer of arbitrary type and returned the address of it (yes I threw in reading back pointer members also, template for T*).

    I'll have a look at the other test cases that seem broken (I get 4 test cases that are broken). Were all cases working before?

    Regards
    // ATS.

  •  08-26-2007, 1:15 PM 2109 in reply to 2108

    Re: SqPlus modifications

    For the PrintBoxf, there was a minor change I did in ClassType that triggered the problems. Undone now in new submit and it works.

    On G++ it showed that some tests broke for me since throwing SquirrelErrors used stack variables. I changed to a global.

    The FunctionOverloading test breaks on my setting. It works for you?

    Regards
    // ATS
  •  09-01-2007, 6:12 AM 2116 in reply to 2109

    Re: SqPlus modifications

    Thank you for clear description and quick fix.
    Could you give me the error message on FunctionOverloading test?

    As for me, the all 16 tests now work well on gcc-3.4.6 (gentoo), gcc-4.1.2 (gentoo),
    gcc-3.4.4 (cygwin), VC2003 and VC2005.

    Anyway I'm going to modify test_Enum.cpp.  Then I will merge the branch into trunk.
    • The name test_Enum is somewhat misleading.  Should it be test_SQChar or else?
    • Unicode build on VC200x is broken by test_Enum.
    Regards,
    Kawachi


  •  09-01-2007, 1:28 PM 2118 in reply to 2116

    Re: SqPlus modifications

    Hello,

    Test is really for a few small features, use either test_Misc.cpp or test_ShortCharEnum.cpp.

    Hope you have included fix for throwing errors with global instead of stack based (with SVN I take it is included).

    I'll look at Unicode version, doesn't surprise me.

    For function overloading, I understood what the problem is:
    - Memory is allocated with malloc
    - Later one runs delete on this.

    I had installed a custom memory handler (squirrel/sqmem.cpp), that exposed the mismatch in malloc/delete.


    Regards
    // ATS
  •  09-02-2007, 6:54 AM 2121 in reply to 2118

    Re: SqPlus modifications

    Hi,

    I've modified the inconsistency of malloc/delete in function overloading.
    Does it work for you?

    K. Kawachi
  •  09-02-2007, 2:24 PM 2125 in reply to 2121

    Re: SqPlus modifications

    Yes, the overload test works now, also with customized mem alloc.

    I'll see if I can get around to test Unicode version under Windows.

    Regards
    // ATS.
  •  09-21-2007, 1:51 PM 2142 in reply to 2125

    Re: SqPlus modifications

    I uploaded an update to sqplus SVN that  fixes the  problem with "enum" test in Unicode mode. 

    It seems Unicode mode only works under Win32, trying under Linux gave me a big error list.

    Well well, all 16 tests went well under Win32 Unicode now.

    Regards
    // ATS.

Page 1 of 3 (33 items)   1 2 3 Next >
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems