A method, device and medium for calling functions with multiple parameters in an adapted virtual machine

CN115509674BActive Publication Date: 2026-08-28WUHAN DOUYU NETWORK TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110634090.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-07
Publication Date
2026-08-28
Estimated Expiration
2041-06-07

AI Technical Summary

Benefits of technology

[0046]本发明提供了一种适配虚拟机中多种参数调用函数的方法,基础类存储了虚拟机中具体的方法,通过模板函数存储多种参数调用函数数据,并能够将任意个参数存储到一个数据中,从而能够适配虚拟机中任意的方法,以及任意参数个数和类型都可以进行适配。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115509674B_ABST
    Figure CN115509674B_ABST
Patent Text Reader

Abstract

The application provides a method for adapting functions with various parameters in a virtual machine, comprising: creating a base class to store different virtual machine methods; creating a template class to provide a template function and containing various parameter function data, and returning an object array as a result to realize function calling of any virtual machine method; and creating an auxiliary class to encapsulate the parameter data, convert any parameter data into an interface of one data, realize adaptive calling of the function calling function with various parameters, store the function data with various parameters through the template function, and store any number of parameters into one data, so that any method in the virtual machine can be adapted, and any number and type of parameters can be adapted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of virtual machine adaptation and invocation technology, and in particular to a method, apparatus and medium for adapting functions to call with multiple parameters in a virtual machine. Background Technology

[0002] In some cases, it's necessary to call a function in the virtual machine from C++. This function may have multiple parameters, and some functions may have only one parameter while others have multiple parameters. The goal is to provide an interface that can accommodate all function calls.

[0003] Therefore, in practical applications, it is necessary to write an interface that can adapt to cases with 0, 1, 2, or multiple parameters. Summary of the Invention

[0004] This invention provides a method for adapting functions to multiple parameters in a virtual machine. The base class stores the specific methods in the virtual machine, and the template function stores the data of multiple parameter calls. It can store any number of parameters in one data, thereby adapting to any method in the virtual machine, and adapting to any number and type of parameters.

[0005] In a first aspect, embodiments of the present invention provide a method for adapting functions to multiple parameters in a virtual machine, including:

[0006] Create a base class to store different virtual machine methods;

[0007] Create a template class to provide template functions, which contain multiple parameter calls to the function data and return an array of objects, so as to implement function calls to any virtual machine method;

[0008] Create an auxiliary class to encapsulate the parameter data, convert any type of parameter data into a data interface, and enable the adaptation and calling of functions with multiple parameters.

[0009] Preferably, the creation of the base class includes:

[0010] Member variables that store the method types in the virtual machine;

[0011] Return the interface to return a member variable of the method type;

[0012] Check the interface to determine if any member variable of any method type exists.

[0013] Preferably, it also includes establishing the actual calling interface, which includes:

[0014] Define an Array of type object;

[0015] Establish an array call interface to call the Array array and create an object array;

[0016] Create a calculation function in the object array to obtain the number of parameters;

[0017] Establish a recursive storage interface to incrementally increment all parameters and update the stored array by recursively calling the calculation function;

[0018] Create a return function to return the updated Array array.

[0019] Preferably, the determination interface specifically includes:

[0020] By using overloaded parenthesis operators, the existence of a corresponding method type member variable can be determined by checking whether the pointer to any method type member variable is null.

[0021] Preferably, the template class includes:

[0022] Parameter interface to set various parameters for calling function data;

[0023] The sequence number interface is used to mark the sequence number of the various parameter function call data;

[0024] The template class inherits from the base class, and the multi-parameter function call data includes: function call data with one parameter, function call data with two parameters, and function call data with multiple parameters.

[0025] Preferably, the sequence number interface includes: a single parameter sequence number interface and a complex parameter sequence number interface;

[0026] The complex parameter index interface includes:

[0027] Establish a function to associate the first parameter data in the function call data with the id sequence number;

[0028] Establish an incrementing association function between other data in the function call data and the ID sequence number;

[0029] And update it to the array of type object;

[0030] The single parameter sequence number interface includes:

[0031] Call the function that associates the parameter data in the function data with the ID sequence number;

[0032] Template the associated function;

[0033] Establish a return interface for the array and update the array of type object.

[0034] Preferably, the creation helper class specifically includes: the creation helper class specifically includes:

[0035] Establish a function to transform variables;

[0036] Store the data of multiple parameters called in a function into variables;

[0037] By obtaining the id number corresponding to the parameter call function data, the function call method corresponding to the variable can be obtained;

[0038] Execute the function call method, passing in the instance object and an array of parameters.

[0039] Secondly, embodiments of the present invention provide a device for adapting function calls with multiple parameters in a virtual machine, including:

[0040] The method type module is used to establish a calling interface for invoking method types in the virtual machine;

[0041] The parameter module is used to create template classes to provide template function interfaces. These template function interfaces contain various parameter call function data and return an object array to support any function call method type.

[0042] The interface module is used to create helper classes, encapsulate the parameter data, convert any type of parameter data into a data interface, and enable the adaptation and calling of functions with multiple parameters.

[0043] Thirdly, embodiments of the present invention provide an electronic device, including an application processor and a memory, characterized in that the processor is used to implement the computer management program stored in the memory to implement the multi-parameter calling function device in the adapted virtual machine.

[0044] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer management program thereon, characterized in that, when the computer management program is executed by a processor, it implements the multi-parameter call function device in the adapted virtual machine.

[0045] Beneficial effects

[0046] This invention provides a method for adapting functions to multiple parameters in a virtual machine. The base class stores the specific methods in the virtual machine, and the template function stores the data of multiple parameter calls. It can store any number of parameters in one data, thereby adapting to any method in the virtual machine, and adapting to any number and type of parameters. Attached Figure Description

[0047] Figure 1 This is a flowchart of the method for calling functions with multiple parameters in an adapted virtual machine, as described in this invention.

[0048] Figure 2 This is a block diagram of an embodiment of the device for adapting to calling functions with multiple parameters in a virtual machine according to the present invention.

[0049] Figure 3 This is a schematic diagram of the hardware structure of the device for adapting to function calls with multiple parameters in a virtual machine, as described in this invention.

[0050] Figure 4 This is a schematic diagram of a possible embodiment of an electronic device provided by an embodiment of the present invention.

[0051] Figure 5 This is a schematic diagram illustrating one possible embodiment of a computer-readable storage medium provided in this invention. Detailed Implementation

[0052] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0053] It should be noted that in the description of this invention, terms such as "center," "upper," "lower," "horizontal," and "inner," indicating directional or positional relationships, are based on the directional or positional relationships shown in the accompanying drawings. These are merely for ease of description and do not indicate or imply that the device or element must have a specific orientation, or be constructed and operated in a specific orientation; therefore, they should not be construed as limitations on this invention. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0054] Furthermore, it should be noted that, in the description of this invention, unless otherwise explicitly specified and limited, the terms "set," "install," "connect," and "link" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal communication between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0055] like Figure 1As shown, based on the technical problems raised in the background, this invention provides a method for adapting functions to multiple parameters in a virtual machine, comprising the following steps:

[0056] Step S110: Create a base class to store different virtual machine methods; specifically including: member variables to store the method types in the virtual machine; a return interface to return member variables of the method types; and a judgment interface to determine whether any member variable of a method type exists. That is, the methods in the virtual machine are encapsulated. Specifically, in a preferred embodiment, this can be implemented by the following code:

[0057] Class VBase{

[0058] vmethoID mid_;

[0059] vmethoID getMid(){returnmid_;}

[0060] Explicit operatorbool()const{

[0061] Return mid_! = null;

[0062] Here, VBase is a wrapper class used to encapsulate methods in the basic virtual machine. methodID mid_ represents a member variable to store the method type in the virtual machine; vmethoID getMid(){return mid_ represents a member function, Explicit operatorbool()const represents a judgment interface; Return mid_! = null to determine if the method exists by checking if mid_ is null.

[0063] In a preferred embodiment, to maintain consistency with other operators, an overloaded parenthesis operator is used, so that the caller can determine the existence of the method in the same way as checking whether a pointer is null.

[0064] It should be noted that this embodiment can call all methods in the virtual machine through a single interface, encapsulating the access, storage, and invocation of virtual machine methods. It also provides an interface to verify the validity and existence of these methods, achieving the beneficial effect of facilitating the transmission and invocation of different virtual machine methods based on encapsulation.

[0065] Step S120: Create a template class to provide template functions, which contain multiple parameter call function data and return an object array to implement function calls for any virtual machine method;

[0066] First, encapsulate all the functionality of the base class to make method calls within the base class more generic.

[0067] In one specific embodiment, the method encapsulation of a specific base class can be implemented by the following code:

[0068] Template<typename...Args> ;

[0069] class VMethod<object(Args...)> ;

[0070] public VBase

[0071] Among them, typename...Args indicates multiple template parameters, and the number of parameters can be adapted to any number of parameters. VMethod represents the template class, which inherits from the VBase base class, and therefore has all the functions of the VBase wrapper class.

[0072] It should be noted that the template class has multiple template parameters typename...Args, indicating that the number of parameters can be adapted to any number of parameters, thereby realizing the basic function of this embodiment and achieving the beneficial effect of adapting to any number of parameters.

[0073] Establish a parameter interface to set various parameter call data, and store the parameter data in an array of type object;

[0074] Establish an index interface, which is used to mark the index of function call data with multiple parameters and update it to an array of type object;

[0075] The function call data with multiple parameters includes: function call data with one parameter, function call data with two parameters, and function call data with multiple parameters; and the template class inherits from the base class.

[0076] Specifically, write an interface to set parameter data:

[0077] static void set(objectArray array,Arg arg0,Args...args)

[0078] The `set` function provides a parameter `objectArray`, where `array` is an array of type `object` used to store the parameter.

[0079] The template parameter arg0 represents the first parameter. The template parameters Args...args represent any number of parameters. The implementation of this interface stores the first parameter and then continues to perform the same recursive logic on any subsequent parameters to store the parameters in the array.

[0080] `array->setElement(id, arg0)` means storing the first argument as the index of the `id` parameter in the array `array`. `ArgsSave`<id+1,Args...> ::set(array,args...); indicates that the set method will continue to be called on subsequent arguments to store them.

[0081] The id+1 indicates that the index of the next parameter needs to be incremented by 1 from the index of the previous parameter. The first parameter has an id value of 0, and subsequent parameters increment sequentially.

[0082] The complex number parameter index interface specifically includes:

[0083] Establish a function to associate the first parameter data in the function call data with the id index; array->setElement(id, arg0);

[0084] Establish an incrementing association function ArgsSave between other data in the function call data and the id sequence number.<id+1,Args...> ::set(array, args...);

[0085] And update the array to an array of type object.

[0086] Specifically: array->setElement(id, arg);

[0087] Where array represents an array, Element represents an associative function, id represents an index, and arg0 represents the first parameter data; ArgsSave represents an incrementing associative function, and args. represents the subsequent parameter data of the first parameter data.

[0088] Then design a template class that can accept any number of parameters.

[0089] template<int id,typename...Args>

[0090] ClassArgsSave;

[0091] Design its template-specific interface.

[0092] template<int id,typenameArg,typename...Args>

[0093] Here, ArgsSave is a template class, and typename corresponds to the number of parameters.

[0094] As a preferred embodiment, it has any number of template parameters Class ArgsSave<id,Arg,Args...> {This template class ArgsSav splits the parameters into two parts: one is a template specialization class that extracts one parameter from any number of template parameters.}

[0095] Write an interface to set parameter data.

[0096] static void set(objectArray array,Arg arg0,Args...args){

[0097] The `set` function provides a parameter `objectArray`, where `array` is an array of type `object` used to store the parameter.

[0098] The template parameter arg0 represents the first parameter. The template parameters Args...args represent any number of parameters. The implementation of this interface stores the first parameter and then continues to perform the same recursive logic on any subsequent parameters to store the parameters in the array.

[0099] `array->setElement(id, arg0)` means storing the first argument as the index of the `id` parameter in the array `array`. `ArgsSave`<id+1,Args...> ::set(array,args...); indicates that the set method will continue to be called on subsequent arguments to store them.

[0100] The id+1 indicates that the index of the next parameter needs to be incremented by 1 from the index of the previous parameter. The first parameter has an id value of 0, and subsequent parameters increment sequentially.

[0101] This step S120, through the implementation of templates and recursion, can automatically perform the storage operation on each parameter in turn, i.e., array->setElement(id,arg); thus ultimately storing them all in the array array.

[0102] It's important to note that the template class has multiple template parameters `typename...Args`, indicating that the number of parameters can be adapted to any number of parameters. This allows the basic functionality to accommodate any number of parameters. Furthermore, given the uncertain number of parameters, an auxiliary function is designed to store any number of parameters, achieving the beneficial effect of storing multiple parameter counts as numbers.

[0103] In a preferred embodiment, in the case of no parameters, an additional parameterless template specialization implementation is required, namely, establishing a single parameter number interface, including:

[0104] The function template that associates parameter data with ID sequence number in the function call data.<int id> ;

[0105] The associated function is templated as structArgsSave <id>;

[0106] The return interface for the array is static void set(objectArray, array).

[0107] Where template represents the associative function, template<int id> With only one ordinal parameter, `struct` indicates associative function templated behavior, `ArgsSave` <id>Template specialization produces a template class with only one index. `static void set(objectArray array)` contains only one array, `array`.

[0108] It is worth noting that by establishing a single parameter number interface, the parameters are gradually reduced through recursive calls, eventually resulting in a situation where there are no parameters. This achieves the beneficial effect of establishing an exit point for the recursive program by creating a single parameter number interface.

[0109] In another implementation, it also includes: establishing the actual invocation interface, which includes:

[0110] Define an array of type object; template<typename...Args>

[0111] Establish an array call interface to call the array and create an object array; objectArrayaveArgs(Args...args)

[0112] Create a function `size of...(args)` in the `object` array to obtain the number of arguments; `autoarray = createobjectArray(sizeof...(args))`.

[0113] Establish a recursive storage interface, ArgsSave<0,Args...>::set(array,args...), to incrementally increment all parameters and update the stored array by recursively calling ArgsSave;

[0114] Create a return function `return array` to return the updated `Array` array.

[0115] Here, `sizeof...(args)` represents the calculation function used to determine the number of arguments. The return value `array` is an array of objects that can store the corresponding number of arguments. `ArgsSave<0,Args...>::set(array,args...)` represents a recursive storage interface, which increments all arguments by recursively calling `ArgsSave` and updates the `array` with each argument. `eturn array` represents the return function, which is a template function that supports any number of arguments and returns an `objectArray`, indicating that it is an array of objects storing multiple object data.

[0116] It should be noted that the actual calling interface established in this embodiment can calculate the number of parameters, and achieves the beneficial effect of numbered storage of multiple parameter counts.

[0117] Step S130: Create an auxiliary class to encapsulate the parameter data, convert any type of parameter data into a data interface, and realize the adaptation and calling of functions with multiple parameters.

[0118] Preferably, a helper class is created, specifically including:

[0119] Use the object type to create a conversion variable function, which includes the function call object self in the virtual machine and various parameter call function data;

[0120] Store the function call data with multiple parameters in the objectarray variable allargs;

[0121] The virtual machine's getFunction interface allows you to retrieve any function call method (Function) using the method's id interface.

[0122] In any function call, the instance object `self` and the array of parameters `allargs` are passed in.

[0123] It is worth noting that the execution of the Function method, which takes in the instance object self and the array allargs of all parameters, achieves the beneficial effect of adapting to all cases of method invocation in a single virtual machine.

[0124] Specifically, it includes the following steps:

[0125] local <object>operator()(object self,Args...args)const;

[0126] auto allargs=saveArgs(args...);

[0127] Function(self, allargs);

[0128] The basic function `saveArgs` is called to store any number of parameters (e.g., `Function = getFunction(getMid())`) into an `objectarray` variable `allargs`.

[0129] Among them, the virtual machine's getFunction interface can obtain the corresponding method Function through the method's id interface.

[0130] Among them, local <object>`operator()(object self, Args...args) const;` creates a virtual machine function call object. The parameter data is the object itself `self`. Using the `object` type indicates that it can support any function call object in the virtual machine. The parameters `Args...args` indicate that it can support any number of parameters. `autoallargs = saveArgs(args...);` encapsulates the parameters. `Function = getFunction(getMid())` stores the specific virtual machine method ID based on this class. We can get the corresponding method through the method ID. The specific method can be obtained through the virtual machine interface `getFunction`, which can obtain the corresponding method `Function` through the method ID interface. `Function(self, allargs)` means passing in the instance object `self` and the array of all parameters `allargs`.

[0131] It is important to note that this embodiment encapsulates the methods for calling the virtual machine based on VBase. This class stores the specific methods in the virtual machine and can store any method. For parameters, this paper designs an auxiliary class that can store any number of parameters in a single data set. Based on this data set and the previously stored method, a function call can be implemented, thus adapting to any method in the virtual machine, and adapting to any number and type of parameters in that method.

[0132] The method for adapting functions to multiple parameters in a virtual machine provided in this embodiment of the invention has the following beneficial effects: the base class stores the specific methods in the virtual machine, and the template function stores the data of multiple parameter calls. It can store any number of parameters in one data, thereby adapting to any method in the virtual machine, and any number and type of parameters can be adapted.

[0133] Figure 2 As shown in Figure 2, this invention provides a module diagram of an embodiment of a device for adapting to function calls with multiple parameters in a virtual machine. This embodiment also provides an embodiment of a device for adapting to function calls with multiple parameters in a virtual machine. The device includes: a method type module 210, used to establish a calling interface for calling method types in the virtual machine; a parameter module 220, used to establish a template class to provide a template function interface, which contains multiple parameter calling function data and returns an object array to support any function calling method type; and an interface module 230, used to create an auxiliary class to encapsulate the parameter data, converting any type of parameter data into an interface for data, thereby achieving the adaptation and calling of functions with multiple parameters.

[0134] Figure 2 The apparatus for adapting to function calls with multiple parameters in a virtual machine in this application embodiment has been described from the perspective of modular functional entities. The apparatus for preventing system function calls in this application embodiment is described in detail below from the perspective of hardware processing. Figure 3 A schematic diagram of the hardware structure of the device for adapting to function calls with multiple parameters in a virtual machine, provided in an embodiment of the present invention; please refer to... Figure 3 The module diagram 300 of the embodiment of the device for adapting to function calls with multiple parameters in a virtual machine in this invention is one embodiment, including:

[0135] Input device 301, output device 302, processor 303, and memory 304 (where the number of processors 303 can be one or more). Figure 3 (Taking a processor 303 as an example). In some embodiments of the present invention, the input device 301, the output device 302, the processor 303, and the memory 304 may be connected via a bus or other means, wherein... Figure 3 Taking the example of a connection between China and Israel via a bus.

[0136] Specifically, by calling the operation instructions stored in memory 304, processor 303 executes the following steps:

[0137] Create a base class to store different virtual machine methods;

[0138] Create a template class to provide template functions, which contain multiple parameter calls to the function data and return an array of objects, so as to implement function calls to any virtual machine method;

[0139] Create a helper class to encapsulate the parameter data, converting any type of parameter data into a data interface, and enabling the adaptation and calling of functions with multiple parameters.

[0140] By calling the operation instructions stored in memory 304, processor 303 is also used to execute... Figure 1 Any of the methods in the corresponding embodiments.

[0141] Figure 4 A schematic diagram of a possible embodiment of an electronic device provided by an embodiment of the present invention is shown in Figure 4.

[0142] In another embodiment, the present invention also provides an electronic device including a memory 410, a processor 420, and a computer program 411 stored in the memory 420 and executable on the processor 420, wherein the processor 420 executes the computer program 411 to perform the following steps.

[0143] Create a base class to store different virtual machine methods;

[0144] Create a template class to provide template functions, which contain multiple parameter calls to the function data and return an array of objects, so as to implement function calls to any virtual machine method;

[0145] Create an auxiliary class to encapsulate the parameter data, convert any type of parameter data into a data interface, and enable the adaptation and calling of functions with multiple parameters.

[0146] Since the electronic device described in this embodiment is for implementing the present invention, those skilled in the art can understand the specific implementation method and various variations of the electronic device based on the method described in the present invention. Therefore, how the electronic device implements the method in the present invention will not be described in detail here. Any device used by those skilled in the art to implement the method in the present invention is within the scope of protection of this application.

[0147] Figure 5 Please refer to the schematic diagram of a possible embodiment of a computer-readable storage medium provided in this invention. Figure 5 .

[0148] like Figure 5 As shown, this embodiment provides a computer-readable storage medium 500 on which a computer program 511 is stored. When the computer program 511 is executed by a processor, it performs the following steps:

[0149] Create a base class to store different virtual machine methods;

[0150] Create a template class to provide template functions, which contain multiple parameter calls to the function data and return an array of objects, so as to implement function calls to any virtual machine method;

[0151] Create an auxiliary class to encapsulate the parameter data, convert any type of parameter data into a data interface, and enable the adaptation and calling of functions with multiple parameters.

[0152] In practical implementation, when the computer program 511 is executed by the processor, it can achieve the following: Figure 1 Any of the corresponding implementation methods in the embodiments.

[0153] It should be noted that the descriptions of each embodiment in the above embodiments have different focuses. For parts that are not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0154] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0155] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0156] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0157] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0158] This invention also provides a computer program product comprising computer software instructions that, when executed on a processing device, cause the processing device to perform actions such as... Figure 1 The flow of the method for preventing system function calls in the corresponding embodiment.

[0159] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).

[0160] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

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

[0162] 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 network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0163] 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.

[0164] 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 USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0165] This invention provides a robust optimization method for calling SO functions on the Android platform. It establishes a conversion interface to convert exception objects in C++ code into exception objects in Java code, thus preventing the program from exiting and avoiding program crashes.

[0166] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will all fall within the scope of protection of the present invention.< / object> < / object> < / id> < / id>

Claims

1. A method for adapting functions to multiple parameters in a virtual machine, characterized in that, include: Create a base class to store different virtual machine methods; Create a template class to provide template functions, which contain multiple parameter calls to the function data and return an array of objects, so as to implement function calls to any virtual machine method; Create an auxiliary class to encapsulate the parameter data, convert any type of parameter data into a data interface, and realize the adaptive calling of functions with multiple parameters; It also includes establishing an actual calling interface, which includes: defining an Array array of type object; establishing an array calling interface to call the Array array and create an object array; establishing a calculation function in the object array to obtain the number of parameters; establishing a recursive storage interface to incrementally increment all parameters and update the storage in the Array array by recursively calling the calculation function; and establishing a return function to return the updated Array array. The template class includes: a parameter interface for setting various parameter call function data; and a sequence number interface for marking the various parameter call function data with sequence numbers. The template class inherits from the base class, and the various parameter call function data includes: call function data with one parameter, call function data with two parameters, and call function data with multiple parameters. The sequence number interface includes: a single parameter sequence number interface and a complex parameter sequence number interface; wherein, the complex parameter sequence number interface includes: establishing a function to associate the first parameter data in the function call data with the id sequence number; establishing an incrementing function to associate other data in the function call data with the id sequence number; and updating it to an array of type object; wherein, the single parameter sequence number interface includes: establishing a function to associate the parameter data in the function call data with the id sequence number; templating the associated function; establishing a return interface for the array, and updating it to the array of type object; The creation of the auxiliary class specifically includes: establishing a function to convert variables; storing multiple parameter call function data in variables; obtaining the function call method corresponding to the variable by obtaining the id number corresponding to the parameter call function data; executing the function call method and passing in the instance object and the array of parameters.

2. The method for adapting to multiple parameter function calls in a virtual machine according to claim 1, characterized in that, The creation of the base class includes: Member variables that store the method types in the virtual machine; Return the interface to return a member variable of the method type; Check the interface to determine if any member variable of any method type exists.

3. The method for adapting to multiple parameter function calls in a virtual machine according to claim 2, characterized in that, The judgment interface specifically includes: By using overloaded parenthesis operators, the existence of a corresponding method type member variable can be determined by checking whether the pointer to any method type member variable is null.

4. An electronic device, comprising an application processor and a memory, characterized in that, The processor is used to implement the method of calling functions with multiple parameters in the adapted virtual machine as described in any one of claims 1-3 when implementing the computer management program stored in the memory.

5. A computer-readable storage medium storing computer management programs thereon, characterized in that, When the computer management program is executed by the processor, it implements the method for calling functions with multiple parameters in an adapted virtual machine as described in any one of claims 1-3.

Citation Information

Patent Citations

  • Method for accessing host program by script program, and system and apparatus thereof

    CN101458633A

  • An arbitrary function adapter implementation method

    CN109840093A