summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2007-11-14 09:56:46 -0800
committerMark Spruiell <mes@zeroc.com>2007-11-14 09:56:46 -0800
commit39f02759cb59efea1ebea37c41ab991e5bd71f6c (patch)
treef6e8775dd80c9c63bf75264b8a0e8812eda43b35 /cpp
parentBut 2534. (diff)
downloadice-39f02759cb59efea1ebea37c41ab991e5bd71f6c.tar.bz2
ice-39f02759cb59efea1ebea37c41ab991e5bd71f6c.tar.xz
ice-39f02759cb59efea1ebea37c41ab991e5bd71f6c.zip
- Fixing NullHandleException in FreezeScript when a script attempts to
access the 'length' member of a string value. - Adding support for string concatenation using the '+' operator. - Updating the FreezeScript/dbmap test to include string functions.
Diffstat (limited to 'cpp')
-rw-r--r--cpp/CHANGES6
-rw-r--r--cpp/src/FreezeScript/Data.cpp1
-rw-r--r--cpp/src/FreezeScript/Parser.cpp15
-rw-r--r--cpp/test/FreezeScript/dbmap/check.xml4
4 files changed, 25 insertions, 1 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES
index 6f0948b395f..a4f4c564177 100644
--- a/cpp/CHANGES
+++ b/cpp/CHANGES
@@ -1,6 +1,12 @@
Changes since version 3.2.X (binary incompatible)
-------------------------------------------------
+- Fixed a bug in FreezeScript that caused a failure when a script
+ attempted to access the 'length' member of a string value.
+
+- Added support for string concatenation in FreezeScript using the
+ '+' operator.
+
- Changed servant locators so both locate() and finished() can
throw user exceptions. (See the manual for details.)
diff --git a/cpp/src/FreezeScript/Data.cpp b/cpp/src/FreezeScript/Data.cpp
index cc51a8a2d0e..1fa91b65209 100644
--- a/cpp/src/FreezeScript/Data.cpp
+++ b/cpp/src/FreezeScript/Data.cpp
@@ -1186,6 +1186,7 @@ void
FreezeScript::StringData::setValue(const string& v)
{
_value = v;
+ _length = IntegerDataPtr::dynamicCast(_factory->createInteger(static_cast<Ice::Long>(_value.size()), true));
}
//
diff --git a/cpp/src/FreezeScript/Parser.cpp b/cpp/src/FreezeScript/Parser.cpp
index ca3c2bdcb9c..0ef4287a0b0 100644
--- a/cpp/src/FreezeScript/Parser.cpp
+++ b/cpp/src/FreezeScript/Parser.cpp
@@ -275,9 +275,22 @@ FreezeScript::BinaryNode::evaluate(const SymbolTablePtr& st)
{
DataPtr leftValue = _left->evaluate(st);
DataPtr rightValue = _right->evaluate(st);
+ StringDataPtr sleft = StringDataPtr::dynamicCast(leftValue);
+ StringDataPtr sright = StringDataPtr::dynamicCast(rightValue);
IntegerDataPtr ileft = IntegerDataPtr::dynamicCast(leftValue);
IntegerDataPtr iright = IntegerDataPtr::dynamicCast(rightValue);
- if(ileft && iright)
+ if(sleft || sright)
+ {
+ if(sleft && sright)
+ {
+ result = _factory->createString(leftValue->stringValue() + rightValue->stringValue(), true);
+ }
+ else
+ {
+ _factory->getErrorReporter()->error("string concatenation requires two string arguments");
+ }
+ }
+ else if(ileft && iright)
{
result = _factory->createInteger(leftValue->integerValue() + rightValue->integerValue(), true);
}
diff --git a/cpp/test/FreezeScript/dbmap/check.xml b/cpp/test/FreezeScript/dbmap/check.xml
index 8194ef023b3..0660d6ab257 100644
--- a/cpp/test/FreezeScript/dbmap/check.xml
+++ b/cpp/test/FreezeScript/dbmap/check.xml
@@ -54,6 +54,10 @@
<fail test="new.stringToFloat - 2920.1 > 0.001"/>
<fail test="new.stringToDouble - 9290.9 > 0.001"/>
<fail test="new.stringToString != 'hello world'"/>
+ <fail test="new.stringToString.length != 11"/>
+ <fail test="new.stringToString.replace(new.stringToString.length, 0, '!') != 'hello world!'"/>
+ <fail test="new.stringToString.replace(0, 6, '') != 'world'"/>
+ <fail test="'hello' + 'world' != 'helloworld'"/>
<fail test="new.stringToEnum != ::New::Test::E1"/>
<!-- Sequences -->