event_rpcgen.py

Branch


Log

Author Commit Date CI Message
Enji Cooper 46c9ead0 2020-06-25T08:08:10 Make all classes Entry, Struct, etc) new-style classes This allows the object methods to be properly inherited and called via `super(..)`, addressing breakage with python 2.x, introduced in cfcc093606e747a5d250787012bac0b149c60d6d. Fixes #1042. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Azat Khuzhin b57b6e46 2020-03-28T16:01:46 event_rpcgen.py: fix arguments-differ
Azat Khuzhin 7cdf75ca 2020-03-28T15:58:57 event_rpcgen.py: fix attribute-defined-outside-init
Azat Khuzhin 121fe013 2020-03-28T15:58:36 event_rpcgen: suppress some warnings to make pylint clean
Enji Cooper 47a2bcf6 2020-03-27T17:24:53 Don't accumulate arguments in `Entry.GetTranslation` Initialize `extradict` safely to avoid accumulating arguments in dict objects passed in across calls. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper 6a3ca347 2020-03-27T17:01:53 Fix improper string concatenations in lists This change adds commas between elements or explicitly concatenates the strings, so the values are no longer concatenated by accident. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper 496fc02b 2020-03-27T16:56:16 Fix warnings regarding unused variables Prefix all unused variables with `_` to mute unused variable warnings with flake8/pylint. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper 80171db5 2020-03-27T16:45:21 Don't override the `type` built-in Name the second parameter to `Entry(..)` `ent_type` to avoid overriding the built-in. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper cfcc0936 2020-03-27T16:27:56 Call `super` to call methods from the parent class Not only does it make it clearer to the reader what the intent is behind the code, it fixes MRO evaluation of classes if the parent-child relationship is nonlinear. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper 83175940 2020-03-27T16:20:24 Address `no-self-use` issues reported by pylint Sprinkle around `@staticmethod` where need be and raise `NotImplementedError` from `Entry.GetInitializer` instead of doing similar with `assert`. `NotImplementedError` will provide a hint to static analyzers that there are abstract methods which need to be implemented, if they aren't, in subclasses. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper 6da0cc61 2020-03-27T16:04:37 Run the code through the black formatter This resolves a number of flake8 issues as well as pylint issues. Not all of the changes mesh between flake8/pylint though, so there are some false positives, but it's better than before. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper 10a04036 2020-03-27T15:58:02 Reformat strings to template This change converts the existing code to use triple-quotes extensively, in the end-goal of making the code to reformat with black more readable before and after the change (black messes around with the formatting in a less than desirable way). Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper 4cde51b6 2020-03-26T22:29:43 Add `argparse` support This change converts raw parsing with `sys.argv` to its equivalent logic with `argparse`. It doesn't fully convert over all of the TODO items listed in the comments, but it does provide some top-level structure which can be used to drive down further improvements and structure. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper 23874cfc 2020-03-26T21:02:13 Precompile regular expressions This change boost performance at scale by pre-compiling regular expressions in the global space, then reusing them many times within functions. This (while not the desired intent of the author) will boost performance when parsing input. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper 1b545a46 2020-03-26T19:15:52 Use bools instead of ints values where possible This is being done to clarify logic and isn't being done for performance reasons whatsoever, as bools are derived from ints. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper 9157b0d2 2020-03-26T19:05:48 Rename all global variables to match the PEP8 spec Global variables should be in all caps, as opposed to lowercase. While here, use named groups for `STRUCT_REF_RE` instead of numbered groups to make the results and their indented tokens to parse more intuitive to the end reader. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper dc576729 2020-03-26T17:37:09 Handle file pointers with context suite patterns This removes the need for manually calling the file pointer's `.close` methods directly. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper 7f115c17 2020-03-26T20:42:40 Iterate over `tokens` with a for instead of while This simplifies the logic and avoids unnecessary copying/slicing of array elements in `tokens`. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper 5408b963 2020-03-26T17:28:09 Fix indentation for `RpcGenError` Indentation for the exception was double what it should have been. This change normalizes the indentation to a consistent standard with the rest of the file. Fix minor flake8 issues while here corresponding to the minimum number of needed blank lines around the class and its methods. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper 30229dcf 2020-03-26T17:21:25 Don't override `file` built-in Use `filep` instead of `file` to clarify the fact that `file` is a file pointer object. This mutes warnings on python 2.7 with `pylint`. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper 2c38d6b1 2020-03-26T17:13:14 Resolve variable name issues per PEP8 Move all logic under `if __name__ == "__main__"` to a `main(..)` function. The purpose of this is to not only address flake8/pylint reported issues with variable names, but also to enable testing of the function in isolation to ensure the logic acts as desired. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Enji Cooper f30cc2b0 2020-03-26T16:07:17 Sort imports per PEP8 Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Azat Khuzhin e85818d2 2018-06-19T10:15:08 Cleanup __func__ detection First of all __func__ is not a macro, it is char[] array, so the code that we had before in cmake, was incorrect, i.e.: #if defined (__func__) #define EVENT____func__ __func__ #elif defined(__FUNCTION__) #define EVENT____func__ __FUNCTION__ #else #define EVENT____func__ __FILE__ #endif So just detect do we have __func__/__FUNCTION__ in configure/cmake before build and define EVENT__HAVE___func__/EVENT__HAVE___FUNCTION__ to use the later to choose which should be used as a __func__ (if it is not presented). Closes: #644
Kiyoshi Aman 8b0aa7b3 2017-09-14T17:39:20 Port `event_rpcgen.py` and `test/check-dumpevents.py` to Python 3. These scripts remain compatible with Python 2.
Azat Khuzhin 253e7fa9 2016-12-06T12:08:32 util-internal: fix __func__ redefinition (netbsd) ==> netbsd: In file included from ../listener.c:57:0: ==> netbsd: ../util-internal.h:58:0: warning: "__func__" redefined [enabled by default] ==> netbsd: #define __func__ EVENT____func__ ==> netbsd: ^ ==> netbsd: In file included from /usr/include/amd64/types.h:39:0, ==> netbsd: from /usr/include/sys/types.h:45, ==> netbsd: from ../listener.c:30: ==> netbsd: /usr/include/sys/cdefs.h:394:0: note: this is the location of the previous definition ==> netbsd: #define __func__ __PRETTY_FUNCTION__
Nick Mathewson 32ed1102 2012-10-26T19:37:00 Merge remote-tracking branch 'origin/patches-2.0'
Ross Lagerwall 0eb01099 2012-10-23T13:30:58 Use python2 rather than python python may refer to either python2 or python3 so rather by explicit by using python2. See PEP 394 - http://www.python.org/dev/peps/pep-0394/ for more details.
Ross Lagerwall 4b5f32a5 2012-10-23T13:26:44 Use python2 rather than python python may refer to either python2 or python3 so rather by explicit by using python2. See PEP 394 - http://www.python.org/dev/peps/pep-0394/ for more details.
Nick Mathewson aa59c1e9 2012-08-28T16:14:17 New --quiet option for event_rpcgen.py
Ross Lagerwall ffb0ba07 2012-03-06T06:05:04 event_rpcgen.py now prints status information to stdout and errors to stderr. Before, running make > /dev/null would result in status information cluttering the error log. This changes it so that event_rpcgen.py prints status information to stdout like the rest of the build tools.
Nick Mathewson bcefd246 2012-02-29T15:07:32 Make event_rpcgen.py output conform to indentifier conventions, more
Nick Mathewson 372bff1c 2012-02-29T15:07:31 Make event_rpcgen.py output conform to indentifier conventions
Nick Mathewson e49e2891 2012-02-10T17:29:53 Update copyright notices to 2012
Nick Mathewson f1250eb6 2010-10-25T15:23:41 add a requested docstring for event_rpcgen.CommandLine.__init__
Nick Mathewson ec347b92 2010-07-07T16:45:03 Move event-config.h to include/event2 This change means that all required include files are in event2, and all files not in event2/* are optional.
Nick Mathewson f6ab2a28 2010-04-23T23:55:30 Fix a memory leak when unmarshalling RPC object arrays The old code would use type_var_add() for its side-effect of expanding the array, then leak the new object that was added to the array. The new code adds a static function to handle the array resizing.
Shuo Chen 755fbf16 2010-04-14T14:27:29 Add void* arguments to request_new and reply_new evrpc hooks This makes evprc setup more extensible, and helps with Shuo Chen's work on implementing Google protocol buffers rpc on top of Libevent 2 evrpc. This patch breaks binary compatibility with previous versions of Libevent, since it changes struct evrpc and the signature of evrpc_register_generic(). Since all compliant code should be calling evrpc_register_generic via EVRPC_REGISTER, it shouldn't break source compatibility. (Code by Shuo Chen; commit message by Nick)
Nick Mathewson 91fe23fc 2009-11-20T15:46:04 Tolerate code that returns from a fatal_cb. Also, replace more abort() calls with EVUTIL_ASSERT() or event_errx.
Nick Mathewson f9de8670 2009-11-16T22:23:06 Fix a declaration of __func__ in rpcgen. svn:r1535
Nick Mathewson a826a758 2009-07-28T19:41:48 Some tweaks to Brodie Thesfield's MSVC patch. svn:r1386
Nick Mathewson 5d71b25b 2009-07-17T18:38:38 Remove all trailing whitespace from end-of-line. svn:r1350
Niels Provos 6469598e 2009-07-03T17:43:26 Allow C identifiers as struct names; allow multiple comments in .rpc files; from Zack Weinberg; plus a tiny tweak svn:r1336
Niels Provos fbb181d1 2009-07-03T17:31:17 Allow specifying the output filename for rpcgen; based on work by jmansion; patch from Zack Weinberg. svn:r1335
Niels Provos bbcc54ef 2009-07-03T17:25:45 fix preamble of rpcgen-generated files to rely on event2 includes; based on work by jmansion; patch from Zack Weinberg. svn:r1334
Niels Provos 37d3e16c 2009-07-03T17:20:56 Raise RpcGenError in event_rpcgen.py; from jmanison and Zack Weinberg svn:r1333
Niels Provos b228ff91 2009-04-25T00:15:31 remove vararg macros for accessing evrpc structs svn:r1243
Nick Mathewson 9516df0e 2009-04-23T05:40:06 Fix c89 bugs reported by Cory Stup. Others may remain. I wasn't able to get gcc --std=c89 to build libevent at all, so I don't know what compiler the original reporter is using here. Note that this change requires us to disable the part of our rpc code that uses variadic macros when using a non-gcc compiler. This is a problem if we want our rpc api to be portable. svn:r1231
Nick Mathewson a8f6d961 2009-04-17T06:56:09 Actually stop using EVBUFFER_LENGTH/DATA, and move them to buffer_compat.h svn:r1183
Nick Mathewson 9993137c 2009-01-27T21:10:31 Remove all trailing whitespace in all the source files. svn:r1063
Niels Provos 99a1063e 2008-06-21T02:21:25 support 64-bit integers in rpc structs svn:r856
Nick Mathewson bb37fbb2 2008-05-05T15:45:47 r19601@catbus: nickm | 2008-05-05 11:45:04 -0400 Make event_rpcgen.py use the new headers. svn:r775
Niels Provos 812d2fd8 2008-04-03T14:27:01 proxy one more generator svn:r701
Niels Provos a7e39551 2008-04-03T03:33:07 slight refactoring svn:r700
Niels Provos d5c15b2e 2008-03-03T03:36:51 make event_rpcgen.py generate code include event-config.h svn:r686
Niels Provos 5c70ea4c 2008-02-28T02:47:43 improved code for evbuffer; avoids memcpy svn:r674
Nick Mathewson 11230f7e 2008-02-18T20:04:01 r18145@catbus: nickm | 2008-02-18 15:02:20 -0500 Stop using deprecated autoconf code to set integer types; detect actual files to include more thoroughly. This should make us work on solaris 9 again. This should be a backport candidate, if it works. Also, make all libevent code use ev_uint32_t etc, rather than uint_32_t. svn:r649
Niels Provos 616a64c8 2007-12-27T20:08:21 additional add argument was missing const qualifier svn:r615
Niels Provos 7e3a7af7 2007-12-24T23:59:41 support string arrays in event_rpcgen svn:r613
Niels Provos 68725dc8 2007-12-23T07:38:11 support integer arrays in rpc structures; this involved some refactoring of the event_rpcgen code, so that other types should be able to get arrays fairly easily svn:r609
Niels Provos 85053473 2007-12-13T06:36:54 fix a bug with event_rpcgen for integers svn:r588
Niels Provos 3b345f3e 2007-12-12T07:02:55 pull setters/getters out of RPC structures to reduce their memory footprint svn:r585
Niels Provos ba487199 2007-12-12T04:39:42 support for 32-bit tag numbers in rpc structures svn:r583
Niels Provos 3c1a6a68 2007-09-23T03:49:28 first attempts at refactoring this code to make it more readable; mostly changing to dictionaries for format strings svn:r450
Niels Provos 640c61ba 2007-09-15T00:53:47 deal with out of memory situations for realloc svn:r429
Niels Provos babd622f 2007-09-09T03:10:16 make allocating array members in event_rpcgen more efficient, but doubling the size of available slots every time we run out. svn:r421
Nick Mathewson 35983cd6 2007-08-16T21:12:53 r14618@catbus: nickm | 2007-08-16 17:11:47 -0400 In ANSI C, int func() is a function with unspecified arguments, whereas int func(void) is a function that takes no arguments. Using int func() to mean a function with no arguments is a C++ism, so let's not use or generate it. svn:r395
Niels Provos b15d715c 2007-07-06T03:36:31 make event_rpcgen.py use the uint_ types; make event.h include stdint.h (wonder which OS that will break) svn:r369
Niels Provos c1aa5480 2006-11-26T16:13:17 support #define in .rpc descriptions svn:r278
Niels Provos 3a15f7d4 2006-11-19T02:03:43 make it work with python2.2 svn:r267
Niels Provos 226fd50a 2006-11-18T21:27:42 use more python builtins; dont use reserved keywords svn:r266
Niels Provos ebf5333f 2006-05-17T13:13:31 oops. the enums were actually creating symbols svn:r212
Niels Provos a3bb4a03 2006-01-22T05:08:50 I often need some very simple HTTP functionality, so this is a first stab at integrating something really simple with HTTP. The interface is still evolving as I start messing with it. Not all the interfaces are properly exported yet. I am also trying to figure out how to intelligently hide the details about the different structures from users, so that that things can be changed around later. svn:r196
Niels Provos 50f7aaef 2005-09-09T06:56:12 make it compile on mac os x svn:r183
Niels Provos 7000fe66 2005-08-30T06:02:09 remove dos opportunity svn:r180
Niels Provos b4ab56dc 2005-08-28T23:48:16 support for arrays on structs. svn:r178
Niels Provos 32acc283 2005-08-27T06:29:52 a few more bug fixes svn:r177
Niels Provos 2813f1b0 2005-08-26T02:15:54 constify svn:r176
Niels Provos aaf56fb6 2005-08-23T07:43:11 fix API problems for get in some types svn:r175
Niels Provos 6e55da60 2005-08-22T01:39:54 typo svn:r174
Niels Provos e5ab86a7 2005-08-22T01:38:23 make use of the built in warn/err code svn:r173
Niels Provos c4e60994 2005-08-22T01:34:34 including the tagging code that is required by event_rpcgen.py; test the new functionality. svn:r172
Niels Provos 949cbd12 2005-08-21T16:25:02 generate marshalling code based on libevent svn:r171