Plug-in function registration method and device and electronic equipment

By setting a custom registration entry and a global registry manager in the source file of the plugin function, the high maintenance cost and low success rate caused by the reliance on centralized static function tables and global variables for plugin function registration are solved, thus achieving efficient and reliable plugin function management.

CN121879834APending Publication Date: 2026-04-17BEITAI ZHENHUAN (CHONGQING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEITAI ZHENHUAN (CHONGQING) TECH CO LTD
Filing Date
2026-03-20
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

In existing technologies, the registration of plugin functions relies on centralized static function table maintenance or registration based on global variables, resulting in high plugin maintenance costs and low registration success rates.

Method used

By adopting an automated and decoupled approach, a custom registration entry is set in the source file of the plugin function, and trigger conditions are bound. When the conditions are met, the plugin function information is automatically written into a globally unique global registry and managed using a registry manager.

Benefits of technology

It achieves efficient and reliable plugin function registration and retrieval, reduces maintenance costs, and improves registration success rate and system reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121879834A_ABST
    Figure CN121879834A_ABST
Patent Text Reader

Abstract

The invention discloses a plug-in function registration method and device and electronic equipment. The method comprises the steps that a source file of a to-be-registered plug-in function is obtained, the source file comprises a registration entry of the to-be-registered plug-in function, and the registration entry is bound with a preset trigger condition; under the condition that the triggering condition is met, registration information of the plug-in function to be registered is written into a global registry, and the global registry is used for storing registration information of all registered plug-in functions. According to the method and the device, the technical problems of high plug-in maintenance cost and low registration success rate due to the fact that the registration of the plug-in function depends on centralized static function table maintenance or a global variable-based registration mode in related technologies are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software development technology, and more specifically, to a method, apparatus, and electronic device for registering plug-in functions. Background Technology

[0002] As the scale of various software systems continues to expand, the demand for scalability, pluggability, and dynamic function integration continues to increase. Plug-in architecture has been widely used in various software such as scientific computing platforms, engineering software, graphics systems, integrated development environments, and data analysis systems.

[0003] In order for the host system to recognize the plugin's capabilities, the plugin needs to provide its exported function table. In related technologies, the registration of plugin functions generally relies on the following methods: centralized static function table maintenance or automatic registration based on global variables. These methods can meet the needs of small-scale plugins, but when the number of plugins is large, team collaboration is frequent, or the degree of modularity increases, problems such as high maintenance costs, uncontrollable initialization order, and insufficient extensibility will be encountered.

[0004] There is currently no effective solution to the above problems. Summary of the Invention

[0005] This application provides a method, apparatus, and electronic device for registering plug-in functions, which at least solves the technical problem in the related art that the registration of plug-in functions relies on centralized static function table maintenance or registration based on global variables, resulting in high plug-in maintenance costs and low registration success rates.

[0006] According to one aspect of the embodiments of this application, a method for registering a plugin function is provided, comprising: obtaining a source file of a plugin function to be registered, wherein the source file includes a registration entry point of the plugin function to be registered, and the registration entry point is bound to a preset trigger condition; and, when the trigger condition is met, writing the registration information of the plugin function to be registered into a global registry, wherein the global registry is used to store the registration information of all registered plugin functions.

[0007] In some embodiments of this application, writing the registration information of the plugin function to be registered into the global registry includes: determining a registration object corresponding to the registration entry point, wherein the registration object is used to reflect the registration behavior of the plugin function to be registered; when loading the registration object, calling the registration function corresponding to the registration object, and using the registration function to write the registration information of the plugin function to be registered into the global registry.

[0008] In some embodiments of this application, the registration object includes a registration macro, wherein the registration macro is used to declare the registration information of the plugin function to be registered; writing the registration information of the plugin function to be registered into the global registry includes: determining the static object corresponding to the registration macro when the source file is compiled; and calling the constructor corresponding to the static object to write the registration information into the global registry when the static object is loaded.

[0009] In some embodiments of this application, the global registry is managed by a registry manager. There is only one registry manager in the host system where the plugin function to be registered resides. The registry manager has a first interface for receiving first registration information of the plugin function and a second interface for the host system to query second registration information.

[0010] In some embodiments of this application, writing the registration information of the plugin function to be registered into the global registry includes: calling the first interface of the registration manager and writing the registration information of the plugin function to be registered into the global registry through the first interface.

[0011] In some embodiments of this application, the registration entry point includes one of the following: macros, annotations, reflection, decorators, and configuration metadata.

[0012] In some embodiments of this application, the triggering conditions are determined based on the computer language of the source file of the plugin function to be registered, and the triggering conditions include: the module containing the plugin function to be registered is loaded, the class containing the plugin function to be registered is initialized, and the plugin function to be registered is scanned.

[0013] According to another aspect of the embodiments of this application, another method for registering plug-in functions is also provided, including: receiving registration information corresponding to multiple plug-in functions to be registered in the host system, wherein the registration information is triggered based on the registration entry in the source file of the plug-in function to be registered, and the registration entry is bound to a preset trigger condition; storing the registration information in the global registry, wherein the global registry is used to store the registration information of all registered plug-in functions in the host system.

[0014] In some embodiments of this application, the method further includes: sending the global registry to the host system in response to a plugin query request from the host system.

[0015] According to another aspect of the embodiments of this application, a method for calling a plug-in function is also provided, comprising: obtaining a global registry, wherein the global registry is used to store registration information of all registered plug-in functions, the registration information is triggered based on the registration entry in the source file of the plug-in function, and the registration entry is bound to a preset trigger condition; and calling the plug-in function according to the global registry.

[0016] In some embodiments of this application, obtaining the global registry includes: sending a plugin query request to a registry manager, wherein the registry manager is used to manage the global registry, and the registry manager has a first interface for receiving registration information of plugin functions and a second interface for receiving plugin query requests; and receiving the global registry returned by the registry manager through the second interface.

[0017] According to another aspect of the embodiments of this application, a device for registering plug-in functions is also provided, comprising: a first acquisition module, configured to acquire the source file of the plug-in function to be registered, wherein the source file includes the registration entry of the plug-in function to be registered, and the registration entry is bound to a preset trigger condition; and a registration module, configured to write the registration information of the plug-in function to be registered into a global registry when the trigger condition is met, wherein the global registry is used to store the registration information of all registered plug-in functions.

[0018] According to another aspect of the embodiments of this application, a device for registering plug-in functions is also provided, comprising: a receiving module, configured to receive registration information corresponding to multiple plug-in functions to be registered in a host system, wherein the registration information is triggered based on the registration entry point in the source file of the plug-in function to be registered, and the registration entry point is bound to a preset trigger condition; and a storage module, configured to store the registration information in a global registry, wherein the global registry is used to store the registration information of all registered plug-in functions in the host system.

[0019] According to another aspect of the embodiments of this application, a device for calling a plug-in function is also provided, comprising: a second acquisition module, configured to acquire a global registry, wherein the global registry is used to store registration information of all registered plug-in functions, the registration information is triggered based on the registration entry in the source file of the plug-in function, and the registration entry is bound to a preset trigger condition; and a calling module, configured to call the plug-in function based on the global registry.

[0020] According to another aspect of the embodiments of this application, an electronic device is also provided, including: a memory and a processor, wherein the memory is used to store program instructions; the processor is connected to the memory and is used to execute the registration and invocation method for implementing the above-described plug-in function.

[0021] According to another aspect of the embodiments of this application, a non-volatile storage medium is also provided, the non-volatile storage medium including a stored computer program, wherein the device where the non-volatile storage medium is located executes the above-mentioned plug-in function registration and invocation method by running the computer program.

[0022] According to another aspect of the embodiments of this application, a computer program product is also provided, including computer instructions that, when executed by a processor, implement the above-described method for registering and calling plug-in functions.

[0023] In this embodiment, an automated and decoupled approach is adopted. By capturing source files containing plugin functions as registration resources, the source files have built-in custom registration entry points. These entry points are pre-bound to specific trigger conditions. When the specified trigger conditions are met, the registration entry points are automatically activated, and the relevant information of the plugin functions is automatically written into a globally unique global registry. This achieves the goal of unified and flexible management of plugin functions, thereby realizing the technical effect of efficient and reliable function registration and retrieval. It also solves the technical problem in related technologies where plugin function registration relies on centralized static function table maintenance or registration methods based on global variables, resulting in high plugin maintenance costs and low registration success rates. Attached Figure Description

[0024] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0025] Figure 1 This is a hardware structure block diagram of a computer terminal for a method of registering plug-in functions according to an embodiment of this application;

[0026] Figure 2 This is a flowchart of a method for registering a plug-in function according to an embodiment of this application;

[0027] Figure 3 This is a flowchart of another method for registering a plug-in function according to an embodiment of this application;

[0028] Figure 4 This is a flowchart of a method for calling a plugin function according to an embodiment of this application;

[0029] Figure 5 This is a schematic diagram of the registration manager structure of a method for registering plug-in functions according to an embodiment of this application;

[0030] Figure 6 This is a schematic diagram of the registration mechanism of a plugin function registration method according to an embodiment of this application;

[0031] Figure 7 This is a schematic diagram of a plug-in function registration device according to an embodiment of this application. Detailed Implementation

[0032] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0033] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0034] To better understand the embodiments of this application, the technical terms involved in the embodiments of this application are explained below:

[0035] Function Registry Manager: In this embodiment, it is responsible for storing and managing the registration information of all plugin functions. As a globally unique instance, it provides a unified registration and query interface, ensuring the automation of registration behavior and the decoupling of plugin functions, thereby improving the maintainability and scalability of the system.

[0036] Registration Entry Point: In this embodiment, the registration point declared in the plugin source file can be implemented through macros, annotations, metadata, etc. It is used to submit plugin function information to the function registration manager. The registration entry point enables the plugin function to automatically complete the registration when it is loaded or initialized (triggering condition) without modifying the core code of the host system, thus simplifying the team collaboration process.

[0037] In related technologies, the method of registering plugin functions using a centralized static function table means that all exported functions of a plugin are declared in a unified array. Every time a function is added or modified, this array must be modified. Therefore, conflicts occur frequently when multiple teams are collaborating, and the scalability is poor, making distributed maintenance impossible, especially when the number of plugins is large.

[0038] For automatic registration based on global variables, the global variables are automatically written to the function registry through their constructors. The initialization order of these global variables depends on the linker's decision, and this linker order may differ from the order of the source files or compilation units, and is not necessarily predictable or controllable. This means that if a plugin depends on the function registration information of another plugin, but the latter is initialized after the former due to the linker's random order, the first plugin to initialize may not find the required function information, leading to registration failure or incorrect order dependencies. Therefore, the initialization order between different compilation units cannot be guaranteed, resulting in registration failure or disordered order, and easily causing problems that cannot be repeatedly debugged.

[0039] To address the aforementioned technical problems, this application provides corresponding solutions, which are detailed below.

[0040] The plugin function registration method provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware block diagram of a computer terminal for implementing a method for registering plug-in functions is shown. Figure 1 As shown, the computer terminal 10 may include one or more processors (shown as 102a, 102b, ..., 102n in the figure) (the processor may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission module 106 for communication functions connected via wired and / or wireless networks. In addition, it may also include: a display, a keyboard, a cursor control device, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, and a BUS bus. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0041] It should be noted that the aforementioned one or more processors and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10. As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).

[0042] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the plug-in function registration method in this embodiment. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby implementing the aforementioned plug-in function registration method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0043] The transmission module 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission module 106 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission module 106 may be a radio frequency (RF) module, used for wireless communication with the Internet.

[0044] The display can be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10.

[0045] It should be noted here that, in some optional embodiments, the above... Figure 1 The computer terminal shown may include hardware components (including circuitry), software components (including computer code stored on a computer-readable medium), or a combination of both hardware and software components. It should be noted that... Figure 1 This is only one instance of a specific particular instance, and is intended to illustrate the types of components that may exist in the aforementioned computer terminal.

[0046] In the above operating environment, this application provides an embodiment of a method for registering plug-in functions. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Also, although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than that shown here.

[0047] Figure 2 This is a flowchart of a method for registering a plugin function according to an embodiment of this application, such as... Figure 2 As shown, the method includes the following steps:

[0048] Step S202: Obtain the source file of the plugin function to be registered. The source file includes the registration entry point of the plugin function to be registered, and the registration entry point is bound to the preset triggering conditions.

[0049] In step S202 above, the plugin function to be registered refers to the functional function in the plugin module that is expected to be recognized and called by the host system, such as instruction processing functions, algorithm functions, GUI operation instructions, data processing routines, etc. The source file contains the code implementation of the plugin function to be registered; it refers to the file written by the plugin developer, containing the specific plugin function implementation and registration entry point.

[0050] The registration entry is a special code snippet in the source file used to declare the registration behavior of plugin functions. It can be in the form of macro definitions, annotations, decorators, etc., and is bound to preset trigger conditions. Once the trigger conditions are met, the registration entry will automatically write the plugin function information to the global registry. The design of the registration entry greatly simplifies the registration process of plugin functions, so that developers do not need to directly intervene in the registration logic of the host system, thereby reducing code conflicts and maintenance difficulty.

[0051] In some embodiments of this application, the registration entry point includes one of the following: macros, annotations, reflection, decorators, and configuration metadata, specifically:

[0052] (1) Macro: A programming preprocessor language feature that can be expanded into a larger code snippet before compilation. It provides a concise way to declare function registration. Developers only need to specify function information in the source file, and the macro will be converted into code for registration behavior during compilation, ensuring the correct submission of function information.

[0053] (2) Annotations: Annotations are tags used to add metadata to code. They are usually parsed at compile time or runtime to guide the behavior of the compiler or runtime. In some programming languages, such as Java, annotations can serve as entry points for plugin function registration. They are used by the class loader or reflection API to automatically call the registration method, thereby achieving dynamic registration of plugin functions.

[0054] (3) Reflection: A programming technique that allows runtime inspection and invocation of object type information, including fields, constructors, and methods. Reflection can be used as a tool for automatic registration, especially in dynamic languages ​​such as Java and Python. By scanning classes and methods at runtime, it automatically registers qualified plugin functions into the manager, which solves the problems of initialization order and module loading order during function registration.

[0055] (4) Decorator: A common design pattern in object-oriented and functional programming, used to add extra behavior or attributes to a function without changing its original function signature. In dynamically typed languages ​​such as Python, decorators can serve as registration entry points, automatically recording the information of the decorated function in the registration manager, simplifying the registration process while ensuring that the original behavior of the function is not interfered with.

[0056] (5) Configuration Metadata: Configuration metadata is data used in software to describe and control software behavior. It is usually stored in a highly readable file format, such as XML or JSON. Configuration metadata can serve as another registration entry point, allowing plugins to dynamically update function information without modifying the code, which is beneficial for the later management and maintenance of plugins.

[0057] The preset triggering conditions are the conditions that determine when a plugin function is registered in the global registry. In some embodiments of this application, the triggering conditions are determined based on the computer language of the source file of the plugin function to be registered. The triggering conditions include, but are not limited to: the module containing the plugin function to be registered is loaded, the class containing the plugin function to be registered is initialized, and the plugin function to be registered is scanned.

[0058] The above registration entry point and triggering conditions constitute the automatic registration mechanism, which can be implemented differently in different languages, for example:

[0059] (1) C / C++: Static objects + macro expansion;

[0060] (2) Java: Reflection scanning during class loading;

[0061] (3) Python: Decorators are executed when a module is loaded;

[0062] (4) Rust: proc macros automatically insert registration code;

[0063] (5) C#: Attribute + AssemblyLoad event.

[0064] Each plugin function defines a corresponding registration object in its source file. When the object is loaded, the registration function is automatically called to write the plugin function information to the global registry. This approach allows developers to complete function registration in a distributed manner without having to centrally modify the main file, thus improving the efficiency of multi-person collaboration.

[0065] For step S202 above, during the compilation or loading phase, the source file preprocessor or loader locates and parses the source file with the registration entry identifier. For example, when using the C / C++ programming language, the registration entry can be identified by the preprocessor macro REGISTER_EXPORT_FUNCTION. When the host system loads the source file containing the macro, the macro will be expanded during compilation to generate the corresponding static object. This object is automatically executed when the module is loaded, passing the information of the plugin function to the global function registration manager.

[0066] Traditional plugin function registration methods (such as centralized static function table maintenance) require developers to manually add the registration information for each plugin function in the main file. This is extremely inconvenient in scenarios with a large number of plugins or frequent team collaboration, easily leading to version conflicts and increased maintenance difficulty. This embodiment of the application sets a registration entry point in the plugin source file. Each time a plugin function is added or modified, the operation only needs to be performed in the local source file, without touching the main file, greatly reducing the collaboration burden and improving development efficiency and code quality.

[0067] Step S204: If the triggering condition is met, the registration information of the plugin function to be registered is written to the global registry. The global registry is used to store the registration information of all registered plugin functions.

[0068] In step S204 above, the global registry is a data structure uniformly maintained by the system, used to store and manage the registration information of all plug-in functions, including function names, function addresses, help documents, etc. It not only provides an index of plug-in functions, but also ensures the integrity of function information and the dynamic calling of plug-in functions. Through the global registry, the host system can quickly locate and call the required plug-in functions without worrying about the specific location or loading status of the functions.

[0069] For example, in the automatic registration method during module loading, when a plugin module is loaded into the host system, the registration entry point within the module is triggered. This entry point calls the registration method of the global function registration manager to register all necessary information about the plugin function (such as function name, pointer, and metadata) in the global registry. As another example, in the dynamic registration method based on class initialization, in an object-oriented environment, when a class containing plugin functions is initialized for the first time, its static initialization block is executed. If a registration entry point is included in this process, the interface of the global function registration manager will be automatically called to store the plugin function's information in the global registry.

[0070] In some embodiments of this application, the global registry is managed by a registry manager. There is only one registry manager in the host system where the plugin function to be registered resides. The registry manager has a first interface for receiving first registration information of the plugin function and a second interface for the host system to query second registration information.

[0071] It should be noted that the registration manager is a globally unique component in the host system. It is responsible for receiving and managing the registration information of all plugin functions, providing registration and query interfaces, ensuring that all plugin function information is stored correctly and uniquely, and providing a unified way for the host system to access this information, thereby achieving decoupling and efficient management of plugin functions.

[0072] For example, its abstract structure can be described as follows:

[0073] class FunctionRegistry {

[0074] Register(FunctionInfo info)

[0075] List <functioninfo>GetExportedFunctions()

[0076] static FunctionRegistry&Instance()

[0077] }

[0078] The registration manager is globally unique, concurrent and safe, and is used to ensure that the initialization sequence is controllable. It stores the descriptions of all plugin exported functions (names, pointers, metadata, help documents, etc.). It provides a unified registration interface (first interface) and a query interface (second interface), which does not depend on the registration order or the module loading order.

[0079] In some embodiments of this application, the registration information of the plugin function to be registered can be written to the global registry in the following way: call the first interface of the registration manager, and write the registration information of the plugin function to be registered to the global registry through the first interface.

[0080] When the host system needs to call plugin functions, it can call the registry manager's query interface (such as GetExportedFunctions()), which returns a list of all plugin functions in the global registry.

[0081] To overcome the initialization order problem, the registration information of the plugin function to be registered can be written to the global registry in the following way: determine the registration object corresponding to the registration entry, whereby the registration object is used to reflect the registration behavior of the plugin function to be registered; when loading the registration object, call the registration function corresponding to the registration object, and use the registration function to write the registration information of the plugin function to be registered to the global registry.

[0082] It's important to note that the registration object is an object created in the plugin function's source file. It encapsulates the relevant information and registration behavior of the plugin function to be registered. The registration object typically has a constructor, which is called when the module is loaded, triggering the plugin function's registration process. The registration object separates the plugin function's registration logic from its implementation, allowing developers to complete the registration without directly interfering with the host system. They only need to declare the registration object within the plugin function's source file.

[0083] The registration function is the constructor or special method of the registration object. It is used to pass the registration information of the plugin function to the global function registration manager. It is a bridge between the plugin function and the global registry. When the triggering conditions are met (such as module loading), the registration function automatically performs the registration operation. For example, by calling the first interface of the registration manager, the registration function can ensure that the information of the plugin function is accurately and timely written into the global registry, so that the host system can discover and call these plugin functions.

[0084] In some embodiments of this application, the registration object includes a registration macro, which is used to declare the registration information of the plugin function to be registered. Under this premise, the registration information of the plugin function to be registered can be written to the global registry in the following way: when the source file is compiled, the static object corresponding to the registration macro is determined; when the static object is loaded, the constructor corresponding to the static object is called to write the registration information to the global registry.

[0085] Specifically, in combination Figure 6 After implementing a new function, developers only need to call the registration macro at the end of the source file. The macro expands during compilation and generates a static object (register_x). When this object is loaded, its constructor is triggered, which can automatically call the registration interface (first interface) of ExportFunctionManager (registration manager) to write the function information to the global registry. When the host system loads the plugin, it obtains the complete list of functions through the bxPluginFunctions interface, thereby realizing unified invocation of plugin functions. The entire process automates function registration, reduces error rate, and improves development efficiency and system reliability. For example, when the host system loads a plugin, it calls the GetExportedFunctions interface, which returns a complete list of functions, including all registered plugin functions. The host system can then invoke plugin functions through this function list.

[0086] In some embodiments of this application, combined with Figure 5 The source file containing each plugin function (e.g.) Figure 5 PluginFile_1.cp and other plugin files can independently call the registration macro REGISTER_EXPORT_FUNCTION to submit the function's information to the global registry. The global registry is managed uniformly by the ExportFunctionManager singleton class, which is responsible for storing and maintaining all plugin functions. Regardless of how many function files are involved in the development, their function information will eventually be centralized in the singleton's global registry. There is no need to modify the function registration array in the main file (such as main.cpp). The host system achieves unified management of plugin functions through the global registry of the singleton's data() function. This mechanism avoids the problem of centralized modification of the main file and greatly reduces the risk of conflicts when multiple people are collaborating.

[0087] Through steps S202 to S204 above, an automated and decoupled approach is adopted. By capturing the source file containing the plugin function as a registration resource, the source file has a built-in custom registration entry point. This entry point is pre-bound to a specific trigger condition. When the specified trigger condition is met, the registration entry point is automatically activated, and the relevant information of the plugin function is automatically written into a globally unique global registry. This achieves the goal of unified and flexible management of plugin functions, thereby realizing the technical effect of efficient and reliable function registration and retrieval. It also solves the technical problem in related technologies where the registration of plugin functions depends on centralized static function table maintenance or registration based on global variables, resulting in high plugin maintenance costs and low registration success rates.

[0088] Figure 3 This is a flowchart of another method for registering a plugin function according to an embodiment of this application, such as... Figure 3 As shown, the method includes:

[0089] Step S302: Receive registration information corresponding to multiple plugin functions to be registered in the host system. The registration information is triggered based on the registration entry point in the source file of the plugin function to be registered, and the registration entry point is bound to a preset trigger condition.

[0090] Step S304: Store the registration information in the global registry, whereby the global registry is used to store the registration information of all registered plugin functions in the host system.

[0091] In some embodiments of this application, the following steps may also be performed: in response to a plugin query request from the host system, a global registry is sent to the host system.

[0092] It should be noted that, Figure 3 Preferred embodiments of the shown examples can be found in [reference needed]. Figure 2 The corresponding solutions in the illustrated embodiments will not be described in detail here.

[0093] Figure 4 This is a flowchart of a method for calling a plugin function according to an embodiment of this application, such as... Figure 4 As shown, the method includes:

[0094] Step S402: Obtain the global registry, which stores the registration information of all registered plugin functions. The registration information is triggered based on the registration entry point in the source file of the plugin function, and the registration entry point is bound to a preset trigger condition.

[0095] In some embodiments of this application, the global registry can be obtained by: sending a plugin query request to a registry manager, wherein the registry manager is used to manage the global registry and has a first interface for receiving registration information of plugin functions and a second interface for receiving plugin query requests; and receiving the global registry returned by the registry manager through the second interface.

[0096] Step S404: Call the plugin function based on the global registry.

[0097] It should be noted that, Figure 4 Preferred embodiments of the shown examples can be found in [reference needed]. Figure 2 and Figure 3 The corresponding solutions in the illustrated embodiments will not be described in detail here.

[0098] In some embodiments of this application, the automatic registration process of plugin functions can be divided into the following steps:

[0099] (1) Define plugin functions: Developers only care about the functional code;

[0100] (2) Declaration of registration entry: using macros / annotations / decorators, etc.;

[0101] (3) Registration behavior is triggered when the module is loaded;

[0102] (4) The registration manager uniformly stores plugin function information;

[0103] (5) The host system obtains the function table and executes the function through a unified interface.

[0104] This application introduces a unified (globally unique) function registration manager, allowing each plugin function to register autonomously within its local module. Furthermore, a unified registration behavior is expressed through a registration entry mechanism (macros, annotations, metadata, decorators, etc.). Plugin functions declare their capabilities through the registration entry point, which is bound to an automatically executed trigger point (such as the constructor during module loading). When the module is loaded, a class is initialized, or a runtime scan occurs, the registration entry point is triggered, and the plugin function information is written to the registration manager. In addition, the host obtains all registered functions through a unified interface, enabling dynamic expansion without relying on a specific programming language; it can be implemented in environments such as C / C++, Rust, Java, C#, and Python.

[0105] By employing the above methods, centralized modification is avoided, eliminating the need to maintain a unified static array; registration is automated, automatically completed during module loading or runtime; cross-module distributed development is supported; initialization order and consistency are guaranteed; and a universal plugin ecosystem mechanism is constructed. In other words, the embodiments of this application not only provide a universal function registration mechanism, but also construct a scalable, reliable, and collaborative plugin function registration and management system applicable to various plug-in software systems. This system includes not only an underlying automatic registration and centralized management mechanism, but also flexible adaptation to the plugin architecture of different platforms, achieving unified organization and efficient scheduling of multi-source functional units.

[0106] This application provides a unified registration entry point for function registration macros, displaying the logic (pseudocode) in a macro-like format: REGISTER_FUNCTION(key, function_ptr, metadata). It provides developers with a unified registration entry point, simplifying the writing of registration code and avoiding repetitive work. Developers only need to call REGISTER_EXPORT_FUNCTION(function name, function pointer, help information) to complete the registration, reducing the error rate.

[0107] Figure 7 This is a structural diagram of a plug-in function registration device according to an embodiment of this application, such as... Figure 7 As shown, the device includes:

[0108] The first acquisition module 702 is used to acquire the source file of the plugin function to be registered. The source file includes the registration entry point of the plugin function to be registered, and the registration entry point is bound to a preset trigger condition.

[0109] Registration module 704 is used to write the registration information of the plugin function to be registered into the global registry when the triggering conditions are met. The global registry is used to store the registration information of all registered plugin functions.

[0110] It should be noted that, Figure 7 The registration device for the plugin function shown is used to execute Figure 2 The plugin function registration method shown, therefore Figure 2 The explanations regarding the plugin function registration method also apply to... Figure 7 The registration mechanism for the plugin functions shown will not be described further here.

[0111] This application embodiment also provides another plugin function registration device, which includes: a receiving module, used to receive registration information corresponding to multiple plugin functions to be registered in the host system, wherein the registration information is triggered based on the registration entry in the source file of the plugin function to be registered, and the registration entry is bound to a preset trigger condition; and a storage module, used to store the registration information in the global registry, wherein the global registry is used to store the registration information of all registered plugin functions in the host system.

[0112] It should be noted that the aforementioned alternative plugin function registration device is used to execute... Figure 3 The plugin function registration method shown, therefore Figure 3 The explanations regarding the registration method of the plugin function in the previous section also apply to the registration device of the other plugin function mentioned above, and will not be repeated here.

[0113] This application embodiment also provides a device for calling a plug-in function. The device includes: a second acquisition module, used to acquire a global registry, wherein the global registry is used to store the registration information of all registered plug-in functions, the registration information is triggered based on the registration entry in the source file of the plug-in function, and the registration entry is bound to a preset trigger condition; and a calling module, used to call the plug-in function according to the global registry.

[0114] It should be noted that the above-mentioned plugin function calling mechanism is used to execute... Figure 4 The plugin function registration method shown, therefore Figure 4 The explanations regarding the calling methods of plugin functions also apply to the aforementioned plugin function calling mechanisms, and will not be repeated here.

[0115] This application also provides an electronic device, which includes a memory and a processor. The memory is used to store program instructions, and the processor is connected to the memory and is used to execute the steps of registering the plug-in function in the various embodiments of this application.

[0116] This application also provides a non-volatile storage medium including a stored computer program, wherein the device containing the non-volatile storage medium executes the steps of the plug-in function registration method in various embodiments of this application by running the computer program.

[0117] This application also provides a computer program product, including computer instructions that, when executed by a processor, implement the steps of the plug-in function registration method in various embodiments of this application.

[0118] This application also provides a computer program that, when executed by a processor, implements the steps of the plug-in function registration method in various embodiments of this application.

[0119] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0120] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0121] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.

[0122] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0123] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0124] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0125] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.< / functioninfo>

Claims

1. A method of registering a plug-in function, characterized by, include: Obtain the source file of the plugin function to be registered, wherein the source file includes the registration entry of the plugin function to be registered, the registration entry is bound to a preset trigger condition, the registration entry includes a code snippet in the source file used to declare the registration behavior of the plugin function to be registered, and the trigger condition includes a condition determined based on the computer language of the source file for determining the timing of the plugin function to be registered in the global registry; If the triggering condition is met, the registration information of the plugin function to be registered is written into the global registry, wherein the global registry is used to store the registration information of all registered plugin functions.

2. The method of claim 1, wherein, Write the registration information of the plugin function to be registered into the global registry, including: Determine the registration object corresponding to the registration entry point, wherein the registration object is used to reflect the registration behavior of the plugin function to be registered; When loading the registration object, the registration function corresponding to the registration object is called, and the registration information of the plugin function to be registered is written to the global registry using the registration function.

3. The method of claim 2, wherein, The registration object includes a registration macro, wherein the registration macro is used to declare the registration information of the plugin function to be registered; writing the registration information of the plugin function to be registered into the global registry includes: During the compilation of the source file, the static object corresponding to the registered macro is determined; When the static object is loaded, the constructor corresponding to the static object is called to write the registration information into the global registry.

4. The method of claim 1, wherein, The global registry is managed by a registry manager. There is only one registry manager in the host system where the plugin function to be registered is located. The registry manager has a first interface for receiving first registration information of the plugin function and a second interface for the host system to query second registration information.

5. The method of claim 4, wherein, Write the registration information of the plugin function to be registered into the global registry, including: The first interface of the registration manager is invoked, and the registration information of the plugin function to be registered is written to the global registry through the first interface.

6. The method of claim 1, wherein, The registration entry points include one of the following: macros, annotations, reflection, decorators, and configuration metadata.

7. The method of claim 1, wherein, The triggering conditions are determined based on the computer language of the source file of the plugin function to be registered, and the triggering conditions include: the module containing the plugin function to be registered is loaded, the class containing the plugin function to be registered is initialized, and the plugin function to be registered is scanned.

8. A method of registering a plug-in function, characterized by, include: The system receives registration information corresponding to multiple plugin functions to be registered in the host system. The registration information is triggered based on the registration entry in the source file of the plugin function to be registered. The registration entry is bound to a preset trigger condition. The registration entry includes a code segment in the source file used to declare the registration behavior of the plugin function to be registered. The trigger condition includes a condition determined based on the computer language of the source file to determine the timing of registering the plugin function to be registered in the global registry. The registration information is stored in the global registry, which is used to store the registration information of all registered plugin functions in the host system.

9. The method of claim 8, wherein, The method further includes: in response to a plugin query request from the host system, sending the global registry to the host system.

10. A method for calling a plugin function, characterized in that, include: Obtain the global registry, wherein the global registry is used to store the registration information of all registered plug-in functions, the registration information is triggered based on the registration entry in the source file of the plug-in function, the registration entry is bound to a preset trigger condition, the registration entry includes a code segment in the source file used to declare the registration behavior of the plug-in function, and the trigger condition includes a condition determined based on the computer language of the source file to determine the timing of the plug-in function being registered in the global registry; The plugin function is called based on the global registry.

11. The method according to claim 10, characterized in that, Get the global registry, including: Send a plugin query request to the registry manager, wherein the registry manager is used to manage the global registry, and the registry manager has a first interface for receiving the registration information of the plugin function and a second interface for receiving the plugin query request; The global registry returned by the registration manager is received through the second interface.

12. A device for registering plug-in functions, characterized in that, include: The first acquisition module is used to acquire the source file of the plugin function to be registered. The source file includes the registration entry of the plugin function to be registered. The registration entry is bound to a preset trigger condition. The registration entry includes a code segment in the source file used to declare the registration behavior of the plugin function to be registered. The trigger condition includes a condition determined based on the computer language of the source file to determine the timing of registering the plugin function to be registered in the global registry. The registration module is used to write the registration information of the plugin function to be registered into the global registry when the triggering conditions are met. The global registry is used to store the registration information of all registered plugin functions.

13. A device for registering plug-in functions, characterized in that, include: The receiving module is used to receive registration information corresponding to multiple plugin functions to be registered in the host system. The registration information is triggered based on the registration entry in the source file of the plugin function to be registered. The registration entry is bound to a preset trigger condition. The registration entry includes a code segment in the source file used to declare the registration behavior of the plugin function to be registered. The trigger condition includes a condition determined based on the computer language of the source file to determine the timing of the plugin function to be registered in the global registry. A storage module is used to store the registration information to a global registry, wherein the global registry is used to store the registration information of all registered plug-in functions in the host system.

14. A device for calling a plug-in function, characterized in that, include: The second acquisition module is used to acquire the global registry, wherein the global registry is used to store the registration information of all registered plug-in functions. The registration information is triggered based on the registration entry in the source file of the plug-in function. The registration entry is bound to a preset trigger condition. The registration entry includes a code segment in the source file used to declare the registration behavior of the plug-in function. The trigger condition includes a condition determined based on the computer language of the source file to determine the timing of the plug-in function being registered in the global registry. The calling module is used to invoke the plugin functions based on the global registry.

15. An electronic device, characterized in that, include: A memory and a processor, wherein the memory is used to store program instructions; the processor is connected to the memory and is used to execute the method for registering a plug-in function according to any one of claims 1 to 7, or to execute the method for registering a plug-in function according to any one of claims 8 to 9, or to execute the method for calling a plug-in function according to any one of claims 10 to 11.

16. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored computer program, wherein the device containing the non-volatile storage medium executes the plug-in function registration method according to any one of claims 1 to 7, or executes the plug-in function registration method according to any one of claims 8 to 9, or executes the plug-in function invocation method according to any one of claims 10 to 11 by running the computer program.

17. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the method for registering the plug-in function as described in any one of claims 1 to 7, or the method for registering the plug-in function as described in any one of claims 8 to 9, or the method for calling the plug-in function as described in any one of claims 10 to 11.