CN107832045B - Method and apparatus for cross programming language interface conversion - Google Patents

Method and apparatus for cross programming language interface conversion Download PDF

Info

Publication number
CN107832045B
CN107832045B CN201710959210.7A CN201710959210A CN107832045B CN 107832045 B CN107832045 B CN 107832045B CN 201710959210 A CN201710959210 A CN 201710959210A CN 107832045 B CN107832045 B CN 107832045B
Authority
CN
China
Prior art keywords
idl file
class
generating
interface
definition information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710959210.7A
Other languages
Chinese (zh)
Other versions
CN107832045A (en
Inventor
郑伟强
王德俊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201710959210.7A priority Critical patent/CN107832045B/en
Publication of CN107832045A publication Critical patent/CN107832045A/en
Application granted granted Critical
Publication of CN107832045B publication Critical patent/CN107832045B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/33Intelligent editors

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a method and a device for cross-programming language interface conversion, and relates to the technical field of computers. One embodiment of the method comprises: generating an IDL file according to the source language interface description class; editing the IDL file; and generating a target language interface description class based on the edited IDL file. The implementation mode can avoid generating excessive redundant codes during cross-programming language interface conversion by editing the IDL file; the repeated work in the modification process is reduced; the controllability and flexibility of the cross-programming language interface conversion process are increased; the multi-state problem of different programming languages in the code conversion process is effectively solved.

Description

Method and apparatus for cross programming language interface conversion
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for cross-programming language interface conversion.
Background
With the development of computer technology, people's lives increasingly depend on computer technology, and system programs with different functions are produced in order to meet various requirements. In the development process of system programs, the situation of cross-department cooperative collaborative development often occurs, and because different programming languages are used among departments, a plurality of cross-programming language interface calling scenes exist in the collaborative development process.
Currently, interface protocol conversions for different programming languages may be automatically generated using tools based on the structural similarity of interface description classes for the service and caller. The interface standard provided by the outside of the service party can be represented by an interface definition class, and the code conversion tool loads the interface definition class, acquires the interface definition and the declaration of the related object contained in the interface definition class and then converts the interface definition into the file of the target programming language.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
1. because the calling party only needs the service party to provide part of interfaces and objects, and the generation tool cannot identify which interfaces and objects are needed by the calling party, excessive redundant codes are generated after the codes are generated;
2. the calling party needs to perform self-defined adjustment on part of codes due to business, and a large amount of repetitive work exists when the automatically generated codes are directly modified;
3. the object instance returned by the interface may have a polymorphic condition, that is, the object declaration returned in the interface description class is a parent class, but the object instance actually returned may be a child class of the parent class, and the object instance possibly returned has multiple child classes, so that the interface description class of the target language cannot acquire the returned real type, and the returned result cannot be serialized after the interface is called.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for cross-programming language interface conversion, which can avoid generating too many redundant codes when converting across programming language interfaces; the repeated work in the modification process is reduced; the controllability and flexibility of the cross-programming language interface conversion process are increased; the multi-state problem of different programming languages in the code conversion process is effectively solved.
To achieve the above object, according to one aspect of an embodiment of the present invention, there is provided a method of converting across programming language interfaces.
The method for converting the cross-programming language interface comprises the following steps: generating an IDL file according to the source language interface description class; editing the IDL file; and generating a target language interface description class based on the edited IDL file.
Optionally, generating the IDL file according to the source language interface description class includes: obtaining class definition information or interface function definition information of the source language interface description class; and generating the IDL file according to the class definition information or the interface function definition information.
Optionally, editing the IDL file comprises at least one of: adding the content of the IDL file; deleting the content of the IDL file; modifying the content of the IDL file; adding annotations in the IDL file.
Optionally, the annotation comprises a comment, an extension field or a version number.
Optionally, generating a target language interface description class based on the edited IDL file includes: acquiring the class definition information, the interface function definition information or the annotation in the edited IDL file; and generating a target language interface description class based on a static template technology.
To achieve the above object, according to another aspect of the present invention, there is provided an apparatus for cross-programming language interface conversion.
An apparatus for cross-programming language interface translation of an embodiment of the present invention comprises: the first generation module is used for generating an IDL file according to the source language interface description class; the editing module is used for editing the IDL file; and the second generation module is used for generating a target language interface description class based on the edited IDL file.
Optionally, the first generating module is further configured to: obtaining class definition information or interface function definition information of the source language interface description class; and generating the IDL file according to the class definition information or the interface function definition information.
Optionally, the editing module is further configured to at least one of: adding the content of the IDL file; deleting the content of the IDL file; modifying the content of the IDL file; adding annotations in the IDL file.
Optionally, the annotation comprises a comment, an extension field or a version number.
Optionally, the second generating module is further configured to: acquiring the class definition information, the interface function definition information or the annotation in the edited IDL file; and generating a target language interface description class based on a static template technology.
To achieve the above object, according to still another aspect of the present invention, there is provided an electronic device for conversion across programming language interfaces.
An electronic device for cross-programming language interface conversion according to an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement a method of cross-programming language interface conversion in accordance with an embodiment of the present invention.
To achieve the above object, according to still another aspect of the present invention, there is provided a computer-readable storage medium.
A computer-readable storage medium of an embodiment of the present invention has stored thereon a computer program that, when executed by a processor, implements a method of cross-programming language interface conversion of an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: because the IDL file mechanism technical means is adopted, the IDL file of the interface definition language is generated according to the source language interface description class; editing the IDL file; and generating a target language interface description class based on the edited IDL file. The technical problems of code redundancy, incapability of self-defining modification, lack of version control and polymorphism are solved by editing the IDL file, so that excessive redundant codes are prevented from being generated during cross-programming language interface conversion; the repeated work in the modification process is reduced; synchronous modification of the service side interface file and the calling side interface file can be realized only by maintaining the IDL intermediate file, so that the controllability and the flexibility of the cross-programming language interface conversion process are improved; the multi-state problem of different programming languages in the code conversion process is effectively solved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a method of cross programming language interface translation, according to an embodiment of the present invention;
FIG. 2 is a first schematic diagram of interface translation for a method of cross-programming language interface translation, according to an embodiment of the present invention;
FIG. 3 is a second schematic diagram of interface translation for a method of cross-programming language interface translation, according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the main modules of an apparatus for cross programming language interface translation, according to an embodiment of the present invention;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 6 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
FIG. 1 is a schematic diagram of the main steps of a method of cross programming language interface translation according to an embodiment of the present invention.
As shown in fig. 1, a method for converting across programming language interfaces according to an embodiment of the present invention mainly includes the following steps:
step S101: and generating an IDL file according to the source language interface description class.
In order to increase controllability and flexibility of a cross-programming language interface conversion process, an Interface Definition Language (IDL) file mechanism is introduced, and an IDL file is generated according to an interface description class of a source language in the cross-programming language interface conversion process.
Because the same interface description classes of different programming languages have structural similarity, interface conversion of different programming languages can be realized through the intermediate file IDL file. In the embodiment of the present invention, the step may be performed by obtaining class definition information or interface function definition information of a source language interface description class; and generating IDL file according to the class definition information or the interface function definition information.
It should be noted that, the class definition information or the interface function definition information may be obtained by using reflection characteristics or text parsing, where the class definition information may be information such as a name, an object, an attribute, a method, a type of a field, and a name of a field of an interface class; the interface function definition information may be information such as an interface function name, a function parameter type, a function parameter name, a function return type, and the like, and when the IDL file is generated, class definition information or interface function definition information is acquired from an interface description class of a source language, and the IDL file is generated based on the acquired class definition information or interface function definition information.
Step S102: and editing the IDL file.
To avoid generating excessive redundant code when converting across programming language interfaces and to reduce repetitive work in the modification process. In the embodiment of the present invention, the IDL file generated in step S101 may be edited, that is, the IDL file is maintained. Through editing the IDL file, the modification of the service side interface description class can be synchronized to the interface description class of the calling side, namely if the service side modifies the code, all the modification of the code can be realized only by modifying corresponding contents in the IDL file.
In an embodiment of the present invention, editing the IDL file includes at least one of the following: adding the content of the IDL file; deleting the content of the IDL file; modifying the content of the IDL file; annotations are added to the IDL file.
When the IDL file is edited, the class definition information of the interface description classes such as the class name and the field name can be selected and modified according to actual requirements, and redundant class definition information and interface function definition information can be deleted. The repeated modification work of a large number of redundant codes in the interface conversion process can be reduced by adding, deleting or modifying codes in the IDL file, such as deleting repeated objects in the IDL file. Meanwhile, editing the IDL file may also add extension information of the interface description class by adding a comment, where the comment is used to identify an extension attribute, for example, the comment "@ Member" may be used to identify extra information of the class, the comment "@ Field" may be used to identify extra information of the Field, and the like.
It should be noted that a certain field in the object of interface communication only describes the information of the parent class in the interface description class of the source language, but the actual communication may be a child class and may be an unfixed child class, so that polymorphic information of the field may be manually added to the field in the form of annotation to identify various types of child class information that may exist in the field, for example, the child class is identified by the annotation "@ MutiType".
In embodiments of the invention, the annotation comprises a comment, an extension field or a version number. Wherein comments may be used to identify the meaning of the field, such as comment information for attributes and comment information for methods; the version number can be used for identifying the modification time of the object, namely the interface version is controlled through an IDL file; the extension field, although not involved in the communication between the service party and the caller, may be flexibly used by the caller, such as identifying class definitions, field definitions or version information, etc.
Step S103: and generating a target language interface description class based on the edited IDL file.
The IDL file edited in step S102 may generate an interface description class of a corresponding target language as needed, thereby completing the cross-programming-language interface conversion.
In the embodiment of the present invention, the step may be performed by acquiring class definition information, interface function definition information, comments, version numbers or extension fields in the edited IDL file; and generating the target language interface description class implementation based on the static template technology. In this step, the class definition information, the interface function definition information, or the information added to the IDL file of the interface description class may be obtained from the edited IDL file by using the reflection characteristic or the text parsing, and the corresponding interface description class of the target language is generated based on the static template technique by using the class definition information, the interface function definition information, or the information added to the IDL file.
It is noted that static template technology (freemaker) is a general tool for generating output text (hypertext markup language HTML web pages, emails, configuration files, source code, etc.) based on templates and data to be changed. In addition, the obtained interface description class of the target language can reserve comment information and extension fields added according to version numbers so as to be flexibly used by a caller, such as identification class definition, field definition or version information and the like.
According to the method for converting the cross-programming language interface, the IDL file mechanism technical means is adopted, and the IDL file of the interface definition language is generated according to the source language interface description class; editing the IDL file; and generating a target language interface description class based on the edited IDL file. The technical problems of code redundancy, incapability of self-defining modification, lack of version control and polymorphism are solved by editing the IDL file, so that excessive redundant codes are prevented from being generated during cross-programming language interface conversion; the repeated work in the modification process is reduced; synchronous modification of the service side interface file and the calling side interface file can be realized only by maintaining the IDL intermediate file, so that the controllability and the flexibility of the cross-programming language interface conversion process are improved; the multi-state problem of different programming languages in the code conversion process is effectively solved.
FIG. 2 is a first schematic diagram of interface translation of a method of cross-programming language interface translation according to an embodiment of the present invention.
As shown in fig. 2, in the embodiment of the present invention, a method for converting an interface of a JAVA language to an interface of a C + + language is described as an example, where a service party provides an interface description class of the JAVA language by using the JAVA language; and the calling party uses the C + + language, and finally the interface description class of the C + + language is required to be obtained.
Assuming that two basic attributes and methods of a commodity are provided in an interface description class of JAVA language, class definition information of the interface description class, i.e. information such as name, object, attribute, method, type of field, name of field, etc. of the interface class is acquired before generating an IDL file, the class definition information can be acquired by using reflection characteristics for JAVA language, and the IDL file is generated based on the above information.
Editing the generated IDL file, deleting redundant interfaces and objects, modifying objects and the like or adding annotations, wherein the content of the annotations comprises annotations for identifying field meanings, version numbers for identifying object modification time, extension fields for identifying class definitions or field definitions or version information and the like.
Specifically, in the embodiment of the present invention, annotations "@ Member" and "@ Field" are added, where a Field "desc" of the annotation "@ Member" indicates class annotation information, a Field "cplussnamespace" indicates a C + + namespace, and a Field "rawjsonnnformat" indicates whether to generate an object marker (json) method; the comment "@ Field" indicates Field comment information, the Field "defaultValue" indicates a default value, the Field "jsonnfield" indicates a json method is generated, the Field "extfieldc" indicates a text box, and the Field "version" indicates a version number.
And generating an interface description class of the C + + language based on the edited IDL file. Specifically, the IDL file generated based on the interface description class in the JAVA language may also obtain class definition information and information such as comments, version numbers, extension fields, and the like added to the IDL file by using the reflection characteristic, and the caller generates the interface description class in the C + + language by using the information, and further serializes an object in the interface description class, where the serializing is a process of converting state information of the object into a form that can be stored or transmitted.
FIG. 3 is a second schematic diagram of interface conversion for a method of converting across programming language interfaces, according to an embodiment of the invention.
As shown in fig. 3, the method for converting an interface across programming languages is also described by taking an example of converting an interface in the JAVA language to an interface in the C + + language, where a service party uses the JAVA language to provide interface description classes in the JAVA language; and the calling party uses the C + + language, and finally the interface description class of the C + + language is required to be obtained.
And acquiring interface function definition information in an interface description class of the JAVA language by utilizing reflection characteristics or text analysis, wherein the interface function definition information can be information such as an interface function name, a function parameter type, a function parameter name, a function return type and the like, and generating an IDL file according to the interface function definition information.
Editing the generated IDL file, deleting redundant interfaces and objects, modifying objects and the like or adding annotations, wherein the content of the annotations comprises annotations for identifying field meanings, version numbers for identifying object modification time, extension fields for identifying class definitions or field definitions or version information and the like.
Specifically, annotations "@ Member" and "@ Field" are added in the embodiment of the present invention, where a Field "desc" of the annotation "@ Member" represents class annotation information, a Field "cplussnamespace" represents a C + + namespace, and a Field "rawjsonnnformat" represents whether a json method is generated; the comment "@ Field" desc "indicates Field comment information, the Field" defaultValue "indicates a default value, the Field" jsonnfield "indicates json method generation, the Field" version "indicates a version number, and the Field" MutiType "indicates subclass information in which the actual object of the Field exists.
In addition, there is a polymorphic situation for the object instance in the interface description class in the source language, that is, the object instance in the interface description class in the source language is a parent class, but may actually be a subclass of the parent class, when the interface in the C + + language needs to extend the parent class of the JAVA interface into multiple subclasses, that is, the parent class "BaseProduct" of the JAVA interface is extended into two subclasses, "YushouProduct" and "GlobalProduct", only one annotation field needs to be added to the IDL file, for example, the subclass is identified by the field "mutittype".
After the IDL file is edited, the reflection characteristic or the text analysis tool of the programming language is used to obtain the interface function definition information and the information such as the comments, version numbers and extension fields added in the IDL file, and the IDL file is used to generate the interface description class of the C + + language, when the interface of the C + + language is generated, the subclass type of the interface of the JAVA language is distinguished according to the comment field, for example, when the object in the IDL file is the subclass "com.
FIG. 4 is a schematic diagram of the main modules of an apparatus for cross programming language interface translation according to an embodiment of the present invention.
As shown in FIG. 4, an apparatus 400 for cross-programming language interface translation according to an embodiment of the present invention comprises: a first generation module 401, an editing module 402 and a second generation module 403.
Wherein the content of the first and second substances,
a first generating module 401, configured to generate an IDL file according to a source language interface description class;
an editing module 402, configured to edit the IDL file;
a second generating module 403, configured to generate a target language interface description class based on the edited IDL file.
In this embodiment of the present invention, the first generating module 401 is further configured to: obtaining class definition information or interface function definition information of the source language interface description class; and generating the IDL file according to the class definition information or the interface function definition information.
In an embodiment of the present invention, the editing module 402 is further configured to at least one of: adding the content of the IDL file; deleting the content of the IDL file; modifying the content of the IDL file; adding annotations in the IDL file.
Further, the annotation includes a comment, an extension field, or a version number.
In this embodiment of the present invention, the second generating module 403 is further configured to: acquiring the class definition information, the interface function definition information or the annotation in the edited IDL file; and generating a target language interface description class based on a static template technology.
According to the device for converting the cross-programming language interface, disclosed by the embodiment of the invention, the IDL file mechanism technical means is adopted, and the IDL file of the interface definition language is generated according to the source language interface description class; editing the IDL file; and generating a target language interface description class based on the edited IDL file. The technical problems of code redundancy, incapability of self-defining modification, lack of version control and polymorphism are solved by editing the IDL file, so that excessive redundant codes are prevented from being generated during cross-programming language interface conversion; the repeated work in the modification process is reduced; synchronous modification of the server side interface file and the calling side interface file can be realized only by maintaining the IDL intermediate file, so that the controllability and the flexibility of the cross-programming language interface conversion process are improved; the multi-state problem of different programming languages in the code conversion process is effectively solved.
FIG. 5 illustrates an exemplary system architecture 500 of a method of cross programming language interface translation or an apparatus for cross programming language interface translation to which embodiments of the present invention may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 serves to provide a medium for communication links between the terminal devices 501, 502, 503 and the server 505. Network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 501, 502, 503 to interact with a server 505 over a network 504 to receive or send messages or the like. The terminal devices 501, 502, 503 may have various communication client applications installed thereon, such as a shopping application, a web browser application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal devices 501, 502, 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 505 may be a server that provides various services, such as a background management server that supports shopping websites browsed by users using the terminal devices 501, 502, 503. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the method for converting across programming language interfaces provided by the embodiment of the present invention is generally executed by the server 505, and accordingly, the apparatus for converting across programming language interfaces is generally disposed in the server 505.
It should be understood that the number of terminal devices, networks, and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 6, a block diagram of a computer system 600 suitable for use with a terminal device implementing an embodiment of the invention is shown. The terminal device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU)601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 601.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a first generation module, an editing module, and a second generation module. The names of these modules do not in some cases constitute a definition of the module itself, for example, an editing module may also be described as a "module that edits the IDL file".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: step S101: generating an IDL file according to the source language interface description class; step S102: editing the IDL file; step S103: and generating a target language interface description class based on the edited IDL file.
According to the technical scheme of the embodiment of the invention, because an IDL file mechanism technical means is adopted, an IDL file of the interface definition language is generated according to the source language interface description class; editing the IDL file; and generating a target language interface description class based on the edited IDL file. The technical problems of code redundancy, incapability of self-defining modification, lack of version control and polymorphism are solved by editing the IDL file, so that excessive redundant codes are prevented from being generated during cross-programming language interface conversion; the repeated work in the modification process is reduced; the synchronous modification of the interface file of the server side and the target code files of the calling side can be realized only by maintaining the IDL intermediate file, so that the controllability and the flexibility of the cross-programming language interface conversion process are improved; the multi-state problem of different program languages in the code conversion process is effectively solved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (6)

1. A method of converting across programming language interfaces, comprising:
generating an IDL file according to the source language interface description class;
editing the IDL file;
generating a target language interface description class based on the edited IDL file;
generating the IDL file according to the source language interface description class comprises the following steps:
obtaining class definition information or interface function definition information of the source language interface description class;
generating the IDL file according to the class definition information or the interface function definition information;
editing the IDL file comprises at least one of:
adding the content of the IDL file;
deleting the content of the IDL file;
modifying the content of the IDL file;
adding annotations in the IDL file; the annotations include comments, extension fields, or version numbers.
2. The method of claim 1, wherein generating a target language interface description class based on the edited IDL file comprises:
acquiring the class definition information, the interface function definition information or the annotation in the edited IDL file;
and generating a target language interface description class based on a static template technology.
3. An apparatus for cross-programming-language interface translation, comprising:
the first generation module is used for generating an IDL file according to the source language interface description class;
the editing module is used for editing the IDL file;
the second generation module is used for generating a target language interface description class based on the edited IDL file;
the first generation module is further to:
obtaining class definition information or interface function definition information of the source language interface description class;
generating the IDL file according to the class definition information or the interface function definition information;
the editing module is further to at least one of:
adding the content of the IDL file;
deleting the content of the IDL file;
modifying the content of the IDL file;
adding annotations in the IDL file; the annotations include comments, extension fields, or version numbers.
4. The apparatus of claim 3, wherein the second generating module is further configured to:
acquiring the class definition information, the interface function definition information or the annotation in the edited IDL file;
and generating a target language interface description class based on a static template technology.
5. An electronic device that converts across programming language interfaces, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of claim 1 or 2.
6. A computer-readable medium, on which a computer program is stored, which program, when being executed by a processor, carries out the method of claim 1 or 2.
CN201710959210.7A 2017-10-16 2017-10-16 Method and apparatus for cross programming language interface conversion Active CN107832045B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710959210.7A CN107832045B (en) 2017-10-16 2017-10-16 Method and apparatus for cross programming language interface conversion

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710959210.7A CN107832045B (en) 2017-10-16 2017-10-16 Method and apparatus for cross programming language interface conversion

Publications (2)

Publication Number Publication Date
CN107832045A CN107832045A (en) 2018-03-23
CN107832045B true CN107832045B (en) 2021-03-30

Family

ID=61648115

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710959210.7A Active CN107832045B (en) 2017-10-16 2017-10-16 Method and apparatus for cross programming language interface conversion

Country Status (1)

Country Link
CN (1) CN107832045B (en)

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110704200A (en) * 2018-07-09 2020-01-17 北京京东尚科信息技术有限公司 Method and device for converting call interface
CN110795147A (en) * 2018-08-01 2020-02-14 北京京东尚科信息技术有限公司 Interface protocol file management method and device
CN109002287B (en) * 2018-08-08 2021-11-26 郑州云海信息技术有限公司 Management method and device for software in cloud data system
CN109343836B (en) * 2018-08-31 2021-09-10 创新先进技术有限公司 Data serialization and data deserialization method, device and equipment
CN110058864B (en) * 2019-04-18 2023-08-22 成都四方伟业软件股份有限公司 Micro-service deployment method and device
CN110377273B (en) * 2019-07-01 2023-07-28 北京字节跳动网络技术有限公司 Data processing method, device, medium and electronic equipment
CN110430222A (en) * 2019-09-12 2019-11-08 北京许继电气有限公司 A kind of service interface implementation method based on protocol mode
CN110716798B (en) * 2019-09-29 2021-11-19 微梦创科网络科技(中国)有限公司 PHP (hypertext preprocessor) timing task management method and system
CN112783748B (en) * 2019-11-06 2024-02-20 腾讯科技(深圳)有限公司 Program debugging method, device, equipment and computer readable storage medium
CN111399902B (en) * 2020-03-25 2023-08-08 北京字节跳动网络技术有限公司 Client source file processing method and device, readable medium and electronic equipment
CN111949253B (en) * 2020-08-07 2023-12-01 抖音视界有限公司 Method, apparatus, computer device and storage medium for combining IDL files
CN111950239A (en) * 2020-08-07 2020-11-17 北京字节跳动网络技术有限公司 Schema document generation method and device, computer equipment and medium
CN111930363B (en) * 2020-08-07 2023-11-24 抖音视界有限公司 Block interface code generation method and device
CN114253520B (en) * 2020-09-21 2024-03-12 抖音视界有限公司 Interface code generation method and device
CN112130837B (en) * 2020-09-25 2022-03-08 腾讯科技(深圳)有限公司 Code processing method and device and storage medium
CN112162755B (en) * 2020-09-28 2023-03-31 抖音视界有限公司 Data processing method, device, medium and electronic equipment
CN113805882A (en) * 2021-09-18 2021-12-17 上海波顿诺华智能科技有限公司 Method and device for developing application program, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102043624A (en) * 2010-12-17 2011-05-04 青岛海信网络科技股份有限公司 Method for automatically programming intermediate communication interface and device
CN103530097A (en) * 2012-07-04 2014-01-22 深圳中兴网信科技有限公司 Implement method and device of module crossing middleware platform
CN105279195A (en) * 2014-07-23 2016-01-27 腾讯科技(深圳)有限公司 Method and apparatus for webpage application to call browser function

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102891837B (en) * 2011-07-22 2016-03-02 华为软件技术有限公司 Message conversion processing method, bridging device and communication system
CN103902283B (en) * 2014-03-03 2017-04-19 华东师范大学 Method for achieving real-time asynchronous communication through model transformation in CORBA
CN105337968A (en) * 2015-10-19 2016-02-17 江苏中威科技软件系统有限公司 Cross platform communication protocol code conversion method and system
US9804829B2 (en) * 2016-03-31 2017-10-31 Ca, Inc. Interface definition language compiler with version reconciliation

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102043624A (en) * 2010-12-17 2011-05-04 青岛海信网络科技股份有限公司 Method for automatically programming intermediate communication interface and device
CN103530097A (en) * 2012-07-04 2014-01-22 深圳中兴网信科技有限公司 Implement method and device of module crossing middleware platform
CN105279195A (en) * 2014-07-23 2016-01-27 腾讯科技(深圳)有限公司 Method and apparatus for webpage application to call browser function

Also Published As

Publication number Publication date
CN107832045A (en) 2018-03-23

Similar Documents

Publication Publication Date Title
CN107832045B (en) Method and apparatus for cross programming language interface conversion
CN107491382B (en) Log output method and device
CN109062563B (en) Method and device for generating page
CN110020329B (en) Method, device and system for generating webpage
BRPI0909213B1 (en) method for implementing editing features for an application program and computer adapted to run a web browser and have a system clipboard
US10437926B2 (en) System and method to generate a data-rich template
CN110780874B (en) Method and device for generating information
CN110795147A (en) Interface protocol file management method and device
CN113626223A (en) Interface calling method and device
CN113378579A (en) Method, system and electronic equipment for voice input of structured data
CN110764770A (en) Method and device for conversion and assignment between objects
CN113641700A (en) Data processing method and device based on Spring boot frame
CN113486635A (en) Document editing method and device, electronic equipment and computer readable medium
CN110807535A (en) Construction method and construction device of unified reservation platform and unified reservation platform system
CN110705271A (en) System and method for providing natural language processing service
CN109901934B (en) Method and device for generating interface help document
CN112486482A (en) Page display method and device
CN113342450B (en) Page processing method, device, electronic equipment and computer readable medium
CN115640279A (en) Method and device for constructing data blood relationship
CN113760279A (en) Method and device for generating page
CN113779018A (en) Data processing method and device
CN113448960A (en) Method and device for importing form file
CN112948472A (en) Data processing method, device, equipment and computer readable medium
CN110858240A (en) Front-end module loading method and device
CN110874302A (en) Method and device for determining buried point configuration information

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant