diff options
author | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-06-11 07:17:14 +0100 |
---|---|---|
committer | Alexandru Scvortov <alexandru@rabbitmq.com> | 2010-06-11 07:17:14 +0100 |
commit | a7ce9d153f6f4db9c70f1b94b3937a4a9e8205ff (patch) | |
tree | fabf89b8fa194f1205777e8c14476906a17209f1 /README.extensions.md | |
parent | 7a5ded9697a314536d9e7b1552e6f37767225030 (diff) | |
download | rabbitmq-codegen-git-a7ce9d153f6f4db9c70f1b94b3937a4a9e8205ff.tar.gz |
updated docs
Diffstat (limited to 'README.extensions.md')
-rw-r--r-- | README.extensions.md | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/README.extensions.md b/README.extensions.md index 3a067baa..74b24fc6 100644 --- a/README.extensions.md +++ b/README.extensions.md @@ -142,22 +142,22 @@ invoked. ## Invoking the spec compiler -Your code generation code should invoke `amqp_codegen.do_main` with -two functions as arguments: one for generating "header-file" text, and -one for generating "implementation-file" text. The `do_main` function +Your code generation code should invoke `amqp_codegen.do_main_dict` +with a dictionary of functions as the sole argument. Each will be +used for generationg a separate file. The `do_main_dict` function will parse the command-line arguments supplied when python was invoked. The command-line will be parsed as: - python your_codegen.py <headerorbody> <mainspec> [<extspec> ...] <outfile> + python your_codegen.py <action> <mainspec> [<extspec> ...] <outfile> -where `<headerorbody>` is either the word `header` or the word `body`, -to select which generation function is called by `do_main`. The -`<mainspec>` and `<extspec>` arguments are file names of specification -documents containing expressions in the syntax given above. The -*final* argument on the command line, `<outfile>`, is the name of the -source-code file to generate. +where `<action>` is a key into the dictionary supplied to +`do_main_dict` and is used to select which generation function is +called. The `<mainspec>` and `<extspec>` arguments are file names of +specification documents containing expressions in the syntax given +above. The *final* argument on the command line, `<outfile>`, is the +name of the source-code file to generate. Here's a tiny example of the layout of a code generation module that uses `amqp_codegen`: @@ -173,9 +173,10 @@ uses `amqp_codegen`: ... if __name__ == "__main__": - amqp_codegen.do_main(generateHeader, generateImpl) + amqp_codegen.do_main_dict({"header": generateHeader, + "body": generateImpl}) -The reasons for this split, such as they are, are that +The reasons for allowing more than one action, are that - many languages have separate "header"-type files (C and Erlang, to name two) |