A data calling method and related equipment

By obtaining the interface data of the SO module and establishing the initial data calling template, and generating the target data calling function with the parameters of the function to be called, the problem of complex writing and maintenance of interface signatures is solved, and the correct correspondence between signature information and interface information is achieved and the program is achieved. stability.

CN115080006BActive Publication Date: 2025-01-10SHENZHEN KINGSPEC ELECTRONICS TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110277530.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-15
Publication Date
2025-01-10
Estimated Expiration
2041-03-15

AI Technical Summary

Technical Problem

The interface signature writing process of existing SO modules is complicated, which can easily lead to errors in the correspondence between signature information and interface information. It is easy to forget to modify the signature when adding parameters, resulting in program crashes and difficulty in maintaining.

Method used

By obtaining the interface data of the SO module, establishing an initial data calling template, and generating the target data calling function in combination with the function parameters to be called, completing the data call based on the objective function, ensuring that the signature information corresponds to the interface information, and reducing the risk of writing errors.

Benefits of technology

The interface signature writing process is simplified, the risk of errors in the correspondence between signature information and interface information is reduced, and the convenience of program maintenance and development efficiency is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115080006B_ABST
    Figure CN115080006B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a data calling method and related equipment, which comprises: obtaining interface data of an SO module, wherein the interface data comprises a name of a class corresponding to an application layer, a name of an interface function corresponding to the application layer and signature information corresponding to the application layer; establishing an initial data calling template according to the name of the class of the application layer, the name of the interface function corresponding to the application layer and signature information corresponding to the application layer; obtaining parameters of a function to be called according to a request for calling the interface data; generating a target data calling function according to the parameters of the function to be called and the initial data calling template; and completing the calling of data in the SO module based on the target data calling function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a data calling method and related equipment. Background Art

[0002] In the prior art, since the SO module is a functional module written in C++, when providing data to the application layer, it is necessary to define the interface signature of the application layer corresponding to each interface in the SO module, and the interface signature has different writing equations and methods due to different parameter types. The writing method of each interface of the existing SO module is to write the signature information of the application layer and the interface information separately, which will lead to a complicated signature writing process of the interface of the SO module, and when adding new parameters, it is easy to forget to modify the signature of the interface of the SO module, resulting in a program crash. At the same time, writing the signature information and interface information of the application layer separately is likely to cause errors in the correspondence between the signature information and the interface information, or writing errors, which makes it difficult for developers to maintain the program, especially when there are more and more interfaces, then the maintenance of the program becomes more difficult. Summary of the invention

[0003] The embodiment of the present invention provides a data calling method and related equipment, which realizes the data calling of function modules written in C++ language such as SO modules when providing data to the application layer.

[0004] In a first aspect, an embodiment of the present invention provides a data calling method, comprising:

[0005] Acquire interface data of the SO module, wherein the interface data includes the name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer, and the signature information corresponding to the application layer;

[0006] Establishing an initial data call template according to the name of the class of the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer;

[0007] Obtaining parameters of the function to be called according to a request for calling the interface data;

[0008] Generate a target data calling function according to the to-be-called function parameters and the initial data calling template;

[0009] The calling function is called based on the target data to complete the calling of the data in the SO module.

[0010] Optionally, the step of establishing an initial data call template according to the name of the class of the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer includes:

[0011] The name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer are stored to obtain a data structure;

[0012] The data structure is used as the initial data calling template.

[0013] Optionally, the step of storing the name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer, and the signature information corresponding to the application layer to obtain a data structure includes:

[0014] The name of the class of the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer are stored according to the set storage method to obtain the data structure.

[0015] Optionally, before the step of generating the target data calling template according to the data to be called and the initial data calling template, the method further includes:

[0016] Storing the initial data calling template in the preset interface of the SO module;

[0017] The initial data calling template is subjected to a uniqueness check.

[0018] Optionally, the step of storing the initial data calling template in a preset interface of the SO module includes:

[0019] Write the preset interface of the SO module:

[0020] bool AddMethod(char*classname,char*methodname,char*methodsig){

[0021] Where AddMethod is the name of the interface, classname is the name of the class corresponding to the application layer, methodname is the name of the method corresponding to the application layer, and methodsig is the signature information of the interface corresponding to the application layer;

[0022] The initial data calling template is stored in the preset interface of the written SO module.

[0023] Optionally, the step of obtaining parameters of the function to be called according to the request for calling the interface data includes:

[0024] According to the request for calling the interface data, the data to be called corresponding to the request is registered to the initial data calling template to obtain the parameters of the function to be called, wherein the function parameters include the function name of the data to be called, the parameters of the data to be called and the signature information of the application layer.

[0025] Optionally, also include:

[0026] Real-time statistics of the number of the initial data calling templates in the preset interface;

[0027] Log output is performed for any of the initial data calling templates according to the number of the initial data calling templates.

[0028] In a second aspect, an embodiment of the present application provides a data calling device, including:

[0029] A data acquisition module, used to obtain interface data of the SO module, wherein the interface data includes the name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer;

[0030] A template creation module, used to create an initial data call template according to the name of the class of the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer;

[0031] A data extraction module, used for obtaining parameters of the function to be called according to a request for calling the interface data;

[0032] A generating module, used for generating a target data calling function according to the to-be-called function parameters and the initial data calling template;

[0033] The calling module is used to call the function based on the target data to complete the call to the data in the SO module.

[0034] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor is configured to implement the steps of the data calling method described above when executing the computer program stored in the memory.

[0035] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored: when the computer program is executed by a processor, the steps of the data calling method as described above are implemented.

[0036] The embodiments of the above invention have the following advantages or beneficial effects:

[0037] By obtaining the interface data of the SO module, wherein the interface data includes the name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer; according to the name of the class of the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer, an initial data call template is established; according to the request for calling the interface data, the parameters of the function to be called are obtained; according to the parameters of the function to be called and the initial data call template, a target data call function is generated; and based on the target data call function, the call to the data in the SO module is completed. The interface data including the name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer are combined with the function parameters of the data to be called to generate the target data call function, so as to facilitate the correspondence between the signature information and the interface information, reduce the risk of the signature information and the interface information of the application layer being written separately during data calling, resulting in an error in the correspondence between the signature information and the interface information, or a writing error, thereby facilitating the maintenance of the program by developers. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 is a flow chart of a data calling method provided by an embodiment of the present application;

[0039] Figure 2 It is a structural diagram of a data calling device provided in an embodiment of the present application;

[0040] Figure 3 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application;

[0041] Figure 4 It is a structural schematic diagram of a storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION

[0042] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0043] Figure 1 This is a flow chart of a data calling method provided by an embodiment of the present application. The data calling method provided by this embodiment compiles the exported data and the interface signature definition together, so that developers can easily maintain the program, while also avoiding the risk of the program crashing due to the developer forgetting to add the signature. The method can be executed by a data calling device, which can be implemented by software and / or hardware, and is usually integrated in a terminal.

[0044] like Figure 1As shown, a data calling method includes:

[0045] S101. Obtain interface data of the SO module, wherein the interface data includes a name of a class corresponding to the application layer, a name of an interface function corresponding to the application layer, and signature information corresponding to the application layer;

[0046] In a possible implementation, the step of establishing an initial data call template according to the name of the class of the application layer, the name of the interface function corresponding to the application layer, and the signature information corresponding to the application layer includes:

[0047] The name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer are stored to obtain a data structure;

[0048] The data structure is used as the initial data calling template.

[0049] For example, define a data structure to contain all the data:

[0050] Struct methodinfo{

[0051] string classname;

[0052] string methodname;

[0053] string methodsig;}

[0054] Among them, string classname; implements the use of string to store the name of the corresponding application layer class; string methodname; is used to store the interface name of the application layer corresponding to the SO module interface; stringmethodsig; is used to store the function signature information of the application layer interface corresponding to the SO module interface, that is, the return value type of the function and all parameter types; Struct methodinfo is the functional statement that defines the structure.

[0055] Exemplarily, a data structure is used to store the name of the corresponding application layer class, the name of the corresponding application layer interface and the function signature information of the corresponding application layer interface, so as to facilitate the subsequent rapid search for the SO module interface.

[0056] In a possible implementation, the step of storing the name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer, and the signature information corresponding to the application layer to obtain a data structure includes:

[0057] The name of the class of the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer are stored according to the set storage method to obtain the data structure.

[0058] For example, the set function statement is used:

[0059] set <methodinfo>methodset;

[0060] Implementing set storage can ensure that a method of a class is unique, which is convenient for developers to check. When duplicate methods are defined, the above set function statement can detect the existence of duplicate methods and then inform the developer that an error has occurred.

[0061] S102, establishing an initial data call template according to the name of the class of the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer;

[0062] In a possible implementation, the step of generating a target data calling template according to the data to be called and the initial data calling template includes:

[0063] Storing the initial data calling template in the preset interface of the SO module;

[0064] The initial data calling template is subjected to a uniqueness check.

[0065] Exemplarily, the preset interface of the SO module is written:

[0066] bool AddMethod(char*classname,char*methodname,char*methodsig){

[0067] Wherein, AddMethod is the name of the interface, classname is the name of the class corresponding to the application layer, methodname is the name of the method corresponding to the application layer, and methodsig is the signature information of the interface corresponding to the application layer.

[0068] Exemplarily, the preset interface of the SO module is written to store the interfaces other than the preset ones on the SO module and the methods of calling data of the above-mentioned application layer, and a uniqueness detection is performed on whether there are identical methods in the methods of calling data of the interfaces other than the preset ones and the above-mentioned application layer, so that it can be known whether there are human development errors during the development stage.

[0069] In a possible implementation, the step of performing a uniqueness check on the initial data calling template includes:

[0070] Construct a methodinfo structure

[0071] Methodinfo m(classname,methodname,methodsig);

[0072] The parameters of the above structure are: classname is the name of the class corresponding to the application layer, methodname is the name of the method corresponding to the application layer, and methodsig is the signature information of the interface corresponding to the application layer.

[0073] Bool bFond=methodset.find(m);

[0074] Use the set to find the interface to see if there is a duplicate interface.

[0075] If the return value bFond is true, it means that the same interface is found, which means that the above interface has been stored before, an error is reported, and the developer is prompted that the current interface has been created before. Therefore, errors in the program can be discovered during program development without reporting errors during program execution.

[0076] If the return value bFond is false, it means that it is not found. You can use the insert statement:

[0077] Methodset.insert(m);

[0078] Insert the above interface.

[0079] For example, errors are discovered in a timely manner during the program development process, avoiding the need to discover errors only when the program is executed, thereby avoiding the need for developers to check the entire program, reducing the developer's workload and improving R&D efficiency.

[0080] In a possible implementation, the step of performing a uniqueness check on the initial data calling template includes:

[0081] Define the first macro command:

[0082] #define CHECK_METHOD(classname,methodname,methodsig)\

[0083] static bool bstatic_##methodid=AddMethod(classname,methodname,methodsig);\

[0084] The initial data call template is detected, wherein the macro command uses the static variable bstatic_##methodid, AddMethod is the preset interface name of the module that provides data for the application layer, Classname is the name of the class corresponding to the application layer, methodname is the interface function name corresponding to the application layer, and methodsig is the signature information corresponding to the application layer.

[0085] For example, when writing an interface, the completed interface is checked immediately, so that the developer can promptly understand whether the currently written interface has been registered during development, and the definition and check of the written interface parameters are bound together to form an integral whole. If the above interface is modified later, the parameter modification will not be missed.

[0086] S103, obtaining parameters of the function to be called according to the request for calling the interface data;

[0087] In a possible implementation, the interface hasId in the SO module is written to provide it to the application layer:

[0088] CHECK_METHOD(javaClassName,"hasId","(I)Z")

[0089] JNIEXPORT jboolean JNICALL Java_com_hashId(JNIEnv*_env,jclass,jint_taskid){

[0090] Among them, JNIEXPORT means that this interface is exported to the application layer for use, jboolean represents the return value, JNICALL represents the function to be called in the SO module, Java_com_hashId is the name of the function to be called in the SO module, and JNIEnv*_env, jclass, and jint_taskid are the parameters of the function to be called in the SO module.

[0091] Exemplarily, calling the second macro command:

[0092] CHECK_METHOD(javaClassName,"hasId","(I)Z")

[0093] Among them, CHECK_METHOD is the first macro command mentioned above; javaClassName is the class name of the application layer corresponding to the so module interface; "hasId" is the application layer function name corresponding to the so module interface in the application layer; "(I)Z" represents the signature information of the so module interface, where the signature information is the parameters and return values ​​of the function to be called in the so module.

[0094] In a possible implementation, the step of obtaining parameters of the function to be called according to the request for calling the interface data includes:

[0095] According to the request for calling the interface data, the data to be called corresponding to the request is registered to the initial data calling template to obtain the parameters of the function to be called, wherein the function parameters include the function name of the data to be called, the parameters of the data to be called and the signature information of the application layer.

[0096] Exemplarily, the interface detection of the SO module and the definition process of the application layer function are arranged before the process of accessing the interface, so as to avoid forgetting to define the interface definition of the SO module corresponding to the application layer. At the same time, when it is necessary to modify the number of parameters or parameter types, since the definition of the application layer function and the interface definition process of the SO module corresponding to the application layer are together, it is convenient to modify and it is not easy to forget to modify. At the same time, AddMethod is called in the specific implementation of the macro to check the function to prevent the same function from being written and to detect writing errors in time.

[0097] S104, generating a target data calling function according to the to-be-called function parameters and the initial data calling template;

[0098] In a possible implementation manner, before calling a function based on the target data to complete the calling of the data in the SO module, the method further includes:

[0099] Verify the function signature of the interface.

[0100] For example, scan all interfaces with JNIEXPORT;

[0101] Scan out all CHECK_METHOD interface calls;

[0102] Verify based on all interfaces with JNIEXPORT and all interfaces with CHECK_METHOD.

[0103] For example, if the SO module interface defines JNIEXPORT, it means that the above interface is an interface provided to the application layer for calling. When the above interface does not define the interface call of CHECK_METHOD, an alarm is issued to prompt the developer that the current interface does not define the interface call of CHECK_METHOD, so that error prompts can be directly given during the development stage.

[0104] If the developer defines an interface call of CHECK_METHOD, it will check whether there is a one-to-one corresponding method in the class and interface of the application layer for the interface name provided to the application layer by the above interface. The above interface includes the class name, method name and parameter signature of the corresponding application layer. If the interface name provided to the application layer by the above interface does not find a one-to-one corresponding method in the class and interface of the application layer, an alarm will also be issued to prompt the developer that the current definition is wrong.

[0105] Furthermore, the interface signature and parameter matching are checked, because even if the interface is defined and the method of the application layer is also defined, the parameter type can only be known whether it matches when the program is executed, and the program execution needs to go through a complex process of packaging, compilation, execution, etc. By scanning the interface declared as JNIEXPORT on the so module, the return value, number of parameters, and parameter type of each parameter of the above JNIEXPORT interface are obtained.

[0106] Find the signature information methodsig when the interface is registered from CHECK_METHOD. Based on the above signature information, the function return value, the number of parameters and the parameter type of each parameter can be parsed.

[0107] The parsed parameters are compared with the signature information methodsig passed in CHECK_METHOD to check whether the parameters are consistent with all the parameters of the signature information. If they are inconsistent, the developer can be directly prompted that the current definition is incorrect, so that parameter errors or return value errors are directly prompted during the development stage, thereby avoiding the problem of developers discovering parameter mismatches during program execution and causing program crashes.

[0108] In a possible implementation manner, before the step of calling a function based on the target data to complete the calling of the data in the SO module, the method further includes:

[0109] When the so module is initialized, check whether all interface parameters are consistent with the application layer signature information;

[0110] If there is any inconsistency, an alarm will be triggered and the technician will be notified.

[0111] Exemplarily, the corresponding Java class instance is obtained: when the above-mentioned data to be called is registered, three parameters classname, methodname, and methodsig are bound, which are the class name, method name, and method signature information respectively.

[0112] Through the function statement:

[0113] class cls=env->FindClass(classname);

[0114] Use the FindClass of the jni interface to find out whether this java class exists, and get the search result through the return value cls. If it does not exist, it means that the application layer does not have this interface, then an alarm is issued and an error message is given;

[0115] Get the corresponding java class method:

[0116] After obtaining the corresponding Java class, obtain the method of the corresponding Java class. If the method and parameters match, the method can be obtained. If the method and parameters do not match, and the obtained method is empty, it can be directly judged that the current parameters or methods do not match, indicating that there is an error and an alarm is issued.

[0117] Through the function:

[0118] jmethodID mid=env->GetMethodID(cls,methodname,methodsig);

[0119] Among them, cls is the Java class found above, methodname is the method of the SO module interface corresponding to the application layer, and methodsig represents the signature information of the corresponding Java class method.

[0120] If the return value mid is not empty, it means that the corresponding Java class method has been found;

[0121] If the return value mid is empty, it means that the corresponding Java class method is not found, then an error message may be prompted and an alarm may be issued.

[0122] S105: Calling a function based on the target data completes calling the data in the SO module.

[0123] In a possible implementation, it further includes:

[0124] Real-time statistics of the number of the initial data calling templates in the preset interface;

[0125] Log output is performed for any of the initial data calling templates according to the number of the initial data calling templates.

[0126] For example, the interface AddMethod is defined to register all interfaces, and a variable methodset is used to store all interfaces in the SO module for the Java layer. It is easy to count the number of interfaces provided by the current SO module, and then it is convenient to log all interfaces. That is, you only need to traverse all elements in the methodset, and all interfaces can be easily output at the same time, so as to compare the number of interfaces and parameter types in the above SO module, and understand the functions defined by the above SO module. Based on the unified interface, it is also convenient to add functions such as interface registration monitoring, historical change information of the interface, etc.

[0127] By obtaining the interface data of the SO module, wherein the interface data includes the name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer; according to the name of the class of the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer, an initial data call template is established; according to the request for calling the interface data, the parameters of the function to be called are obtained; according to the parameters of the function to be called and the initial data call template, a target data call function is generated; and based on the target data call function, the call to the data in the SO module is completed. The interface data including the name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer are combined with the function parameters of the data to be called to generate the target data call function, so as to facilitate the correspondence between the signature information and the interface information, reduce the risk of the signature information and the interface information of the application layer being written separately during data calling, resulting in an error in the correspondence between the signature information and the interface information, or a writing error, thereby facilitating the maintenance of the program by developers. The interface of each SO module is checked immediately when it is written, so that developers can easily know whether the interface has been registered during development, and the definition and check of its interface parameters are integrated, and if there are any subsequent modifications, the parameter modifications will not be missed.

[0128] Second, as Figure 2 As shown, the embodiment of the present application provides a data calling device, including:

[0129] The data acquisition module 201 is used to obtain the interface data of the SO module, wherein the interface data includes the name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer;

[0130] A template creation module 202, configured to create an initial data call template according to the name of the class of the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer;

[0131] A data extraction module 203 is used to obtain parameters of the function to be called according to the request for calling the interface data;

[0132] A generating module 204, configured to generate a target data calling function according to the to-be-called function parameters and the initial data calling template;

[0133] The calling module 205 is used to complete the calling of the data in the SO module based on the target data calling function.

[0134] See also Figure 3 , Figure 3 A schematic diagram of an embodiment of an electronic device provided in an embodiment of the present application.

[0135] like Figure 3 As shown, an embodiment of the present application provides an electronic device, including a memory 310, a processor 320, and a computer program 311 stored in the memory 310 and executable on the processor 320. When the processor 320 executes the computer program 311, the following steps are implemented: obtaining interface data of the SO module, wherein the interface data includes the name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer, and the signature information corresponding to the application layer; establishing an initial data call template according to the name of the class of the application layer, the name of the interface function corresponding to the application layer, and the signature information corresponding to the application layer; obtaining parameters of a function to be called according to a request to call the interface data; generating a target data call function according to the parameters of the function to be called and the initial data call template; and completing the call to the data in the SO module based on the target data call function.

[0136] like Figure 4 As shown, this embodiment provides a computer-readable storage medium 400, on which a computer program 411 is stored. When the computer program 411 is executed by a processor, the following steps are implemented: obtaining interface data of the SO module, wherein the interface data includes the name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer, and the signature information corresponding to the application layer; establishing an initial data call template according to the name of the class of the application layer, the name of the interface function corresponding to the application layer, and the signature information corresponding to the application layer; obtaining parameters of the function to be called according to a request to call the interface data; generating a target data call function according to the parameters of the function to be called and the initial data call template; and completing the call to the data in the SO module based on the target data call function.

[0137] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0138] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0139] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0140] Computer program code for performing the operation of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0141] It should be understood by those skilled in the art that the modules or steps of the present invention described above can be implemented by a general-purpose computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, optionally, they can be implemented by a program code executable by a computer device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0142] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.< / methodinfo>

Claims

1. A data calling method, characterized in that: include: Acquire interface data of the SO module, wherein the interface data includes the name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer, and the signature information corresponding to the application layer; Establishing an initial data call template according to the name of the class of the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer; Obtaining parameters of the function to be called according to a request for calling the interface data; Storing the initial data calling template in the preset interface of the SO module; Performing a uniqueness check on the initial data calling template includes: Define the first macro command: #define CHECK_METHOD(classname,methodname,methodsig)\ static bool bstatic_##methodid=AddMethod(classname,methodname, methodsig);\, wherein the first macro command uses the static variable bstatic_##methodid, AddMethod is the preset interface name of the module that provides data for the application layer, Classname is the name of the class corresponding to the application layer, methodname is the name of the interface function corresponding to the application layer, methodsig is the signature information corresponding to the application layer, the preset interface is used to store the interface other than the preset interface on the SO module and the data calling method of the application layer, and is also used to perform the singleness detection on whether there is the same method in the interface other than the preset interface and the data calling method of the application layer; Generate a target data calling function according to the to-be-called function parameters and the initial data calling template; Calling a function based on the target data completes calling the data in the SO module; The step of establishing an initial data call template according to the name of the class of the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer comprises: The name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer are stored to generate a data structure; The data structure is used as the initial data calling template.

2. The data calling method according to claim 1, characterized in that: The step of storing the name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer to generate a data structure includes: The name of the class of the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer are stored according to the set storage method to obtain the data structure.

3. The data calling method according to claim 1, characterized in that: The step of storing the initial data calling template in the preset interface of the SO module includes: Write the preset interface of the SO module: bool AddMethod(char*classname,char*methodname,char*methodsig){ Where AddMethod is the name of the interface, classname is the name of the class corresponding to the application layer, methodname is the name of the method corresponding to the application layer, and methodsig is the signature information of the interface corresponding to the application layer; The initial data calling template is stored in the preset interface of the written SO module.

4. The data calling method according to claim 1, characterized in that: The step of obtaining parameters of the function to be called according to the request for calling the interface data comprises: According to the request for calling the interface data, the data to be called corresponding to the request is registered to the initial data calling template to obtain the parameters of the function to be called, wherein the function parameters include the function name of the data to be called, the parameters of the data to be called and the signature information of the application layer.

5. The data calling method according to claim 1, characterized in that: Also includes: Real-time statistics of the number of the initial data calling templates in the preset interface; Log output is performed for any of the initial data calling templates according to the number of the initial data calling templates.

6. A data calling device, characterized in that: include: A data acquisition module, used to obtain interface data of the SO module, wherein the interface data includes the name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer; a template establishment module, used to establish an initial data call template according to the name of the class of the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer, including storing the name of the class corresponding to the application layer, the name of the interface function corresponding to the application layer and the signature information corresponding to the application layer to generate a data structure; and using the data structure as the initial data call template; A data extraction module, used for obtaining parameters of the function to be called according to a request for calling the interface data; A detection module, used to store the initial data call template in a preset interface of the SO module, and perform a uniqueness detection on the initial data call template, including: Define the first macro command: #define CHECK_METHOD(classname,methodname,methodsig)\ static bool bstatic_##methodid=AddMethod(classname,methodname, methodsig);\, wherein the first macro command uses the static variable bstatic_##methodid, AddMethod is the preset interface name of the module that provides data for the application layer, Classname is the name of the class corresponding to the application layer, methodname is the name of the interface function corresponding to the application layer, methodsig is the signature information corresponding to the application layer, the preset interface is used to store the interface other than the preset interface on the SO module and the data calling method of the application layer, and is also used to perform the singleness detection on whether there is the same method in the interface other than the preset interface and the data calling method of the application layer; A generating module, used for generating a target data calling function according to the to-be-called function parameters and the initial data calling template; The calling module is used to call the function based on the target data to complete the call to the data in the SO module.

7. An electronic device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor is used to implement the steps of the data calling method as described in any one of claims 1 to 5 when executing the computer program stored in the memory.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the data calling method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Dynamic registration method of application layer interface and related device

    CN109960597A

  • Cross-programming-language code calling method and device, medium and equipment

    CN111176626A