mirror of
https://github.com/mumble-voip/mumble.git
synced 2025-10-26 11:19:16 +00:00
3.6 KiB
3.6 KiB
Incrementing the Mumble API version
Overview
Plugins are used to extend the Mumble client with custom functionality. They are compiled against multiple header files which contain all function and structure signatures that can be used by the plugin. If you are commiting breaking API changes (such as additions or deletions) to these function signatures on the Mumble side, the API version will probably have to be increased. This is done to ensure plugins will have access to these functions when they are compiled against the new API version, while old plugins, using previous API versions, will still work.
Instructions
If your commit includes breaking API changes, the following steps have to be followed:
- Create a new
Mumble_API_v_<MA>_<MI>_x.hfile in plugins/.- Replace
<MA>with the API major version and<MI>with the API minor version. - Usually, you will have to increase the
<MI>version by 1 compared to the previous latest version. So if the previous API string was1.2.0, you would probably want to increase the second number by one and create the fileMumbleAPI_v_1_3_x.h. - The last "patch" digit of the version string is reserved for non-breaking API changes such as small fixes. Since non-breaking changes do not require a major or minor API increment, we do not worry about the "patch" digit in this document.
- Replace
- Make sure you correctly set the
MUMBLE_PLUGIN_API_MAJOR_MACRO,MUMBLE_PLUGIN_API_MINOR_MACROand include guard to the new API version.- You probably want to set the
MUMBLE_PLUGIN_API_PATCH_MACROto0.
- You probably want to set the
- Rename the
structwithin the file to match the new API version string.- There is a
typedefat the end of the file which has to use the newstructname, too.
- There is a
- Make your desired changes to the function signatures contained in the header file.
- Open the MumbleAPI_structs.h file and add your new API header file as first include.
- Move the previous first include, the last most recent API version, into the
NO_AUXILIARY_DEFINITIONSsection. - This will make sure auxiliary variables and macros always contain the most recent version on the mumble side.
- Move the previous first include, the last most recent API version, into the
- Add an
elsecase to the Plugin.cpp file in thePlugin::initmethod.- You will want to return the newly created
struct, if the API version requested by the plugin matches your new one.
- You will want to return the newly created
- Create a new function signature in API.h. It should return your new
structand be of the namegetMumbleAPI_v_<MA>_<MI>_x. - Amend the previous
API_v_<MA>_x_x.cppfile, or create a new one in this folder.- For the foreseeable future, reuse the previous cpp file. Creating a new cpp file will probably only be useful on extensive API re-designs.
- If you have created a new
API_v_<MA>_x_x.cpp, you must add it to the CMakeLists.txt.
- Implement the
getMumbleAPI_v_<MA>_<MI>_xfunction inside theAPI_v_<MA>_x_x.cppfile and return a struct with all functions you want to expose in your API version. - When adding a new function or new function signature, copy an existing "C FUNCTION WRAPPER" inside the
API_v_<MA>_x_x.cppfile. That wrapper should then call your new function. - Implement your new API changes in the
API_v_<MA>_x_x.cppfile.- If you change the signature of an old function, it is probably best to call the new function in the old implementation with default values.
- This way, old plugins will still be working more or less as expected.