Method, storage medium, device and system for obtaining general data types in virtual machines

By creating a general data storage model and object array at the C++ layer and using the virtual machine interface registration mode, the problem of large interface maintenance work in the existing technology is solved, and the flexibility and adaptation of data interaction between the C++ layer and the virtual machine is realized. sex.

CN114356317BActive Publication Date: 2025-02-11GUIZHOU LANZHI DIGITAL TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111521466.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-13
Publication Date
2025-02-11
Estimated Expiration
2041-12-13

AI Technical Summary

Technical Problem

When sending C++ layer calculation result data to a virtual machine, a separate interface needs to be designed for each data type, resulting in large workloads in interface maintenance and difficulty in adapting to new data types.

Method used

By creating a general data storage model and object array, storing and converting different types of data, the interface registration mode provided by the virtual machine is used to register interfaces at the C++ layer, so that all data types are adapted through one interface.

Benefits of technology

It reduces the number of interfaces written, reduces the workload of interface maintenance, and realizes the flexibility and adaptability of data interaction between the C++ layer and the virtual machine.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114356317B_ABST
    Figure CN114356317B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, storage medium, device and system for obtaining a general data type in a virtual machine, and relates to the field of data processing. The method comprises creating a general data storage model to store all types of data in a C++ layer; creating an object array to store type information of data stored in the general data storage model; obtaining key value information of data stored in the general data storage model and storing it in the created string array; based on the type information of data stored in the object array, storing the numerical information of data stored in the general data storage model in the object array; registering an interface in the C++ layer based on an interface registration mode provided by a virtual machine, and the virtual machine calling the registered interface to obtain key value information, type information and numerical information of data. The present invention can reduce the number of interfaces to be written and effectively reduce the workload of interface maintenance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing, and in particular to a method, storage medium, device and system for obtaining general data types in a virtual machine. Background Art

[0002] In some cases, the result data calculated in the C++ layer needs to be sent to the virtual machine. For example, the data calculation or encryption process is executed in the C++ layer, and the result data obtained needs to be sent to the virtual machine for use. These result data may be of different types, which may be string types, integer types, floating-point types, or may contain multiple types of result data at the same time, and the types of each result data are different.

[0003] For the above situation, the current common solution is to design a separate interface for each situation to adapt to different types of data, which will result in the formation of multiple interfaces with different return data, making it difficult to maintain the interface, and when new data types are added, new interfaces need to be added accordingly. Summary of the invention

[0004] In view of the defects existing in the prior art, the purpose of the present invention is to provide a method, storage medium, device and system for obtaining general data types in a virtual machine, which can reduce the number of interface writing and effectively reduce the workload of interface maintenance.

[0005] To achieve the above purpose, the present invention provides a method for obtaining a general data type in a virtual machine, which specifically includes the following steps:

[0006] Creating a general data storage model, and storing all types of data in the C++ layer based on the created general data storage model;

[0007] Creating an object array, and storing type information of data stored in the general data storage model based on the created object array;

[0008] Traversing the universal data storage model, obtaining key value information of the data stored in the universal data storage model and storing it in the created string array;

[0009] Based on the type information of the data stored in the object array, the numerical information of the data stored in the universal data storage model is stored in the object array;

[0010] The interface is registered at the C++ layer based on the interface registration mode provided by the virtual machine, and the virtual machine calls the registered interface to obtain the key value information, type information and value information of the data.

[0011] Based on the above technical solutions,

[0012] Each data stored in the general data storage model includes the numerical content, type information and key value information of the data;

[0013] The data types include Boolean type, floating point type, long integer type, integer type and string type.

[0014] On the basis of the above technical solution, the type information of the data stored in the general data storage model is stored based on the created object array, and the specific steps include:

[0015] Create a type acquisition interface for obtaining data type information;

[0016] Traversing the general data storage model based on a for loop, obtaining type information of the data stored in the general data storage model e;

[0017] The type information obtained is stored in the object array through the created type acquisition interface.

[0018] On the basis of the above technical solution, the traversal of the general data storage model to obtain the key value information of the data stored in the general data storage model specifically includes:

[0019] Create an interface for obtaining key-value information of data, and create a string array for storing key-value information;

[0020] Based on the created interface for obtaining key value information, the universal data storage model is traversed by a for loop to obtain the key value information of the data stored in the universal data storage model;

[0021] Store the obtained key value information into a string array.

[0022] On the basis of the above technical solution, based on the type information of the data stored in the object array, the numerical information of the data stored in the general data storage model is stored in the object array, and the specific steps include:

[0023] Create an interface for obtaining numerical information of data;

[0024] Traversing the general data storage model based on a for loop, obtaining numerical information of the data stored in the general data storage model;

[0025] Based on the type information of the data stored in the object array, obtain the numerical information of the data corresponding to the type information;

[0026] The numerical information is stored in the object array through the created interface for obtaining numerical information.

[0027] On the basis of the above technical solution, the interface registration mode provided by the virtual machine is used to register the interface at the C++ layer, and the virtual machine calls the registered interface to obtain the key value information, type information and value information of the data. The specific steps include:

[0028] Interface registration is performed at the C++ layer based on the interface registration mode provided by the virtual machine. The registered interfaces include type information interface, key value information interface, and value information interface.

[0029] The virtual machine calls the type information interface to obtain the type information stored in the object array;

[0030] The virtual machine calls the key value information interface to obtain the key value information stored in the string array;

[0031] The virtual machine calls the value information interface to obtain the value information stored in the object array.

[0032] On the basis of the above technical solution, after the virtual machine calls the registered interface to obtain the key value information, type information and value information of the data, it also includes:

[0033] Create a ResultData object to store the key value information, type information, and value information obtained by the virtual machine;

[0034] Map the ResultData object to the virtual machine.

[0035] The present invention provides a readable storage medium on which a computer program is stored, and the program implements the steps of the above-mentioned method when executed by a processor.

[0036] An electronic device provided by the present invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the steps of the above-mentioned method are implemented when the processor executes the program.

[0037] The present invention provides a general data type acquisition system in a virtual machine, comprising:

[0038] A first creation module, which is used to create a general data storage model, and store all types of data in the C++ layer based on the created general data storage model;

[0039] A second creation module, which is used to create an object array, and store type information of the data stored in the general data storage model based on the created object array;

[0040] A first storage module, which is used to traverse the universal data storage model, obtain key value information of data stored in the universal data storage model and store it in a created string array;

[0041] A second storage module, which is used to store the numerical information of the data stored in the universal data storage model into the object array based on the type information of the data stored in the object array;

[0042] The acquisition module is used to register the interface in the C++ layer based on the interface registration mode provided by the virtual machine, and drive the virtual machine to call the registered interface to obtain the key value information, type information and value information of the data.

[0043] Compared with the prior art, the advantages of the present invention are: by registering the interface at the C++ layer based on the interface registration mode provided by the virtual machine, all data types can be adapted through one interface, thereby realizing data interaction between the C++ layer and the virtual machine, reducing the number of interface writing, thereby avoiding the need to write multiple interfaces to adapt the data interaction between the C++ layer and the virtual machine, and effectively reducing the workload of interface maintenance. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0045] Figure 1 This is a flowchart of a method for obtaining a general data type in a virtual machine in an embodiment of the present invention;

[0046] Figure 2 The present invention is a schematic diagram of the structure of a system for acquiring general data types in a virtual machine according to an embodiment of the present invention. DETAILED DESCRIPTION

[0047] The embodiment of the present invention provides a method for obtaining a general data type in a virtual machine, by registering an interface in a C++ layer based on an interface registration mode provided by the virtual machine, so that all data types can be adapted through one interface, thereby realizing data interaction between the C++ layer and the virtual machine, reducing the number of interface writing, thereby avoiding writing multiple interfaces to adapt data interaction between the C++ layer and the virtual machine, and effectively reducing the maintenance workload of the interface. The embodiment of the present invention also provides a storage medium, an electronic device, and a system for obtaining a general data type in a virtual machine.

[0048] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0049] See also Figure 1 As shown, a method for obtaining a general data type in a virtual machine provided by an embodiment of the present invention specifically includes the following steps:

[0050] S1: Create a general data storage model, and store all types of data in the C++ layer based on the created general data storage model;

[0051] In an embodiment of the present invention, each data stored in the general data storage model includes the numerical content, type information and key value information of the data; the data types include Boolean type, floating point type, long integer type, integer type and string type.

[0052] In the C++ layer, a model capable of storing any type of data is required. The present invention uses a general data storage model, which can store any type of data. The specific process for storing data in the general data storage model is as follows:

[0053] First, use an enumeration variable to represent each type of data. The corresponding execution code is:

[0054] Enum Type{data type.

[0055] NULL=0, this type indicates an empty type.

[0056] Bool, this type is a Boolean type.

[0057] Double, this type is a floating point type.

[0058] Long, this type is a long integer type.

[0059] Int, this type is an integer type.

[0060] String, this type is a string type.

[0061] }

[0062] Then all types of data in the C++ layer are stored in the common data storage model.

[0063] It should be noted that, in the general data storage model, each stored data includes numerical content (ie, data content), type information and key value information.

[0064] Considering the actual demand situation, since there will be multiple return data, and the mapping relationship of each data needs to be told to the virtual machine, so that the virtual machine can easily obtain the corresponding data, therefore, the present invention is designed to combine three elements into one element for each data support type based on the general data storage model, that is, the three elements of the data's numerical content, type information and key value information are combined into one element, and then stored in the general data storage model, and each element corresponds to an array. Therefore, corresponding to any kind of return data situation, three arrays are used to complete the data transmission, so as to achieve the purpose of transmitting with the least information as possible, while covering all data transmission situations.

[0065] S2: Create an object array, and store the type information of the data stored in the general data storage model based on the created object array;

[0066] There are many data types corresponding to virtual machines, and these data have corresponding types in virtual machines. Based on the actual situation, no matter how many data exist, only one interface is needed for conversion, so a universal conversion and storage method is needed. The present invention adopts a basic class object of virtual machine data type, in which all data types are inherited from object, so all data types can be converted through object, so the present invention uses an object array to store all data.

[0067] In the embodiment of the present invention, by creating an object array, the type information of all data is first stored, each data type is a type, and the type information of all data is stored in the object array.

[0068] S3: traverses the general data storage model, obtains the key value information of the data stored in the general data storage model, and stores it in the created string array;

[0069] When storing data, each data is set with a key value information to store the name of the data, so that the virtual machine can know how to obtain each corresponding data. A string is stored in the general data storage model as the key value information, and then the relevant data of the key value information can be obtained by traversing the general data storage model.

[0070] S4: based on the type information of the data stored in the object array, the numerical information of the data stored in the general data storage model is stored in the object array;

[0071] S5: Register the interface at the C++ layer based on the interface registration mode provided by the virtual machine. The virtual machine calls the registered interface to obtain the key value information, type information and value information of the data.

[0072] After the key value information, type information and value information of the C++ layer data are stored, these three data can be obtained by calling the registered interface, and these three data correspond to the number of returned results.

[0073] In the embodiment of the present invention, the type information of the data stored in the general data storage model is stored based on the created object array, and the specific steps include:

[0074] S201: Create a type acquisition interface for acquiring type information of data;

[0075] The relevant execution code of the created type acquisition interface is:

[0076] Local <arrayobject>getTypes()

[0077] Among them, Local represents code definition, ArrayObject represents object array, and getTypes() represents obtaining data type information.

[0078] Since the present invention aims to implement the data exchange function between the C++ layer and the virtual machine, the C++ layer and the virtual machine have different management of the object life cycle. Therefore, when obtaining type information through the type acquisition interface, it is necessary to return a smart pointer type Local, so that the object life cycle can be automatically managed without the need to specifically manage the object life cycle in the C++ layer or the virtual machine.

[0079] After obtaining the type information through the type acquisition interface, the return value is an Int array, which stores the type information of all data.

[0080] S202: traversing the general data storage model based on a for loop to obtain type information of data stored in the general data storage model;

[0081] The general data storage model is traversed through the for loop, and the corresponding execution code is:

[0082] For(int i=0;i <commonType.size();++i)

[0083] Wherein, For represents a for loop, commonType.size() represents the data stored in the common data storage model, and commonType is the common data storage model created by the present invention.

[0084] S203: The acquired type information is stored in the object array through the created type acquisition interface.

[0085] Since the type information is an enumeration variable, the return value is an Int array that can store the type information. For the return of the result, the corresponding execution code is:

[0086] IntArray dat;

[0087] dat->setElement(i,commonType[i].type);

[0088] Return data;

[0089] Among them, IntArray dat means creating a variable of return value, dat->setElement(i,commonType[i].type) means storing type information in the return value, and Return data means returning result.

[0090] In the embodiment of the present invention, traversing the general data storage model to obtain key value information of data stored in the general data storage model, the specific steps include:

[0091] S301: creating an interface for obtaining key value information of data, and creating a string array for storing the key value information;

[0092] The interface created to obtain the key value information of the data, the relevant execution code is:

[0093] Local <stringarray>getKeys()

[0094] Among them, Local represents code definition, StringArray represents string array, and getKeys() represents obtaining key value information of data.

[0095] Since the present invention aims to implement the data exchange function between the C++ layer and the virtual machine, the C++ layer and the virtual machine have different management of the object life cycle. Therefore, when obtaining type information through the type acquisition interface, it is necessary to return a smart pointer type Local, so that the object life cycle can be automatically managed without the need to specifically manage the object life cycle in the C++ layer or the virtual machine.

[0096] S302: Based on the created interface for obtaining key value information, the general data storage model is traversed by a for loop to obtain key value information of the data stored in the general data storage model;

[0097] The for loop is used to traverse the general data storage model. The relevant execution code is:

[0098] For(int i=0;i <commonType.size();++i)

[0099] Among them, For represents a for loop, and commonType.size() represents the data stored in the common data storage model.

[0100] S303: Store the acquired key value information into a string array. Since the key value information is string information, the present invention stores the key value information through a string array.

[0101] For the return of results, the corresponding execution code is:

[0102] IntArray dat;

[0103] dat->setElement(i,commonType[i].type);

[0104] Return data;

[0105] Among them, IntArray dat means creating a variable of the return value, dat->setElement(i,commonType[i].type) means storing the type information in the return value, and Return data means the return result.

[0106] In an embodiment of the present invention, based on the type information of the data stored in the object array, the numerical information of the data stored in the general data storage model is stored in the object array, and the specific steps include:

[0107] S401: Creating an interface for obtaining numerical information of data;

[0108] The interface created to obtain the numerical information of the data, the relevant execution code is:

[0109] Local <stringarray>getValues()

[0110] Among them, Local represents code definition, StringArray represents string array, and getValues() represents obtaining numerical information of data.

[0111] Since the present invention aims to implement the data exchange function between the C++ layer and the virtual machine, the C++ layer and the virtual machine have different management of the object life cycle. Therefore, when obtaining type information through the type acquisition interface, it is necessary to return a smart pointer type Local, so that the object life cycle can be automatically managed without the need to specifically manage the object life cycle in the C++ layer or the virtual machine.

[0112] S402: traversing the general data storage model based on a for loop to obtain numerical information of data stored in the general data storage model;

[0113] The for loop is used to traverse the general data storage model. The relevant execution code is:

[0114] For(int i=0;i <commonType.size();++i)

[0115] Among them, For represents a for loop, and commonType.size() represents the data stored in the common data storage model.

[0116] S403: based on the type information of the data stored in the object array, obtaining the numerical information of the data corresponding to the type information;

[0117] S404: The obtained numerical information is stored in the object array through the created interface for obtaining the numerical information.

[0118] Based on the type information of the data, the present invention stores the numerical information of the data in the object array and implements data conversion. The corresponding execution code is:

[0119] Switch(commonType[i].type){

[0120] Case Null;

[0121] {

[0122] dat->setElement(i,null);

[0123] }

[0124] Case Bool;

[0125] {

[0126] dat->setElement(i,commonType[i].value.Bool())

[0127] }

[0128] Case Double;

[0129] {

[0130] dat->setElement(i,commonType[i].value.Double());

[0131] }

[0132] Case Long;

[0133] {

[0134] dat->setElement(i,commonType[i].value.Long());

[0135] }

[0136] Case Int;

[0137] {

[0138] dat->setElement(i,commonType[i].value.Int());

[0139] }

[0140] Case String;{

[0141] dat->setElement(i,commonType[i].value.String());

[0142] }

[0143] Return data;}

[0144] Among them, Switch represents code definition; commonType[i].type represents obtaining the corresponding data by judging the type of the current data; Case Null represents that the data is a null type data; dat->setElement(i,null) represents storing null type data in an array; Case Bool represents Boolean type data; dat->setElement(i,commonType[i].value.Bool()) represents storing null type data in an array; commonType[i].value.Bool() represents that the retrieved content is a Boolean type data; Case Double represents a floating point type data; dat->setElement(i,commonType[i].value.Double()) represents storing null type data in an array; commonType[i].value.Double() represents that the retrieved content is a floating point type data; Case Long means that it is a long integer type data; dat->setElement(i,commonType[i].value.Long()) means storing an empty type of data in the array; commonType[i].value.Long() means that the retrieved content is a long integer type data; Case Int means that it is an integer type data; dat->setElement(i,commonType[i].value.Int()) means storing an empty type of data in the array; commonType[i].value.Int() means that the retrieved content is an integer type data; Case String means that it is a string type data; dat->setElement(i,commonType[i].value.String()) means storing an empty type of data in the array; commonType[i].value.String() means that the retrieved content is a string type data; Return data means the returned result.

[0145] Through the above conversion process, the data is uniformly stored in the object array according to the data type. Even if there are multiple different types of data, one object array can be used for storage.

[0146] In the embodiment of the present invention, interface registration is performed at the C++ layer based on the interface registration mode provided by the virtual machine, and the virtual machine calls the registered interface to obtain key value information, type information, and value information of the data. The specific steps include:

[0147] S501: registering interfaces at the C++ layer based on the interface registration mode provided by the virtual machine, where the registered interfaces include a type information interface, a key value information interface, and a value information interface;

[0148] S502: The virtual machine calls the type information interface to obtain the type information stored in the object array;

[0149] Among them, the type information interface is specifically Local <arrayobject>types = getTypes(). Since the interface is registered in the C++ layer, the type information interface can be called in the virtual machine. By calling the type information interface, the type information array of all data can be obtained. The size of types in the type information interface is the size of the returned data, and types stores the type information of all data. The return value is the smart pointer designed earlier, so that the life cycle can be automatically managed.

[0150] S503: The virtual machine calls the key value information interface to obtain the key value information stored in the string array;

[0151] Among them, the key value information interface is specifically Local <stringarray>keys = getKeys(). Since the interface is registered in the C++ layer, the key-value information interface can be called in the virtual machine. By calling the key-value information interface, the key-value information array of all data can be obtained. In the key-value information interface, keys stores the key-value information of all data, and the return value is the smart pointer designed previously, so that the life cycle can be automatically managed.

[0152] S504: The virtual machine calls the value information interface to obtain the value information stored in the object array.

[0153] The specific interface of numerical information is Local <objectarray>values ​​= getValues(). Since the interface is registered in the C++ layer, the value information interface can be called in the virtual machine. By calling the value information interface, the value information array of all data can be obtained. In the value information interface, values ​​stores the value information of all data, and the return value is the smart pointer designed before, so that the life cycle can be automatically managed.

[0154] After getting all the type information, we also get all the value information. Then we need to traverse in the virtual machine to get the specific value. The corresponding execution code is:

[0155] For(int i=0;i <types.length();i++){

[0156] Switch(types->getElement[i]){

[0157] Object v=values->getElement(i);

[0158] Case Null; {

[0159] Object v=values->getElement(i);

[0160] }

[0161] Case Bool;

[0162] {Boolean b = (Boolean) v;}

[0163] Case Double;

[0164] {Double b=(Double)v}

[0165] Case Long; indicates that it is a Long type data.

[0166] {Long b=(Long)v}

[0167] Case Int;

[0168] {Integer b = (Integer) v;}

[0169] Case String;

[0170] {String b = (String) v}

[0171] Among them, For(int i = 0; i < types.length(); i++) means obtaining the type information of the data by traversing types, and types.length() represents the length of the data; Switch(types->getElement[i]) means judging the type of the current data to obtain the corresponding data; Object v = values->getElement(i) means taking out the numerical information of the corresponding data; Case Null indicates that the data is a null type; Object v = values->getElement(i) represents the value of the null type data, and the content of v is also null; Case Bool indicates that it is a boolean type of data; Boolean b = (Boolean)v means converting to a boolean type; Case Double indicates that it is a floating-point type of data; Double b = (Double)v means converting to a floating-point type; Case Long indicates that it is a long integer type of data; Long b = (Long)v means converting to a long integer type; Case Int indicates that it is an integer type of data; Integer b = (Integer)v means converting to an integer type; Case String indicates that it is a string type of data; String b = (String)v means converting to a string type.

[0172] Through the above conversion process, it can be converted into the corresponding data type, and in the virtual machine, the corresponding data can be obtained according to the key-value information of the data, and it is the exact type of data, so that subsequent use can be carried out.

[0173] In the embodiment of the present invention, after the virtual machine calls the registered interface to obtain the key-value information, type information, and numerical information of the data, it further includes:

[0174] S601: Create a ResultData object to store the key-value information, type information, and numerical information obtained by the virtual machine;

[0175] The created ResultData object is specifically:

[0176] Struct ResultData{

[0177] global <arrayobject>types;

[0178] global <stringarray>keys;

[0179] global <objectarray>values;

[0180] }

[0181] Among them, Struct ResultData represents the created ResultData object; global <arrayobject>types means storing the returned type information array; global <stringarray>keys means storing the returned key value information array; global <objectarray>values ​​represents the array of numerical information returned for storage.

[0182] S602: Map the ResultData object to the virtual machine.

[0183] Create a ResultData object in the C++ layer and store data in the ResultData object, then pass the ResultData object to the virtual machine, and the virtual machine obtains data based on the three properties of the ResultData object.

[0184] In the traditional solution, for the data interaction between the C++ layer and the virtual machine, it is necessary to return an interface for integer type data, an interface for floating point type data, and an interface for string type data. If multiple data are returned, a separate structure needs to be designed to package the return results of multiple data, and different structures need to be defined when the types of each returned data are different. For example: if an integer type data and a floating point type data are returned, it is necessary to define an integer type data interface and a floating point type data interface, and for the returned results, it is also necessary to design the mapping relationship of the results in the virtual machine; if an integer type data, a floating point type data, and a string type data are returned, it is necessary to define an integer type data interface, a floating point type data interface, and a string type data interface, and for the returned results, it is also necessary to design the mapping relationship of the results in the virtual machine.

[0185] In the present invention, only a mapping relationship between a return interface and a virtual machine needs to be designed. The ResultData object includes all situations and can adapt to different situations, without the need to design an interface separately for each situation.

[0186] The method for obtaining general data types in a virtual machine in an embodiment of the present invention registers an interface in the C++ layer based on the interface registration mode provided by the virtual machine, so that all data types can be adapted through one interface, thereby realizing data interaction between the C++ layer and the virtual machine, reducing the number of interface writing, thereby avoiding the need to write multiple interfaces to adapt the data interaction between the C++ layer and the virtual machine, and effectively reducing the workload of interface maintenance.

[0187] An embodiment of the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the method for obtaining general data types in a virtual machine described in the above embodiment are implemented.

[0188] An embodiment of the present invention further provides a readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the method for obtaining a general data type in a virtual machine are implemented.

[0189] The storage medium may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may 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 may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, device or device.

[0190] 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, device, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0191] 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).

[0192] See also Figure 2 As shown, an embodiment of the present invention further provides a method for obtaining a general data type in a virtual machine, including a first creation module, a second creation module, a first storage module, a second storage module and an acquisition module.

[0193] The first creation module is used to create a general data storage model, and store all types of data in the C++ layer based on the created general data storage model; the second creation module is used to create an object array, and store the type information of the data stored in the general data storage model based on the created object array; the first storage module is used to traverse the general data storage model, obtain the key value information of the data stored in the general data storage model and store it in the created string array; the second storage module is used to store the numerical information of the data stored in the general data storage model in the object array based on the type information of the data stored in the object array; the acquisition module is used to register the interface in the C++ layer based on the interface registration mode provided by the virtual machine, and drive the virtual machine to call the registered interface to obtain the key value information, type information and numerical information of the data.

[0194] The general data type acquisition system in the virtual machine of the embodiment of the present invention registers the interface in the C++ layer based on the interface registration mode provided by the virtual machine, so that all data types can be adapted through one interface, thereby realizing data interaction between the C++ layer and the virtual machine, reducing the number of interface writing, thereby avoiding the writing of multiple interfaces to adapt the data interaction between the C++ layer and the virtual machine, and effectively reducing the workload of interface maintenance.

[0195] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.

[0196] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process in the flowchart. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.< / objectarray> < / stringarray> < / arrayobject> < / objectarray> < / stringarray> < / arrayobject> < / objectarray> < / stringarray> < / arrayobject> < / stringarray> < / stringarray> < / arrayobject>

Claims

1. A method for obtaining a general data type in a virtual machine, characterized in that: The specific steps include: Creating a general data storage model, and storing all types of data in the C++ layer based on the created general data storage model; Creating an object array, and storing type information of data stored in the general data storage model based on the created object array; Traversing the universal data storage model, obtaining key value information of the data stored in the universal data storage model and storing it in the created string array; Based on the type information of the data stored in the object array, the numerical information of the data stored in the universal data storage model is stored in the object array; The interface is registered at the C++ layer based on the interface registration mode provided by the virtual machine, and the virtual machine calls the registered interface to obtain the key value information, type information and value information of the data; The key value information is used to store the name of the data, and a character string is stored in the general data storage model as the key value information.

2. A method for obtaining a general data type in a virtual machine according to claim 1, characterized in that: Each data stored in the general data storage model includes the numerical content, type information and key value information of the data; The data types include Boolean type, floating point type, long integer type, integer type and string type.

3. A method for obtaining a general data type in a virtual machine according to claim 1, characterized in that: The specific steps of storing the type information of the data stored in the general data storage model based on the created object array include: Create a type acquisition interface for obtaining data type information; Traversing the general data storage model based on a for loop, obtaining type information of the data stored in the general data storage model; The type information obtained is stored in the object array through the created type acquisition interface.

4. A method for obtaining a general data type in a virtual machine according to claim 1, characterized in that: The traversing the general data storage model to obtain key value information of data stored in the general data storage model specifically comprises: Create an interface for obtaining key-value information of data, and create a string array for storing key-value information; Based on the created interface for obtaining key value information, the universal data storage model is traversed by a for loop to obtain the key value information of the data stored in the universal data storage model; Store the obtained key value information into a string array.

5. The method for obtaining a general data type in a virtual machine according to claim 1, characterized in that: Based on the type information of the data stored in the object array, the numerical information of the data stored in the general data storage model is stored in the object array, and the specific steps include: Create an interface for obtaining numerical information of data; Traversing the general data storage model based on a for loop, obtaining numerical information of the data stored in the general data storage model; Based on the type information of the data stored in the object array, obtain the numerical information of the data corresponding to the type information; The numerical information is stored in the object array through the created interface for obtaining numerical information.

6. A method for obtaining a general data type in a virtual machine according to claim 1, characterized in that: The interface registration mode provided by the virtual machine is used to register the interface at the C++ layer, and the virtual machine calls the registered interface to obtain the key value information, type information and value information of the data. The specific steps include: Interface registration is performed at the C++ layer based on the interface registration mode provided by the virtual machine. The registered interfaces include type information interface, key value information interface, and value information interface. The virtual machine calls the type information interface to obtain the type information stored in the object array; The virtual machine calls the key value information interface to obtain the key value information stored in the string array; The virtual machine calls the value information interface to obtain the value information stored in the object array.

7. A method for obtaining a general data type in a virtual machine according to claim 1, characterized in that: After the virtual machine calls the registered interface to obtain the key information, type information and value information of the data, it also includes: Create a ResultData object to store the key value information, type information, and value information obtained by the virtual machine; Map the ResultData object to the virtual machine.

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

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A system for obtaining general data types in a virtual machine, characterized in that: include: A first creation module, which is used to create a general data storage model, and store all types of data in the C++ layer based on the created general data storage model; A second creation module, which is used to create an object array, and store type information of the data stored in the general data storage model based on the created object array; A first storage module, which is used to traverse the universal data storage model, obtain key value information of data stored in the universal data storage model and store it in a created string array; A second storage module, which is used to store the numerical information of the data stored in the universal data storage model into the object array based on the type information of the data stored in the object array; An acquisition module, which is used to register the interface in the C++ layer based on the interface registration mode provided by the virtual machine, and drive the virtual machine to call the registered interface to obtain the key value information, type information and value information of the data; The key value information is used to store the name of the data, and a character string is stored in the general data storage model as the key value information.

Citation Information

Patent Citations

  • Dynamic registration method of application layer interface and related device

    CN109960597A

  • Data acquisition method and related device

    CN110795169A