summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/Parser.cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2007-06-26 12:51:22 -0400
committerBernard Normier <bernard@zeroc.com>2007-06-26 12:51:22 -0400
commit7eaa0615dcaf8c40eab393e95f6d844f34b72602 (patch)
treea541d659cb63ec4bd8bde141e9de351e24299be3 /cpp/src/Slice/Parser.cpp
parenthttp://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=2260 - invalid generated a... (diff)
downloadice-7eaa0615dcaf8c40eab393e95f6d844f34b72602.tar.bz2
ice-7eaa0615dcaf8c40eab393e95f6d844f34b72602.tar.xz
ice-7eaa0615dcaf8c40eab393e95f6d844f34b72602.zip
slice2xxx updates + Java Freeze updates and demo
Diffstat (limited to 'cpp/src/Slice/Parser.cpp')
-rw-r--r--cpp/src/Slice/Parser.cpp100
1 files changed, 100 insertions, 0 deletions
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index 45ae1635d78..47a39dc5325 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -20,6 +20,17 @@ using namespace Slice;
extern FILE* slice_in;
extern int slice_debug;
+//
+// Operation attributes
+//
+// read + supports must be 0 (the default)
+//
+
+static string readWriteAttribute[] = { "read", "write" };
+static string txAttribute[] = { "supports", "mandatory", "required", "never" };
+enum { Supports, Mandatory, Required, Never };
+
+
namespace Slice
{
@@ -4565,6 +4576,95 @@ Slice::Operation::returnsData() const
return false;
}
+int
+Slice::Operation::attributes() const
+{
+ string freezeMD;
+
+ if(!findMetaData("freeze:", freezeMD))
+ {
+ ClassDefPtr classDef = ClassDefPtr::dynamicCast(container());
+ assert(classDef != 0);
+ classDef->findMetaData("freeze:", freezeMD);
+ }
+
+ if(freezeMD != "")
+ {
+ int result = 0;
+
+ freezeMD = freezeMD.substr(strlen("freeze:"));
+
+ int i = 0;
+ while(i < 2)
+ {
+ if(freezeMD.find(readWriteAttribute[i]) == 0)
+ {
+ result = i;
+ freezeMD = freezeMD.substr(readWriteAttribute[i].size());
+ break; // while
+ }
+ i++;
+ }
+ if(i == 2)
+ {
+ cout << definitionContext()->filename() << ":" << line()
+ << ": warning: invalid freeze metadata for operation" << endl;
+ }
+ else
+ {
+ if(freezeMD.size() == 0)
+ {
+ freezeMD = (result == 0) ? ":supports" : ":required";
+ }
+
+ //
+ // Remove ":"
+ //
+ freezeMD = freezeMD.substr(1);
+
+ int i = 0;
+ while(i < 4)
+ {
+ if(freezeMD.find(txAttribute[i]) == 0)
+ {
+ if(result != 0 && (i == int(Supports) || i == int(Never)))
+ {
+ cout << definitionContext()->filename() << ":" << line()
+ << ": warning: invalid freeze metadata for operation" << endl;
+ }
+ else
+ {
+ result |= (i << 1);
+ }
+ freezeMD = freezeMD.substr(txAttribute[i].size());
+ break; // while
+ }
+ i++;
+ }
+
+ if(i == 4)
+ {
+ cout << definitionContext()->filename() << ":" << line()
+ << ": warning: invalid freeze metadata for operation" << endl;
+
+ //
+ // Set default
+ //
+ if(result != 0)
+ {
+ result |= (int(Required) << 1);
+ }
+ }
+ }
+ return result;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+
string
Slice::Operation::kindOf() const
{