From 5e725fcaebd06bef6c57910a485464be4707b954 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Sun, 3 Jun 2012 14:03:14 +0200 Subject: [PATCH] Make generated code closer to correct code --- .../description.human_readable.json | 26 +++- .../description.normalized.json | 126 ++++++++++++++---- .../JsonDescriptionOfGithubApiV3/normalize.py | 6 +- .../GithubObject.Concatenation.stringOf.py | 1 + 4 files changed, 125 insertions(+), 34 deletions(-) create mode 100644 codegen/templates/GithubObject.Concatenation.stringOf.py diff --git a/codegen/JsonDescriptionOfGithubApiV3/description.human_readable.json b/codegen/JsonDescriptionOfGithubApiV3/description.human_readable.json index 295ae6ac..514b43ef 100644 --- a/codegen/JsonDescriptionOfGithubApiV3/description.human_readable.json +++ b/codegen/JsonDescriptionOfGithubApiV3/description.human_readable.json @@ -456,7 +456,10 @@ "parameter": { "name": "id", "type": "integer" }, "url": [ { "type": "constant", "value": "https://api.github.com/gists/comments/" }, - { "type": "argument", "value": [ "id" ] } + { + "type": "stringOf", + "value": [ { "type": "argument", "value": [ "id" ] } ] + } ] }, "createElement": { @@ -739,7 +742,12 @@ }, { "type": "constant", "value": "/comments" }, { "type": "constant", "value": "/" }, - { "type": "argument", "value": [ "id" ] } + { + "type": "stringOf", + "value": [ + { "type": "argument", "value": [ "id" ] } + ] + } ] } }, @@ -1109,7 +1117,10 @@ "parameter": { "name": "id", "type": "integer" }, "url" : [ { "type": "constant", "value": "https://api.github.com/teams/" }, - { "type": "argument", "value": [ "id" ] } + { + "type": "stringOf", + "value": [ { "type": "argument", "value": [ "id" ] } ] + } ] } } @@ -1211,8 +1222,13 @@ ] }, { "type": "constant", "value": "/comments" }, - { "type": "constant", "value": "/" }, - { "type": "argument", "value": [ "id" ] } + { "type": "constant", "value": "/" }, + { + "type": "stringOf", + "value": [ + { "type": "argument", "value": [ "id" ] } + ] + } ] } }, diff --git a/codegen/JsonDescriptionOfGithubApiV3/description.normalized.json b/codegen/JsonDescriptionOfGithubApiV3/description.normalized.json index ba1c67d9..8a9a222b 100644 --- a/codegen/JsonDescriptionOfGithubApiV3/description.normalized.json +++ b/codegen/JsonDescriptionOfGithubApiV3/description.normalized.json @@ -362,9 +362,14 @@ "value": "https://api.github.com/authorizations/" }, { - "type": "argument", + "type": "stringOf", "value": [ - "id" + { + "type": "argument", + "value": [ + "id" + ] + } ] } ], @@ -520,9 +525,14 @@ "value": "https://api.github.com/user/keys/" }, { - "type": "argument", + "type": "stringOf", "value": [ - "id" + { + "type": "argument", + "value": [ + "id" + ] + } ] } ], @@ -2697,9 +2707,14 @@ "value": "https://api.github.com/gists/comments/" }, { - "type": "argument", + "type": "stringOf", "value": [ - "id" + { + "type": "argument", + "value": [ + "id" + ] + } ] } ], @@ -4068,9 +4083,14 @@ "value": "/comments/" }, { - "type": "argument", + "type": "stringOf", "value": [ - "id" + { + "type": "argument", + "value": [ + "id" + ] + } ] } ], @@ -6412,9 +6432,14 @@ "value": "https://api.github.com/teams/" }, { - "type": "argument", + "type": "stringOf", "value": [ - "id" + { + "type": "argument", + "value": [ + "id" + ] + } ] } ], @@ -6967,9 +6992,14 @@ "value": "/comments/" }, { - "type": "argument", + "type": "stringOf", "value": [ - "id" + { + "type": "argument", + "value": [ + "id" + ] + } ] } ], @@ -7968,9 +7998,14 @@ "value": "/comments/" }, { - "type": "argument", + "type": "stringOf", "value": [ - "id" + { + "type": "argument", + "value": [ + "id" + ] + } ] } ], @@ -8236,9 +8271,14 @@ "value": "/downloads/" }, { - "type": "argument", + "type": "stringOf", "value": [ - "id" + { + "type": "argument", + "value": [ + "id" + ] + } ] } ], @@ -9007,9 +9047,14 @@ "value": "/hooks/" }, { - "type": "argument", + "type": "stringOf", "value": [ - "id" + { + "type": "argument", + "value": [ + "id" + ] + } ] } ], @@ -9158,9 +9203,14 @@ "value": "/issues/" }, { - "type": "argument", + "type": "stringOf", "value": [ - "number" + { + "type": "argument", + "value": [ + "number" + ] + } ] } ], @@ -9300,9 +9350,14 @@ "value": "/issues/events/" }, { - "type": "argument", + "type": "stringOf", "value": [ - "id" + { + "type": "argument", + "value": [ + "id" + ] + } ] } ], @@ -9426,9 +9481,14 @@ "value": "/keys/" }, { - "type": "argument", + "type": "stringOf", "value": [ - "id" + { + "type": "argument", + "value": [ + "id" + ] + } ] } ], @@ -9700,9 +9760,14 @@ "value": "/milestones/" }, { - "type": "argument", + "type": "stringOf", "value": [ - "number" + { + "type": "argument", + "value": [ + "number" + ] + } ] } ], @@ -9875,9 +9940,14 @@ "value": "/pulls/" }, { - "type": "argument", + "type": "stringOf", "value": [ - "number" + { + "type": "argument", + "value": [ + "number" + ] + } ] } ], diff --git a/codegen/JsonDescriptionOfGithubApiV3/normalize.py b/codegen/JsonDescriptionOfGithubApiV3/normalize.py index 4cf8f4a7..33e096b4 100755 --- a/codegen/JsonDescriptionOfGithubApiV3/normalize.py +++ b/codegen/JsonDescriptionOfGithubApiV3/normalize.py @@ -210,9 +210,13 @@ class Collection: if "url" in desc[ "getElement" ]: urlForGetElement = desc[ "getElement" ][ "url" ] else: + if desc[ "getElement" ][ "parameter" ][ "type" ] == "string": + partForArgument = { "type": "argument", "value": [ desc[ "getElement" ][ "parameter" ][ "name" ] ] } + else: + partForArgument = { "type": "stringOf", "value": [ { "type": "argument", "value": [ desc[ "getElement" ][ "parameter" ][ "name" ] ] } ] } urlForGetElement = self.__url + [ { "type": "constant", "value": "/" }, - { "type": "argument", "value": [ desc[ "getElement" ][ "parameter" ][ "name" ] ] }, + partForArgument, ] self.methods.append( Function( diff --git a/codegen/templates/GithubObject.Concatenation.stringOf.py b/codegen/templates/GithubObject.Concatenation.stringOf.py new file mode 100644 index 00000000..c35f1061 --- /dev/null +++ b/codegen/templates/GithubObject.Concatenation.stringOf.py @@ -0,0 +1 @@ +str( {% include "GithubObject.Concatenation.py" with concatenation=value only %} ) \ No newline at end of file