OPT_SCOPE_CALL = 'call'
OPT_SCOPE_NOTIFIED = 'notified'
+# Transfer options
+OPT_TRANSFER_NONE = 'none'
+OPT_TRANSFER_CONTAINER = 'container'
+OPT_TRANSFER_FULL = 'full'
+
+
class DocBlock(object):
def __init__(self, name):
if not option in ALL_OPTIONS:
message.warn('invalid option: %s' % (option, ),
positions=self.position)
-
+ if option == OPT_TRANSFER:
+ value = self.options[option]
+ if value is None:
+ message.warn('transfer needs a value',
+ self.position)
+ continue
+ if value.length() != 1:
+ message.warn('transfer needs one value, not %d' % (
+ value.length()), self.position)
+ continue
+ valuestr = value.one()
+ if valuestr not in [OPT_TRANSFER_NONE,
+ OPT_TRANSFER_CONTAINER,
+ OPT_TRANSFER_FULL]:
+ message.warn('invalid transfer value: %r' % (
+ valuestr, ), self.position)
class DocOptions(object):
def __init__(self):
def __repr__(self):
return '<DocOption %r>' % (self._array, )
+ def length(self):
+ return len(self._array)
+
def one(self):
assert len(self._array) == 1
return self._array[0]
node.transfer = self._get_transfer_default(parent, node)
transfer_tag = options.get(OPT_TRANSFER)
- if transfer_tag:
+ if transfer_tag and transfer_tag.length() == 1:
node.transfer = transfer_tag.one()
self._adjust_container_type(parent, node, options)
--- /dev/null
+
+/**
+ * test_transfer_invalid:
+ * @param: (transfer):
+ * @param2: (transfer invalid):
+ * @param3: (transfer full foo):
+ */
+void test_transfer_invalid(int param, int param2, int param3);
+
+// EXPECT:4: Warning: Test: transfer annotation needs a value
+// EXPECT:5: Warning: Test: invalid transfer annotation value: 'invalid'
+// EXPECT:6: Warning: Test: transfer annotation needs one value, not 2