Method and device for creating bridge object, storage medium and electronic device

By obtaining target annotation information, generating script files and creating bridge objects, the problem of inefficient retrieval of target components is solved, and automated component calls and efficient maintenance are achieved.

CN114265587BActive Publication Date: 2025-08-15QINGDAO HAIER TECH +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111425025.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-26
Publication Date
2025-08-15
Estimated Expiration
2041-11-26

AI Technical Summary

Technical Problem

In the prior art, the efficiency of retrieving target components is low, and different developers adopt different technical solutions to increase maintenance costs.

Method used

By obtaining target annotation information, generating target script files, creating bridge objects, providing target applications with interfaces to call target components, realizing automated generation of script files and creating bridge objects.

Benefits of technology

Improve the efficiency of the target component to retrieve, avoid inefficiency and code error-prone problems when writing script files manually, and reduce maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114265587B_ABST
    Figure CN114265587B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for creating a bridge object, a storage medium, and an electronic device, wherein the method includes: obtaining one or more target annotation information, wherein the one or more target annotation information is used to indicate, by annotation, one or more target components where application resources used by a target application are located; generating a target script file corresponding to each target annotation information in the one or more target annotation information, obtaining one or more target script files, wherein the target script file is used to record the code for implementing the call to the target component indicated by the corresponding target annotation information; creating the one or more target script files as a bridge object, wherein the bridge object is used to provide the target application with an interface for calling one or more target components. The above technical solution solves the problem of low efficiency in calling target components in related technologies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communications, and in particular to a method and device for creating a bridge object, a storage medium, and an electronic device. Background Art

[0002] With the rapid iteration of the Zhijia app, the development cycle is shortened. Although the Zhijia app has fully completed the migration from the native technology stack to the Flutter technology stack, saving considerable manpower and time during the development process, many basic modules, such as user information, logging, push notifications, and devices, are still developed using native technology. To enable top-level Flutter modules to call underlying native modules, Flutter plugin technology is often used. Flutter plugins act as bridge objects. Program developers manually create Flutter plugin-style bridge objects to call native components as needed. This creation process is prone to errors, and different developers often use different technical solutions to solve the same problem, significantly increasing maintenance costs.

[0003] In view of the low efficiency of calling target components in related technologies, no effective solutions have been proposed yet. Summary of the Invention

[0004] The embodiments of the present invention provide a method and device for creating a bridge object, a storage medium, and an electronic device, so as to at least solve the problem of low efficiency in calling a target component in the related art.

[0005] According to an embodiment of the present invention, a method for creating a bridging object is provided, comprising: obtaining one or more target annotation information, wherein the one or more target annotation information are used to indicate, by annotation, one or more target components where application resources used on a target application are located; generating a target script file corresponding to each target annotation information in the one or more target annotation information to obtain one or more target script files, wherein the target script file is used to record code for implementing a call to a target component indicated by the target annotation information corresponding to the target annotation information; creating the one or more target script files as a bridging object, wherein the bridging object is used to provide the target application with an interface for calling the one or more target components.

[0006] Optionally, generating a target script file corresponding to each target annotation information in the one or more target annotation information includes: determining the target component type to which the target component indicated by each target annotation information belongs; obtaining a target call template corresponding to the target component type from component types and call templates with corresponding relationships; and generating a target script file corresponding to each target annotation information based on each target annotation information and the target call template.

[0007] Optionally, generating the target script file corresponding to each target annotation information based on each target annotation information and the target calling template includes one of the following: adding each target annotation information to the target calling template to obtain the target script file corresponding to each target annotation information; obtaining the target function code corresponding to each target annotation information from the annotation information and function code with a corresponding relationship; adding the target function code to the target calling template to obtain the target script file corresponding to each target annotation information.

[0008] Optionally, before determining the target component type to which the target component indicated by each target annotation information belongs, the method also includes: obtaining the calling code of each native component in multiple native components; annotating the calling code of each native component to obtain annotation information and native components with corresponding relationships.

[0009] Optionally, before obtaining the target calling template corresponding to the target component type from the component types and calling templates with corresponding relationships, the method also includes: clustering multiple native components to obtain multiple component types; extracting common code from the calling code of the native component corresponding to each component type in the multiple component types to obtain the component type and calling template with corresponding relationships.

[0010] Optionally, the one or more target script files are created as a bridge object, and the method further includes: splicing the one or more target script files to obtain an intermediate file; performing format conversion on the intermediate file to obtain the bridge object in the target format, wherein the target format is a code format that allows it to be loaded by the target application.

[0011] Optionally, after creating the one or more target script files as a bridge object, the method further includes: receiving a component call request sent by the target application, wherein the component call request is used to request to call a component to be called among the one or more target components; and forwarding the component call request to the component to be called through the bridge object.

[0012] According to another embodiment of the present invention, a device for creating a bridging object is also provided, including: a first acquisition module, used to acquire one or more target annotation information, wherein the one or more target annotation information is used to indicate one or more target components where application resources used on the target application are located by annotation; a generation module, used to generate a target script file corresponding to each target annotation information in the one or more target annotation information, to obtain one or more target script files, wherein the target script file is used to record the code for implementing the call to the target component indicated by the target annotation information corresponding to the target annotation information; a creation module, used to create the one or more target script files as a bridging object, wherein the bridging object is used to provide the target application with an interface for calling the one or more target components.

[0013] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the above-mentioned method for creating a bridge object when running.

[0014] According to another aspect of an embodiment of the present invention, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the method for creating a bridge object through the computer program.

[0015] In an embodiment of the present invention, one or more target annotation information is obtained, wherein the one or more target annotation information is used to indicate one or more target components where application resources used on the target application are located by way of annotation; a target script file corresponding to each target annotation information in the one or more target annotation information is generated to obtain one or more target script files, wherein the target script file is used to record the code for implementing the call to the target component indicated by the target annotation information corresponding to the target annotation information; the one or more target script files are created as a bridge object, wherein the bridge object is used to provide the target application with an interface for calling the one or more target components That is, annotation information is set for the component through annotation, and the code used to implement the calling component is recorded through the script file. When the called component is different, the script file used to call the component is also different. When the target annotation information is obtained, the target component can be used to determine the target script file used to call the target component through the target annotation information, and then the target script file corresponding to the target annotation information can be generated, and a bridge object that provides the target application with an interface for calling the target component is created. The purpose of automatically generating script files and creating bridge objects according to annotation information is achieved, and the problems of low efficiency and easy code errors caused by manually writing script files for calling components in related technologies are avoided. The above technical solution solves the problems of low efficiency in calling target components in related technologies and achieves the technical effect of improving the efficiency of calling target components. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0017] Figure 1 This is a hardware structure diagram of a computer terminal for a method for creating a bridge object according to an embodiment of the present invention;

[0018] Figure 2 is a flowchart of a method for creating a bridge object according to an embodiment of the present invention;

[0019] Figure 3 is a schematic diagram of optionally generating a bridge object according to an embodiment of the present application;

[0020] Figure 4 It is an optional component call timing diagram according to the embodiment of the request itself;

[0021] Figure 5 is a structural diagram of an optional bridge object creation model according to an embodiment of the present application;

[0022] Figure 6This is a structural block diagram of a device for creating a bridge object according to an embodiment of the present invention. DETAILED DESCRIPTION

[0023] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.

[0024] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0025] The method embodiments provided in the embodiments of the present application can be executed in a computer terminal, a computer terminal or a similar computing device. Taking running on a computer terminal as an example, Figure 1 This is a hardware structure diagram of a computer terminal for a method of creating a bridge object according to an embodiment of the present invention. Figure 1 As shown, the computer terminal may include one or more ( Figure 1 Only one is shown) a processor 102 (the processor 102 may include but is not limited to a microprocessor MCU or a programmable logic device FPGA and other processing devices) and a memory 104 for storing data. In an exemplary embodiment, the computer terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above-mentioned computer terminal. For example, the computer terminal may also include Figure 1 More or fewer components than shown, or with Figure 1 Equivalent functions or comparisons shown Figure 1 Shown are different configurations with more functionality.

[0026] The memory 104 can be used to store computer programs, such as software programs and modules of application software, such as the computer program corresponding to the method for creating a bridge object in the embodiment of the present invention. The processor 102 executes the computer programs stored in the memory 104 to execute various functional applications and data processing, thereby implementing the above-mentioned method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories may be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0027] The transmission device 106 is used to receive or send data via a network. A specific example of the aforementioned network may include a wireless network provided by a computer terminal's communications provider. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0028] In this embodiment, a method for creating a bridge object is provided, which is applied to the above-mentioned computer terminal. Figure 2 4 is a flow chart of a method for creating a bridge object according to an embodiment of the present invention, the flow includes the following steps:

[0029] Step S202: obtaining one or more target annotation information, wherein the one or more target annotation information is used to indicate one or more target components where application resources used by the target application are located by way of annotation;

[0030] Step S204: generating a target script file corresponding to each target annotation information in the one or more target annotation information, thereby obtaining one or more target script files, wherein the target script file is used to record the code for implementing the target component indicated by the target annotation information corresponding to the call;

[0031] Step S206: Create the one or more target script files as a bridge object, wherein the bridge object is used to provide an interface for the target application to call the one or more target components.

[0032] Through the above steps, one or more target annotation information is obtained, wherein the one or more target annotation information is used to indicate one or more target components where the application resources used on the target application are located by annotation; a target script file corresponding to each target annotation information in the one or more target annotation information is generated to obtain one or more target script files, wherein the target script file is used to record the code for implementing the call to the target component indicated by the target annotation information corresponding to the target annotation information; the one or more target script files are created as a bridge object, wherein the bridge object is used to provide the target application with an interface for calling the one or more target components, That is, annotation information is set for the component through annotation, and the code used to implement the calling component is recorded through the script file. When the called component is different, the script file used to call the component is also different. When the target annotation information is obtained, the target component can be used to determine the target script file used to call the target component through the target annotation information, and then the target script file corresponding to the target annotation information can be generated, creating a bridge object that provides the target application with an interface for calling the target component. The purpose of automatically generating script files and creating bridge objects according to the annotation information is achieved, avoiding the low efficiency and error-prone code problems caused by manually writing script files for calling components in the related art. The above technical solution solves the problems of low efficiency in calling target components in the related art and achieves the technical effect of improving the efficiency of calling target components.

[0033] In the technical solution provided in the above step S202, the target component is a component in a non-target application, and the target application cannot directly call the target component. For example, the target component may be a component on other applications, or a component stored in a certain storage location (the storage location is not in the target application).

[0034] In the technical solution provided in the above step S204, this solution does not limit the writing language of the script file. For example, the script file can be, but is not limited to, codes written in Java language, codes written in C++ language, etc.

[0035] Optionally, in this embodiment, the script file may be pre-set according to the component, or may be generated according to the annotation information of the component and a calling template.

[0036] In the technical solution provided in the above step S206, the bridge object may be obtained by combining one or more script files in a certain order, or by performing format conversion on the script files, which is not limited in this solution.

[0037] Figure 3This is an optional bridge object generation schematic diagram according to an embodiment of the present application, which is used to generate a target bridge object for calling a target component where an application resource used by a target application is located. The bridge object is used to provide an interface for the target application to call the target component, such as Figure 3 As shown:

[0038] S301: The developer creates the service class and corresponding interface declaration provided by the component, and uses the annotation model to add annotation information to the service class and interface declaration information to obtain the target annotation information of the service class and interface that the target application needs to call;

[0039] S302, generating a request for requesting Annotation analysis (annotation parsing library) to generate a target bridge object for calling a target component according to target annotation information;

[0040] 303, calling the annotation parsing library to parse the target annotation information;

[0041] S304, the annotation parsing library parses the target annotation information, thereby matching a target component that matches the target annotation information from the preset components in the annotation parsing library, and generating a bridge object that calls the target component according to the target script corresponding to the target component.

[0042] Figure 4 It is an optional component call timing diagram according to the embodiment of the request itself, through Figure 3 The embodiment generates a bridge object for calling the target component, and provides a bridge object for calling the Native component for the Flutter project, such as Figure 4 As shown:

[0043] S401: The operator starts the Flutter APP.

[0044] S402: When the Flutter APP needs to call a component in Native, it sends a request to the Flutter Plugin to call the bridge object generated by the Flutter Plugin.

[0045] S403: Call the target component in Native through the bridge object generated by the Flutter Plugin.

[0046] S404: Return the result of retrieving the target component in Native to the Flutter Plugin.

[0047] S405: Provide the target component's call result to the Flutter project.

[0048] Figure 5This is a structural diagram of an optional bridge object creation model according to an embodiment of the present application, which is used to generate a bridge object for calling a component based on the annotation information of the component that the target application needs to call, such as Figure 5 As shown, the entire structure consists of two major parts. The Flutter plugin primarily serves as a bridge for native data and services presented to the upper layer. Annotation_analysis generates bridge objects for calling components based on annotation information of the required components. During development, the required functional and business code in the Flutter plugin is first extracted to form templated code. This code then parses the annotations to generate the script code for calling the target component. Second, the functional code of the component required for templated code generation, excluding the plugin interface signature, is listed. This functional code is then designed as annotation information and created in the annotation library. Third, the annotation parsing library (annotation_generator) obtains the annotation information and the annotated target information through the source_gen library to generate the script code described in the first step. Fourth, once the conditions for script code generation are met, the code_builder library converts the completed script code into valid Dart code, completing the core steps of generating bridge objects through annotations. During use, the Flutter plugin sends the target annotation information of the target component that the target application needs to access to the annotation parsing library (annotation_generator). This library uses the annotations in the annotation parsing library to parse the target annotation information. Once completed, the console runs the command provided by the builder_runner library. This command launches source_gen to analyze the target annotation information and generate the script code described above. Finally, the code_builder library generates legal Dart code and outputs it to a file, resulting in a bridge object.

[0049] In an exemplary embodiment, generating a target script file corresponding to each target annotation information in the one or more target annotation information includes:

[0050] Determining the target component type to which the target component indicated by each target annotation information belongs;

[0051] Obtaining a target call template corresponding to the target component type from component types and call templates having a corresponding relationship;

[0052] A target script file corresponding to each target annotation information is generated according to each target annotation information and the target call template.

[0053] Optionally, in this embodiment, the target component type may be a component type determined according to a function of the target component, or may be a component type determined according to a data type in the target component.

[0054] Optionally, in this embodiment, there is a correspondence between the calling template and one or more component types. For example, the calling template A may correspond only to component type a, or there may be a correspondence between the calling template A and component type a and component type b.

[0055] Optionally, in this embodiment, the calling template includes logic code for implementing the calling component.

[0056] In an exemplary embodiment, generating a target script file corresponding to each target annotation information according to each target annotation information and the target call template includes one of the following:

[0057] Adding each target annotation information to the target call template to obtain a target script file corresponding to each target annotation information;

[0058] The target function code corresponding to each target annotation information is obtained from the annotation information and function code having a corresponding relationship; the target function code is added to the target call template to obtain the target script file corresponding to each target annotation information.

[0059] Optionally, in this embodiment, the target annotation information may include, but is not limited to, annotation information for indicating the called target component, and may also include annotation information of the calling interface of the target component, etc.

[0060] Optionally, in this embodiment, the target function code may include, but is not limited to, a code for implementing the business function of the target component, a code for indicating the interface of the target component, etc., which is not limited in this solution.

[0061] In an exemplary embodiment, before determining the target component type to which the target component indicated by each target annotation information belongs, the method further includes:

[0062] Get the calling code of each native component in multiple native components;

[0063] The calling code of each native component is annotated to obtain annotation information and native components with corresponding relationships.

[0064] Optionally, in this embodiment, the native component is a pre-stored component that can be called by the target application.

[0065] Optionally, in this embodiment, the calling code of the native component may include, but is not limited to, code adapted to the native component business function, code for business logic, code for indicating the component interface, and the like.

[0066] In an exemplary embodiment, before obtaining the target call template corresponding to the target component type from the component types and call templates having a corresponding relationship, the method further includes:

[0067] Cluster multiple native components to obtain multiple component types;

[0068] Common code is extracted from the calling code of the native component corresponding to each component type in the multiple component types to obtain a component type and a calling template with a corresponding relationship.

[0069] Optionally, in this embodiment, the clustering of native components may be performed based on the similarity of the business codes of the components, or may be performed based on the component functions of the native components, which is not limited in this solution.

[0070] In an exemplary embodiment, the one or more target script files are created as bridge objects, and the method further comprises:

[0071] Splicing the one or more target script files to obtain an intermediate file;

[0072] The intermediate file is format-converted to obtain the bridge object in a target format, wherein the target format is a code format that allows it to be loaded by the target application.

[0073] Optionally, in this embodiment, the format conversion may be obtained by processing the intermediate file using a root conversion model.

[0074] Optionally, in this embodiment, the target format may include, but is not limited to, Dart format, CSS format, JSON format, and the like.

[0075] In an exemplary embodiment, after creating the one or more target script files as bridge objects, the method further includes:

[0076] receiving a component calling request sent by the target application, wherein the component calling request is used to request calling a component to be called among the one or more target components;

[0077] The component call request is forwarded to the component to be called through the bridge object.

[0078] Optionally, in this embodiment, the target application calls the content corresponding to the component call request in the target component through the bridge object.

[0079] Optionally, in this embodiment, the component call request may include, but is not limited to, application information of the target application, account information of the account logged in to the target application, call content information, etc. For example, when the component only contains application information, the component to be called corresponding to the application can be called; when the component only contains account information, the component to be called corresponding to the account information can be called; when the component contains call content information, the component to be called corresponding to the call content information can be called.

[0080] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of various embodiments of the present invention.

[0081] Figure 6 is a structural block diagram of a device for creating a bridge object according to an embodiment of the present invention; Figure 6 Shown, including:

[0082] A first acquisition module 62 is configured to acquire one or more target annotation information, wherein the one or more target annotation information is used to indicate one or more target components where application resources used by a target application are located by way of annotation;

[0083] A generating module 64 is configured to generate a target script file corresponding to each target annotation information in the one or more target annotation information, thereby obtaining one or more target script files, wherein the target script file is configured to record the code for implementing the target component indicated by the target annotation information corresponding to the target annotation information;

[0084] The creation module 66 is configured to create the one or more target script files as a bridge object, wherein the bridge object is configured to provide an interface for the target application to call the one or more target components.

[0085] Optionally, the generation module includes: a determination unit for determining the target component type to which the target component indicated by each target annotation information belongs; an acquisition unit for acquiring the target call template corresponding to the target component type from the component type and call template with a corresponding relationship; and a generation unit for generating the target script file corresponding to each target annotation information based on each target annotation information and the target call template.

[0086] Optionally, the generation unit includes one of the following: adding each target annotation information to the target call template to obtain the target script file corresponding to each target annotation information; obtaining the target function code corresponding to each target annotation information from the annotation information and function code with a corresponding relationship; adding the target function code to the target call template to obtain the target script file corresponding to each target annotation information.

[0087] Optionally, the device also includes: a second acquisition module, used to obtain the calling code of each native component in multiple native components before determining the target component type to which the target component indicated by each target annotation information belongs; an annotation module, used to annotate the calling code of each native component to obtain annotation information and native components with corresponding relationships.

[0088] Optionally, the device also includes: a clustering module, which is used to cluster multiple native components to obtain multiple component types before obtaining the target calling template corresponding to the target component type from the component types and calling templates with corresponding relationships; an extraction module, which is used to extract common code from the calling code of the native component corresponding to each component type in the multiple component types to obtain the component type and calling template with corresponding relationships.

[0089] Optionally, the creation module includes: a splicing unit for splicing the one or more target script files to obtain an intermediate file; a conversion unit for converting the format of the intermediate file to obtain the bridge object in the target format, wherein the target format is a code format that allows it to be loaded by the target application.

[0090] Optionally, the device further includes: a receiving module for receiving a component call request sent by the target application after the one or more target script files are created as a bridge object, wherein the component call request is used to request to call a component to be called among the one or more target components; and a forwarding module for forwarding the component call request to the component to be called through the bridge object.

[0091] Through the above embodiment, one or more target annotation information is obtained, wherein the one or more target annotation information is used to indicate one or more target components where the application resources used on the target application are located by annotation; a target script file corresponding to each target annotation information in the one or more target annotation information is generated to obtain one or more target script files, wherein the target script file is used to record the code for implementing the call to the target component indicated by the target annotation information corresponding to the target annotation information; the one or more target script files are created as a bridge object, wherein the bridge object is used to provide the target application with an interface for calling the one or more target components That is, annotation information is set for the component through annotation, and the code used to implement the calling component is recorded through the script file. When the called component is different, the script file used to call the component is also different. When the target annotation information is obtained, the target component can be used to determine the target script file used to call the target component through the target annotation information, and then the target script file corresponding to the target annotation information can be generated, and a bridge object that provides the target application with an interface for calling the target component is created. The purpose of automatically generating script files and creating bridge objects according to annotation information is achieved, and the problems of low efficiency and easy code errors caused by manually writing script files for calling components in related technologies are avoided. The above technical solution solves the problems of low efficiency in calling target components in related technologies and achieves the technical effect of improving the efficiency of calling target components.

[0092] An embodiment of the present invention further provides a storage medium, which includes a stored program, wherein the program executes any of the above methods when it is run.

[0093] Optionally, in this embodiment, the storage medium may be configured to store program codes for executing the following steps:

[0094] Acquire one or more target annotation information, wherein the one or more target annotation information is used to indicate one or more target components where application resources used by the target application are located by way of annotation;

[0095] Generate a target script file corresponding to each target annotation information in the one or more target annotation information to obtain one or more target script files, wherein the target script file is used to record the code for implementing the target component indicated by the target annotation information corresponding to the call;

[0096] The one or more target script files are created as a bridge object, wherein the bridge object is used to provide an interface for the target application to call the one or more target components.

[0097] An embodiment of the present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0098] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0099] Optionally, in this embodiment, the processor may be configured to execute the following steps through a computer program:

[0100] Acquire one or more target annotation information, wherein the one or more target annotation information is used to indicate one or more target components where application resources used by the target application are located by way of annotation;

[0101] Generate a target script file corresponding to each target annotation information in the one or more target annotation information to obtain one or more target script files, wherein the target script file is used to record the code for implementing the target component indicated by the target annotation information corresponding to the call;

[0102] The one or more target script files are created as bridge objects, wherein the bridge object is used to provide an interface for the target application to call the one or more target components. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0103] Optionally, specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.

[0104] Obviously, those skilled in the art will appreciate that the various modules or steps of the present invention described above can be implemented using a general-purpose computing device, centralized on a single computing device, or distributed across a network of multiple computing devices. Alternatively, they can be implemented using program code executable by a computing device, which can then be stored in a storage device and executed by the computing device. In some cases, the steps shown or described can be performed in a different order than that shown, or can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.

[0105] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the principles of the present invention are intended to be within the scope of protection of the present invention.

Claims

1. A method for creating a bridge object, characterized in that: include: Acquire one or more target annotation information, wherein the one or more target annotation information is used to indicate one or more target components where application resources used by the target application are located by way of annotation; Generate a target script file corresponding to each target annotation information in the one or more target annotation information to obtain one or more target script files, wherein the target script file is used to record the code for implementing the target component indicated by the target annotation information corresponding to the call, and the target script file is generated according to the target call template corresponding to the component type of the target component and the annotation information, and the target call template is obtained by performing general code extraction on the calling code of the native component according to the component function similarity of the native component; The one or more target script files are created as a bridge object, wherein the bridge object is used to provide an interface for the target application to call the one or more target components.

2. The method for creating a bridge object according to claim 1, wherein: Generating a target script file corresponding to each target annotation information in the one or more target annotation information includes: Determining the target component type to which the target component indicated by each target annotation information belongs; Obtaining a target call template corresponding to the target component type from component types and call templates having a corresponding relationship; A target script file corresponding to each target annotation information is generated according to each target annotation information and the target call template.

3. The method for creating a bridge object according to claim 2, wherein: Generating a target script file corresponding to each target annotation information according to each target annotation information and the target call template includes one of the following: Adding each target annotation information to the target call template to obtain a target script file corresponding to each target annotation information; Obtaining a target function code corresponding to each target annotation information from the annotation information and the function code having a corresponding relationship; The target function code is added to the target call template to obtain the target script file corresponding to each target annotation information.

4. The method for creating a bridge object according to claim 2, wherein: Before determining the target component type to which the target component indicated by each target annotation information belongs, the method further includes: Get the calling code of each native component in multiple native components; The calling code of each native component is annotated to obtain annotation information and native components with corresponding relationships.

5. The method for creating a bridge object according to claim 2, wherein: Before obtaining the target call template corresponding to the target component type from the component types and call templates having a corresponding relationship, the method further includes: Cluster multiple native components to obtain multiple component types; Common code is extracted from the calling code of the native component corresponding to each component type in the multiple component types to obtain a component type and a calling template with a corresponding relationship.

6. The method for creating a bridge object according to claim 1, wherein: Creating the one or more target script files as bridge objects, the method further comprising: Splicing the one or more target script files to obtain an intermediate file; The intermediate file is format-converted to obtain the bridge object in a target format, wherein the target format is a code format that allows it to be loaded by the target application.

7. The method for creating a bridge object according to any one of claims 1 to 6, characterized in that: After creating the one or more target script files as bridge objects, the method further includes: receiving a component calling request sent by the target application, wherein the component calling request is used to request calling a component to be called among the one or more target components; The component call request is forwarded to the component to be called through the bridge object.

8. A device for creating a bridge object, characterized in that: include: A first acquisition module is configured to acquire one or more target annotation information, wherein the one or more target annotation information is used to indicate one or more target components where application resources used by a target application are located by way of annotation; A generating module, configured to generate a target script file corresponding to each target annotation information in the one or more target annotation information, to obtain one or more target script files, wherein the target script file is used to record the code for implementing the target component indicated by the target annotation information corresponding to the call; A creation module, configured to create the one or more target script files as a bridge object, wherein the bridge object is configured to provide an interface for the target application to call the one or more target components; The target script file is generated based on the target call template corresponding to the component type of the target component and the annotation information. The target call template is obtained by performing general code extraction on the calling code of the native component based on the component function similarity of the native component.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method described in any one of claims 1 to 7 when executed.

10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.

Citation Information

Patent Citations

  • Cross-process callback execution method and device, equipment and storage medium

    CN111880866A

  • Data calling method and device, storage medium and electronic device

    CN113110896A

  • Generating Interfaces From Annotated Entity Definitions For Developing Applications

    US20200272438A1