Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

modify parser to generate meta block in .json

  • Loading branch information...
commit bca7e6f86778cb4d4afb4e754876d43dd379a95b 1 parent 546678b
James Cooper authored
67 barrister/parser.py
@@ -6,8 +6,24 @@
6 6 :copyright: 2012 by James Cooper.
7 7 :license: MIT, see LICENSE for more details.
8 8 """
  9 +
  10 +import time
  11 +import copy
  12 +import operator
9 13 import cStringIO
10 14 from plex import Scanner, Lexicon, Str, State, IGNORE, Begin, Any, AnyBut, AnyChar, Range, Rep
  15 +try:
  16 + import json
  17 +except:
  18 + import simplejson as json
  19 +
  20 +def md5(s):
  21 + try:
  22 + import hashlib
  23 + return hashlib.md5(s).hexdigest()
  24 + except:
  25 + import md5
  26 + return md5.new(s).hexdigest()
11 27
12 28 native_types = [ "int", "float", "string", "bool" ]
13 29 letter = Range("AZaz")
@@ -19,7 +35,7 @@
19 35 comment = Str("// ") | Str("//")
20 36 type_opts = Str("[") + Rep(AnyBut("{}]\n")) + Str("]")
21 37
22   -def parse(idl_text, name=None, validate=True):
  38 +def parse(idl_text, name=None, validate=True, add_meta=True):
23 39 if isinstance(idl_text, (str, unicode)):
24 40 idl_text = cStringIO.StringIO(idl_text)
25 41
@@ -28,6 +44,8 @@ def parse(idl_text, name=None, validate=True):
28 44 if validate:
29 45 scanner.validate()
30 46 if len(scanner.errors) == 0:
  47 + if add_meta:
  48 + scanner.add_meta()
31 49 return scanner.parsed
32 50 else:
33 51 raise IdlParseException(scanner.errors)
@@ -52,6 +70,53 @@ def eof(self):
52 70 if self.cur:
53 71 self.add_error("Unexpected end of file")
54 72
  73 + def add_meta(self):
  74 + import barrister
  75 + meta = {
  76 + "type" : "meta",
  77 + "barrister_version" : barrister.__version__,
  78 + "date_generated" : int(time.time() * 1000),
  79 + "checksum" : self.get_checksum()
  80 + }
  81 + self.parsed.append(meta)
  82 +
  83 + def get_checksum(self):
  84 + """
  85 + Returns a checksum based on the IDL that ignores comments and ordering,
  86 + but detects changes to types, parameter order, and enum values.
  87 + """
  88 + arr = [ ]
  89 + for elem in self.parsed:
  90 + if elem["type"] == "struct":
  91 + s = ""
  92 + fields = copy.copy(elem["fields"])
  93 + fields.sort(key=operator.itemgetter("name"))
  94 + for f in fields:
  95 + s += "\t%s\t%s\t%s\t%s" % (f["name"], f["type"], f["is_array"], f["optional"])
  96 + arr.append("struct\t%s\t%s\t%s\n" % (elem["name"], elem["extends"], s))
  97 + elif elem["type"] == "enum":
  98 + s = "enum\t%s" % elem["name"]
  99 + vals = copy.copy(elem["values"])
  100 + vals.sort(key=operator.itemgetter("value"))
  101 + for v in vals: s += "\t%s" % v["value"]
  102 + s += "\n"
  103 + arr.append(s)
  104 + elif elem["type"] == "interface":
  105 + s = "interface\t%s" % elem["name"]
  106 + funcs = copy.copy(elem["functions"])
  107 + funcs.sort(key=operator.itemgetter("name"))
  108 + for f in funcs:
  109 + s += "[%s" % f["name"]
  110 + for p in f["params"]:
  111 + s += "\t%s\t%s" % (p["type"], p["is_array"])
  112 + ret = f["returns"]
  113 + s += "(%s\t%s\t%s)]" % (ret["type"], ret["is_array"], ret["optional"])
  114 + s += "\n"
  115 + arr.append(s)
  116 + arr.sort()
  117 + #print arr
  118 + return md5(json.dumps(arr))
  119 +
55 120 def add_error(self, message, line=-1):
56 121 if line < 0:
57 122 (name, line, col) = self.position()
100 barrister/test/parser_test.py
@@ -11,6 +11,7 @@
11 11 :license: MIT, see LICENSE for more details.
12 12 """
13 13
  14 +import time
14 15 import unittest
15 16 from barrister.parser import parse, IdlParseException
16 17
@@ -35,7 +36,7 @@ def test_parse_comment(self):
35 36 { "type" : "struct", "name" : "Person", "extends" : "",
36 37 "comment" : "this is a person", "fields" : [
37 38 field("age", "int") ] } ]
38   - self.assertEquals(expected, parse(idl))
  39 + self.assertEquals(expected, parse(idl, add_meta=False))
39 40
40 41 def test_parse_struct(self):
41 42 idl = """struct Person {
@@ -46,7 +47,7 @@ def test_parse_struct(self):
46 47 "type" : "struct",
47 48 "comment" : "", "extends" : "",
48 49 "fields" : [ field("email", "string"), field("age", "int") ] } ]
49   - self.assertEquals(expected, parse(idl))
  50 + self.assertEquals(expected, parse(idl, add_meta=False))
50 51
51 52 def test_parse_multiple(self):
52 53 idl = """struct Person { email string }
@@ -59,7 +60,7 @@ def test_parse_multiple(self):
59 60 "type" : "struct",
60 61 "comment" : "", "extends" : "",
61 62 "fields" : [ field("furry", "bool") ] } ]
62   - self.assertEquals(expected, parse(idl))
  63 + self.assertEquals(expected, parse(idl, add_meta=False))
63 64
64 65 def test_parse_enum(self):
65 66 idl = """enum Status { success fail
@@ -68,7 +69,7 @@ def test_parse_enum(self):
68 69 "values" : [ { "value" : "success", "comment" : "" },
69 70 { "value" : "fail", "comment" : "" },
70 71 { "value" : "invalid", "comment" : "" } ] } ]
71   - self.assertEquals(expected, parse(idl))
  72 + self.assertEquals(expected, parse(idl, add_meta=False))
72 73
73 74 def test_parse_interface(self):
74 75 idl = """interface MyService {
@@ -87,12 +88,12 @@ def test_parse_interface(self):
87 88 { "name" : "login", "comment" : "",
88 89 "returns" : ret_field("LoginResponse"), "params" : [
89 90 { "type" : "LoginRequest", "name" : "req", "is_array": False } ] } ] } ]
90   - self.assertEquals(expected, parse(idl, validate=False))
  91 + self.assertEquals(expected, parse(idl, add_meta=False, validate=False))
91 92
92 93 def test_invalid_struct(self):
93 94 idl = """struct foo { """
94 95 try:
95   - parse(idl)
  96 + parse(idl, add_meta=False)
96 97 self.fail("should have thrown exception")
97 98 except IdlParseException as e:
98 99 expected = [ { "line": 1, "message" : "Unexpected end of file" } ]
@@ -102,7 +103,7 @@ def test_missing_name(self):
102 103 idls = [ "struct {", "enum {", "interface { " ]
103 104 for idl in idls:
104 105 try:
105   - parse(idl)
  106 + parse(idl, add_meta=False)
106 107 self.fail("should have thrown exception")
107 108 except IdlParseException as e:
108 109 expected = [ { "line": 1, "message" : "Missing identifier" } ]
@@ -115,7 +116,7 @@ def test_enum_comments(self):
115 116 expected = [ { "name" : "Status", "type" : "enum", "comment" : "",
116 117 "values" : [ { "comment" : "Request successful",
117 118 "value": "success" } ] } ]
118   - self.assertEquals(expected, parse(idl))
  119 + self.assertEquals(expected, parse(idl, add_meta=False))
119 120
120 121 def test_array_type(self):
121 122 idl = """struct Animal {
@@ -123,7 +124,7 @@ def test_array_type(self):
123 124 expected = [ { "name" : "Animal", "type" : "struct", "comment" : "",
124 125 "extends" : "",
125 126 "fields" : [ field("friend_names", "string", "", True) ] } ]
126   - self.assertEquals(expected, parse(idl))
  127 + self.assertEquals(expected, parse(idl, add_meta=False))
127 128
128 129 def test_array_return_type(self):
129 130 idl = """interface FooService {
@@ -134,7 +135,7 @@ def test_array_return_type(self):
134 135 { "name" : "repeat", "comment" : "",
135 136 "returns" : ret_field("string", True),
136 137 "params" : [ { "type" : "string", "name" : "s", "is_array": False } ] } ] } ]
137   - self.assertEquals(expected, parse(idl))
  138 + self.assertEquals(expected, parse(idl, add_meta=False))
138 139
139 140 def test_struct_comments(self):
140 141 idl = """struct Animal {
@@ -143,7 +144,7 @@ def test_struct_comments(self):
143 144 expected = [ { "name" : "Animal", "type" : "struct", "comment" : "",
144 145 "extends" : "",
145 146 "fields" : [ field("color", "string", "fur color") ] } ]
146   - self.assertEquals(expected, parse(idl))
  147 + self.assertEquals(expected, parse(idl, add_meta=False))
147 148
148 149 def test_function_comments(self):
149 150 idl = """interface FooService {
@@ -159,7 +160,7 @@ def test_function_comments(self):
159 160 "params" : [
160 161 { "type" : "int", "name" : "a", "is_array": False },
161 162 { "type" : "int", "name" : "b", "is_array": True } ] } ] } ]
162   - self.assertEquals(expected, parse(idl))
  163 + self.assertEquals(expected, parse(idl, add_meta=False))
163 164
164 165 def test_interface_comments(self):
165 166 idl = """// FooService is a..
@@ -173,7 +174,7 @@ def test_interface_comments(self):
173 174 { "name" : "blah99", "returns" : ret_field("blah_Response"),
174 175 "comment" : "", "params" : [ ] }
175 176 ] } ]
176   - self.assertEquals(expected, parse(idl, validate=False))
  177 + self.assertEquals(expected, parse(idl, add_meta=False, validate=False))
177 178
178 179
179 180 def test_extends_struct(self):
@@ -191,7 +192,7 @@ def test_extends_struct(self):
191 192 { "name" : "Cat", "type" : "struct",
192 193 "extends" : "Animal", "comment" : "",
193 194 "fields" : [ field("purr_volume", "int") ] } ]
194   - self.assertEquals(expected, parse(idl))
  195 + self.assertEquals(expected, parse(idl, add_meta=False))
195 196
196 197 def test_no_dupe_types(self):
197 198 idl = """struct Animal {
@@ -211,7 +212,7 @@ def test_no_dupe_types(self):
211 212 do_other() bool
212 213 }"""
213 214 try:
214   - parse(idl)
  215 + parse(idl, add_meta=False)
215 216 self.fail("should have thrown exception")
216 217 except IdlParseException as e:
217 218 expected = [ { "line": 4, "message" : "type Animal already defined" },
@@ -227,7 +228,7 @@ def test_no_cycles(self):
227 228 residents []Animal
228 229 }"""
229 230 try:
230   - parse(idl)
  231 + parse(idl, add_meta=False)
231 232 self.fail("should have thrown exception")
232 233 except IdlParseException as e:
233 234 expected = [ { "line": 0, "message" : "cycle detected in: struct Animal" },
@@ -242,7 +243,7 @@ def test_cycle_detection(self):
242 243 toLoan []Book
243 244 toAck []Book
244 245 }"""
245   - parse(idl)
  246 + parse(idl, add_meta=False)
246 247
247 248 def test_interface_cant_be_field_type(self):
248 249 idl = """struct Animal {
@@ -252,7 +253,7 @@ def test_interface_cant_be_field_type(self):
252 253 do_something() bool
253 254 }"""
254 255 try:
255   - parse(idl)
  256 + parse(idl, add_meta=False)
256 257 self.fail("should have thrown exception")
257 258 except IdlParseException as e:
258 259 expected = [ { "line": 0, "message" : "interface FooService cannot be a field type" } ]
@@ -269,7 +270,7 @@ def test_types_exist(self):
269 270 a int
270 271 }"""
271 272 try:
272   - parse(idl)
  273 + parse(idl, add_meta=False)
273 274 self.fail("should have thrown exception")
274 275 except IdlParseException as e:
275 276 expected = [ { "line": 0, "message" : "undefined type: Color" },
@@ -290,7 +291,7 @@ def test_cant_override_parent_field(self):
290 291 gender bool
291 292 }"""
292 293 try:
293   - parse(idl)
  294 + parse(idl, add_meta=False)
294 295 self.fail("should have thrown exception")
295 296 except IdlParseException as e:
296 297 expected = [ { "line": 0, "message" : "Cat cannot redefine parent field color" },
@@ -303,7 +304,7 @@ def test_struct_cant_extend_enum(self):
303 304 color string
304 305 }"""
305 306 try:
306   - parse(idl)
  307 + parse(idl, add_meta=False)
307 308 self.fail("should have thrown exception")
308 309 except IdlParseException as e:
309 310 expected = [ { "line": 0, "message" : "Animal cannot extend enum Status" } ]
@@ -314,7 +315,7 @@ def test_struct_cant_extend_native_type(self):
314 315 color string
315 316 }"""
316 317 try:
317   - parse(idl)
  318 + parse(idl, add_meta=False)
318 319 self.fail("should have thrown exception")
319 320 except IdlParseException as e:
320 321 expected = [ { "line": 0, "message" : "Animal cannot extend float" } ]
@@ -323,7 +324,7 @@ def test_struct_cant_extend_native_type(self):
323 324 def test_struct_must_have_fields(self):
324 325 idl = "struct Animal { }"
325 326 try:
326   - parse(idl)
  327 + parse(idl, add_meta=False)
327 328 self.fail("should have thrown exception")
328 329 except IdlParseException as e:
329 330 expected = [ { "line": 1, "message" : "Animal must have at least one field" } ]
@@ -332,7 +333,7 @@ def test_struct_must_have_fields(self):
332 333 def test_interface_must_have_funcs(self):
333 334 idl = "interface FooService { }"
334 335 try:
335   - parse(idl)
  336 + parse(idl, add_meta=False)
336 337 self.fail("should have thrown exception")
337 338 except IdlParseException as e:
338 339 expected = [ { "line": 1, "message" : "FooService must have at least one function" } ]
@@ -341,7 +342,7 @@ def test_interface_must_have_funcs(self):
341 342 def test_enum_must_have_values(self):
342 343 idl = "enum Status { }"
343 344 try:
344   - parse(idl)
  345 + parse(idl, add_meta=False)
345 346 self.fail("should have thrown exception")
346 347 except IdlParseException as e:
347 348 expected = [ { "line": 1, "message" : "Status must have at least one value" } ]
@@ -356,7 +357,7 @@ def test_cycle_detection_for_interfaces(self):
356 357 subtract(a int, b int) BaseResponse
357 358 }"""
358 359 # should work - cycle detection should reset per function
359   - parse(idl)
  360 + parse(idl, add_meta=False)
360 361
361 362 def test_interface_cant_be_param(self):
362 363 idl = """interface BlargService {
@@ -367,7 +368,7 @@ def test_interface_cant_be_param(self):
367 368 subtract(a int, b int) BlargService
368 369 }"""
369 370 try:
370   - parse(idl)
  371 + parse(idl, add_meta=False)
371 372 self.fail("should have thrown exception")
372 373 except IdlParseException as e:
373 374 expected = [ { "line": 0, "message" : "interface BlargService cannot be a field type" },
@@ -383,7 +384,7 @@ def test_optional_struct_field(self):
383 384 "extends" : "", "comment" : "",
384 385 "fields" : [ field("firstName", "string"),
385 386 field("email", "string", optional=True) ] } ]
386   - self.assertEquals(expected, parse(idl))
  387 + self.assertEquals(expected, parse(idl, add_meta=False))
387 388
388 389 def test_optional_return_type(self):
389 390 idl = """interface FooService {
@@ -393,7 +394,48 @@ def test_optional_return_type(self):
393 394 "functions" :
394 395 [ { "name" : "sayHi", "comment" : "", "params" : [ ],
395 396 "returns" : ret_field("string", optional=True) } ] } ]
396   - self.assertEquals(expected, parse(idl))
  397 + self.assertEquals(expected, parse(idl, add_meta=False))
  398 +
  399 + def test_add_meta(self):
  400 + idl = """interface FooService {
  401 + do_foo() string
  402 +}"""
  403 + start = int(time.time() * 1000)
  404 + parsed = parse(idl, add_meta=True)
  405 + meta = parsed[-1]
  406 + generated = meta["date_generated"]
  407 + checksum = meta["checksum"]
  408 + stop = int(time.time() * 1000)
  409 + self.assertTrue(generated >= start and generated <= stop)
  410 + self.assertTrue(checksum != None)
  411 +
  412 + def test_meta_checksum(self):
  413 + base = "enum Y {\ndog\ncat\n}\nstruct Z {\n a int }\n"
  414 + base2 = "// foo\nstruct Z {\n //foo2\na int }\nenum Y {\ncat\ndog\n}\n"
  415 + equivalent = [ base+"interface FooService {\n do_foo() string\n}",
  416 + "interface FooService {\n do_foo() string\n}"+base2,
  417 + base+" interface FooService {\n // stuff\n do_foo() string\n\n}" ]
  418 + first_checksum = None
  419 + for idl in equivalent:
  420 + parsed = parse(idl, add_meta=True)
  421 + meta = parsed[-1]
  422 + checksum = meta["checksum"]
  423 + if first_checksum == None:
  424 + first_checksum = checksum
  425 + else:
  426 + self.assertEquals(first_checksum, checksum)
  427 +
  428 + base3 = "enum Y {\ndog2\ncat\n}\nstruct Z {\n a int }\n"
  429 + base4 = "enum Y {\ndog\ncat\n}\nstruct Z {\n a float }\n"
  430 + different = [ base3+"interface FooService {\n do_foo() string\n}",
  431 + base4+"interface FooService {\n do_foo() string\n}",
  432 + base+"interface FooService {\n do_foo(a int) string\n}",
  433 + base+"interface FooService {\n do_foo(a int) string\n do_bar() int\n}",
  434 + base+"// foo interface\n interface FooService {\n // stuff\n do_foo() float\n\n}" ]
  435 + for idl in different:
  436 + parsed = parse(idl, add_meta=True)
  437 + meta = parsed[-1]
  438 + self.assertNotEquals(first_checksum, meta["checksum"])
397 439
398 440 if __name__ == "__main__":
399 441 unittest.main()
2  conform/conform.json
... ... @@ -1 +1 @@
1   -[{"type": "comment", "value": "Barrister conformance IDL\n\nThe bits in here have silly names and the operations\nare not intended to be useful. The intent is to\nexercise as much of the IDL grammar as possible"}, {"comment": "", "values": [{"comment": "", "value": "ok"}, {"comment": "", "value": "err"}], "type": "enum", "name": "Status"}, {"comment": "", "values": [{"comment": "", "value": "add"}, {"comment": "", "value": "multiply"}], "type": "enum", "name": "MathOp"}, {"comment": "", "extends": "", "type": "struct", "name": "Response", "fields": [{"comment": "", "optional": false, "is_array": false, "type": "Status", "name": "status"}]}, {"comment": "testing struct inheritance", "extends": "Response", "type": "struct", "name": "RepeatResponse", "fields": [{"comment": "", "optional": false, "is_array": false, "type": "int", "name": "count"}, {"comment": "", "optional": false, "is_array": true, "type": "string", "name": "items"}]}, {"comment": "", "extends": "", "type": "struct", "name": "HiResponse", "fields": [{"comment": "", "optional": false, "is_array": false, "type": "string", "name": "hi"}]}, {"comment": "", "extends": "", "type": "struct", "name": "RepeatRequest", "fields": [{"comment": "", "optional": false, "is_array": false, "type": "string", "name": "to_repeat"}, {"comment": "", "optional": false, "is_array": false, "type": "int", "name": "count"}, {"comment": "", "optional": false, "is_array": false, "type": "bool", "name": "force_uppercase"}]}, {"comment": "", "extends": "", "type": "struct", "name": "Person", "fields": [{"comment": "", "optional": false, "is_array": false, "type": "string", "name": "personId"}, {"comment": "", "optional": false, "is_array": false, "type": "string", "name": "firstName"}, {"comment": "", "optional": false, "is_array": false, "type": "string", "name": "lastName"}, {"comment": "", "optional": true, "is_array": false, "type": "string", "name": "email"}]}, {"comment": "", "functions": [{"comment": "returns a+b", "returns": {"optional": false, "is_array": false, "type": "int"}, "params": [{"is_array": false, "type": "int", "name": "a"}, {"is_array": false, "type": "int", "name": "b"}], "name": "add"}, {"comment": "performs the given operation against \nall the values in nums and returns the result", "returns": {"optional": false, "is_array": false, "type": "float"}, "params": [{"is_array": true, "type": "float", "name": "nums"}, {"is_array": false, "type": "MathOp", "name": "operation"}], "name": "calc"}, {"comment": "returns the square root of a", "returns": {"optional": false, "is_array": false, "type": "float"}, "params": [{"is_array": false, "type": "float", "name": "a"}], "name": "sqrt"}, {"comment": "Echos the req1.to_repeat string as a list,\noptionally forcing to_repeat to upper case\n\nRepeatResponse.items should be a list of strings\nwhose length is equal to req1.count", "returns": {"optional": false, "is_array": false, "type": "RepeatResponse"}, "params": [{"is_array": false, "type": "RepeatRequest", "name": "req1"}], "name": "repeat"}, {"comment": "returns a result with:\n hi=\"hi\" and status=\"ok\"", "returns": {"optional": false, "is_array": false, "type": "HiResponse"}, "params": [], "name": "say_hi"}, {"comment": "returns num as an array repeated 'count' number of times", "returns": {"optional": false, "is_array": true, "type": "int"}, "params": [{"is_array": false, "type": "int", "name": "num"}, {"is_array": false, "type": "int", "name": "count"}], "name": "repeat_num"}, {"comment": "simply returns p.personId\n\nwe use this to test the '[optional]' enforcement, \nas we invoke it with a null email", "returns": {"optional": false, "is_array": false, "type": "string"}, "params": [{"is_array": false, "type": "Person", "name": "p"}], "name": "putPerson"}], "type": "interface", "name": "A"}, {"comment": "a second interface to prove that the server dispatcher\nunderstands how to distinguish between interfaces in a contract", "functions": [{"comment": "simply returns s \nif s == \"return-null\" then you should return a null ", "returns": {"optional": true, "is_array": false, "type": "string"}, "params": [{"is_array": false, "type": "string", "name": "s"}], "name": "echo"}], "type": "interface", "name": "B"}]
  1 +[{"type": "comment", "value": "Barrister conformance IDL\n\nThe bits in here have silly names and the operations\nare not intended to be useful. The intent is to\nexercise as much of the IDL grammar as possible"}, {"comment": "", "values": [{"comment": "", "value": "ok"}, {"comment": "", "value": "err"}], "type": "enum", "name": "Status"}, {"comment": "", "values": [{"comment": "", "value": "add"}, {"comment": "", "value": "multiply"}], "type": "enum", "name": "MathOp"}, {"comment": "", "extends": "", "type": "struct", "name": "Response", "fields": [{"comment": "", "optional": false, "is_array": false, "type": "Status", "name": "status"}]}, {"comment": "testing struct inheritance", "extends": "Response", "type": "struct", "name": "RepeatResponse", "fields": [{"comment": "", "optional": false, "is_array": false, "type": "int", "name": "count"}, {"comment": "", "optional": false, "is_array": true, "type": "string", "name": "items"}]}, {"comment": "", "extends": "", "type": "struct", "name": "HiResponse", "fields": [{"comment": "", "optional": false, "is_array": false, "type": "string", "name": "hi"}]}, {"comment": "", "extends": "", "type": "struct", "name": "RepeatRequest", "fields": [{"comment": "", "optional": false, "is_array": false, "type": "string", "name": "to_repeat"}, {"comment": "", "optional": false, "is_array": false, "type": "int", "name": "count"}, {"comment": "", "optional": false, "is_array": false, "type": "bool", "name": "force_uppercase"}]}, {"comment": "", "extends": "", "type": "struct", "name": "Person", "fields": [{"comment": "", "optional": false, "is_array": false, "type": "string", "name": "personId"}, {"comment": "", "optional": false, "is_array": false, "type": "string", "name": "firstName"}, {"comment": "", "optional": false, "is_array": false, "type": "string", "name": "lastName"}, {"comment": "", "optional": true, "is_array": false, "type": "string", "name": "email"}]}, {"comment": "", "functions": [{"comment": "returns a+b", "returns": {"optional": false, "is_array": false, "type": "int"}, "params": [{"is_array": false, "type": "int", "name": "a"}, {"is_array": false, "type": "int", "name": "b"}], "name": "add"}, {"comment": "performs the given operation against \nall the values in nums and returns the result", "returns": {"optional": false, "is_array": false, "type": "float"}, "params": [{"is_array": true, "type": "float", "name": "nums"}, {"is_array": false, "type": "MathOp", "name": "operation"}], "name": "calc"}, {"comment": "returns the square root of a", "returns": {"optional": false, "is_array": false, "type": "float"}, "params": [{"is_array": false, "type": "float", "name": "a"}], "name": "sqrt"}, {"comment": "Echos the req1.to_repeat string as a list,\noptionally forcing to_repeat to upper case\n\nRepeatResponse.items should be a list of strings\nwhose length is equal to req1.count", "returns": {"optional": false, "is_array": false, "type": "RepeatResponse"}, "params": [{"is_array": false, "type": "RepeatRequest", "name": "req1"}], "name": "repeat"}, {"comment": "returns a result with:\n hi=\"hi\" and status=\"ok\"", "returns": {"optional": false, "is_array": false, "type": "HiResponse"}, "params": [], "name": "say_hi"}, {"comment": "returns num as an array repeated 'count' number of times", "returns": {"optional": false, "is_array": true, "type": "int"}, "params": [{"is_array": false, "type": "int", "name": "num"}, {"is_array": false, "type": "int", "name": "count"}], "name": "repeat_num"}, {"comment": "simply returns p.personId\n\nwe use this to test the '[optional]' enforcement, \nas we invoke it with a null email", "returns": {"optional": false, "is_array": false, "type": "string"}, "params": [{"is_array": false, "type": "Person", "name": "p"}], "name": "putPerson"}], "type": "interface", "name": "A"}, {"comment": "a second interface to prove that the server dispatcher\nunderstands how to distinguish between interfaces in a contract", "functions": [{"comment": "simply returns s \nif s == \"return-null\" then you should return a null ", "returns": {"optional": true, "is_array": false, "type": "string"}, "params": [{"is_array": false, "type": "string", "name": "s"}], "name": "echo"}], "type": "interface", "name": "B"}, {"barrister_version": "0.1.0", "type": "meta", "date_generated": 1334261700516, "checksum": "34f6238ed03c6319017382e0fdc638a7"}]

0 comments on commit bca7e6f

Please sign in to comment.
Something went wrong with that request. Please try again.