|
|
SqPlus modifications
Last post 01-12-2008, 12:36 PM by ats. 32 replies.
-
08-17-2007, 6:10 AM |
-
ats
-
-
-
Joined on 01-17-2007
-
-
Posts 102
-
-
|
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-18-2007, 3:04 AM |
-
ats
-
-
-
Joined on 01-17-2007
-
-
Posts 102
-
-
|
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-24-2007, 10:34 PM |
-
Katsuaki Kawachi
-
-
-
Joined on 06-27-2006
-
Tokyo, Japan
-
Posts 57
-
-
|
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 |
-
ats
-
-
-
Joined on 01-17-2007
-
-
Posts 102
-
-
|
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 |
-
Katsuaki Kawachi
-
-
-
Joined on 06-27-2006
-
Tokyo, Japan
-
Posts 57
-
-
|
Thanks. I did some modifications to your branch at SF. - Deleting const for scsprintf() in constructor (check here please)
- 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 |
-
ats
-
-
-
Joined on 01-17-2007
-
-
Posts 102
-
-
|
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.
|
|
-
-
09-01-2007, 6:12 AM |
-
Katsuaki Kawachi
-
-
-
Joined on 06-27-2006
-
Tokyo, Japan
-
Posts 57
-
-
|
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
|
|
-
-
-
-
Page 1 of 3 (33 items)
1
|
|