Page generation method and device, electronic equipment, storage medium and computer program product
By processing expression data as intermediate expressions and using preset data engine to parse, the problem that the Hongmeng system terminal cannot parse JSON data is solved, and fast and efficient page rendering and updates are achieved, improving the flexibility and iterative efficiency of page display.
Patent Information
- Application Number
- CN202411314203.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2024-12-17
AI Technical Summary
The terminal of the Hongmeng system cannot parse JSON format data, resulting in the inability to apply dynamic rendering technology and the inability to achieve fast and efficient page rendering updates.
By processing the expression data of the first language type into intermediate expression data that supports the interaction between the first language type and the third language type data, and using the preset data engine for parsing, breaking the interaction barrier between language types and realizing JSON Analysis of format data.
It realizes fast and efficient rendering and updating pages on the Hongmeng system terminal, improves the flexibility and iterative efficiency of page display, and solves the application obstacles of dynamic rendering technology on the Hongmeng terminal.
Smart Images

Figure CN119149034A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of front-end technology, and in particular to a page generation method, device, electronic device, storage medium and computer program product. Background Art
[0002] Dynamic technology is a commonly used technical means for current mobile terminal development. It supports the server to send the view tree and fill data to the client through the data in the format of JavaScript Object Notation (JSON) for rendering and data filling to form a new page. When the content of the page changes, you only need to modify the JSON format data sent by the server to achieve dynamic update of the page, which increases the update rate of the page. Among them, the Hongmeng system terminal uses ArkTS as the development language, and the eval() function that can parse JSON format data has been deleted from the ArkTS language. As a result, when the application page rendering is changed on the Hongmeng system terminal, the JSON format data cannot be parsed, resulting in the inability to apply dynamic rendering technology to the Hongmeng system terminal, making it impossible to quickly and efficiently change the page rendering of the page on the Hongmeng system terminal. Summary of the invention
[0003] The embodiments of the present application provide a page generation method, device, electronic device, storage medium and computer program product, which can quickly and efficiently modify the page rendering of the page on the Hongmeng system terminal.
[0004] The technical solution of this application is implemented as follows:
[0005] The present application embodiment provides a page generation method, including:
[0006] Processing expression data of a first language type into intermediate expression data of a second language type; wherein the second language type is a language type that supports interaction between data of the first language type and data of a third language type; the first language type is a local system language type; and the third language type is a language type of page rendering data sent by a server;
[0007] Extracting and parsing the intermediate expression data based on a preset data engine to obtain target expression data; wherein the preset data engine is used to process expression content for the third language type data;
[0008] The target page is rendered based on the analysis of the page rendering data by the target expression data.
[0009] In the above solution, the intermediate expression data includes: a container of elements to be parsed; the processing of the expression data of the first language type into the intermediate expression data of the second language type includes:
[0010] Processing the expression data into first recognizable data corresponding to the second language type;
[0011] The first identifiable data is encapsulated as the to-be-parsed element container.
[0012] In the above scheme, the extracting and parsing of the intermediate expression data based on the preset data engine to obtain the target expression data includes:
[0013] extracting the expression content corresponding to the third language type from the intermediate expression data;
[0014] The expression content is processed based on the preset data engine to obtain the target expression data.
[0015] In the above solution, before processing the expression data of the first language type into intermediate expression data of the second language type, the method further includes:
[0016] Processing the environment data of the first language type into second identifiable data corresponding to the second language type; wherein the environment data is used to construct a processing environment corresponding to the expression data for the preset data engine;
[0017] encapsulating the second identifiable data into an object container;
[0018] Based on the object container, the processing environment is constructed for the preset data engine.
[0019] In the above solution, the environment data includes: initialization parameters; the initialization parameters are correspondingly encapsulated as a first object container; wherein the first object container holds the required information for initializing the preset data engine.
[0020] In the above scheme, the environment data includes: environment element parameters; the environment element parameters are correspondingly encapsulated as a second object container; wherein the second object container holds at least one of the following environment element parameters in the expression data: variables, objects and functions.
[0021] In the above solution, the processing environment is constructed for the preset data engine based on the object container, including:
[0022] Determine a first callback function corresponding to the first object container in a preset callback function set; wherein the preset callback function set stores a plurality of object containers and a callback function subset corresponding to each of the object containers; the callback function subset includes a callback function for processing the object container as data of a type processable by the preset database;
[0023] Processing the first object container based on the first callback function to determine a first parameter object; wherein the first parameter object belongs to the third language type;
[0024] Based on the first parameter object, a context corresponding to the expression data is initialized for the preset data engine to construct the processing environment.
[0025] In the above solution, the processing environment is constructed for the preset data engine based on the object container, including:
[0026] For each data layer in the second object container, traverse layer by layer to extract the environmental element parameters;
[0027] Based on the parameter type of the environmental element parameter, the processing environment is constructed for the preset data engine.
[0028] In the above solution, the processing environment is constructed for the preset data engine based on the parameter type of the environmental element parameter, including:
[0029] If the environment element parameter is the variable or the object, a second parameter object converted based on the environment element parameter is registered with the preset data engine to construct the processing environment; wherein the second parameter object belongs to the third language type.
[0030] In the above solution, the processing environment is constructed for the preset data engine based on the parameter type of the environmental element parameter, including:
[0031] If the environment element parameter is the function, the function is added to the corresponding second callback function in the preset callback function set, and the corresponding third parameter object is obtained by processing the second callback function; wherein the third parameter object belongs to the third language type;
[0032] The preset data engine is registered based on the third parameter object to build the processing environment.
[0033] In the above solution, after constructing the processing environment for the preset data engine based on the object container, the method further includes:
[0034] Based on the reference relationship between each parameter object in the reference object set, the reference identifier of the parameter object in the reference object set is updated; wherein the reference object set includes: at least one of the first parameter object, the second parameter object and the third parameter object corresponding to the expression data; the reference identifier represents a numerical value whose size changes dynamically in direct proportion to the number of times the corresponding parameter object is referenced.
[0035] In the above scheme, the method further includes: when the reference identifier of the Nth parameter object in the reference object set is reduced to a preset threshold, deleting the Nth parameter object in the reference object set; N is an integer greater than 0.
[0036] In the above solution, after parsing the page rendering data based on the target expression data and rendering the target page, the method further includes:
[0037] When the parameter object corresponding to the expression data meets the release condition, a corresponding target callback function subset is determined in the preset callback function set based on the context object identifier; the context object identifier belongs to the initialization parameter;
[0038] The callback function release methods included in the target callback function subset are traversed and called to release the first object container and the first parameter object initialized for the preset data engine.
[0039] The present application also provides a page generation device, including:
[0040] a data processing unit, configured to process expression data of a first language type into intermediate expression data of a second language type; wherein the second language type is a language type supporting interaction between data of the first language type and data of a third language type; the first language type is a local system language type; and the third language type is a language type of page rendering data sent by a server;
[0041] A first parsing unit, configured to extract and parse the intermediate expression data based on a preset data engine to obtain target expression data; wherein the preset data engine is configured to process expression content for data of a third language type;
[0042] The second parsing unit is used to parse the page rendering data based on the target expression data to render a target page.
[0043] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor implements the steps in the above method when executing the computer program.
[0044] An embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method are implemented.
[0045] An embodiment of the present application also provides a computer program product, including a computer program, which implements the steps in the above method when executed by a processor.
[0046] In an embodiment of the present application, expression data of the first language type is processed into intermediate expression data of the second language type; wherein the second language type is a language type that supports interaction between data of the first language type and data of the third language type; the first language type is a local system language type; the third language type is a language type of page rendering data sent by the server; the intermediate expression data is extracted and parsed based on a preset data engine to obtain target expression data; wherein the preset data engine is used to process the expression content for the third language type data; based on the analysis of the page rendering data by the target expression data, the target page is rendered. In this way, by processing the expression data into intermediate expression data that can establish interaction between data of the first language type and data of the third language type, the interaction barrier between data of the first language type and data of the third language type is broken, and then the target expression data that can parse the page rendering data of the third language type is obtained by processing with the preset data engine, thereby realizing the analysis of the data of the third language type (JSON format data), that is, realizing the analysis of the dynamic JSON format data sent by the server, thereby realizing fast and efficient page rendering changes to the pages on the Hongmeng system terminal. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 An optional flow chart of a page generation method provided in an embodiment of the present application;
[0048] Figure 2 An optional flow chart of a page generation method provided in an embodiment of the present application;
[0049] Figure 3 An optional flow chart of a page generation method provided in an embodiment of the present application;
[0050] Figure 4 An optional flow chart of a page generation method provided in an embodiment of the present application;
[0051] Figure 5 An optional flow chart of a page generation method provided in an embodiment of the present application;
[0052] Figure 6An optional flow chart of a page generation method provided in an embodiment of the present application;
[0053] Figure 7 An optional flow chart of a page generation method provided in an embodiment of the present application;
[0054] Figure 8 An optional flow chart of a page generation method provided in an embodiment of the present application;
[0055] Fig. 9 A schematic diagram of the structure of a page generation device provided in an embodiment of the present application;
[0056] Fig.10 A hardware entity schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application are further elaborated in detail below in conjunction with the drawings and embodiments. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0058] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0059] If similar descriptions of "first / second" appear in the application documents, the following instructions are added. In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0060] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0061] Among the related technologies, dynamic rendering technology is the page rendering technology currently used by most applications (Application, App) in the industry. Its dynamic distribution and reduced version release features have greatly improved the efficiency of App development and iteration. However, the Hongmeng operating system blocks the native eval() function, resulting in the inability to parse the dynamically distributed page rendering data through the expression string, which has greatly hindered the migration of dynamic technology from the Android / iOS platform to the Hongmeng platform. There is currently no official or third-party Hongmeng-side JSON expression parsing solution. This makes it impossible to use dynamic rendering technology to quickly update the Hongmeng-side page.
[0062] This application embodiment provides a page generation method, see Figure 1 , is an optional flow chart of the page generation method provided in the embodiment of the present application, which will be combined with Figure 1 The steps shown are explained:
[0063] S101. Processing expression data of a first language type into intermediate expression data of a second language type; wherein the second language type is a language type that supports interaction between data of the first language type and data of a third language type; the first language type is a local system language type; and the third language type is a language type of page rendering data sent by a server.
[0064] In the embodiment of the present application, the page rendering data sent by the server for page generation is data of the third language type (JSON type). The terminal is based on the first language type (ArkTS language) as the development language of the local system. There is no parsing function for the JSON language in the ArkTS language, only expression data of the first language type (used to parse the page rendering data of the third language type), so in the embodiment of the present application, the expression data of the first language type needs to be processed into intermediate expression data of the second language type that can support the interaction between the data of the first language type and the data of the third language type.
[0065] The second language type may include: napi language: napi is the abbreviation of Node-API, which is the intermediate language for the interaction between ArkTS language and C / C++ language in Hongmeng application development. The napi language can be used to realize the mutual conversion between ArkTS objects and C / C++ objects. In some other embodiments, the second language type may also be other languages with the same function.
[0066] In the embodiment of the present application, the terminal may process the expression data of the first language type into intermediate expression data of the napi language type.
[0067] S102: extract and parse the intermediate expression data based on a preset data engine to obtain target expression data; wherein the preset data engine is used to process expression content for third language type data.
[0068] In the embodiment of the present application, the terminal can extract the expression content from the intermediate expression data, and then process the extracted expression content through a preset data engine to obtain target expression data (page rendering data for parsing JSON data). The preset data engine is used to process the expression content for the third language type data.
[0069] The preset data engine may include: quickJS engine: an open source, lightweight, convenient third-party library for processing JSON expressions. In other embodiments, the preset data engine may also be other third-party libraries with the same function.
[0070] In an embodiment of the present application, the terminal may first extract the JSON format expression content from the intermediate expression, and then use the quickJS engine to process the extracted intermediate expression content to obtain the target expression data.
[0071] S103: parsing the page rendering data based on the target expression data to render a target page
[0072] In the embodiment of the present application, the terminal can parse the page rendering data sent by the server through the target expression data to obtain the parsing result, and then use the parsing result to update the corresponding rendering page to obtain the target page.
[0073] This application proposes a way to bypass the restrictions of the Hongmeng system on the eval() function. Figure 2 , through the C / C++ layer code, the C / C++ underlying logic is implemented to handle the initialization, injection, parsing and release operations of JSON elements. And the bridging of the C / C++ layer code and the ArkTS layer code is realized through the napi technology, so as to achieve the same effect as the eval() function. In order to realize the JSON expression parsing function with the same function as the native eval() method, this application integrates the open source framework quickJS through the C / C++ code layer, and opens up the interaction between the ArkTS code and the C / C++ code through the napi technology, and finally realizes the JSON expression parsing function; in addition, this application also provides the function of custom injection of JSON elements in the ArkTS layer, and solves the potential memory leakage problem, expands the capability range of JSON expression parsing in dynamic technology, and can greatly improve the flexibility of HarmonyOS App page display and the efficiency of demand iteration.
[0074] In an embodiment of the present application, expression data of the first language type is processed into intermediate expression data of the second language type; wherein the second language type is a language type that supports interaction between data of the first language type and data of the third language type; the first language type is a local system language type; the third language type is a language type of page rendering data sent by the server; the intermediate expression data is extracted and parsed based on a preset data engine to obtain target expression data; wherein the preset data engine is used to process the expression content for the third language type data; based on the analysis of the page rendering data by the target expression data, the target page is rendered. In this way, by processing the expression data into intermediate expression data that can establish interaction between data of the first language type and data of the third language type, the interaction barrier between data of the first language type and data of the third language type is broken, and then the target expression data that can parse the page rendering data of the third language type is obtained by processing with the preset data engine, thereby realizing the analysis of the data of the third language type (JSON format data), that is, realizing the analysis of the dynamic JSON format data sent by the server, thereby realizing fast and efficient page rendering changes to the pages on the Hongmeng system terminal.
[0075] See also Figure 3 , is an optional flow chart of the page generation method provided in the embodiment of the present application, Figure 1 S101 to S102 shown in the figure can also be implemented by S201 to S204, which will be described in combination with the steps:
[0076] S201. Process the expression data into first recognizable data corresponding to the second language type.
[0077] In the embodiment of the present application, the terminal may process the expression data of the ArkTS element into first recognizable data recognizable in a second language type.
[0078] Exemplary, combined Figure 2 In step (13), in the embodiment of the present application, when the business layer calls the JSON expression parsing method, the expression data of the ArkTS element will also be converted into a napi_value value (the first identifiable data).
[0079] S202: Encapsulate the first identifiable data into the to-be-parsed element container.
[0080] In the embodiment of the present application, the terminal may encapsulate the processed first identifiable data into a container of elements to be parsed.
[0081] Exemplary, combined Figure 2 In step (14), the terminal may encapsulate the napi_value value as a JS element container.
[0082] S203: Extract the expression content corresponding to the third language type from the to-be-parsed element container.
[0083] In the embodiment of the present application, the terminal can extract the expression content in JSON language format from the element container to be parsed.
[0084] S204: Process the expression content based on the preset data engine to obtain the target expression data.
[0085] In the embodiment of the present application, the terminal processes the expression content in the JSON language format based on a preset data engine to obtain the target expression data.
[0086] Exemplary, combined Figure 2 In steps (15 to 20), the terminal directly takes out the JSON expression content to be parsed from the JS element container in the form of a string, and then passes it to the preset data engine for parsing, and then passes the final parsed target expression data back to the business layer layer by layer to render the target page.
[0087] In an embodiment of the present application, the expression data is processed into first identifiable data corresponding to the second language type. The first identifiable data is encapsulated as an element container to be parsed. The expression content corresponding to the third language type is extracted from the element container to be parsed. The expression content is processed based on the preset data engine to obtain target expression data. In this way, by processing the expression data into an element container to be parsed that can establish interaction between data of the first language type and data of the third language type, the interaction barrier between the data of the first language type and the data of the third language type is broken, and then the target expression data that can parse the page rendering data of the third language type is obtained through the preset data engine, thereby realizing the parsing of the data of the third language type (JSON format data), that is, realizing the parsing of the dynamic JSON format data sent by the server, and then realizing fast and efficient page rendering changes to the pages on the Hongmeng system terminal.
[0088] See also Figure 4 , is an optional flow chart of the page generation method provided in the embodiment of the present application, Figure 1 The S101 shown in the figure may also include S301 to S303, which will be described in combination with the steps:
[0089] S301. Process the environment data of the first language type into second identifiable data corresponding to the second language type; wherein the environment data is used to construct a processing environment corresponding to the expression data for the preset data engine.
[0090] In the embodiment of the present application, the terminal has environment data of a first language type. The environment data is used to construct a processing environment corresponding to the expression data for a preset data engine. In the process of constructing the processing environment, the terminal needs to process the environment data into second identifiable data of a second language type.
[0091] Exemplarily, the terminal may process the environmental data into a napi_value value (second identifiable data) recognizable in the napi language.
[0092] S302: Encapsulate the second identifiable data into an object container.
[0093] In the embodiment of the present application, the terminal may encapsulate the second identifiable data into an object container based on the corresponding API of quickJSON.
[0094] S303: Based on the object container, construct the processing environment for the preset data engine.
[0095] In the embodiment of the present application, the terminal can extract the environmental parameters in the object container, and pass them to the preset data engine based on the extracted environmental parameters for constructing the processing environment.
[0096] In some other embodiments, the object container can be processed by the corresponding callback function to obtain environmental parameters. The obtained environmental parameters are passed to the preset data engine to build a processing environment. Among them, the callback function is a common programming technique, which can call a predefined function to process the result after the asynchronous operation is completed. The callback function is usually used in scenarios such as processing events, performing asynchronous operations, or responding to user input. The role of the callback function is to separate the code logic, making the code more modular and maintainable. Using the callback function can avoid blocking the operation of the program and improve the performance and efficiency of the program. In addition, the callback function can also realize the reuse of code because they can be called from multiple places.
[0097] In an embodiment of the present application, the terminal constructs a processing environment corresponding to the expression data in a preset data engine by processing and transmitting the environmental data of the first language type. In this way, after the preset data engine has the corresponding processing environment, the expression data can be processed smoothly without being restricted by the environment. After receiving the page rendering data sent by the server, the page rendering data can be parsed using the target expression data after processing the expression data, thereby achieving fast rendering and updating of the page.
[0098] See also Figure 5 , is an optional flow chart of the page generation method provided in the embodiment of the present application, Figure 4 S303 shown in FIG. 4 can also be implemented through S401 to S403, which will be described in combination with the steps:
[0099] S401. Determine a first callback function corresponding to the first object container in a preset callback function set; wherein the preset callback function set stores multiple object containers and a callback function subset corresponding to each of the object containers; the callback function subset includes a callback function for processing the object container as data of a type that can be processed by the preset database.
[0100] In an embodiment of the present application, the environmental data includes: initialization parameters; the initialization parameters are correspondingly encapsulated as a first object container; wherein the first object container holds the required information for initializing the preset data engine. The terminal stores a plurality of object containers stored in the preset callback function set, and a callback function subset corresponding to each of the object containers; the callback function subset includes a callback function for processing the object container into data that can be processed by the preset database. The corresponding callback function subset can be determined for the first object container, and the first callback function is determined in the callback function subset based on the identification information common to the first object container. The first callback function is used to process and form a parameter object that can be processed by the preset data engine.
[0101] Exemplary, combined Figure 2 Steps (1 to 2) in the code. When the business layer uses the present invention to parse JSON expressions, it is necessary to initialize the JSON context (initialization parameters) first. The initialization parameters are the runtime environment for expression data parsing, temporary variables generated during parsing and running, function references, etc. The terminal passes the initialization parameters (such as the JSON context unique identifier, memory limit information, etc.) to the logic layer. The logic layer first converts the initialization parameters of the passed ArkTS element into napi_value values that can be recognized by the napi language, and then uses the napi_value value to create a JSContext container (first object container).
[0102] S402: Process the first object container based on the first callback function to determine a first parameter object.
[0103] In the embodiment of the present application, the terminal processes the first object container based on the first callback function to determine the first parameter object, wherein the first parameter object belongs to the third language type.
[0104] S403: Based on the first parameter object, initialize the context corresponding to the expression data for the preset data engine and construct the processing environment.
[0105] In the embodiment of the present application, the terminal passes the first parameter object to the preset data engine, initializes the context of the expression data based on the first parameter object, and constructs a processing environment.
[0106] Exemplary, combined Figure 2 The terminal registers the JSContext container to the preset callback function set, and finally converts the JSContext container into a C / C++ object (the first parameter object), and passes the C / C++ object to quickJS to perform context initialization operations.
[0107] In an embodiment of the present application, a first callback function corresponding to a first object container is determined in a preset callback function set. The first object container is processed based on the first callback function, and a first parameter object is determined. Based on the first parameter object, a context corresponding to the expression data is initialized for a preset data engine, and a processing environment is constructed. In this way, a processing environment suitable for processing expression data can be constructed based on the initialization parameters of the first language type. In this way, after the preset data engine has a corresponding processing environment, the expression data can be processed smoothly without being restricted by the environment. After receiving the page rendering data sent by the server, the target expression data after processing the expression data can be used to parse the page rendering data, thereby realizing fast rendering and updating of the page.
[0108] See also Figure 6 , is an optional flow chart of the page generation method provided in the embodiment of the present application, Figure 4 S303 shown in FIG. 1 can also be implemented through S501 to S502, which will be described in combination with the steps:
[0109] S501 : For each data layer in the second object container, traverse layer by layer to extract the environmental element parameters.
[0110] In the embodiment of the present application, the environmental data includes: environmental element parameters; the environmental element parameters are correspondingly encapsulated as a second object container; wherein the second object container holds at least one of the following environmental element parameters: variables, objects, and functions. The second object container includes multiple data layers, and the terminal traverses each data layer layer by layer to extract the environmental element parameters of each layer.
[0111] S502: Based on the parameter type of the environmental element parameter, construct the processing environment for the preset data engine.
[0112] In an embodiment of the present application, the terminal processes the environmental element parameters differently based on whether the extracted environmental element parameters are variables, objects, or functions, and passes the parameter objects after corresponding processing on the environmental element parameters to the preset data engine for constructing the processing environment.
[0113] In the embodiment of the present application, if the environment element parameter is the variable or the object, the second parameter object (C / C++ object) converted based on the environment element parameter is registered with the preset data engine to construct the processing environment, wherein the second parameter object belongs to the third language type.
[0114] In an embodiment of the present application, if the environment element parameter is the function, the function is added to the corresponding second callback function in the preset callback function set, and the corresponding third parameter object (C / C++ object) is obtained through the second callback function processing; wherein the third parameter object belongs to the third language type. The preset data engine is registered based on the third parameter object to construct the processing environment. Among them, a callback function subset corresponding to the second object container can be determined in the preset callback function set, and then a second callback function having the same identification information as the second object container can be determined in the callback function subset.
[0115] Exemplary, combined Figure 2 Steps (6 to 12) in the application. This application supports the business layer to customize the injection of JSON elements (environmental element parameters) according to different business scenarios, such as device information, custom functions, etc. These JSON elements may be called during the JSON expression parsing process to expand the scope of dynamic capabilities. The environmental element parameters of the ArkTS layer can be passed to the logic layer and converted into napi_value values, and then the napi_value values are converted into JS element containers (the outermost layer of the napi_value value is converted into a JS element container; steps (6 to 7)). After obtaining the JS element container (second object container), the type of environmental element parameters is determined layer by layer through the breadth-first traversal algorithm. If it is a non-function element such as a variable or object, it is directly converted into a JS element (second parameter object) of the base layer and passed to the preset data engine to register and build a processing environment (step 9). If it is judged to be a function element, it is necessary to first add the second object container to the corresponding callback function subset in the preset callback function set to obtain a third parameter object, and finally pass the third parameter object to the base layer for registration and construction of the processing environment (steps 10 to 12).
[0116] In an embodiment of the present application, for each data layer in the second object container, the environmental element parameters are traversed layer by layer to extract them. Based on the parameter type of the environmental element parameters, the processing environment is constructed for the preset data engine. In this way, a processing environment suitable for processing expression data can be constructed based on the environmental element parameters of the first language type. In this way, after the preset data engine has the corresponding processing environment, the expression data can be processed smoothly without being restricted by the environment. After receiving the page rendering data sent by the server, the target expression data after the expression data processing can be used to parse the page rendering data, thereby realizing fast rendering and updating of the page.
[0117] See also Figure 7 , which is an optional flow chart of the page generation method provided in the embodiment of the present application, will be described in combination with the steps:
[0118] S601: Based on the reference relationship between each parameter object in the reference object set, update the reference identifier of the parameter object in the reference object set.
[0119] In an embodiment of the present application, a reference object set is stored in the terminal. The reference object set includes: at least one of the first parameter object, the second parameter object and the third parameter object corresponding to the expression data; each parameter object corresponds to a reference identifier. The reference identifier represents a numerical value that changes dynamically in direct proportion to the number of times the corresponding parameter object is referenced. The terminal updates the reference identifier of the parameter object in the reference object set based on the reference relationship between the parameter objects in the reference object set. That is, based on the number of times each parameter object in the reference object set is referenced, the reference identifier corresponding to the parameter is updated.
[0120] The reference or release between the parameter objects is realized based on the function call when the terminal renders the page or exits the page. Numbers can be used as reference identifiers corresponding to parameter objects. When a parameter object is referenced once by other parameter objects, the value of the reference identifier for the parameter object is increased by 1. When a parameter object is released by other parameter objects, the value of the reference identifier for the parameter object is reduced by 1.
[0121] In some other embodiments, when the reference identifier of the Nth parameter object in the reference object set decreases to a preset threshold, the Nth parameter object is deleted from the reference object set; N is an integer greater than 0. The preset threshold may be 0.
[0122] In the embodiment of the present application, each C / C++ object will be added to the reference object set when it is created. At the same time, each C / C++ object will carry a reference identifier, which defaults to 0. Every time the object is referenced, the reference identifier of the C / C++ object will be increased by 1, and every time the object that references the C / C++ object is released, the reference identifier of the C / C++ object will be reduced by 1. When the reference identifier of an object drops to 0, the C / C++ object will be deleted from the reference object set. When the JSON context object is released, the reference object set it holds will be traversed. If the reference object set is not empty, it means that an object has not been released during the use of JSON, that is, a memory leak has occurred in the JSON context. If the memory leak continues to occur, a memory overflow will eventually occur, causing the application to crash.
[0123] In this application, if the data passed in by the business layer when calling the method to inject JSON elements contains a callback function, this function object will be referenced by the JSON context object at the beginning of creation, resulting in its reference ID being 1. When it is finally released, its reference ID is also 1, resulting in a memory leak. Figure 2 , this application provides a preset callback function set at the logic layer, which maintains a subset of callback functions referenced by each JSONContext container and its corresponding JSON context object. When releasing the JSON context object, all callback functions in this list will be traversed and released first, so that the reference identifier of each function object will be reduced from 1 to 0, thereby avoiding the occurrence of memory leaks.
[0124] In an embodiment of the present application, based on the reference relationship between each parameter object in the reference object set, the reference identifier of the parameter object in the reference object set is updated. When the reference identifier of the Nth parameter object in the reference object set is reduced to a preset threshold, the Nth parameter object is deleted from the reference object set. In this way, after a terminal releases or references a parameter object, the parameter object in the reference object set can use the reference identifier to record its own reference status, and when the number of references is 0, the corresponding parameter object is deleted from the reference object set, which saves storage space and improves resource utilization.
[0125] See also Figure 8 , is an optional flow chart of the page generation method provided in the embodiment of the present application, Figure 5 S403 shown may also include S701 to S702, which will be described in combination with the steps:
[0126] S701: When the parameter object corresponding to the expression data meets the release condition, determine the corresponding target callback function subset in the preset callback function set based on the context object identifier.
[0127] In an embodiment of the present application, when the target page is exited, the object container containing the context object identifier can be determined in the preset callback function set based on the context object identifier corresponding to the page (which belongs to the initialization parameter), and then the target callback function subset corresponding to the object container can be determined.
[0128] Exemplary, combined Figure 2 In steps (21 to 22), after the business layer completes the JSON expression parsing function, it needs to release the JS context operation at an appropriate time (such as page exit). The main process is to pass the JSON context unique identifier (context object identifier) corresponding to the target page to the logic layer, and first obtain the corresponding JSContext container and the target callback function subset it holds from the preset callback function set through the JSON context unique identifier in the logic layer.
[0129] S702: traverse and call the callback function release method included in the target callback function subset to release the first object container and the first parameter object initialized for the preset data engine.
[0130] In the embodiment of the present application, the terminal calls the callback function release method included in the target callback function subset to release the first object container and the first parameter object initialized for the preset data engine. After releasing the first parameter object, the reference identifier corresponding to the first parameter object can be reduced by 1 in the reference object set.
[0131] Exemplary, combined Figure 2 In steps (23 to 24), each callback function release method in the target callback function set is traversed, and the callback function release method obtained in each traversal is used to release the corresponding JSContext container and synchronize the base layer to release the first parameter object.
[0132] In an embodiment of the present application, when the parameter object corresponding to the expression data meets the release condition, the corresponding target callback function subset is determined in the preset callback function set based on the context object identifier. The callback function release method included in the target callback function subset is traversed and called to release the first object container and the first parameter object initialized for the preset data engine. In this way, the corresponding first object container and the first parameter object are released after the page is exited, which reduces the storage space occupied and the storage of redundant information.
[0133] See also Fig. 9 , which is a structural diagram of the page generation device provided in an embodiment of the present application.
[0134] The embodiment of the present application provides a page generation 800 , including: a data processing unit 801 , a first parsing unit 802 , and a second parsing unit 803 .
[0135] The data processing unit 801 is used to process the expression data of the first language type into the intermediate expression data of the second language type; wherein the second language type is a language type that supports the interaction between the data of the first language type and the data of the third language type; the first language type is a local system language type; and the third language type is a language type of the page rendering data sent by the server;
[0136] A first parsing unit 802 is used to extract and parse the intermediate expression data based on a preset data engine to obtain target expression data; wherein the preset data engine is used to process expression content for the third language type data;
[0137] The second parsing unit 803 is used to parse the page rendering data based on the target expression data to render a target page.
[0138] In an embodiment of the present application, the intermediate expression data includes: a container of elements to be parsed; the data processing unit 801 in the page generation device 800 is used to process the expression data into first identifiable data corresponding to the second language type; and encapsulate the first identifiable data into the container of elements to be parsed.
[0139] In an embodiment of the present application, the first parsing unit 802 in the page generating device 800 is used to extract the expression content corresponding to the third language type from the intermediate expression data; and process the expression content based on the preset data engine to obtain the target expression data.
[0140] In the embodiment of the present application, the data processing unit 801 in the page generating device 800 is used to process the environment data of the first language type into second identifiable data corresponding to the second language type; wherein the environment data is used to construct a processing environment corresponding to the expression data for the preset data engine;
[0141] encapsulating the second identifiable data into an object container;
[0142] Based on the object container, the processing environment is constructed for the preset data engine.
[0143] In an embodiment of the present application, the environmental data includes: initialization parameters; the initialization parameters are correspondingly encapsulated as a first object container; wherein the first object container holds the required information for initializing the preset data engine.
[0144] In an embodiment of the present application, the environmental data includes: environmental element parameters; the environmental element parameters are correspondingly encapsulated as a second object container; wherein the second object container holds at least one of the following environmental element parameters: variables, objects, and functions.
[0145] In the embodiment of the present application, the data processing unit 801 in the page generating device 800 is used to determine the first callback function corresponding to the first object container in the preset callback function set; wherein the preset callback function set stores multiple object containers and a callback function subset corresponding to each of the object containers; the callback function subset includes a callback function for processing the object container as data of a type processable by the preset database;
[0146] Processing the first object container based on the first callback function to determine a first parameter object; wherein the first parameter object belongs to the third language type;
[0147] Based on the first parameter object, a context corresponding to the expression data is initialized for the preset data engine to construct the processing environment.
[0148] In the embodiment of the present application, the data processing unit 801 in the page generating device 800 is used to traverse each data layer in the second object container layer by layer to extract the environmental element parameters;
[0149] Based on the parameter type of the environmental element parameter, the processing environment is constructed for the preset data engine.
[0150] In an embodiment of the present application, the data processing unit 801 in the page generation device 800 is used to register the second parameter object converted based on the environment element parameter for the preset data engine to build the processing environment if the environment element parameter is the variable or the object; wherein the second parameter object belongs to the third language type.
[0151] In the embodiment of the present application, the data processing unit 801 in the page generating device 800 is used to add the function into the corresponding second callback function in the preset callback function set if the environment element parameter is the function, and obtain the corresponding third parameter object through the second callback function processing; wherein the third parameter object belongs to the third language type
[0152] The preset data engine is registered based on the third parameter object to build the processing environment.
[0153] In an embodiment of the present application, the page generation device 801 is used to update the reference identifier of the parameter object in the reference object set based on the reference relationship between the respective parameter objects in the reference object set; wherein the reference object set includes: at least one of the first parameter object, the second parameter object and the third parameter object corresponding to the expression data; the reference identifier represents a numerical value whose size changes dynamically in direct proportion to the number of times the corresponding parameter object is referenced.
[0154] In the embodiment of the present application, the page generating device 801 is used to delete the Nth parameter object in the reference object set when the reference identifier of the Nth parameter object in the reference object set is reduced to a preset threshold; N is an integer greater than 0.
[0155] In the embodiment of the present application, the page generation device 801 is used to determine the corresponding target callback function subset in the preset callback function set based on the context object identifier when the parameter object corresponding to the expression data meets the release condition; the context object identifier belongs to the initialization parameter;
[0156] The callback function release methods included in the target callback function subset are traversed and called to release the first object container and the first parameter object initialized for the preset data engine.
[0157] It should be noted that in the embodiments of the present application, if the above-mentioned page generation method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable a page generation device (which can be a personal computer, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.
[0158] Correspondingly, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the terminal-side method are implemented.
[0159] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0160] It should be noted that Fig.10 A hardware entity diagram of an electronic device provided in an embodiment of the present application, such as Fig.10 As shown, an embodiment of the present application provides an electronic device 900, including a memory 902 and a processor 901, wherein the memory 902 stores a computer program that can be run on the processor 901, and the processor 901 implements the steps in the above method when executing the program, wherein;
[0161] The processor 901 generally controls the overall operation of the electronic device 900 .
[0162] The memory 902 is configured to store instructions and applications executable by the processor 901, and can also cache data to be processed or processed by the processor 901 and various modules in the electronic device 900 (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).
[0163] Correspondingly, an embodiment of the present application further provides a computer program product, including a computer program, which can be executed by the processor 901 of the electronic device 900 to complete the steps in the method on the page generating device 800 side.
[0164] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned sequence numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments.
[0165] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0166] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0167] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0168] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0169] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: a mobile storage device, a read-only memory (ROM), a magnetic disk or an optical disk, and other media that can store program codes.
[0170] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a mobile storage device, a ROM, a magnetic disk, or an optical disk.
[0171] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A page generation method, characterized in that: include: Processing expression data of a first language type into intermediate expression data of a second language type; wherein the second language type is a language type that supports interaction between data of the first language type and data of a third language type; the first language type is a local system language type; and the third language type is a language type of page rendering data sent by a server; Extracting and parsing the intermediate expression data based on a preset data engine to obtain target expression data; wherein the preset data engine is used to process expression content for the third language type data; The target page is rendered based on the analysis of the page rendering data by the target expression data.
2. The page generation method according to claim 1, characterized in that: The intermediate expression data includes: a container of elements to be parsed; the processing of the expression data of the first language type into the intermediate expression data of the second language type includes: Processing the expression data into first recognizable data corresponding to the second language type; The first identifiable data is encapsulated as the to-be-parsed element container.
3. The page generation method according to claim 1, characterized in that: The extracting and parsing of the intermediate expression data based on the preset data engine to obtain the target expression data includes: extracting the expression content corresponding to the third language type from the intermediate expression data; The expression content is processed based on the preset data engine to obtain the target expression data.
4. The page generation method according to any one of claims 1 to 3, characterized in that: Before processing the expression data of the first language type into intermediate expression data of the second language type, the method further includes: Processing the environment data of the first language type into second identifiable data corresponding to the second language type; wherein the environment data is used to construct a processing environment corresponding to the expression data for the preset data engine; encapsulating the second identifiable data into an object container; Based on the object container, the processing environment is constructed for the preset data engine.
5. The page generation method according to claim 4, characterized in that: The environmental data includes: initialization parameters; the initialization parameters are correspondingly packaged into a first object container; wherein the first object container holds the required information for initializing the preset data engine.
6. The page generation method according to claim 4, characterized in that: The environment data includes: environment element parameters; the environment element parameters are correspondingly encapsulated as a second object container; wherein the second object container holds at least one of the following environment element parameters in the expression data: variables, objects and functions.
7. The page generation method according to claim 5, characterized in that: The step of constructing the processing environment for the preset data engine based on the object container includes: Determine a first callback function corresponding to the first object container in a preset callback function set; wherein the preset callback function set stores a plurality of object containers and a callback function subset corresponding to each of the object containers; the callback function subset includes a callback function for processing the object container as data of a type processable by the preset database; Processing the first object container based on the first callback function to determine a first parameter object; wherein the first parameter object belongs to the third language type; Based on the first parameter object, a context corresponding to the expression data is initialized for the preset data engine to construct the processing environment.
8. The page generation method according to claim 6, characterized in that: The step of constructing the processing environment for the preset data engine based on the object container includes: For each data layer in the second object container, traverse layer by layer to extract the environmental element parameters; Based on the parameter type of the environmental element parameter, the processing environment is constructed for the preset data engine.
9. The page generation method according to claim 8, characterized in that: The step of constructing the processing environment for the preset data engine based on the parameter type of the environmental element parameter includes: If the environment element parameter is the variable or the object, a second parameter object converted based on the environment element parameter is registered with the preset data engine to construct the processing environment; wherein the second parameter object belongs to the third language type.
10. The page generation method according to claim 8, characterized in that: The step of constructing the processing environment for the preset data engine based on the parameter type of the environmental element parameter includes: If the environment element parameter is the function, the function is added to the corresponding second callback function in the preset callback function set, and the corresponding third parameter object is obtained by processing the second callback function; wherein the third parameter object belongs to the third language type; The preset data engine is registered based on the third parameter object to build the processing environment.
11. The page generation method according to claim 4, characterized in that: After constructing the processing environment for the preset data engine based on the object container, the method further includes: Based on the reference relationship between each parameter object in the reference object set, the reference identifier of the parameter object in the reference object set is updated; wherein the reference object set includes: at least one of the first parameter object, the second parameter object and the third parameter object corresponding to the expression data; the reference identifier represents a numerical value whose size changes dynamically in direct proportion to the number of times the corresponding parameter object is referenced.
12. The page generation method according to claim 11, characterized in that: The method further includes: when the reference identifier of the Nth parameter object in the reference object set decreases to a preset threshold, deleting the Nth parameter object in the reference object set; N is an integer greater than 0.
13. The page generation method according to claim 7, characterized in that: After parsing the page rendering data based on the target expression data and rendering the target page, the method further includes: When the parameter object corresponding to the expression data meets the release condition, a corresponding target callback function subset is determined in the preset callback function set based on the context object identifier; the context object identifier belongs to the initialization parameter; The callback function release methods included in the target callback function subset are traversed and called to release the first object container and the first parameter object initialized for the preset data engine.
14. A page generating device, characterized in that: include: a data processing unit, configured to process expression data of a first language type into intermediate expression data of a second language type; wherein the second language type is a language type supporting interaction between data of the first language type and data of a third language type; the first language type is a local system language type; and the third language type is a language type of page rendering data sent by a server; A first parsing unit, configured to extract and parse the intermediate expression data based on a preset data engine to obtain target expression data; wherein the preset data engine is configured to process expression content for data of a third language type; The second parsing unit is used to parse the page rendering data based on the target expression data to render a target page.
15. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor implements the steps in the method according to any one of claims 1 to 13 when executing the computer program.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps in the method according to any one of claims 1 to 13 are implemented.
17. A computer program product comprising a computer program, characterized in that The computer program implements the steps of the method according to any one of claims 1 to 13 when executed by a processor.
Citation Information
Cited By
Method and system for dynamically instrumenting swan NEXT Native layer function
CN121301172A
