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 | bcbba2abd857303acc45f449ce3c158549a74225 (patch) | |
tree | fabf89b8fa194f1205777e8c14476906a17209f1 | |
parent | f9540497689c8483a88fcfd172205f8c8fd0a33c (diff) | |
download | rabbitmq-codegen-bug18524.tar.gz |
updated docsbug18524
-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 3a067ba..74b24fc 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) |