Disclosure of Invention
In view of this, embodiments of the present disclosure at least provide a method, an apparatus, a computer device, and a storage medium for combining IDL files, which are used to generate IDL files according to a required interface type, so as to improve the efficiency of consulting IDL files and improve the performance of generating interface codes.
In a first aspect, an embodiment of the present disclosure provides a method for combining IDL files, including:
according to a predefined interface description meta-information structure, extracting interface description meta-information from a plurality of IDL files respectively, wherein the interface description meta-information comprises an interface type and a common type;
traversing the interface types in the interface description meta information, and determining the interface types to be used;
determining a common type to be used according to the type of the interface to be used;
and generating an IDL file containing the required interface according to the type of the required interface and the common type required to be used.
In one possible implementation, extracting interface description meta information from a plurality of IDL files according to a predefined interface description meta information structure includes:
analyzing the IDL file to obtain an abstract syntax tree AST;
traversing the AST, and determining the function type as the interface type of the interface description meta information;
other types than the function type are determined as the common type of the interface description meta information.
In one possible implementation manner, traversing the interface types in the interface description meta information to determine the interface types to be used includes:
acquiring interface requirement information of a required interface;
and determining the interface type to be used from the interface types in the interface description meta information according to the interface requirement information.
In one possible implementation manner, the general type to be used is determined according to the type of the interface to be used, and specifically includes:
starting recursively searching the dependent common types from the request type and the return type of the interface type to be used;
the searched common type is determined to be the common type which needs to be used.
In one possible implementation, the type of interface that needs to be used and the general type that needs to be used include file path attributes; the interface type consists of an interface name and interface information, and the common type consists of a type name and type information; and
according to the type of the interface required to be used and the common type required to be used, generating an IDL file containing the required interface specifically comprises the following steps:
aggregating the types of interfaces to be used and the common types to be used according to the types of interfaces to be used and the file paths of the common types to be used;
and generating IDL files of the required interfaces according to the aggregated interface information in the interface types required to be used and the type information in the common types required to be used.
In a second aspect, an embodiment of the present disclosure further provides an apparatus for combining IDL files, including:
the first generation module is used for respectively extracting interface description meta information from a plurality of IDL files according to a predefined interface description meta information structure, wherein the interface description meta information comprises an interface type and a common type; the first selection module is used for traversing the interface types in the interface description meta information and determining the interface types to be used;
the second selecting module is used for determining the common type to be used according to the type of the interface to be used;
and the second generation module is used for generating an IDL file containing the required interface according to the type of the interface required to be used and the common type required to be used.
In one possible implementation manner, the first generating module is specifically configured to parse the IDL file to obtain an abstract syntax tree AST; traversing the AST, and determining the function type as the interface type of the interface description meta information; other types than the function type are determined as the common type of the interface description meta information.
In one possible implementation manner, the first selecting module is specifically configured to obtain interface requirement information of a required interface; and determining the interface type to be used from the interface types in the interface description meta information according to the interface requirement information.
In a possible implementation manner, the second selecting module is specifically configured to recursively search for a common type that depends on from a request type and a return type of an interface type that needs to be used; the searched common type is determined to be the common type which needs to be used.
In one possible implementation, the type of interface that needs to be used and the general type that needs to be used include file path attributes; the interface type consists of an interface name and interface information, and the common type consists of a type name and type information; and
the second generation module is specifically configured to aggregate the interface type to be used and the common type to be used according to the interface type to be used and the file path of the common type to be used; and generating IDL files of the required interfaces according to the aggregated interface information in the interface types required to be used and the type information in the common types required to be used.
In a third aspect, embodiments of the present disclosure further provide a computer device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory in communication via the bus when the computer device is running, the machine-readable instructions when executed by the processor performing the steps of the first aspect, or any of the possible implementations of the first aspect.
In a fourth aspect, the presently disclosed embodiments also provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the first aspect, or any of the possible implementations of the first aspect.
The description of the effects of the apparatus, the computer device, and the computer-readable storage medium for combining IDL files is referred to the description of the method for combining IDL files, and is not repeated here.
According to the method, the device, the computer equipment and the storage medium for combining IDL files, according to the predefined interface description meta-information structure, interface description meta-information of the IDL files is extracted from a plurality of IDL files respectively, interface types needing to be used are determined from the interface types in the interface description meta-information, common types needing to be used are determined according to the interface types needing to be used, and finally IDL files containing the needed interfaces are generated according to the interface types needing to be used and the common types needing to be used, in the process, the IDL files are combined into one IDL file containing only relevant types of the needed interfaces, and IDL file consulting efficiency is improved; moreover, compared with the prior art that the interface code is generated by using the full IDL file, the performance of generating the interface code is improved due to filtering out the unnecessary interface types.
The foregoing objects, features and advantages of the disclosure will be more readily apparent from the following detailed description of the preferred embodiments taken in conjunction with the accompanying drawings.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present disclosure more apparent, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are only some embodiments of the present disclosure, but not all embodiments. The components of the embodiments of the present disclosure, which are generally described and illustrated in the figures herein, may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present disclosure provided in the accompanying drawings is not intended to limit the scope of the disclosure, as claimed, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be made by those skilled in the art based on the embodiments of this disclosure without making any inventive effort, are intended to be within the scope of this disclosure.
According to research, when an interface user needs to use a plurality of services, the interface code containing all interfaces needs to be generated by using the full IDL files of the used services, so that on one hand, the required interface types are inconvenient to consult from the IDL files, and on the other hand, the performance of generating the interface code is influenced.
Based on the above-mentioned research, the present disclosure provides a method for combining IDL files, which is used to combine multiple IDL files into one IDL file only including related types of required interfaces, so as to implement on-demand combination, improve efficiency of consulting interface types in the IDL file, and improve performance of generating interface codes.
The present invention is directed to a method for manufacturing a semiconductor device, and a semiconductor device manufactured by the method.
The following description of the embodiments of the present disclosure will be made clearly and fully with reference to the accompanying drawings in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present disclosure. The components of the present disclosure, as generally described and illustrated in the figures herein, may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present disclosure provided in the accompanying drawings is not intended to limit the scope of the disclosure, as claimed, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be made by those skilled in the art based on the embodiments of this disclosure without making any inventive effort, are intended to be within the scope of this disclosure.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures.
For the sake of understanding the present embodiment, first, a method for combining IDL files disclosed in the embodiments of the present disclosure will be described in detail, where an execution body of the method for combining IDL files provided in the embodiments of the present disclosure is generally a computer device having a certain computing capability, and the computer device includes, for example: the terminal device, or server or other processing device, may be a User Equipment (UE), mobile device, user terminal, cellular phone, cordless phone, personal digital assistant (Personal Digital Assistant, PDA), handheld device, computing device, vehicle mounted device, wearable device, etc. In some possible implementations, the combined IDL file method can be implemented by way of a processor invoking computer readable instructions stored in a memory.
The method for combining IDL files provided by the embodiments of the present disclosure will be described below by taking an execution body as an example of a computing device.
Example 1
Referring to fig. 1, a flowchart of a method for combining IDL files according to a first embodiment of the present disclosure is shown, where the method includes steps S101 to S104, in which:
s101: according to the predefined interface description meta-information structure, the interface description meta-information is extracted from the IDL files respectively.
In order to complete the combination of IDL files, the IDL files need to be parsed into interface description meta-information, then the interface meta-information is processed, and finally the IDL files are generated.
According to the embodiment of the disclosure, the interface description meta-information structure can be defined in advance, and considering that the interface description meta-information structure needs to be utilized for not only forward and reverse conversion of IDL files, but also convenient for selection according to needs. Since the on-demand selection is based on the interface, the interface type is extracted separately. In one embodiment, the interface description meta-information structure top layer may include an interface type api and a generic type.
Because the types defined in the last plurality of IDL files are aggregated together, to prevent naming conflicts, the name referenced by the domain name may be used as a key. In a specific implementation, the api and the type in the meta information structure of the interface description may be a mapping structure, where a key mapped by the api is an interface name referenced by a domain name, a mapped value is interface information, a key mapped by the type is a type name referenced by the domain name, and a mapped value is type information.
In this step, according to the predefined interface description meta information structure, for each IDL file, parsing is performed respectively, so as to obtain the interface description meta information of the IDL file.
S102: and traversing the interface types in the interface description meta information to determine the interface types to be used.
In this step, the user may select the interface to be used by providing a command line or page interaction, and after obtaining the selection of the user, traverse the interface type in the interface description meta information, and mark the corresponding interface type according to the selected interface type to be used as needed, thereby obtaining the interface type to be used.
S103: the general type to be used is determined according to the type of the interface to be used.
In this step, the normal type relied on can be found recursively starting from the request type and the return type of the required interface type determined in step S102, and marked as required, and finally the interface type marked as required and the normal type are combined into new interface description meta information.
S104: and generating an IDL file containing the required interface according to the type of the required interface and the common type required to be used.
In this step, since each type contains a file path attribute, aggregation can be performed according to the file path.
In one embodiment, the interface type and the normal type in the new interface description meta information generated in step S103 may be traversed, the aggregation is performed according to the interface type to be used and the file path of the normal type to be used, and the generated IDL file of the required interface is generated according to the aggregated interface information in the interface type to be used and the type information in the normal type to be used.
Example two
In order to maintain good universality and reduce development cost, in specific implementation, the IDL file may not be directly parsed into interface meta information, but may be parsed into an AST first, and then the AST is converted into interface description meta information, and the parsing process may refer to the flow shown in fig. 2, and includes the following steps:
s201: and analyzing the IDL file to obtain AST.
In this step, the IDL file may be parsed by an official or community parser to obtain a corresponding AST (abstract syntax tree).
S202: traversing the AST, and determining the function type as the interface type of the interface description meta-information.
In this step, the function type in the AST is put into the interface type mapping structure according to the preset interface description meta information structure.
S203: other types than the function type are determined as the common type of the interface description meta information.
In this step, the other types in the AST are put into the normal type mapping structure, and the interface description meta information corresponding to the IDL file is generated by combining with the interface type mapping structure in step S202.
S204: the file path attribute is added in all types.
So far, through the steps S201 to S204, the interface description meta information corresponding to the IDL file is obtained. The interface description meta information is exemplified as follows:
it will be appreciated by those skilled in the art that in the above-described method of the specific embodiments, the written order of steps is not meant to imply a strict order of execution but rather should be construed according to the function and possibly inherent logic of the steps.
The method for combining IDL files according to the requirement can combine a plurality of IDL files into the IDL file only containing relevant types of the needed interfaces, filter out unnecessary types, improve the efficiency of consulting the types in the IDL file and improve the performance of generating interface codes.
Based on the same inventive concept, the embodiment of the disclosure further provides a combined IDL file device corresponding to the combined IDL file method, and since the principle of solving the problem of the device in the embodiment of the disclosure is similar to that of the combined IDL file method in the embodiment of the disclosure, the implementation of the device can refer to the implementation of the method, and the repetition is omitted.
Example III
Referring to fig. 3, a schematic diagram of a combined IDL file according to a third embodiment of the present disclosure is shown, where the apparatus includes: a first generating module 301, a first selecting module 302, a second selecting module 303, and a second generating module 304; wherein,
a first generating module 301, configured to extract interface description meta information from a plurality of IDL files according to a predefined interface description meta information structure, where the interface description meta information includes an interface type and a common type;
the first selection module 302 is configured to traverse the interface types in the interface description meta information and determine the interface types to be used;
a second selecting module 303, configured to determine a common type to be used according to a type of an interface to be used;
the second generating module 304 is configured to generate an IDL file containing the required interface according to the type of the interface required to be used and the normal type required to be used.
In a possible implementation manner, the first generating module is specifically configured to parse the IDL file to obtain an abstract syntax tree AST; traversing the AST, and determining the function type as the interface type of the interface description meta information; other types than the function type are determined as the common type of the interface description meta information.
In a possible implementation manner, the first selecting module is specifically configured to obtain interface requirement information of a required interface; and determining the interface type to be used from the interface types in the interface description meta information according to the interface requirement information.
In a possible implementation manner, the second selecting module is specifically configured to recursively search for a common type that depends on from a request type and a return type of an interface type that needs to be used; the searched common type is determined to be the common type which needs to be used.
In one possible implementation, the type of interface that needs to be used and the general type that needs to be used include file path attributes; the interface type consists of an interface name and interface information, and the common type consists of a type name and type information; and
the second generation module is specifically configured to aggregate the interface type to be used and the common type to be used according to the interface type to be used and the file path of the common type to be used; and generating IDL files of the required interfaces according to the aggregated interface information in the interface types required to be used and the type information in the common types required to be used.
The process flow of each module in the apparatus and the interaction flow between the modules may be described with reference to the related descriptions in the above method embodiments, which are not described in detail herein.
Example four
The disclosed embodiments also provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the combined IDL file method described in the above method embodiments. Wherein the storage medium may be a volatile or nonvolatile computer readable storage medium.
The computer program product of the combined IDL file method provided in the embodiments of the present disclosure includes a computer readable storage medium storing program codes, where the program codes include instructions for executing the steps of the combined IDL file method described in the above method embodiments, and specific reference may be made to the above method embodiments, which are not repeated herein.
The disclosed embodiments also provide a computer program which, when executed by a processor, implements any of the methods of the previous embodiments. The computer program product may be realized in particular by means of hardware, software or a combination thereof. In an alternative embodiment, the computer program product is embodied as a computer storage medium, and in another alternative embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK), or the like.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described system and apparatus may refer to corresponding procedures in the foregoing method embodiments, which are not described herein again. In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present disclosure may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer readable storage medium executable by a processor. Based on such understanding, the technical solution of the present disclosure may be embodied in essence or a part contributing to the prior art or a part of the technical solution, or in the form of a software product stored in a storage medium, including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in the embodiments of the present disclosure. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Finally, it should be noted that: the foregoing examples are merely specific embodiments of the present disclosure, and are not intended to limit the scope of the disclosure, but the present disclosure is not limited thereto, and those skilled in the art will appreciate that while the foregoing examples are described in detail, it is not limited to the disclosure: any person skilled in the art, within the technical scope of the disclosure of the present disclosure, may modify or easily conceive changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features thereof; such modifications, changes or substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the disclosure, and are intended to be included within the scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.