From a7ce9d153f6f4db9c70f1b94b3937a4a9e8205ff Mon Sep 17 00:00:00 2001 From: Alexandru Scvortov Date: Fri, 11 Jun 2010 07:17:14 +0100 Subject: updated docs --- README.extensions.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'README.extensions.md') 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 [ ...] + python your_codegen.py [ ...] -where `` is either the word `header` or the word `body`, -to select which generation function is called by `do_main`. The -`` and `` arguments are file names of specification -documents containing expressions in the syntax given above. The -*final* argument on the command line, ``, is the name of the -source-code file to generate. +where `` is a key into the dictionary supplied to +`do_main_dict` and is used to select which generation function is +called. The `` and `` arguments are file names of +specification documents containing expressions in the syntax given +above. The *final* argument on the command line, ``, 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) -- cgit v1.2.1