Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyojun Kang committed Mar 31, 2017
1 parent 4ee1bba commit 3d494d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/pdf-service.nrm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@error("")
@error
union markdown-parse-error = symbol-error | syntax-error (text reason);

type html = text;
Expand Down
10 changes: 10 additions & 0 deletions src/Nirum/Targets/Python.hs
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,10 @@ compileTypeDeclaration
let methodMetadata' = commaNl methodMetadata
dummyMethods <- mapM compileMethod methods'
clientMethods <- mapM compileClientMethod methods'
methodErrorTypes <- mapM compileErrorType methods'
let dummyMethods' = T.intercalate "\n\n" dummyMethods
clientMethods' = T.intercalate "\n\n" clientMethods
methodErrorTypes' = T.intercalate "," methodErrorTypes
insertStandardImport "json"
insertThirdPartyImports [ ("nirum.constructs", ["name_dict_type"])
, ("nirum.deserialize", ["deserialize_meta"])
Expand All @@ -736,6 +738,7 @@ class $className(service_type):
__nirum_method_names__ = name_dict_type([
$methodNameMap
])
__nirum_error_types__ = dict([$methodErrorTypes'])

{dummyMethods'}

Expand All @@ -751,6 +754,13 @@ class {className}_Client(client_type, $className):
className = toClassName' name'
commaNl :: [T.Text] -> T.Text
commaNl = T.intercalate ",\n"
compileErrorType :: Method -> CodeGen Code
compileErrorType (Method mn _ _ me _) =
case me of
Just errorTypeExpression -> do
et <- compileTypeExpression src errorTypeExpression
return [qq|('{toAttributeName' mn}', $et)|]
Nothing -> return ""
compileMethod :: Method -> CodeGen Code
compileMethod (Method mName params rtype _etype _anno) = do
let mName' = toAttributeName' mName
Expand Down

0 comments on commit 3d494d0

Please sign in to comment.