CN111475150A - 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
CN111475150A
CN111475150A CN202010264081.1A CN202010264081A CN111475150A CN 111475150 A CN111475150 A CN 111475150A CN 202010264081 A CN202010264081 A CN 202010264081A CN 111475150 A CN111475150 A CN 111475150A
Authority
CN
China
Prior art keywords
file
annotation
code
binding
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.)
Granted
Application number
CN202010264081.1A
Other languages
Chinese (zh)
Other versions
CN111475150B (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

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
    • 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

Abstract

According to the technical scheme provided by the embodiment of the application, when an original code is written, the original code is annotated based on a preset annotation format, then the annotation type is determined according to keywords in the original code annotation, annotation information is converted into an ID L file based on the corresponding annotation type, a binding code of a target language is generated based on an ID L file, mapping from the target code to the original code is achieved, the capability of the original component for using a corresponding function on the target language can be obtained based on the binding code, a developer does not need to manually write the binding code, the binding code of the target language can be automatically generated according to the annotation input when the original code is written, and 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 mainstream programming language frameworks, although an application can be written in one language, there are situations where the application cannot be satisfied with that language alone, for example, a standard library does not provide the functions required by the application, and in particular, the functions are platform dependent and can only be written in other languages.
To solve the above problem, the programming language framework usually provides a set of API (application programming Interface), such as Java JNI (Java native Interface), node.js N-API, etc. The developer can write binding code according to the rules of the set of API and register functions implemented in another language into the target language to obtain the ability to use the functions at its application layer.
However, writing the bound code requires time, the more complex the interface is, the longer the time is required, and the bound code needs to be written by a developer for a large amount of time, resulting in a reduction in project development efficiency.
Disclosure of Invention
The embodiment of the application provides a cross-language binding method, a device, equipment and a storage medium, so as to automatically generate a binding code of a target language and improve the project development efficiency.
In a first aspect, an embodiment of the present application provides a cross-language binding method, including:
traversing comments in original codes, and extracting keywords and comment information in the comments, wherein the original codes are annotated based on a preset comment format, and the comment format comprises the keywords and the comment information;
determining an annotation type based on the keyword and converting the annotation information into an ID L file based on the annotation type;
and generating binding codes of the target language based on the ID L file, wherein the binding codes are used for realizing the mapping of the target codes to the original codes and providing an interface described by the target language.
Further, the determining an annotation type based on the keyword and converting the annotation information into an ID L 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;
generating an ID L object according to the parsed annotation information, and generating an ID L file based on the ID L object.
Further, the generating the binding code of the target language based on the ID L file includes:
reading the ID L file, and acquiring an ID L object in the ID L file;
traversing the ID L object, determining the object type of the ID L object;
and registering the ID L object into the target language according to the object type to obtain a binding code corresponding to the object type.
Further, after generating the binding code of the target language based on the ID L file, the method further includes:
generating a target language component and/or application based on the bound code.
Further, the generating of the target language component and/or the executable program based on the bound code includes
Combining and compiling the binding code and the original component to generate a target language component; and/or
And combining and compiling the binding code, the original component and the application program code to generate an executable program.
Further, after determining the annotation type based on the keyword and converting the annotation information into an ID L file based on the annotation type, the method further includes:
an API document is generated based on the ID L file.
Further, the generating an API document based on the ID L file includes:
reading the ID L file, and acquiring an ID L object in the ID L file;
the ID L 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 ID L file generation module, and a binding code generation module, where:
the annotation extraction module is used for traversing annotations in the original codes and extracting keywords and annotation information in the annotations, wherein the original codes are annotated based on a preset annotation format, and the annotation format comprises the keywords and the annotation information;
an ID L file generating module for determining a comment type based on the keyword and converting the comment information into an ID L file based on the comment type;
and the binding code generation module is used for generating binding codes of the target language based on the ID L file, wherein the binding codes are used for realizing the mapping of the target codes to the original codes and providing an interface described by the target language.
Further, the ID L file generating module is specifically configured to determine a comment type based on the keyword and parse the comment information according to the comment type, generate an ID L object according to the parsed comment information, and generate an ID L file based on the ID L object.
Further, the binding code generation module is specifically configured to read an ID L file, acquire an ID L object in an ID L file, traverse the ID L object, determine an object type of the ID L object, and register the ID L object in a target language according to the object type to obtain a binding code corresponding to the object type.
Further, the apparatus includes a component generation module configured to generate a target language component based on the binding code.
Further, the component generation module is specifically configured to combine and compile the bound code and the original component to generate a target language component.
Further, the apparatus includes a program generation module configured to generate an executable program based on the bound code.
Further, the program generation module is specifically configured to combine and compile the bound code, the original component, and the application program code to generate an executable program.
Further, the apparatus further comprises an API document generating module for generating an API document based on the ID L file.
Further, the API document generation module is specifically used for reading the ID L file, acquiring the ID L object in the ID L file, and converting the ID L object into the API document by using a document generation tool.
In a third aspect, an embodiment of the present application provides a computer device, including: a memory and one or more processors;
the memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a 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 according to the first aspect when executed by a computer processor.
According to the method and the device, when the original code is written, the original code is annotated based on a preset annotation format, then the annotation type is determined according to keywords in the original code annotation, the annotation information is converted into the ID L file based on the corresponding annotation type, the binding code of the target language is generated based on the ID L 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 annotation input when the original code is written, and the project development efficiency is improved.
Drawings
FIG. 1 is a flowchart 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 an ID L object according to an embodiment of the present disclosure;
FIG. 4 is a flow diagram for generating a binding code and target language component according to an embodiment of the present application;
FIG. 5 is a diagram illustrating 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, specific embodiments of the present application will be described in detail 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 of the application. It should be further noted that, for the convenience of description, only some but not all of the relevant portions of the present application are shown in the drawings. Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently or simultaneously. In addition, the order of the operations may be re-arranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figure. The processes may correspond to methods, functions, procedures, subroutines, and the like.
Fig. 1 is 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 executed by a cross-language binding apparatus, and the cross-language binding apparatus may be implemented by hardware and/or software and integrated in a computer device.
The following description will be given taking as an example that the cross-language binding apparatus executes the cross-language binding method. Referring to fig. 1, the cross-language binding method includes:
s101: and traversing the annotation in the original code, and 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 code is written, the original code and the original component interface are annotated according to a preset annotation format, and the annotated content comprises keywords and annotation information. For example, the related annotation content such as "class", "attribute", "member function", "enumeration", etc. in the original code, the keyword in the corresponding annotation indicates that the annotation type is the related content such as "class", "attribute", "member function", "enumeration", etc., and the following annotation information is the specific annotation content for the code content. For example, annotating content in JavaScript is: "// type: annotate content ", where either" class "or" class: "may be used as a key.
Optionally, when the original code is annotated, the annotation is performed using a self-described annotation format to improve readability of the code.
Illustratively, when the original component needs to correspond to the binding code of the target language, the original code corresponding to the original component is read, the annotations in the original code are extracted through an annotation extraction tool, the annotations in the original code are traversed, and keywords and annotation information in each annotation are extracted.
And S102, determining the annotation type based on the keywords, and converting the annotation information into an ID L file based on the annotation type.
Illustratively, after extracting the keywords and the annotation information in the annotation, the annotation type of the annotation information is judged according to the keywords.
For example, assume that the annotation content is "// return: and annotating content, wherein the correspondingly extracted key words and the correspondingly extracted annotation information are respectively return values and annotation content, and the annotation type is the return value if the return value of the corresponding original code for the identification function can be judged according to the key words return value.
After the ID L object is generated, the ID L objects corresponding to all the annotations are further stored in one or more ID L files in a unified mode, and the ID L files are stored.
It will be appreciated that since ID L (Interface Description L arrangement) is a computer language used to describe the Interface of software components, the Interface is 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 ID L file can be translated into binding code in other target languages based on the nature of the cross-platform communication of the ID L file.
And S103, generating binding codes of the target language based on the ID L file, wherein the binding codes are used for realizing the mapping of the target codes to the original codes and providing an interface described by the target language.
Illustratively, when a function of using an original component or original code across languages is required, the corresponding ID L file is read, an ID L object in the ID L file is acquired, and the ID L object is registered in the target language according to the object type, thereby converting each ID L object into a 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 manner similar to the original components used on the original language at the application layer of the target language, the binding code can be used for realizing the mapping of the target code to the original code, and the interfaces described by the target language are provided.
According to the method, when the original code is written, the original code is annotated based on a preset annotation format, then the annotation type is determined according to keywords in the original code annotation, the annotation information is converted into the ID L file based on the corresponding annotation type, the binding code of the target language is generated based on the ID L 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 manually write the binding code, the binding code of the target language can be automatically generated according to the annotation input when the original code is written, and the project development efficiency is improved.
Fig. 2 is a flowchart of another cross-language binding method provided in an embodiment of the present application, which is an embodiment of the cross-language binding method. Referring to fig. 2, the cross-language binding method includes:
s201: and traversing the annotation in the original code, and 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 annotation, the annotation type of each annotation is determined according to the keywords, for example, assuming that the annotation content is "/" constant: and the annotation content is constant, the corresponding extracted key word and annotation information are constant and annotation content respectively, and the annotation type is constant if the corresponding original code is constant such as integer value, character string and the like according to the key word constant.
Furthermore, the annotation information is analyzed according to the annotation type, that is, unnecessary information in the annotation information is filtered out and converted into a data structure convenient for subsequent processing (the specific data structure type is not limited in the scheme, and the existing data structure can be selected according to actual needs).
S203, generating an ID L object according to the analyzed annotation information, and generating an ID L file based on the ID L object.
For example, for a comment with a key of "constant", a new ID L object of "constant" is created for recording the corresponding comment content, and the object type is recorded as "constant" in the ID L object.
Further, after obtaining the ID L object, the ID L object is saved to one or more ID L files.
Fig. 3 is a schematic flowchart of a process for generating an ID L object according to an embodiment of the present application, and as shown in fig. 3, a header file or an annotation file (original component or original code) is read first, a keyword in an annotation is retrieved after the annotation is obtained, then a type of the annotation is determined according to the keyword, and the annotation content is analyzed in a corresponding type analysis manner according to the determined type of the annotation, for example, it is determined whether the annotation is "class", if so, the annotation content is analyzed according to the "class" analysis manner, so as to filter useless information and convert the useless information into a data structure suitable for an ID L, if the annotation type does not belong to the "class", it is further determined whether the annotation content is "attribute", and it is further determined until the annotation type is determined.
The ID L object corresponding to the newly-created attribute and member function is added to the ID L file or ID L object corresponding to the latest class, because the object-oriented expression is used, the class is used for specifying the form of the object and generally comprises data and a method for processing the data, namely the attribute and the member function, and the attribute and the member function are generally called as the members of the class.
S204, reading the ID L file, obtaining the ID L object in the ID L file, traversing the ID L object, and determining the object type of the ID L object.
Specifically, the ID L file is read, the ID L object in the ID L file is acquired, the acquired ID L object is traversed, and the object type of the ID L object is determined, wherein the object type determination can be performed according to the type field in the ID L object, for example, if the type field of the ID L object contains "class", the object type corresponding to the ID L object is "class".
S205, registering the ID L object into the target language according to the object type to obtain a binding code corresponding to the object type.
The binding code is used for realizing the mapping of the target code to the original component and providing an interface described by the target language, namely injecting (registering) the functions and the interface of the original component into the target language. And generating the binding code through a code generator corresponding to the target language. Injecting the functions and interfaces of the original component into the target language means that mapping to the interfaces of the original component needs to be completed in addition to the description in the target language. Thus, the application layer in the target language can use the functionality of the original component or original code in a manner similar to the way the original component or original code was 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 to which the interface is actually mapped is actually called. Binding code is the logic that implements this mapping and provides a uniform interface described in the target language.
Specifically, after the object type of the ID L object is determined, the ID L object is parsed according to the object type, the content recorded therein is acquired, and the ID L object is registered in the target language, so that the binding code corresponding to the object type is obtained.
The binding code generation process is a process of converting the analyzed ID L object into a registration code of a function, a constant and the like of a target language, the registration can be understood as injecting an external function, a constant and the like into the target language by using an API provided by a target language framework, and further, after the binding code is obtained, the binding code is stored in a preset storage position.
S206: generating a target language component and/or application based on the bound code.
Specifically, for the generation of the target language component, the bound code and the code or library of the original component are combined and compiled to generate the target language component. And injecting the functions and interfaces of the original components into the target language, so that when the interfaces described by the target language are called, the interfaces of the original components to which the interfaces are actually mapped 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 (for example, an EXE program). It will be appreciated that the application code can be tied to a plurality of original components and to code to produce a complete executable suite.
Wherein the compiling work can be performed by a compiler provided by the target language.
Fig. 4 is a flow chart of generating a binding code and a target language component according to an embodiment of the present application, and as shown in fig. 4, first reads an ID L file and obtains an ID L object therein, obtains a key therein according to a type field in an ID L object, and determines an object classification to which the ID L object belongs according to the key, for example, first determines whether the ID L object is a "class" object classification, if so, parses the ID L object according to a parsing manner corresponding to the "class" and obtains the content of the ID L object, otherwise, further determines whether the ID L object is an "enumeration" object classification until the object type of the ID L object is determined.
And further, after the binding codes are obtained, the binding codes and the codes or libraries of the original components are combined and compiled by a compiler provided by the target language to generate target language components (application layer encapsulation).
The binding code is responsible for registering the functions of the software components to the level of the target language one by one, and the application layer encapsulation is responsible for packaging the functions of the original components into an object-oriented interface, wherein the interface internally points to the actual implementation of the original components.
It can be understood that, in fact, as long as there is bound code, the developer can achieve the purpose of using the functions of the original component, and the provision of the target language component can improve the reuse rate of the code, for example, JavaScript has many kinds of engines, such as JerryScript commonly used in embedded systems and V8 commonly used in PCs, and different engines provide different APIs with different registration capabilities, resulting in different bound codes, but only one copy of application layer encapsulation (target language component) needs to be generated and can be used in different engines. In addition, the target language component provides a uniform interface for the application layer, and the change engine cannot influence the application program.
And S207, generating an API document based on the ID L file.
The generation method of the API document provided by the embodiment is similar to the generation process of the binding code, and is different from the output file format, wherein the file format of the API document can be Markdown, HTM L document and the like, and the corresponding API document can be generated by executing a document generation tool based on the ID L file.
Illustratively, the generation process of the API document specifically comprises reading an ID L file, acquiring an ID L object in an ID L file, and converting the ID L object into the API document by using a document generation tool.
Specifically, an ID L file is read, an ID L object in an ID L file is obtained, the obtained ID L object is traversed, the object type of the ID L object is judged, the ID L object is further analyzed according to the object type, the recorded content is obtained, a document generation tool converts the ID L object into an API document, and the API document is further stored in a preset storage position after the API document is obtained.
It is to be understood that the format of the comments, the ID L file, the API file, and the like provided in the present embodiment is not limited, and may be replaced with a file format such as INI, JSON, and the like, and a parsing of the format may be added as needed.
The original code is annotated based on a preset annotation format when the original code is written, then the annotation type is determined according to keywords in the original code annotation, the annotation information is converted into an ID L file based on the corresponding annotation type, the binding code of the target language is generated based on the ID L 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 manually write the binding code, the binding code of the target language can be automatically generated according to the annotation input when the original code is written, the project development efficiency is improved, the ID L file is used as an intermediate layer, the adaptation to different platforms or different languages is realized, meanwhile, the target language component can improve the reuse rate of the code, a uniform interface is provided for an application layer, the influence of a change engine on the application program is reduced, the difficulty of cross-language or cross-platform application of the software component is effectively reduced, the development time is shortened, the developer does not need to know details, the iterative code binding, the version of other language versions can be generated by one key when the code is written according to the fixed rule, the later stage synchronization problem is greatly improved, and the overall maintenance problem is greatly improved.
Fig. 5 is a schematic diagram of a cross-language binding apparatus provided in an embodiment of the present application, and referring to fig. 5, the cross-language binding apparatus includes an annotation extraction module 51, an ID L file generation module 52, and a binding code generation module 53.
The system comprises a comment extraction module 51, an ID L file generation module 52 and a bound code generation module 53, wherein the comment extraction module 51 is used for traversing comments in original codes and extracting keywords and comment information in the comments, the original codes are annotated based on a preset comment format, the comment format comprises the keywords and the comment information, the ID L file generation module 52 is used for determining comment types based on the keywords and converting the comment information into an ID L file based on the comment types, and the bound code generation module 53 is used for generating bound codes of a target language based on the ID L file, the bound codes are used for realizing mapping from the target codes to the original codes and providing an interface described by the target language.
According to the method, when the original code is written, the original code is annotated based on a preset annotation format, then the annotation type is determined according to keywords in the annotation of the original code, the annotation information is converted into the ID L file based on the corresponding annotation type, the binding code of the target language is generated based on the ID L 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 manually write the binding code, the binding code of the target language can be automatically generated according to the annotation input when the original code is written, the project development efficiency is improved, the ID L file is used as an intermediate layer, and the adaptation to different platforms or different languages is realized.
In one embodiment, the ID L file generating module 52 is specifically configured to determine a comment type based on the keyword and parse the comment information according to the comment type, and generate an ID L object according to the parsed comment information and generate an ID L file based on the ID L object.
In one embodiment, the binding code generation module 53 is specifically configured to read an ID L file, obtain an ID L object in an ID L file, traverse the ID L object, determine an object type of the ID L object, and register the ID L object in 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 to generate a target language component based on the binding code.
In one embodiment, the component generation module is specifically configured to combine and compile the bound code and the original component to generate the target language component.
In one embodiment, the apparatus further comprises a program generation module to generate an executable program based on the bound code.
In one embodiment, the program generation module is specifically configured to combine and compile the bound 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 ID L file.
In one embodiment, the API document generation module is specifically configured to read the ID L file, obtain the ID L objects in the ID L file, and convert the ID L objects into API documents 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 for storing 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 provided in 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 other means, as exemplified by the bus connection in fig. 6.
The memory 62 is a computer-readable storage medium that can be used to store software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the cross-language binding method described in any embodiment of the present application (e.g., the annotation extraction module 51, the ID L file generation module 52, and the binding code generation module 53 in the cross-language binding apparatus), the memory 62 can be primarily comprised of a program storage area and a data storage area, wherein the program storage area can store an operating system, application programs required for at least one function, the data storage area can store data created according to the use of the device, etc., furthermore, the memory 62 can comprise a high-speed random access memory, and can also comprise a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices.
The input device 63 is operable to receive input numeric or character information and to generate key signal inputs relating to user settings and function controls of the apparatus. 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 executing software programs, instructions and modules stored in the memory 62, that is, implements the cross-language binding method described above.
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.
The embodiment of the application also provides a storage medium containing computer executable instructions, and the computer executable instructions are used for executing the cross-language binding method provided by the embodiment when being executed by a computer processor, and the cross-language binding method comprises traversing comments in original code, extracting keywords and comment information in the comments, wherein the original code is annotated based on a preset comment format, the comment format comprises the keywords and the comment information, determining a comment type based on the keywords, converting the comment information into an ID L file based on the comment type, and generating binding code of a target language based on the ID L file, wherein the binding code is used for realizing mapping of the target code to the original code and providing an interface described by the target language.
Storage medium-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.; non-volatile 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 different second 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, such as in different computer systems that are connected by a network. The storage medium may store program instructions (e.g., embodied as a computer program) that are executable by one or more processors.
Of course, the storage medium provided in the embodiments of the present application contains computer-executable instructions, and the computer-executable instructions are not limited to the cross-language binding method described above, and may also perform related operations in the cross-language binding method provided in any embodiments of the present application.
The cross-language binding apparatus, the device and the storage medium provided in the foregoing embodiments may execute the cross-language binding method provided in any embodiment of the present application, and reference may be made to the cross-language binding method provided in any embodiment of the present application without detailed technical details described in the foregoing embodiments.
The foregoing is considered as illustrative of the preferred embodiments of the invention and the technical principles employed. The present application is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present application has been described in more detail with reference to the above embodiments, the present application is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present application, and the scope of the present application is determined by the scope of the claims.

Claims (10)

1. A cross-language binding method, comprising:
traversing comments in original codes, and extracting keywords and comment information in the comments, wherein the original codes are annotated based on a preset comment format, and the comment format comprises the keywords and the comment information;
determining an annotation type based on the keyword and converting the annotation information into an ID L file based on the annotation type;
and generating binding codes of the target language based on the ID L file, wherein the binding codes are used for realizing the mapping of the target codes to the original codes and providing an interface described by the target language.
2. The cross-language binding method according to claim 1, wherein the determining a comment type based on the keyword and converting the comment information into an ID L file based on the comment type comprises:
determining an annotation type based on the keyword, and analyzing the annotation information according to the annotation type;
generating an ID L object according to the parsed annotation information, and generating an ID L file based on the ID L object.
3. The cross-language binding method according to claim 2, wherein the generating of the binding code of the target language based on the ID L file comprises:
reading the ID L file, and acquiring an ID L object in the ID L file;
traversing the ID L object, determining the object type of the ID L object;
and registering the ID L object into the target language according to the object type to obtain a binding code corresponding to the object type.
4. The cross-language binding method according to claim 1, further comprising, after generating the binding code of the target language based on the ID L file:
generating a target language component and/or application based on the bound code.
5. The cross-language binding method of claim 4, wherein generating target language components and/or executable programs based on the bound code comprises
Combining and compiling the binding code and the original component to generate a target language component; and/or
And combining and compiling the binding code, the original component and the application program code to generate an executable program.
6. The cross-language binding method according to any one of claims 1-5, wherein after determining a comment type based on the keyword and converting the comment information into an ID L file based on the comment type, further comprising:
an API document is generated based on the ID L file.
7. The cross-language binding method according to claim 6, wherein the generating an API document based on the ID L file comprises:
reading the ID L file, and acquiring an ID L object in the ID L file;
the ID L object is converted into an API document using a document generation tool.
8. A cross-language binding apparatus, comprising an annotation extraction module, an ID L file generation module, and a binding code generation module, wherein:
the annotation extraction module is used for traversing annotations in the original codes and extracting keywords and annotation information in the annotations, wherein the original codes are annotated based on a preset annotation format, and the annotation format comprises the keywords and the annotation information;
an ID L file generating module for determining a comment type based on the keyword and converting the comment information into an ID L file based on the comment type;
and the binding code generation module is used for generating binding codes of the target language based on the ID L file, wherein the binding codes are used for realizing the mapping of the target codes to the original codes and providing an interface described by the target language.
9. A computer device, comprising: a memory and one or more processors;
the memory for storing 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 of any one of claims 1-7.
10. A storage medium containing computer-executable instructions for performing the cross-language binding method of any one of claims 1-7 when executed by a computer processor.
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 true CN111475150A (en) 2020-07-31
CN111475150B 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)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112764763A (en) * 2020-12-31 2021-05-07 亿企赢网络科技有限公司 Code conversion method, system, equipment and computer readable storage medium
CN113157261A (en) * 2021-03-31 2021-07-23 上海万物新生环保科技集团有限公司 Code generation method and device

Citations (5)

* 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
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

Patent Citations (5)

* 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
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并行化性能提升的研究与实现", no. 6, pages 139 - 80 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112764763A (en) * 2020-12-31 2021-05-07 亿企赢网络科技有限公司 Code conversion method, system, equipment and computer readable storage medium
CN112764763B (en) * 2020-12-31 2024-01-26 亿企赢网络科技有限公司 Code conversion method, system, equipment and computer readable storage medium
CN113157261A (en) * 2021-03-31 2021-07-23 上海万物新生环保科技集团有限公司 Code generation method and device
CN113157261B (en) * 2021-03-31 2024-04-16 上海万物新生环保科技集团有限公司 Code generation method and device

Also Published As

Publication number Publication date
CN111475150B (en) 2023-12-05

Similar Documents

Publication Publication Date Title
US10509854B2 (en) Annotation processing of computer files
TWI556170B (en) Projecting native application programming interfaces of an operating system into other programming languages (2)
WO2019237701A1 (en) Cross-language programming
US10942718B2 (en) Systems and/or methods for type inference from machine code
US7512938B2 (en) Typed intermediate representation for object-oriented languages
JP2019053729A (en) Test method and test apparatus of smart contract
CN111475150B (en) Cross-language binding method, device, equipment and storage medium
US10846417B2 (en) Identifying permitted illegal access operations in a module system
US10387142B2 (en) Using annotation processors defined by modules with annotation processors defined by non-module code
CN105867886B (en) Method and device for writing table
CN111158665B (en) Code generation method and device, electronic equipment and storage medium
CN113138755A (en) JSON serialization and deserialization optimization method and system
US10983771B1 (en) Quality checking inferred types in a set of code
US8661425B1 (en) Method, apparatus, and computer-readable medium for storing data associated with a firmware program
CN109032572B (en) Method for Java program method internal connection based on byte code
CN110737431B (en) Software development method, development platform, terminal device and storage medium
US10635416B2 (en) Property filtering
US20140351799A1 (en) Binary interface instrumentation
US11106522B1 (en) Process memory resurrection: running code in-process after death
WO2022074712A1 (en) Specification information extraction device, specification information extraction method, and program
CN115599388B (en) API (application program interface) document generation method, storage medium and electronic equipment
CN117270962B (en) Method and device for processing coloring language, storage medium and electronic equipment
CN111626585B (en) Script data extraction method and device, computer equipment and storage medium
CN117348887A (en) Code compression method, device, equipment and storage medium
CN102323891B (en) Programming method

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