Application running method, device, electronic device and storage medium
By reading and writing function pointers from the lifecycle phase into the executable file generated during the application compilation phase, the coupling problem between the main project and business components is solved, enabling low-cost and efficient maintenance and decoupling of business components.
Patent Information
- Application Number
- CN202010627293.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-01
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2040-07-01
AI Technical Summary
In existing technologies, the main application project needs to manually maintain the registry, which increases maintenance costs. Furthermore, the high coupling between the main project and business components makes independent development and testing difficult.
By reading the function pointers of callback functions of business components from the executable file generated during the application compilation phase and writing them into the data table corresponding to the lifecycle phase, the callback function corresponding to the function pointer is read from the data table and executed when the lifecycle phase is entered, thus avoiding the need for direct maintenance of the registry and the introduction of business components in the main project.
This decouples the main project from business components, reduces maintenance costs, simplifies the process of adding and deleting business components, and improves the independence of development and testing.
Smart Images

Figure CN113760396B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to computer technology, and in particular to an application running method, device, electronic device and storage medium. Background Art
[0002] After being started, the application installed on the terminal will go through various life cycle stages, including the foreground running stage, the background running stage, etc. When the application enters a certain life cycle stage, it is necessary to perform certain processing operations by calling the preset method function of the business component pre-registered in the registry. For example, when the shopping application enters the background running stage from the foreground running stage, it is necessary to call a method function of the video business component to pause the video. Similarly, when the shopping application enters the foreground running stage from the background running stage, it is necessary to call another method function to continue playing the video.
[0003] In the process of implementing the present invention, the inventors found that there are at least the following technical problems in the prior art:
[0004] In the above existing solutions, the main project of the application needs to maintain a registry for each life cycle stage. If there are new or deleted business components, the registry needs to be manually inserted or deleted, which has high maintenance costs. In addition, each business component needs to be introduced into the main project, which increases the coupling between the main project and the business components, making it difficult to independently develop and test the main project and the business components. Summary of the invention
[0005] The embodiments of the present invention provide an application operation method, device, electronic device and storage medium to solve the coupling problem between a main project and a business component and to achieve efficient and low-cost maintenance of the business component.
[0006] In a first aspect, an embodiment of the present invention provides an application running method, the method comprising:
[0007] When a startup trigger event of an application is detected, a function pointer of a callback function of a business component and a life cycle stage corresponding to the function pointer are read from an executable file generated in the application compilation phase, and the function pointer is written into a data table corresponding to the life cycle stage;
[0008] After detecting that the application program has entered a life cycle stage, a function pointer is read from the data table corresponding to the entered life cycle stage, and a callback function corresponding to the read function pointer is executed.
[0009] In a second aspect, an embodiment of the present invention further provides an application running device, the device comprising:
[0010] A function pointer writing module is used to read the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer from the executable file generated in the application compilation phase when the application startup trigger event is detected, and write the function pointer into the data table corresponding to the life cycle stage;
[0011] The callback function reading module is used to read the function pointer from the data table corresponding to the entered life cycle stage after detecting that the application enters the life cycle stage, and execute the callback function corresponding to the read function pointer.
[0012] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0013] one or more processors;
[0014] A memory for storing one or more programs;
[0015] When the one or more programs are executed by the one or more processors, the one or more processors implement any application running method described in the embodiments of the present invention.
[0016] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any application running method described in the embodiments of the present invention.
[0017] The technical solution of the embodiment of the present invention, when detecting the start trigger event of the application, reads the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer from the executable file generated in the compilation stage of the application, writes the function pointer into the data table corresponding to the life cycle stage, and after detecting that the application enters the life cycle stage, reads the function pointer from the data table corresponding to the entered life cycle stage, and executes the callback function corresponding to the read function pointer, so as to solve the problem that when adding or deleting business components in the prior art, it is necessary to manually insert or delete the registry, which has high maintenance cost, and where the business components are needed in the life cycle code of the main project, it is necessary to introduce each business component into the main project, which increases the coupling between the main project and the business components. The technical solution of the embodiment of the present invention, when entering the life cycle stage, the main project reads the function pointer from the data table, executes the callback function corresponding to the function pointer, does not need to maintain the registry, and does not need to introduce the business components into the main project, so as to achieve the decoupling between the main project and the business components. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 is a flow chart of an application running method provided in Embodiment 1 of the present invention;
[0020] Figure 2 is a flow chart of an application running method provided by Embodiment 2 of the present invention;
[0021] Figure 3 This is a schematic diagram of the self-registration process of the service component provided in the second embodiment of the present invention;
[0022] Figure 4 is a flow chart of an application running method provided by Embodiment 3 of the present invention;
[0023] Figure 5 is a schematic diagram of the structure of an application running device provided in Embodiment 4 of the present invention;
[0024] Figure 6 It is a structural schematic diagram of an electronic device provided in Embodiment 5 of the present invention. DETAILED DESCRIPTION
[0025] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0026] Embodiment 1
[0027] Figure 1 This is a flowchart of an application running method provided in the first embodiment of the present invention. This embodiment is applicable to the compilation and running scenario of the application. The method can be executed by an application running device, which can be implemented by software and / or hardware and integrated in a terminal with an application.
[0028] Before introducing the technical solution of the embodiment of the present invention, in order to better understand the technical solution of the embodiment of the present invention, the compilation phase and the running phase of the application, as well as the life cycle of the application are first introduced:
[0029] Before the application runs, the programmer needs to write some source code. The source code contains the life cycle method functions corresponding to each life cycle stage of the application. The life cycle method functions are included in the main project. When the application starts running and enters a life cycle stage, the life cycle method functions corresponding to the life cycle stage will be executed. When the programmer has finished writing the source code, the source code needs to be compiled. At this time, the application enters the compilation stage, which compiles the source code written by the programmer to generate the final executable file. When the user clicks the icon of the installed application to trigger the application to start, the application first enters the loading stage, and after the loading stage, it enters the running stage, that is, the life cycle stage of the application.
[0030] Each application has different life cycle stages, and the application will switch life cycle stages during operation based on factors such as user operations. For example, when a user is watching a video introduction of a product on the product details page of the Taobao application, the application is in the foreground life cycle stage. At this time, if the user clicks the "Back" button on the phone to pause the video playback, the Taobao application will be triggered to enter the background life cycle stage from the foreground life cycle stage. If the user clicks the icon of the application again at this time, the application will enter the foreground life cycle stage from the background life cycle stage and continue to play the video.
[0031] The method of this embodiment specifically includes the following steps:
[0032] S110. When a startup trigger event of an application is detected, the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer are read from the executable file generated in the application compilation phase, and the function pointer is written into a data table corresponding to the life cycle stage.
[0033] For example, a user writes some source code, and after the source code is written, it needs to be compiled. The executable file can be a file generated by the application program during the compilation phase of the source code. When a startup trigger event of the application program is detected, the application program enters the loading phase and loads the executable file generated during the compilation phase into the memory. The trigger event here can be, for example, that the user clicks to open the Taobao application program.
[0034] The callback function is a method function under the business component, for example, it can be a method function that pauses or plays a certain video component in Taobao. The function pointer can be a pointer corresponding to the callback function, and each callback function has a corresponding function pointer.
[0035] Specifically, when a certain application is detected to be started, the main project will read the function pointer of the callback function of the business component of the application and the life cycle stage corresponding to the function pointer from the executable file generated in the compilation stage of the Taobao application, and write the function pointer into the data table corresponding to the life cycle stage corresponding to the function pointer. In this way, when the application enters the life cycle stage later, the callback function corresponding to it will be called back and executed based on the function pointer.
[0036] It should be noted that the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer are read from the executable file generated in the application compilation stage, and the function pointer is written into the data table corresponding to the life cycle stage. Specifically, it can be: by executing the loader code, the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer are read from the executable file generated in the application compilation stage, and the function pointer is written into the data table corresponding to the life cycle stage.
[0037] S120: After detecting that the application has entered a life cycle stage, read a function pointer from a data table corresponding to the entered life cycle stage, and execute a callback function corresponding to the read function pointer.
[0038] Exemplarily, after the loading phase is over, the application enters the life cycle phase. According to the different life cycle phases entered by the application, the corresponding function pointer is read from the data table corresponding to the different life cycle phases entered, and the callback function corresponding to the read function pointer is executed.
[0039] For example, when the Taobao application is triggered to start, the executable file generated in the compilation phase is loaded into the memory, and the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer are read from the loaded executable file, and the function pointer is written into the data table corresponding to the corresponding life cycle stage. When the loading is completed, Taobao enters its life cycle stage. When a user watches a video introduction of a product on the product details page of the Taobao application, the application is in the foreground running life cycle stage. At this time, if the user clicks the "Back" button on the phone, it will trigger the application to switch to the background running life cycle stage. At this time, the function pointer 1 is read from the data table corresponding to the background running life cycle stage, and the callback function 1 corresponding to the read function pointer 1 is executed to pause the video playback.
[0040] Then, when the user clicks on the icon of the application, the application is triggered to enter the foreground running life cycle stage from the background running life cycle stage. At this time, another function pointer 2 is read from the data table corresponding to the foreground running life cycle stage, and the callback function 2 corresponding to the read other function pointer 2 is executed to achieve continued playback of the video.
[0041] In this way, when adding a business component, the function pointer corresponding to the callback function of the newly added business component can be written into the executable file during the compilation stage. The function pointer corresponding to the callback function of the newly added component can be read from the executable file during the startup loading stage and written into the data table of the corresponding life cycle stage. When entering the life cycle stage, the corresponding function pointer is read according to the life cycle stage entered, and the callback function corresponding to the function pointer is executed. Similarly, when a business component is to be deleted, the function pointer corresponding to the callback function of the business component that has been deleted during the compilation stage will not be written into the executable file. The function pointer corresponding to the callback function of the deleted component will not be written into the data table of the corresponding life cycle stage during the startup loading stage. When entering the life cycle stage, the main project will not be able to read the function pointer corresponding to the life cycle stage.
[0042] This solves the problem in the prior art that when adding or deleting business components, the registry needs to be manually inserted or deleted, which has high maintenance costs. In addition, where business components are needed in the lifecycle code of the main project, each business component needs to be introduced into the main project, which increases the coupling problem between the main project and the business components. When the technical solution of the embodiment of the present invention enters the lifecycle stage, the main project reads the function pointer from the data table and executes the callback function corresponding to the function pointer. There is no need to maintain the registry, and there is no need to introduce business components into the main project, thus achieving decoupling between the main project and the business components.
[0043] It should be noted that the function pointer is read from the data table corresponding to the entered life cycle stage, and the callback function corresponding to the read function pointer is executed. Specifically, the function pointer can be read from the data table corresponding to the entered life cycle stage by executing the main project code, and the callback function corresponding to the read function pointer is executed. In this way, the decoupling between the main project and the business component is achieved.
[0044] It should be noted that the data table actually contains identifiers of life cycle stages corresponding to function pointers. When reading function pointers, all function pointers corresponding to identifiers of all life cycle stages in the data table are read by traversing.
[0045] The technical solution of the embodiment of the present invention, when detecting the start trigger event of the application, reads the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer from the executable file generated in the compilation stage of the application, writes the function pointer into the data table corresponding to the life cycle stage, and after detecting that the application enters the life cycle stage, reads the function pointer from the data table corresponding to the entered life cycle stage, and executes the callback function corresponding to the read function pointer, so as to solve the problem that when adding or deleting business components in the prior art, the registration table needs to be manually inserted or deleted, the maintenance cost is high, and where the business components are needed in the life cycle code of the main project, each business component needs to be introduced in the main project, which increases the coupling between the main project and the business components. The technical solution of the embodiment of the present invention, when entering the life cycle stage, the main project reads the function pointer from the data table, executes the callback function corresponding to the function pointer, does not need to maintain the registration table, and does not need to introduce the business components in the main project, so as to achieve the decoupling between the main project and the business components.
[0046] Embodiment 2
[0047] Figure 2 A flowchart of the application running method provided for the second embodiment of the present invention, the embodiment of the present invention can be combined with the various optional schemes in the above embodiments. Based on the above embodiments, this embodiment preferably includes before detecting the start trigger event of the application program: when compiling the application program, the function pointer of the callback function of the business component that needs to be executed in one or more life cycle stages, and the life cycle stage corresponding to the function pointer, are written into the data segment of the executable file generated after compilation. Reading the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer from the executable file generated in the application compilation stage includes: reading the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer from the data segment of the executable file generated after compilation.
[0048] The explanations of the terms that are the same or corresponding to the above embodiments are not repeated here. Figure 2 , the application running method provided in this embodiment includes:
[0049] S210. When compiling the application, write the function pointer of the callback function of the business component that needs to be executed in one or more life cycle stages, and the life cycle stage corresponding to the function pointer, into the data segment of the executable file generated after compilation.
[0050] Exemplary, reference Figure 3The schematic diagram of the self-registration process of the business component, when compiling the source code of the application, if the life cycle stage of the application is one, the function pointer of the callback function of the business component that needs to be executed in this life cycle stage and the life cycle stage corresponding to the function pointer can be written into the data segment of the executable file generated after compilation in the form of static variables, for example, it can be written into the __DATA segment of the Mach-O file generated after compilation. If the life cycle stage of the application is multiple, the function pointers of each callback function corresponding to each life cycle stage that the business component needs to execute in each life cycle stage and each life cycle stage corresponding to each function pointer can be written into the data segment of the executable file generated after compilation. So that the function pointers of the callback functions corresponding to each life cycle stage can be read from the data segment of the executable file generated after compilation. Optionally, the function pointer can be stored in a static variable in the form of a key-value pair, where the key represents the life cycle stage and the value represents the function pointer.
[0051] The final executable file of an application on the iOS platform is a binary Mach-O file. The Mach-O file mainly contains __TEXT, __DATA, and __LINKEDIT segments. __TEXT mainly stores mach headers, machine instructions, and read-only constants. _DATA contains initialized global static variables and local static variables. __LINKEDIT contains information about function variables (such as names and addresses).
[0052] Optionally, the function pointer of the callback function of the business component that needs to be executed in one or more life cycle stages, and the life cycle stage corresponding to the function pointer, are written into the data segment of the executable file generated after compilation. Specifically, it can be: the function pointer of the callback function of the business component that needs to be executed in one or more life cycle stages, the life cycle stage corresponding to the function pointer, and the preset position parameters are used as input parameters to call and execute a preset method function, so as to write the function pointer and the life cycle stage corresponding to the function pointer into the data segment of the executable file generated after compilation according to the preset position parameters.
[0053] Exemplarily, the preset position parameter may be a function pointer of a callback function of a preset business component that needs to be executed in one or more life cycle stages, and a position parameter in the data segment of the subsequently generated executable file. For example, the preset method function here may be a macro function.
[0054] The function pointer of the callback function that the business component needs to execute at one or more life cycle stages, the life cycle stage corresponding to the function pointer, and the position parameters of the function pointer of the callback function that the business component needs to execute at one or more life cycle stages in the data segment of the subsequently generated executable file are used as input parameters, and the business component calls the above-mentioned preset method function. According to the position parameters of the function pointer of the callback function that the business component needs to execute at one or more life cycle stages in the data segment of the subsequently generated executable file, the function pointer of the callback function that the business component needs to execute at one or more life cycle stages and the life cycle stage corresponding to the function pointer are written into the data segment of the executable file generated after compilation. In this way, the position of the function pointer of the callback function that the business component needs to execute at one or more life cycle stages and the life cycle stage corresponding to the function pointer in the data segment of the executable file can be clearly known, so that the function pointer of the callback function corresponding to each life cycle stage can be read based on the position later, and the callback function corresponding to the function pointer can be executed.
[0055] Optionally, before compiling the application, the method further includes: setting a preset attribute modifier for the preset method function to identify that the preset method function is called and executed during the compiling stage.
[0056] Exemplarily, the preset attribute modifier may be an identifier for modifying the preset method function. After the programmer writes the source code of the application, before the source code is compiled, the preset method function is modified and the corresponding preset attribute modifier is set to identify that the preset method function is called and executed during the compilation stage. For example, the attribute__ modifier is set for the section method (i.e., macro method) so that the section method can be called and executed during compilation.
[0057] S220. When a startup trigger event of an application is detected, the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer are read from the data segment of the executable file generated after compilation, and the function pointer is written into a data table corresponding to the life cycle stage.
[0058] S230: After detecting that the application has entered a life cycle stage, read a function pointer from a data table corresponding to the entered life cycle stage, and execute a callback function corresponding to the read function pointer.
[0059] The technical solution of an embodiment of the present invention is to write the function pointers of the callback functions of the business components that need to be executed in one or more life cycle stages, and the life cycle stages corresponding to the function pointers, into the data segment of the executable file generated after compilation when compiling the application, so that the function pointers of the callback functions corresponding to each life stage can be read from the data segment of the executable file generated after compilation later.
[0060] Embodiment 3
[0061] Figure 4 The flowchart of the application running method provided for the third embodiment of the present invention can be combined with the various optional schemes in the above embodiments. Based on the above embodiments, this embodiment preferably includes after the application is started: when a trigger operation on the first business component in the currently displayed page is detected, obtaining the identification information of the target method function of the second business component that needs to be called in advance for the first business component; parsing the identification information, and after determining that the target method function of the second business component needs to be called according to the parsing result, calling and executing the target method function.
[0062] The explanations of the terms that are the same or corresponding to the above embodiments are not repeated here. Figure 3 , the application running method provided in this embodiment includes:
[0063] S310. When compiling an application, write the function pointer of the callback function of the business component that needs to be executed in one or more life cycle stages, and the life cycle stage corresponding to the function pointer, into the data segment of the executable file generated after compilation.
[0064] S320. When a startup trigger event of an application is detected, the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer are read from the data segment of the executable file generated after compilation, and the function pointer is written into a data table corresponding to the life cycle stage.
[0065] S330: After detecting that the application has entered a life cycle stage, read a function pointer from a data table corresponding to the entered life cycle stage, and execute a callback function corresponding to the read function pointer.
[0066] S340. If the entered life cycle stage is the foreground running stage, when a trigger operation on the first business component in the currently displayed page is detected, the identification information of the target method function of the second business component that needs to be called and is pre-set for the first business component is obtained; the identification information is parsed, and after determining that the target method function of the second business component needs to be called according to the parsing result, the target method function is called and executed.
[0067] Exemplarily, the currently displayed page may be the page currently displayed after a certain application is opened when the application is started. The first business component may be any business component in the application. The second business component may be another business component in the application. The target method function may be any method function in the second business component. The identification information of the target method function of the second business component to be called may be any identifier that can represent the target method function of calling the second business component, for example, a Uniform Resource Locator (URL), a modifier, an icon identifier, etc., which is not limited here, as long as the target method function can be identified.
[0068] Optionally, the identification information may include: a component identification of the first business component and a function identification of the target method function, and input parameters required for calling the target method function. The component identification of the first business component may be any identification that can represent the first component; the identification of the target method function may be any identification that can represent the target method function.
[0069] When a trigger operation on the first business component in the currently displayed page is detected, identification information of a target method function of the second business component that needs to be called by the first business component is obtained, which is pre-set in the code of the first business component, and the identification information is passed to the parser. The parser parses the identification information, determines based on the parsing result that the target method function of the second business component needs to be called, and then calls and executes the target method function.
[0070] This solution uses the dynamic characteristics of the Objective-C language to perform routing interaction between business components through URLs, thereby solving the problem in the prior art that when a method function of another business component needs to be called in one business component, the other business component needs to be introduced in the header file of the business component, resulting in coupling of the two business components. This solution of the embodiment of the present invention achieves decoupling between the business components.
[0071] The technical solution of the embodiment of the present invention achieves decoupling between the business components by acquiring identification information of a target method function of a second business component that is pre-set for the first business component and needs to be called when a trigger operation on the first business component in the currently displayed page is detected; parsing the identification information, and after determining that the target method function of the second business component needs to be called based on the parsing result, calling and executing the target method function.
[0072] The following is an embodiment of an application running device provided in an embodiment of the present invention. The device and the application running methods of the above-mentioned embodiments belong to the same inventive concept. For details not fully described in the embodiment of the application running device, reference can be made to the embodiment of the above-mentioned application running method.
[0073] Embodiment 4
[0074] Figure 5 A schematic diagram of the structure of an application running device provided in Embodiment 4 of the present invention is shown in FIG. Figure 5 As shown, the device includes: a function pointer writing module 310 and a callback function reading module 320.
[0075] The function pointer writing module 310 is used to read the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer from the executable file generated in the application compilation phase when the application startup trigger event is detected, and write the function pointer into the data table corresponding to the life cycle stage;
[0076] The callback function reading module 320 is used to read a function pointer from the data table corresponding to the entered life cycle stage after detecting that the application has entered the life cycle stage, and execute the callback function corresponding to the read function pointer.
[0077] Based on the technical solution of the above embodiment, the device further includes:
[0078] The information writing module is used to write the function pointer of the callback function of the business component that needs to be executed in one or more life cycle stages, and the life cycle stage corresponding to the function pointer, into the data segment of the executable file generated after compilation when compiling the application.
[0079] Based on the technical solution of the above embodiment, the function pointer writing module 310 is specifically used for:
[0080] The function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer are read from the data segment of the executable file generated after the compilation.
[0081] Based on the technical solution of the above embodiment, the information writing module is specifically used for:
[0082] The function pointer of the callback function of the business component that needs to be executed in one or more life cycle stages, the life cycle stage corresponding to the function pointer, and the preset position parameters are used as input parameters to call and execute the preset method function, so as to write the function pointer and the life cycle stage corresponding to the function pointer into the data segment of the executable file generated after compilation according to the preset position parameters.
[0083] Based on the technical solution of the above embodiment, the device further includes:
[0084] The function modification module is used to set a preset attribute modifier for the preset method function to identify that the preset method function is called and executed during the compilation stage; wherein the preset method function is a macro function.
[0085] Based on the technical solution of the above embodiment, the function pointer writing module 310 is further specifically used for:
[0086] By executing the loader code, the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer are read from the executable file generated in the application compilation stage, and the function pointer is written into the data table corresponding to the life cycle stage.
[0087] Based on the technical solution of the above embodiment, the callback function reading module 320 is specifically used for:
[0088] By executing the main project code, a function pointer is read from the data table corresponding to the entered life cycle stage, and a callback function corresponding to the read function pointer is executed.
[0089] Based on the technical solution of the above embodiment, the device further includes:
[0090] An identification information acquisition module, used to acquire identification information of a target method function of a second business component that needs to be called and is preset for the first business component when a trigger operation on the first business component in the currently displayed page is detected;
[0091] The function calling and executing module is used to parse the identification information, and after determining that a target method function of the second business component needs to be called according to the parsing result, call and execute the target method function.
[0092] Optionally, the identification information includes: a component identification of the first business component and a function identification of the target method function, and input parameters required for calling the target method function.
[0093] The application running device provided in the embodiment of the present invention can execute the method provided in any embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method.
[0094] It is worth noting that in the embodiment of the above-mentioned application running device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0095] Embodiment 5
[0096] Figure 6 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present invention. Figure 6 A block diagram of an exemplary electronic device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 6 The electronic device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0097] like Figure 6 As shown, the electronic device 12 is in the form of a general purpose computing device. The service components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 connecting different system service components (including the system memory 28 and the processing unit 16).
[0098] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0099] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0100] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 6 not shown, usually called a "hard drive"). Although Figure 6Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0101] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods of the embodiments described herein.
[0102] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), may communicate with one or more devices that enable a user to interact with the electronic device 12, and / or may communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the electronic device 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 via a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0103] The processing unit 16 executes various functional applications and data processing by running the program stored in the system memory 28, for example, implementing an application running method provided by the embodiment of the present invention, the method comprising:
[0104] When a startup trigger event of an application is detected, a function pointer of a callback function of a business component and a life cycle stage corresponding to the function pointer are read from an executable file generated in the application compilation phase, and the function pointer is written into a data table corresponding to the life cycle stage;
[0105] After detecting that the application program has entered a life cycle stage, a function pointer is read from the data table corresponding to the entered life cycle stage, and a callback function corresponding to the read function pointer is executed.
[0106] Of course, those skilled in the art can understand that the processor can also implement the technical solution of the method for determining the reserved inventory amount provided in any embodiment of the present invention.
[0107] The electronic device proposed in this embodiment and the application running method proposed in the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as executing the application running method.
[0108] Embodiment 6
[0109] Embodiment 6 of the present invention provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the application running method steps as described in any embodiment of the present invention are implemented. The method includes:
[0110] When a startup trigger event of an application is detected, a function pointer of a callback function of a business component and a life cycle stage corresponding to the function pointer are read from an executable file generated in the application compilation phase, and the function pointer is written into a data table corresponding to the life cycle stage;
[0111] After detecting that the application program has entered a life cycle stage, a function pointer is read from the data table corresponding to the entered life cycle stage, and a callback function corresponding to the read function pointer is executed.
[0112] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0113] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0114] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0115] Computer program code for performing the operations of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0116] It should be understood by those skilled in the art that the modules or steps of the present invention described above can be implemented by a general-purpose computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, optionally, they can be implemented by a program code executable by a computer device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0117] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
[0118] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. An application running method, characterized in that: include: When the application is compiled, the function pointer of the callback function of the business component that needs to be executed in one or more life cycle stages and the life cycle stage corresponding to the function pointer are written into the data segment of the executable file generated after compilation; When a startup trigger event of an application is detected, a function pointer of a callback function of a business component and a life cycle stage corresponding to the function pointer are read from an executable file generated in the application compilation phase, and the function pointer is written into a data table corresponding to the life cycle stage; After detecting that the application program has entered a life cycle stage, a function pointer is read from the data table corresponding to the entered life cycle stage, and a callback function corresponding to the read function pointer is executed.
2. The method according to claim 1, characterized in that: The step of reading the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer from the executable file generated in the application compilation stage includes: The function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer are read from the data segment of the executable file generated after the compilation.
3. The method according to claim 2, characterized in that The step of writing the function pointer of the callback function of the business component that needs to be executed in one or more life cycle stages, and the life cycle stage corresponding to the function pointer, into the data segment of the executable file generated after compilation includes: The function pointer of the callback function of the business component that needs to be executed in one or more life cycle stages, the life cycle stage corresponding to the function pointer, and the preset position parameters are used as input parameters to call and execute the preset method function, so as to write the function pointer and the life cycle stage corresponding to the function pointer into the data segment of the executable file generated after compilation according to the preset position parameters.
4. The method according to claim 3, characterized in that Before compiling the application, the method further includes: A preset attribute modifier is set for the preset method function to identify that the preset method function is called and executed during the compilation phase; wherein the preset method function is a macro function.
5. The method according to claim 1, characterized in that The step of reading the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer from the executable file generated in the application compilation stage, and writing the function pointer into the data table corresponding to the life cycle stage comprises: By executing the loader code, the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer are read from the executable file generated in the application compilation stage, and the function pointer is written into the data table corresponding to the life cycle stage; The step of reading a function pointer from the data table corresponding to the entered life cycle stage, and executing a callback function corresponding to the read function pointer includes: By executing the main project code, a function pointer is read from the data table corresponding to the entered life cycle stage, and a callback function corresponding to the read function pointer is executed.
6. The method according to any one of claims 1 to 5, characterized in that After the application is started, the method further includes: When a trigger operation on a first business component in a currently displayed page is detected, identification information of a target method function of a second business component that needs to be called and is preset for the first business component is obtained; The identification information is parsed, and after determining that a target method function of the second business component needs to be called according to the parsing result, the target method function is called and executed.
7. The method according to claim 6, characterized in that The identification information includes: a component identification of the first business component, a function identification of the target method function, and input parameters required for calling the target method function.
8. An application running device, characterized in that: include: A function pointer writing module is used to read the function pointer of the callback function of the business component and the life cycle stage corresponding to the function pointer from the executable file generated in the application compilation phase when the application startup trigger event is detected, and write the function pointer into the data table corresponding to the life cycle stage; A callback function reading module is used to read a function pointer from the data table corresponding to the entered life cycle stage after detecting that the application has entered the life cycle stage, and execute the callback function corresponding to the read function pointer; The information writing module is used to write the function pointer of the callback function of the business component that needs to be executed in one or more life cycle stages, and the life cycle stage corresponding to the function pointer, into the data segment of the executable file generated after compilation when compiling the application.
9. An electronic device, characterized in that: The electronic device comprises: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the application running method as described in any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the application running method as described in any one of claims 1 to 7 is implemented.
