177 lines
3.5 KiB
YAML
177 lines
3.5 KiB
YAML
---
|
|
name: in list param
|
|
desc: verify in list params with @length
|
|
idl: |
|
|
interface foo {
|
|
bar(list<bool> l @length(c), int32 c) -> void
|
|
}
|
|
lang: py
|
|
test/interface.py:
|
|
- def bar(self, l)
|
|
test/client.py:
|
|
- def bar(self, l)
|
|
- start_write_list(len(l))
|
|
test/server.py:
|
|
- start_read_list
|
|
- not: codec.read_int32()
|
|
|
|
---
|
|
name: out list param
|
|
desc: verify out list params with @length
|
|
idl: |
|
|
interface foo {
|
|
bar(out list<bool> l @length(c) @max_length(10), out int32 c) -> void
|
|
}
|
|
lang: py
|
|
test/interface.py:
|
|
- def bar(self, l)
|
|
test/client.py:
|
|
- def bar(self, l)
|
|
- perform_request
|
|
- start_read_list
|
|
- not: codec.read_int32()
|
|
test/server.py:
|
|
- def _handle_bar
|
|
- self._handler.bar(l)
|
|
- codec.start_write_message
|
|
- not: codec.write_int32(len(l.value))
|
|
|
|
---
|
|
name: inout list param
|
|
desc: verify inout list params with @length
|
|
idl: |
|
|
interface foo {
|
|
bar(inout list<bool> l @length(c) @max_length(10), inout int32 c) -> void
|
|
}
|
|
lang: py
|
|
test/interface.py:
|
|
- def bar(self, l)
|
|
test/client.py:
|
|
- def bar(self, l)
|
|
- start_write_list(len(l.value))
|
|
- perform_request
|
|
- start_read_list
|
|
- not: codec.read_int32()
|
|
test/server.py:
|
|
- def _handle_bar
|
|
- start_read_list
|
|
- not: codec.read_int32()
|
|
- self._handler.bar(l)
|
|
- codec.start_write_message
|
|
- not: codec.write_int32(len(l.value))
|
|
|
|
---
|
|
name: other param
|
|
desc: verify non-list in/out/inout params with @length
|
|
params:
|
|
dir:
|
|
- in
|
|
- out
|
|
- inout
|
|
type:
|
|
# - string
|
|
- binary
|
|
idl: |
|
|
interface foo {
|
|
bar({dir} {type} v @length(c) @max_length(10), {dir} int32 c) -> void
|
|
}
|
|
lang: py
|
|
test/client.py:
|
|
- def bar(self, v)
|
|
- if: dir in ('in', )
|
|
then:
|
|
- write_{type}(v)
|
|
- if: dir in ('inout', )
|
|
then:
|
|
- write_{type}(v.value)
|
|
- if: dir in ('in', 'inout')
|
|
then:
|
|
- not: write_int32(len(v))
|
|
- perform_request
|
|
- if: dir in ('inout',)
|
|
then:
|
|
- v.value = codec.read_{type}()
|
|
- not: _ = codec.read_int32()
|
|
test/server.py:
|
|
- def _handle_bar
|
|
- if: dir in ('in', 'inout')
|
|
then:
|
|
- re: v(\.value)? = codec.read_{type}()
|
|
- not: _ = codec.read_int32()
|
|
- self._handler.bar(v)
|
|
- if: dir in ('out',)
|
|
then:
|
|
- write_{type}(v.value)
|
|
- not: write_int32(len(v.value))
|
|
|
|
---
|
|
name: list struct
|
|
desc: verify lists with @length in struct
|
|
params:
|
|
members: # struct parameters in either order
|
|
- |
|
|
int32 cnt
|
|
list<bool> spoon @length(cnt)
|
|
- |
|
|
list<bool> spoon @length(cnt)
|
|
int32 cnt
|
|
idl: |
|
|
struct Fork {
|
|
{members}
|
|
}
|
|
interface foo {
|
|
bar(in Fork f) -> void
|
|
}
|
|
lang: py
|
|
test/interface.py:
|
|
- def bar(self, f)
|
|
test/common.py:
|
|
- class Fork
|
|
- "@property"
|
|
- def cnt
|
|
- def _read
|
|
- if: members.startswith('int32')
|
|
then:
|
|
- not: _ = codec.read_int32()
|
|
- start_read_list
|
|
else:
|
|
- start_read_list
|
|
- not: _ = codec.read_int32()
|
|
- def _write
|
|
- if: members.startswith('int32')
|
|
then:
|
|
- not: codec.write_int32(self.cnt)
|
|
- start_write_list
|
|
else:
|
|
- start_write_list
|
|
- not: codec.write_int32(self.cnt)
|
|
|
|
---
|
|
name: other struct
|
|
desc: verify non-list struct members with @length
|
|
params:
|
|
type:
|
|
# - string
|
|
- binary
|
|
idl: |
|
|
struct Fork {
|
|
int32 cnt
|
|
{type} spoon @length(cnt)
|
|
}
|
|
interface foo {
|
|
bar(in Fork f) -> void
|
|
}
|
|
lang: py
|
|
test/interface.py:
|
|
- def bar(self, f)
|
|
test/common.py:
|
|
- class Fork
|
|
- "@property"
|
|
- def cnt
|
|
- def _read
|
|
- not: _ = codec.read_int32()
|
|
- read_{type}
|
|
- def _write
|
|
- not: codec.write_int32(self.cnt)
|
|
- write_{type}
|