diff --git a/src/_watchdog_fsevents.c b/src/_watchdog_fsevents.c index 8ab109f9..bd5d515a 100644 --- a/src/_watchdog_fsevents.c +++ b/src/_watchdog_fsevents.c @@ -215,12 +215,18 @@ static PyMethodDef _watchdog_fseventsmethods[] = /** - * Adds all the module attributes. + * Adds all the _watchdog_fsevents module attributes and is meant only to be + * called within the module initialization function. * * :param module: * The module to which attributes will be added. * :type module: * A pointer to a Python object representing a module. + * + * Attributes added: + * __version__: tuple denoting the version number of the module. + * VERSION_INFO: tuple denoting the version number of the module. + * VERSION_STRING: string denoting the version number of the module. */ static void Watchdog_AddModuleAttributes(PyObject *module) @@ -236,16 +242,30 @@ Watchdog_AddModuleAttributes(PyObject *module) PyModule_AddIntConstant(module, MODULE_CONSTANT_NAME_POLLOUT, kCFFileDescriptorWriteCallBack); + /* Version tuple */ PyModule_AddObject(module, MODULE_ATTRIBUTE_NAME_VERSION, version_tuple); PyModule_AddObject(module, MODULE_ATTRIBUTE_NAME_VERSION_INFO, version_tuple); + /* Version string */ PyModule_AddObject(module, MODULE_ATTRIBUTE_NAME_VERSION_STRING, Py_BuildValue("s", WATCHDOG_VERSION_STRING)); + /* major version */ + PyModule_AddIntConstant(module, + MODULE_CONSTANT_NAME_VERSION_MAJOR, + WATCHDOG_VERSION_MAJOR); + /* minor version */ + PyModule_AddIntConstant(module, + MODULE_CONSTANT_NAME_VERSION_MINOR, + WATCHDOG_VERSION_MINOR); + /* build version */ + PyModule_AddIntConstant(module, + MODULE_CONSTANT_NAME_VERSION_BUILD, + WATCHDOG_VERSION_BUILD); } diff --git a/src/_watchdog_fsevents.h b/src/_watchdog_fsevents.h index 8ebecd6a..9c57237f 100644 --- a/src/_watchdog_fsevents.h +++ b/src/_watchdog_fsevents.h @@ -57,6 +57,9 @@ typedef int Py_ssize_t; #define MODULE_NAME "_watchdog_fsevents" #define MODULE_CONSTANT_NAME_POLLIN "POLLIN" #define MODULE_CONSTANT_NAME_POLLOUT "POLLOUT" +#define MODULE_CONSTANT_NAME_VERSION_MAJOR "VERSION_MAJOR" +#define MODULE_CONSTANT_NAME_VERSION_MINOR "VERSION_MINOR" +#define MODULE_CONSTANT_NAME_VERSION_BUILD "VERSION_BUILD" #define MODULE_ATTRIBUTE_NAME_VERSION "__version__" #define MODULE_ATTRIBUTE_NAME_VERSION_INFO "VERSION_INFO" #define MODULE_ATTRIBUTE_NAME_VERSION_STRING "VERSION_STRING" @@ -90,7 +93,8 @@ typedef struct _StreamCallbackInfo } StreamCallbackInfo; /** - * Macro that forces returning NULL if given argument is NULL. + * Macro that forces returning NULL from the caller function if given argument + * is NULL. */ #define RETURN_NULL_IF_NULL(o) \ do \ @@ -100,7 +104,8 @@ typedef struct _StreamCallbackInfo while(0) /** - * Macro that forces returning NULL if given argument is true. + * Macro that forces returning NULL from the caller function if given argument + * is truthy. */ #define RETURN_NULL_IF(c) \ do \ @@ -110,7 +115,8 @@ typedef struct _StreamCallbackInfo while(0) /** - * Macro that forces returning NULL if given argument is false. + * Macro that forces returning NULL from the caller function if given argument + * is falsy. */ #define RETURN_NULL_IF_NOT(c) \ do \ @@ -120,7 +126,8 @@ typedef struct _StreamCallbackInfo while(0) /** - * Macro that forces returning if given argument is true. + * Macro that forces returning from the caller function if given argument is + * truthy. */ #define RETURN_IF(c) \ do \ @@ -130,7 +137,8 @@ typedef struct _StreamCallbackInfo while(0) /** - * Macro that forces returning if given argument is false. + * Macro that forces returning from the caller function if given argument is + * falsy. */ #define RETURN_IF_NOT(c) \ do \ @@ -139,13 +147,15 @@ typedef struct _StreamCallbackInfo } \ while(0) +/** + * Latency (float) for the event streams registered with the FSEvents API. + */ #define FS_EVENT_STREAM_LATENCY (0.01) -/* Initialization. */ +/* Initializes internal data structures when the module is initialized. */ void Watchdog_FSEvents_Init(void); - /* CFRunLoopForEmitter global dict functions. */ CFRunLoopRef Watchdog_CFRunLoopForEmitter_GetItem(PyObject *emitter_thread);