CN111475150B - Cross-language binding method, device, equipment and storage medium - Google Patents

Cross-language binding method, device, equipment and storage medium Download PDF

Info

Publication number
CN111475150B
CN111475150B CN202010264081.1A CN202010264081A CN111475150B CN 111475150 B CN111475150 B CN 111475150B CN 202010264081 A CN202010264081 A CN 202010264081A CN 111475150 B CN111475150 B CN 111475150B
Authority
CN
China
Prior art keywords
annotation
idl
binding
code
language
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
CN202010264081.1A
Other languages
Chinese (zh)
Other versions
CN111475150A (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.)
Guangzhou Zhiyuan Electronics Co Ltd
Original Assignee
Guangzhou Zhiyuan Electronics 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 Guangzhou Zhiyuan Electronics Co Ltd filed Critical Guangzhou Zhiyuan Electronics Co Ltd
Priority to CN202010264081.1A priority Critical patent/CN111475150B/en
Publication of CN111475150A publication Critical patent/CN111475150A/en
Application granted granted Critical
Publication of CN111475150B publication Critical patent/CN111475150B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

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)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application discloses a cross-language binding method, a device, equipment and a storage medium. According to the technical scheme provided by the embodiment of the application, when the original code is written, the original code is annotated based on the preset annotation format, then the annotation type is determined according to the keywords in the original code annotation, the annotation information is converted into the IDL file based on the corresponding annotation type, the binding code of the target language is generated based on the IDL file, the mapping from the target code to the original code is realized, the capability of the original component for using the corresponding function on the target language can be obtained based on the binding code, a developer does not need to write the binding code manually, the binding code of the target language can be automatically generated according to the annotations input when the original code is written, and the project development efficiency is improved.

Description

Cross-language binding method, device, equipment and storage medium
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a cross-language binding method, device, equipment and storage medium.
Background
For the mainstream programming language framework, although an application program can be completely written in one language, there are cases where the application program cannot be satisfied by using the language alone, for example, the standard library does not provide functions required by the application program, and in particular, the functions are platform-related and can only be written in other languages.
To solve the above problem, the programming language framework typically provides a set of APIs (Application Programming Interface, application program interfaces), such as JNI (JavaNative Interface ) of Java, N-API of node.js, etc. A developer may write binding code according to the rules of the set of APIs to register functions implemented in another language onto the target language to obtain the ability to use those functions at its application layer.
However, the more complex the interface, the longer it takes to write the binding code, which requires a lot of time for the developer to write the binding code, resulting in reduced project development efficiency.
Disclosure of Invention
The embodiment of the application provides a cross-language binding method, device, equipment and storage medium, which are used for automatically generating binding codes of target languages and improving the project development efficiency.
In a first aspect, an embodiment of the present application provides a cross-language binding method, including:
traversing notes in original codes, extracting keywords and note information in the notes, wherein the original codes are annotated based on a preset note format, and the note format comprises the keywords and the note information;
determining an annotation type based on the keyword, and converting the annotation information into an IDL file based on the annotation type;
and generating binding codes of the target language based on the IDL file, wherein the binding codes are used for realizing the mapping from the target codes to the original codes and providing interfaces described by the target language.
Further, the determining the annotation type based on the keyword and converting the annotation information into an IDL file based on the annotation type includes:
determining an annotation type based on the keyword, and analyzing the annotation information according to the annotation type;
and generating an IDL object according to the parsed annotation information, and generating an IDL file based on the IDL object.
Further, the generating the binding code of the target language based on the IDL file includes:
reading an IDL file to obtain an IDL object in the IDL file;
traversing the IDL object and determining the object type of the IDL object;
and registering the IDL object into a target language according to the object type to obtain a binding code corresponding to the object type.
Further, after the binding code of the target language is generated based on the IDL file, the method further includes:
a target language component and/or application is generated based on the binding code.
Further, the generation of the target language component and/or the executable program based on the binding code comprises
Combining the binding code with the original component and compiling to generate a target language component; and/or
The binding code, the original component, and the application code are combined and compiled to generate an executable program.
Further, after determining the annotation type based on the keyword and converting the annotation information into the IDL file based on the annotation type, the method further includes:
and generating an API document based on the IDL file.
Further, the generating an API document based on the IDL file includes:
reading an IDL file to obtain an IDL object in the IDL file;
the IDL object is converted into an API document using a document generation tool.
In a second aspect, an embodiment of the present application provides a cross-language binding apparatus, including an annotation extraction module, an IDL file generation module, and a binding code generation module, where:
the annotation extraction module is used for traversing the annotation in the original code, extracting the keyword and the annotation information in the annotation, wherein the original code carries out annotation based on a preset annotation format, and the annotation format comprises the keyword and the annotation information;
an IDL file generation module for determining an annotation type based on the keyword and converting the annotation information into an IDL file based on the annotation type;
and the binding code generation module is used for generating binding codes of the target language based on the IDL file, wherein the binding codes are used for realizing the mapping from the target codes to the original codes and providing interfaces described by the target language.
Further, the IDL file generating module is specifically configured to: determining an annotation type based on the keyword, and analyzing the annotation information according to the annotation type; and generating an IDL object according to the parsed annotation information, and generating an IDL file based on the IDL object.
Further, the binding code generating module is specifically configured to: reading an IDL file to obtain an IDL object in the IDL file; traversing the IDL object and determining the object type of the IDL object; and registering the IDL object into a target language according to the object type to obtain a binding code corresponding to the object type.
Further, the apparatus also includes a component generation module for generating a target language component based on the binding code.
Further, the component generating module is specifically configured to combine the binding code with the original component and compile the binding code to generate a target language component.
Further, the apparatus also includes a program generation module for generating an executable program based on the binding code.
Further, the program generating module is specifically configured to combine and compile the binding code, the original component, and the application program code to generate an executable program.
Further, the device also comprises an API document generation module for generating an API document based on the IDL file.
Further, the API document generation module is specifically configured to read an IDL file, and obtain an IDL object in the IDL file; the IDL object is converted into an API document using a document generation tool.
In a third aspect, an embodiment of the present application provides a computer apparatus, including: a memory and one or more processors;
the memory is used for storing one or more programs;
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the cross-language binding method as described in the first aspect.
In a fourth aspect, embodiments of the present application provide a storage medium containing computer-executable instructions for performing the cross-language binding method of the first aspect when executed by a computer processor.
According to the embodiment of the application, when the original code is written, the original code is annotated based on the preset annotation format, then the annotation type is determined according to the keywords in the original code annotation, the annotation information is converted into the IDL file based on the corresponding annotation type, the binding code of the target language is generated based on the IDL file, the mapping from the target code to the original code is realized, the capability of the original component for using the corresponding function on the target language can be obtained based on the binding code, a developer does not need to write the binding code manually, and the binding code of the target language can be automatically generated according to the annotations input when the original code is written, so that the project development efficiency is improved.
Drawings
FIG. 1 is a flow chart of a cross-language binding method provided by an embodiment of the present application;
FIG. 2 is a flow chart of another cross-language binding method provided by an embodiment of the present application;
FIG. 3 is a schematic flow chart of generating IDL objects according to an embodiment of the present application;
FIG. 4 is a flow chart of the generation of binding code and target language components provided by an embodiment of the present application;
FIG. 5 is a schematic diagram of a cross-language binding apparatus according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the following detailed description of specific embodiments of the present application is given with reference to the accompanying drawings. It is to be understood that the specific embodiments described herein are merely illustrative of the application and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the matters related to the present application are shown in the accompanying drawings. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart depicts operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently, or at the same time. Furthermore, the order of the operations may be rearranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figures. The processes may correspond to methods, functions, procedures, subroutines, and the like.
Fig. 1 shows a flowchart of a cross-language binding method provided by an embodiment of the present application, where the cross-language binding method provided by the embodiment of the present application may be performed by a cross-language binding apparatus, and the cross-language binding apparatus may be implemented by using hardware and/or software and integrated in a computer device.
The following describes an example of a cross-language binding method performed by the cross-language binding apparatus. Referring to fig. 1, the cross-language binding method includes:
s101: traversing the annotation in the original code, extracting the keyword and the annotation information in the annotation, wherein the original code is annotated based on a preset annotation format, and the annotation format comprises the keyword and the annotation information.
When the original codes are written, the original codes and the original component interfaces are annotated according to a preset annotation format, and the annotated content comprises keywords and annotation information. For example, related annotation contents such as "class", "attribute", "member function", "enumeration" in the original code, and the keywords in the corresponding annotations are related contents indicating that the annotation types are "class", "attribute", "member function", "enumeration", and the like, and the later annotation information is specific annotation content for the code content. For example, annotating content in JavaScript is: "// class: annotating content ", wherein" class "or" class: "can be used as a keyword".
Optionally, when annotating the original code, the annotation is performed using a self-describing annotation format to improve the readability of the code.
When the original component is required to be corresponding to the binding code of the target language, the original code corresponding to the original component is read, the notes in the original code are extracted through a note extraction tool, the notes in the original code are traversed, and the keywords and the note information in each note are extracted.
S102: an annotation type is determined based on the keyword and the annotation information is converted to an IDL file based on the annotation type.
Illustratively, after extracting the keyword and the annotation information in the annotation, the annotation type of the annotation information is determined according to the keyword.
For example, assume that the annotation content is "// return value: the annotation content is corresponding to the extracted keywords and the annotation information which are respectively a return value and an annotation content, and the return value of the corresponding original code for identifying the function can be judged according to the keyword return value, so that the annotation type is the return value.
Further, after determining the annotation type of the annotation, the annotation content is converted into an IDL object according to the annotation type. Where IDL objects record classes, properties, member functions, enumerations, constants, etc. described in the annotated content. After the IDL object is generated, further, all the IDL objects corresponding to all the annotations are uniformly stored in one or more IDL files, and the IDL files are stored.
It will be appreciated that since IDL (Interface Description Language ) is a computer language used to describe interfaces of software components, interfaces are described in a neutral manner so that objects running on different platforms or programs written in different languages can communicate with each other. Then the IDL file may be converted to binding code in other target languages based on the characteristics of the cross-platform communication of the IDL file.
S103: and generating binding codes of the target language based on the IDL file, wherein the binding codes are used for realizing the mapping from the target codes to the original codes and providing interfaces described by the target language.
For example, when the function of the original component or the original code is required to be used across languages, the corresponding IDL file is read, the IDL object in the IDL file is obtained, and the IDL object is registered to the target language according to the object type, so that each IDL object is converted into the binding code in the target language.
The functions and interfaces of the original components are injected into the target language through the binding code, so that the original components can be used in a mode similar to the original components in the original language at an application layer of the target language, the binding code can be used for realizing the mapping from the target code to the original code, and the interfaces described in the target language are provided.
According to the method, when the original code is written, the original code is annotated based on the preset annotation format, then the annotation type is determined according to the keywords in the original code annotation, the annotation information is converted into the IDL file based on the corresponding annotation type, the binding code of the target language is generated based on the IDL file, mapping from the target code to the original code is achieved, the capability of the original component for using the corresponding function on the target language can be obtained based on the binding code, a developer does not need to write the binding code manually, and the binding code of the target language can be automatically generated according to the annotations input when the original code is written, so that the project development efficiency is improved.
FIG. 2 is a flowchart of another cross-language binding method according to an embodiment of the present application, where the cross-language binding method is a specific implementation of the cross-language binding method. Referring to fig. 2, the cross-language binding method includes:
s201: traversing the annotation in the original code, extracting the keyword and the annotation information in the annotation, wherein the original code is annotated based on a preset annotation format, and the annotation format comprises the keyword and the annotation information.
S202: and determining an annotation type based on the keyword, and analyzing the annotation information according to the annotation type.
Specifically, after extracting the keywords and the annotation information in the annotations, the annotation type of each annotation is determined according to the keywords, for example, assuming that the annotation content is "/" constant: annotation content is/", the corresponding extracted keywords and annotation information are respectively a constant and annotation content, and according to the keyword constant, the corresponding original code can be judged to be constant such as a integer value, a character string and the like, and then the annotation type is constant.
Further, the annotation information is parsed according to the annotation type, i.e. unnecessary information in the annotation information is filtered out and converted into a data structure which is convenient for subsequent processing (the specific data structure type is not limited in this scheme, and the existing data structure can be selected according to actual needs).
S203: and generating an IDL object according to the parsed annotation information, and generating an IDL file based on the IDL object.
Specifically, after the analysis of the annotation information is completed, the annotation content is converted into an IDL object of a corresponding type according to the annotation type, and the object type of the IDL object is recorded, wherein the object type corresponds to the annotation type. For example, for an annotation whose key is "constant", an IDL object of "constant" is created for recording the corresponding annotation content, and the object type is recorded as "constant" in the IDL object. The recording mode of the object type can be that a type field is set in the IDL object to make a statement, and the object type of the IDL object can be judged according to the type field after the IDL object is read.
Further, after the IDL object is obtained, the IDL object is saved to one or more IDL files.
Fig. 3 is a schematic flow chart of generating an IDL object according to an embodiment of the present application, as shown in fig. 3, a header file or an annotation file (an original component or an original code) is read first, after an annotation is obtained, a keyword in the annotation is retrieved, then an annotation type is determined according to the keyword, and the annotation content is analyzed in a corresponding type analysis manner according to the determined annotation type. For example, whether the annotation content is "class" is determined first, if so, the annotation content is parsed according to the parsing method of "class" to filter the garbage and convert the garbage into a data structure suitable for IDL, if the annotation type does not belong to "class", whether the annotation type is "attribute" is further determined, and the determination is sequentially performed until the annotation type is determined. Further, after the analysis of the annotation content is completed, an IDL object corresponding to the annotation type is newly created.
The IDL object corresponding to the newly created "attribute" and "member function" is added to the IDL file or IDL object corresponding to the latest "class", because this is an object-oriented expression, and the class is used for specifying the form of the object, and generally includes the method of data and processing data, that is, the attribute and the member function, and the attribute and the member function are generally called as members of the class. The remaining IDL objects are handled in the same way, e.g., enumeration is a data type, typically a collection of constants, so newly created "constant" IDL objects are added to the latest "enumerated" IDL file or IDL object, where the constants are unchanged data, either integer values or strings.
S204: and reading the IDL file, acquiring an IDL object in the IDL file, traversing the IDL object, and determining the object type of the IDL object.
Specifically, the IDL file is read, an IDL object in the IDL file is obtained, the obtained IDL object is traversed, and the object type of the IDL object is judged. The determination of the object type may be performed according to a type field in the IDL object, for example, if the type field of the IDL object contains a "class", the object type corresponding to the IDL object is a "class".
S205: and registering the IDL object into a target language according to the object type to obtain a binding code corresponding to the object type.
Wherein the binding code is used to implement the mapping of the object code to the original component and to provide an interface described in the target language, i.e. to inject (register) the functionality and interface of the original component into the target language. The generation of the binding code can be performed by a code generator corresponding to the target language. Injecting the functions and interfaces of the original component into the target language means that the mapping of the interfaces to the original component is accomplished in addition to the description using the target language. The functionality of the original component or original code may thus be used at the application layer of the target language in a manner similar to that of the original component or original code used in the original language.
When the application layer corresponding to the target language calls the interface described by the target language, the interface of the original component which is actually mapped by the interface is actually called. Binding code is the logic that implements this mapping, as well as providing a unified interface described in the target language.
Specifically, after determining the object type of the IDL object, analyzing the IDL object according to the object type to obtain the content recorded in the IDL object, and registering the IDL object in the target language to obtain the binding code corresponding to the object type.
The generation process of the binding code is a process of converting the IDL object obtained by analysis into a registration code such as a function or a constant of the target language. Registration may be understood as the injection of external functions or constants, etc., into the target language using an API provided by the target language framework. Further, after the binding code is obtained, the binding code is stored in a preset storage position.
S206: a target language component and/or application is generated based on the binding code.
Specifically, for the generation of the target language component, the binding code is combined with the code or library of the original component, and the target language component is compiled. The functions and interfaces of the original component are injected into the target language, so that when the interfaces described by the target language are called, the interfaces of the original component, which the interfaces are actually mapped to, are actually called.
In addition, for the generation of the target language application program, specifically, the binding code, the code or library of the original component, and the application program code are combined and compiled to generate an executable program (e.g., an EXE program). It will be appreciated that the application code may be integrated with a plurality of original components and binding code into a complete set of executable programs.
Wherein the compiling work can be performed by a compiler provided in the target language.
Fig. 4 is a flowchart of generating a binding code and a target language component according to an embodiment of the present application, as shown in fig. 4, an IDL file is read first and an IDL object therein is obtained, a keyword therein is obtained according to a type field in the IDL object, and an object class to which the IDL object belongs is determined according to the keyword. For example, whether the IDL object is classified as a class object is first determined, if yes, the IDL object is analyzed according to an analysis mode corresponding to the class and the content of the IDL object is obtained, otherwise, whether the IDL object is classified as an enumeration object is further determined until the object type of the IDL object is determined.
Further, after the content of the IDL object is analyzed, the IDL object is registered in the target language, and the binding code of the corresponding classification is obtained. Further, after the binding code is obtained, the binding code is combined with the code or library of the original component by using a compiler provided by the target language, and the target language component (application layer package) is generated by compiling.
Wherein the binding code is responsible for registering the functions of the software components one by one to the level of the target language, and the application layer encapsulation is responsible for packaging the functions of the original components into an object oriented interface which is internally directed to the actual implementation of the original components.
It can be understood that, as long as the binding code is available, the developer can achieve the purpose of using the original component function, and the target language component can improve the reuse rate of the code, for example, javaScript has various engines, such as jerrycript commonly used in embedded systems and V8 commonly used on PCs, and different engines provide different APIs with registration capability, so that the binding code is different, but the application layer package (target language component) can be used in different engines only by generating one copy. In addition, the target language component provides a uniform interface for the application layer, and the replacement engine cannot influence the application program.
S207: and generating an API document based on the IDL file.
The method for generating the API document provided in this embodiment is similar to the process for generating the binding code, except that the output file format is different. Wherein the file format of the API document may be Markdown, HTML document or the like, the IDL file-based execution document generating tool may generate a corresponding API document.
Illustratively, the generating process of the API document specifically includes: reading an IDL file to obtain an IDL object in the IDL file; the IDL object is converted into an API document using a document generation tool.
Specifically, the IDL file is read, an IDL object in the IDL file is obtained, the obtained IDL object is traversed, and the object type of the IDL object is judged. Further, the IDL object is parsed according to the object type, the content recorded therein is obtained, and the IDL object is converted into an API document by the document generating tool. Further, after the API document is obtained, the API document is saved in a preset storage position.
It can be understood that the annotation, IDL file, API file, etc. provided in this embodiment are not limited in format, and may be replaced with file formats such as INI, JSON, etc. as required, and parsing of the format may be added.
According to the method, when the original code is written, the original code is annotated based on the preset annotation format, then the annotation type is determined according to the keywords in the original code annotation, the annotation information is converted into the IDL file based on the corresponding annotation type, the binding code of the target language is generated based on the IDL file, mapping from the target code to the original code is achieved, the capability of the original component for using the corresponding function on the target language can be obtained based on the binding code, a developer does not need to write the binding code manually, and the binding code of the target language can be automatically generated according to the annotations input when the original code is written, so that the project development efficiency is improved. IDL files are used as middle layers to adapt to different platforms or different languages. Meanwhile, the target language component can improve the reuse rate of codes, provide a uniform interface for an application layer and reduce the influence of the replacement engine on the application program. And the difficulty of cross-language or cross-platform application of the software component is effectively reduced, and the development time is shortened. The developer does not need to know binding details, and can generate binding codes, components and API documents of other language versions by one key only by writing notes according to fixed rules when writing codes; and the problem of synchronization caused by later version iteration is not needed, so that the overall maintainability is greatly improved.
Fig. 5 is a schematic diagram of a cross-language binding apparatus according to an embodiment of the present application. Referring to fig. 5, the cross-language binding apparatus includes an annotation extraction module 51, an IDL file generation module 52, and a binding code generation module 53.
The annotation extraction module 51 is configured to traverse annotations in an original code, extract keywords and annotation information in the annotations, where the original code performs annotations based on a preset annotation format, and the annotation format includes the keywords and the annotation information; an IDL file generation module 52 for determining an annotation type based on the keyword and converting the annotation information into an IDL file based on the annotation type; and a binding code generating module 53, configured to generate a binding code of the target language based on the IDL file, where the binding code is used to implement mapping from the target code to the original code, and provide an interface described in the target language.
According to the method, when the original code is written, the original code is annotated based on the preset annotation format, then the annotation type is determined according to the keywords in the original code annotation, the annotation information is converted into the IDL file based on the corresponding annotation type, the binding code of the target language is generated based on the IDL file, mapping from the target code to the original code is achieved, the capability of the original component for using the corresponding function on the target language can be obtained based on the binding code, a developer does not need to write the binding code manually, and the binding code of the target language can be automatically generated according to the annotations input when the original code is written, so that the project development efficiency is improved. IDL files are used as middle layers to adapt to different platforms or different languages.
In one embodiment, the IDL file generating module 52 is specifically configured to: determining an annotation type based on the keyword, and analyzing the annotation information according to the annotation type; and generating an IDL object according to the parsed annotation information, and generating an IDL file based on the IDL object.
In one embodiment, the binding code generation module 53 is specifically configured to: reading an IDL file to obtain an IDL object in the IDL file; traversing the IDL object and determining the object type of the IDL object; and registering the IDL object into a target language according to the object type to obtain a binding code corresponding to the object type.
In one embodiment, the apparatus further comprises a component generation module for generating a target language component based on the binding code.
In one embodiment, the component generation module is specifically configured to combine the binding code with the original component and compile the generated target language component.
In one embodiment, the apparatus further comprises a program generation module for generating an executable program based on the binding code.
In one embodiment, the program generation module is specifically configured to combine and compile the binding code, the original component, and the application code to generate an executable program.
In one embodiment, the apparatus further comprises an API document generation module for generating an API document based on the IDL file.
In one embodiment, the API document generation module is specifically configured to read an IDL file, and obtain an IDL object in the IDL file; the IDL object is converted into an API document using a document generation tool.
The embodiment of the application also provides computer equipment which can integrate the cross-language binding device provided by the embodiment of the application. Fig. 6 is a schematic structural diagram of a computer device according to an embodiment of the present application. Referring to fig. 6, the computer apparatus includes: an input device 63, an output device 64, a memory 62, and one or more processors 61; the memory 62 is configured to store one or more programs; the one or more programs, when executed by the one or more processors 61, cause the one or more processors 61 to implement the cross-language binding method as provided by the embodiments described above. Wherein the input device 63, the output device 64, the memory 62 and the processor 61 may be connected by a bus or otherwise, for example in fig. 6 by a bus connection.
The memory 62 is used as a storage medium readable by a computing device and storing software programs, computer-executable programs, and modules corresponding to the cross-language binding method according to any embodiment of the present application (e.g., the comment extraction module 51, the IDL file generation module 52, and the binding code generation module 53 in the cross-language binding apparatus). The memory 62 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, at least one application program required for functions; the storage data area may store data created according to the use of the device, etc. In addition, memory 62 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some examples, memory 62 may further comprise memory located remotely from processor 61, which may be connected to the device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input means 63 may be used to receive entered numeric or character information and to generate key signal inputs related to user settings and function control of the device. The output device 64 may include a display device such as a display screen.
The processor 61 executes various functional applications of the device and data processing by running software programs, instructions and modules stored in the memory 62, i.e. implements the above-described cross-language binding method.
The cross-language binding device and the computer equipment provided by the embodiment can be used for executing the cross-language binding method provided by the embodiment, and have corresponding functions and beneficial effects.
Embodiments of the present application also provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are for performing a cross-language binding method as provided by the above embodiments, the cross-language binding method comprising: traversing notes in original codes, extracting keywords and note information in the notes, wherein the original codes are annotated based on a preset note format, and the note format comprises the keywords and the note information; determining an annotation type based on the keyword, and converting the annotation information into an IDL file based on the annotation type; and generating binding codes of the target language based on the IDL file, wherein the binding codes are used for realizing the mapping from the target codes to the original codes and providing interfaces described by the target language.
Storage media-any of various types of memory devices or storage devices. The term "storage medium" is intended to include: mounting media such as CD-ROM, floppy disk or tape devices; computer system memory or random access memory such as DRAM, DDR RAM, SRAM, EDO RAM, lanbas (Rambus) RAM, etc.; nonvolatile memory such as flash memory, magnetic media (e.g., hard disk or optical storage); registers or other similar types of memory elements, etc. The storage medium may also include other types of memory or combinations thereof. In addition, the storage medium may be located in a first computer system in which the program is executed, or may be located in a second, different computer system connected to the first computer system through a network such as the internet. The second computer system may provide program instructions to the first computer for execution. The term "storage medium" may include two or more storage media that may reside in different locations (e.g., in different computer systems connected by a network). The storage medium may store program instructions (e.g., embodied as a computer program) executable by one or more processors.
Of course, the storage medium containing the computer executable instructions provided by the embodiments of the present application is not limited to the cross-language binding method described above, and may also perform the related operations in the cross-language binding method provided by any embodiment of the present application.
The cross-language binding apparatus, device and storage medium provided in the foregoing embodiments may perform the cross-language binding method provided in any embodiment of the present application, and technical details not described in detail in the foregoing embodiments may be referred to the cross-language binding method provided in any embodiment of the present application.
The foregoing description is only of the preferred embodiments of the application and the technical principles employed. The present application is not limited to the specific embodiments described herein, but is capable of numerous modifications, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the application. Therefore, while the application has been described in connection with the above embodiments, the application is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit of the application, the scope of which is set forth in the following claims.

Claims (9)

1. A cross-language binding method, comprising:
traversing notes in original codes, extracting keywords and note information in the notes, wherein the original codes are annotated based on a preset note format, and the note format comprises the keywords and the note information;
determining an annotation type based on the keyword, and converting the annotation information into an IDL file based on the annotation type, wherein the method comprises the following steps: determining an annotation type based on the keyword, analyzing the annotation information according to the annotation type, generating an IDL object according to the analyzed annotation information, and generating an IDL file based on the IDL object;
and generating binding codes of the target language based on the IDL file, wherein the binding codes are used for realizing the mapping from the target codes to the original codes and providing an interface of the target language description.
2. The cross-language binding method of claim 1, wherein the generating binding code of a target language based on the IDL file comprises:
reading an IDL file to obtain an IDL object in the IDL file;
traversing the IDL object and determining the object type of the IDL object;
and registering the IDL object into a target language according to the object type to obtain a binding code corresponding to the object type.
3. The cross-language binding method of claim 1, wherein after generating the binding code of the target language based on the IDL file, further comprising:
a target language component and/or application is generated based on the binding code.
4. A cross-language binding method as claimed in claim 3, wherein the generating a target language component and/or a executable program based on the binding code comprises:
combining the binding code with the original component and compiling to generate a target language component; and/or
The binding code, the original component, and the application code are combined and compiled to generate an executable program.
5. The cross-language binding method of any one of claims 1 to 4, wherein after determining an annotation type based on the keyword and converting the annotation information into an IDL file based on the annotation type, further comprising:
and generating an API document based on the IDL file.
6. The cross-language binding method of claim 5, wherein the generating an API document based on the IDL file comprises:
reading an IDL file to obtain an IDL object in the IDL file;
the IDL object is converted into an API document using a document generation tool.
7. The cross-language binding device is characterized by comprising an annotation extraction module, an IDL file generation module and a binding code generation module, wherein:
the annotation extraction module is used for traversing the annotation in the original code, extracting the keyword and the annotation information in the annotation, wherein the original code carries out annotation based on a preset annotation format, and the annotation format comprises the keyword and the annotation information;
the IDL file generation module is used for determining an annotation type based on the keyword, converting the annotation information into an IDL file based on the annotation type, specifically used for determining the annotation type based on the keyword, analyzing the annotation information according to the annotation type, generating an IDL object according to the analyzed annotation information, and generating an IDL file based on the IDL object;
and the binding code generation module is used for generating binding codes of the target language based on the IDL file, wherein the binding codes are used for realizing the mapping from the target codes to the original codes and providing interfaces of target language descriptions.
8. A computer device, comprising: a memory and one or more processors;
the memory is used for storing one or more programs;
when executed by the one or more processors, causes the one or more processors to implement the cross-language binding method of any one of claims 1-6.
9. A storage medium containing computer executable instructions which, when executed by a computer processor, are for performing the cross-language binding method of any one of claims 1-6.
CN202010264081.1A 2020-04-07 2020-04-07 Cross-language binding method, device, equipment and storage medium Active CN111475150B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010264081.1A CN111475150B (en) 2020-04-07 2020-04-07 Cross-language binding method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010264081.1A CN111475150B (en) 2020-04-07 2020-04-07 Cross-language binding method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111475150A CN111475150A (en) 2020-07-31
CN111475150B true CN111475150B (en) 2023-12-05

Family

ID=71749973

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010264081.1A Active CN111475150B (en) 2020-04-07 2020-04-07 Cross-language binding method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111475150B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112764763B (en) * 2020-12-31 2024-01-26 亿企赢网络科技有限公司 Code conversion method, system, equipment and computer readable storage medium
CN113157261B (en) * 2021-03-31 2024-04-16 上海万物新生环保科技集团有限公司 Code generation method and device
CN114237614B (en) * 2021-12-14 2024-09-13 北京奇艺世纪科技有限公司 Application processing method and device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106919434A (en) * 2017-03-22 2017-07-04 恒生电子股份有限公司 A kind of code generating method and device
CN107608889A (en) * 2017-09-15 2018-01-19 杭州销冠网络科技有限公司 A kind of test script automatic generation method and system
CN110210009A (en) * 2018-02-28 2019-09-06 中兴通讯股份有限公司 Annotation process method, device and equipment, computer readable storage medium
CN110955416A (en) * 2019-10-12 2020-04-03 平安普惠企业管理有限公司 Interface document generation method, device, equipment and computer storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040201600A1 (en) * 2001-12-14 2004-10-14 Microsoft Corporation Methods and system for providing an XML-based interface description language

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106919434A (en) * 2017-03-22 2017-07-04 恒生电子股份有限公司 A kind of code generating method and device
CN107608889A (en) * 2017-09-15 2018-01-19 杭州销冠网络科技有限公司 A kind of test script automatic generation method and system
CN110210009A (en) * 2018-02-28 2019-09-06 中兴通讯股份有限公司 Annotation process method, device and equipment, computer readable storage medium
CN110955416A (en) * 2019-10-12 2020-04-03 平安普惠企业管理有限公司 Interface document generation method, device, equipment and computer storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
包婧.JavaScript并行化性能提升的研究与实现.《中国优秀硕士学位论文全文数据库 信息科技辑》.2015,(第6期),第I139-80页. *

Also Published As

Publication number Publication date
CN111475150A (en) 2020-07-31

Similar Documents

Publication Publication Date Title
CN111475150B (en) Cross-language binding method, device, equipment and storage medium
TWI556170B (en) Projecting native application programming interfaces of an operating system into other programming languages (2)
US7526755B2 (en) Plug-in pre- and postconditions for static program analysis
US10509854B2 (en) Annotation processing of computer files
KR20210002701A (en) Execution control through cross-level trace mapping
US20040261065A1 (en) Method and system for compiling multiple languages
US8020156B2 (en) Bulk loading system and method
JP2019053729A (en) Test method and test apparatus of smart contract
US20080313208A1 (en) Apparatus, system, and method for automated context-sensitive message organization
JP2008505423A (en) Generation of unwind information for optimized programs
US9021455B2 (en) Packed data objects
CN111258563A (en) Interface document generation method and device, storage medium and electronic equipment
US20080040656A1 (en) Instance annotation in object-oriented programming
US10846417B2 (en) Identifying permitted illegal access operations in a module system
KR20080038306A (en) Nullable and late binding
CN114356964A (en) Data blood margin construction method and device, storage medium and electronic equipment
CN105867886B (en) Method and device for writing table
CN109032572B (en) Method for Java program method internal connection based on byte code
CN112860232B (en) Component implementation method and device
CN111158665B (en) Code generation method and device, electronic equipment and storage medium
US11347487B2 (en) Confining reflective access based on module boundaries
CN113176877B (en) Entity class generation method, device and storage medium
US10635416B2 (en) Property filtering
US9720660B2 (en) Binary interface instrumentation
CN113704819A (en) Code printing output method and device of application log and computer readable storage medium

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 510000 room 306, 3rd floor, 43 Sicheng Road, software park, Tianhe District, Guangzhou City, Guangdong Province

Applicant after: GUANGZHOU ZHIYUAN ELECTRONICS Co.,Ltd.

Address before: 510000 room 517, 1023 Gaopu Road, Tianhe Software Park, Tianhe District, Guangzhou City, Guangdong Province

Applicant before: GUANGZHOU ZHIYUAN ELECTRONICS Co.,Ltd.

GR01 Patent grant
GR01 Patent grant