Data processing method and device, electronic equipment and storage medium
By detecting object access instructions and generating object proxy in an environment that does not support Proxy and Object.defineProperty, the problem of difficulty in implementing object proxy is solved, and the two-way binding and protection of objects is realized, and it has high universality.
Patent Information
- Application Number
- CN202311174532.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-12
- Publication Date
- 2025-03-14
AI Technical Summary
In the context of translation into c++ code or directly compiling to Web Assembly (WASM) environment, it is difficult for the existing technology to implement object proxy because the underlying environment does not support proxy technologies such as Proxy and Object.defineProperty.
By detecting the access instructions of the object, the object's proxy is generated according to the object's type, the object's operation events are listened to, and the object's operation events are responded to, so as to realize the object's proxy function. The method includes declaring a proxy variable or proxy class and generating associated attribute access methods to listen for and respond to the object's attribute operations.
It realizes that without relying on the underlying proxy technical support, the object's proxy response is used to reduce object access pressure, realize two-way binding and object protection, and has high universality.
Smart Images

Figure CN119621362A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to a data processing method and device, an electronic device, and a storage medium. Background Art
[0002] Usually, the proxy of the original object is generated through the Proxy and Object.defineProperty technologies in the Typescript proxy mode. The proxy of the object is accessed to respond to the operation of the original object. It is widely used in scenarios such as two-way binding between the client and the original object, protecting the original object, and enhancing the original object. However, the Typescript proxy mode is used in an environment that is translated into C++ code or directly compiled into a binary instruction set designed for a stack-based virtual machine (Web Assembly, WASM). Because the underlying environment does not support proxy technologies such as Proxy and Object.defineProperty, it is difficult to implement object proxy. Summary of the invention
[0003] The present disclosure provides a data processing method and device, an electronic device, and a storage medium.
[0004] According to a first aspect of an embodiment of the present disclosure, there is provided a data processing method, including:
[0005] In response to detecting an access instruction of an object, generating a proxy for the object according to a type of the object;
[0006] According to the agent of the object, monitoring the operation events of the object;
[0007] According to the operation event, respond to the operation on the object.
[0008] In some embodiments, generating a proxy for the object according to the type of the object includes:
[0009] Declare a proxy for the object according to the type of the object and the name of the object;
[0010] The step of monitoring the operation event on the object according to the proxy of the object includes:
[0011] generating attribute access methods of a proxy associated with the object;
[0012] Based on the attribute access method of the proxy associated with the object, the operation events on the attributes of the object are monitored.
[0013] In some embodiments, declaring a proxy of the object according to the type of the object and the name of the object includes:
[0014] Declare the proxy with a type consistent with the type of the object and a name including the name of the object.
[0015] In some embodiments, the declared type is consistent with the type of the object, and the proxy whose name includes the name of the object includes:
[0016] In the case where the type of the object includes a basic data type, declaring a proxy variable of the basic data type; wherein the variable name of the proxy variable includes the name of the object, and the proxy variable has a variable value consistent with the object; the basic data type includes at least one of the following: character type, numeric type, Boolean type, time type;
[0017] The method for generating a property access method of a proxy associated with the object comprises:
[0018] Generates attribute access methods for the proxy variable.
[0019] In some embodiments, the declared type is consistent with the type of the object, and the proxy whose name includes the name of the object includes:
[0020] In the case where the type of the object includes a class, declaring a proxy class of the class type; wherein the class name of the proxy class includes the name of the object, and the proxy class has attributes consistent with those of the object;
[0021] The method for generating a property access method of a proxy associated with the object comprises:
[0022] For each attribute in the proxy class, an attribute access method associated with the attribute of the proxy class is generated in the declaration body of the proxy class.
[0023] In some embodiments, the declared type is consistent with the type of the object, and the proxy whose name includes the name of the object includes:
[0024] In the case where the type of the object includes a set, declaring a proxy set of a set type; wherein the set name of the proxy set includes the name of the object, and the proxy set has set elements consistent with the object;
[0025] The method for generating a property access method of a proxy associated with the object comprises:
[0026] Generate a property access method associated with all set elements of the proxy set in the declaration body corresponding to the proxy set.
[0027] In some embodiments, the declared type is consistent with the type of the object, and the proxy whose name includes the name of the object includes:
[0028] In the case where the type of the object includes a key-value pair, declaring a proxy key-value pair whose type is a key-value pair; wherein the name of the proxy key-value pair includes the name of the object, and the proxy key-value pair has a key-value pair consistent with that of the object;
[0029] The method for generating a property access method of a proxy associated with the object comprises:
[0030] For each key of the proxy, a property access method associated with the key of the proxy key-value pair is generated in a declaration body corresponding to the proxy.
[0031] In some embodiments, the generating a property access method of a proxy associated with the object includes:
[0032] The attribute access method is generated, the method name including the name of the object and associating the proxy of the object.
[0033] In some embodiments, the attribute access method includes an attribute acquisition method and / or an attribute setting method; and the responding to the operation on the object according to the operation event includes:
[0034] In the case where an operation event representing obtaining the attribute of the object is monitored through the attribute obtaining method, the attribute value of the proxy of the object is returned;
[0035] or,
[0036] When an operation event representing setting the property of the object is monitored by calling the property setting method, the property values of the object and the agent are set.
[0037] In some embodiments, the operation event carries a target attribute value; and when the operation event representing setting the attribute of the object is monitored by calling the attribute setting method, setting the attribute values of the object and the agent includes:
[0038] When an operation event representing setting the property of the object is monitored by calling the property setting method, in response to the property value of the agent before setting being inconsistent with the target property value, the property values of the object and the agent are set to the target property value.
[0039] In some embodiments, the object includes an object in a page; and responding to an operation on the object according to the operation event includes:
[0040] In the case where an operation event representing setting the property of the object is monitored by calling the property setting method, sending a property setting notification to the object;
[0041] According to the property setting notification, in response to the property value of the object after setting being inconsistent with the property value of the object before setting, the object in the page is rendered according to the property value of the object after setting.
[0042] According to a second aspect of an embodiment of the present disclosure, there is provided a data processing device, including:
[0043] A generating module, configured to generate a proxy for the object according to the type of the object in response to detecting an access instruction to the object;
[0044] A monitoring module, used for monitoring operation events on the object according to the agent of the object;
[0045] The response module is used to respond to the operation on the object according to the operation event.
[0046] In some embodiments, the generating module is used to declare the proxy of the object according to the type of the object and the name of the object;
[0047] The monitoring module is used to generate a property access method of the agent associated with the object; based on the property access method of the agent associated with the object, monitor the operation events on the properties of the object.
[0048] In some embodiments, the generating module is used to declare the proxy whose type is consistent with the type of the object and whose name includes the name of the object.
[0049] In some embodiments, the generating module is used to declare a proxy variable of a type of the basic data type when the type of the object includes a basic data type; wherein the variable name of the proxy variable includes the name of the object, and the proxy variable has a variable value consistent with the object; the basic data type includes at least one of the following: character type, numeric type, Boolean type, time type;
[0050] The monitoring module is used to generate a property access method for the proxy variable.
[0051] In some embodiments, the generating module is used to declare a proxy class of the class type when the type of the object includes a class; wherein the class name of the proxy class includes the name of the object, and the proxy class has attributes consistent with the object;
[0052] The monitoring module is used to generate, for each attribute in the proxy class, an attribute access method associated with the attribute of the proxy class in the declaration body of the proxy class.
[0053] In some embodiments, the generating module is used to declare a proxy set of type set when the type of the object includes set; wherein the set name of the proxy set includes the name of the object, and the proxy set has set elements consistent with the object;
[0054] The monitoring module is used to generate a property access method associated with all set elements of the proxy set in a declaration body corresponding to the proxy set.
[0055] In some embodiments, the generating module is used to declare a proxy key-value pair of type as a key-value pair when the type of the object includes a key-value pair; wherein the name of the proxy key-value pair includes the name of the object, and the proxy key-value pair has a key-value pair consistent with the object;
[0056] The monitoring module is used to generate, for each key of the proxy, a property access method associated with the key of the proxy key-value pair in a declaration body corresponding to the proxy.
[0057] In some embodiments, the monitoring module is used to generate the property access method whose method name includes the name of the object and is associated with the proxy of the object.
[0058] In some embodiments, the property access method includes a property acquisition method and / or a property setting method; the response module is used to return the property value of the object's agent when an operation event representing the acquisition of the object's property is monitored through the property acquisition method; or, when an operation event representing the setting of the object's property is monitored by calling the property setting method, set the property values of the object and the agent.
[0059] In some embodiments, the operation event carries a target attribute value; the response module is used to set the attribute values of the object and the agent to the target attribute value in response to the attribute value of the agent before setting being inconsistent with the target attribute value when monitoring the operation event representing the setting of the attribute of the object by calling the attribute setting method.
[0060] In some embodiments, the object includes an object in a page; the response module is used to send a property setting notification to the object when an operation event representing setting the property of the object is monitored by calling the property setting method; based on the property setting notification, in response to the property value of the object after setting being inconsistent with the property value of the object before setting, render the object in the page based on the property value of the object after setting.
[0061] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0062] A processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the method as described in the first aspect above.
[0063] According to a fourth aspect of an embodiment of the present disclosure, there is provided a storage medium, including:
[0064] When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method as described in the first aspect above.
[0065] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0066] In response to detecting an access instruction to an object, the data processing device of the disclosed embodiment generates a proxy for the object according to the type of the object, thereby monitoring operation events on the object according to the object's proxy and responding to operations on the object. On the one hand, access to the object can be achieved by accessing the object's proxy, which reduces the access pressure on the object while achieving two-way binding between components and data in client pages, protecting objects, etc.; and in the case where the object's proxy includes a method for determining access rights, an information encryption method, etc., the object can be enhanced through the proxy. On the other hand, the proxy solution provided by the disclosed embodiment does not need to rely on underlying proprietary designs such as Proxy, Object.defineProperty, etc., and can respond to operations on the object through the object's proxy in a variety of scenarios including translation into C++ code and direct compilation to WASM, and has high universality.
[0067] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0069] Figure 1 This is an example of a data processing method flow shown in the embodiment of the present disclosure Figure 1 .
[0070] Figure 2 This is an example of a data processing method flow shown in the embodiment of the present disclosure Figure 2 .
[0071] Figure 3 This is an example of a data processing method flow shown in the embodiment of the present disclosure Figure 3 .
[0072] Figure 4 It is a diagram of a data processing device shown in an embodiment of the present disclosure.
[0073] Figure 5 It is a block diagram of an electronic device shown in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0074] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0075] In order to achieve the response of the operation event of the object through the proxy of the object in an environment including the binary instruction set (WebAssembly, WASM) translated into C++ code or directly compiled into the stack virtual machine design, the embodiment of the present disclosure provides a data processing method, the execution subject of which can be a data processing device, for example, the data processing method can be executed by a terminal device or a server or other electronic device, wherein the terminal device can be a mobile phone, a camera, a tablet computer, a vehicle-mounted device, a wearable device, etc. In some possible implementations, the data processing method can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0076] The technical names in the embodiments of the present disclosure are explained as follows:
[0077] Agent: It means handling things for the client. Through the agent, the client (such as technical developers) does not need to contact the real target object, but can contact the agent of the target object to achieve the goal. According to the period of creation of the agent, it can be divided into: static agent and dynamic agent.
[0078] Static proxy: Static proxy is created by technical developers or tools to generate the source code of the proxy class, and then compile the proxy class. The so-called static means that the relationship between the proxy class and the delegate class is determined before the program runs.
[0079] Dynamic proxy: Dynamic proxy is dynamically generated through reflection mechanism, including proxy based on interface implementation and proxy based on inheritance implementation.
[0080] Two-way binding: The process of establishing a connection between your application (client view) and your business logic.
[0081] The relationship between proxy and two-way binding: The proxy can intercept the reading and assignment of the original data, establish a connection between the data and the view or business logic, and thus realize data binding. When operating the data, the binding action is triggered, automatically reflecting the use and change of the data.
[0082] Figure 1 This is an example of a data processing method flow shown in the embodiment of the present disclosure Figure 1 ,Depend on Figure 1 It can be seen that the following steps are included:
[0083] S101, in response to detecting an access instruction to an object, generating a proxy for the object according to the type of the object;
[0084] S102, monitoring operation events on the object according to the agent of the object;
[0085] S103: Respond to the operation on the object according to the operation event.
[0086] In the embodiment of the present disclosure, the object may be an object in a client page, such as a component, a picture, a text, etc.; the object may also be an object in a memory, etc., which is not limited in the present disclosure.
[0087] In step S101, the data processing device detects an access instruction to an object, for example, a loading instruction of a client page, or an initialization instruction for an object in a memory, and generates a proxy for the object according to the type of the object when an access instruction to the object is detected.
[0088] In some embodiments, the data processing device generates a proxy of the same type as the object based on the type of the object. For example, if the object type is character type, a proxy of character type is generated; if the object type is class type, a proxy of class type is generated.
[0089] In some embodiments, the data processing device determines the type of agent corresponding to the type of the object according to the type of the object and the preset agent type correspondence, and then generates the agent of the object according to the agent type. The preset agent type correspondence includes a mapping between the type of the object and the type of the agent, which can be a one-to-one mapping between the type of the object and the type of the agent; or a many-to-one mapping between the type of the object and the type of the agent, for example, the type of the agent mapped to the type of the character type, the numeric type, and the Boolean type of the object can be unified as the character type.
[0090] It should be noted that the proxy of the object in the embodiment of the present disclosure may be pre-generated (static proxy strategy), or may be a proxy of the newly added object dynamically generated after the object is added (dynamic proxy strategy). The proxy of the object in the embodiment of the present disclosure has properties consistent with the properties of the object. For example, if the property value of the object of the character type is "Beijing City", the property value of the corresponding character type proxy is also "Beijing City", so that the object properties can be accessed later by accessing the properties of the proxy.
[0091] In step S102, the data processing device monitors operation events on the object according to the agent of the object. For example, based on the client page displayed after loading, the data processing device monitors the user's operation events on the component, such as monitoring the operation event of the user modifying the numerical value in the edit box component; or based on the built-in sound receiving component, the data processing device monitors the user's voice events on the component, such as receiving the voice representing the modification of the numerical value in the edit box component; it can also monitor the operation events such as obtaining and setting the object in the memory.
[0092] In step S103, the data processing device responds to the operation on the object according to the operation event; for example, if the type of the object is numeric and the type of the agent is character, the operation event represents the acquisition of the attribute value of the object, and the data processing device uses the acquired attribute value of the agent as the response result of the operation on the object according to the monitored operation event on the object. For another example, if the type of the object and the type of the agent are both classes, the operation event represents the setting of the attribute value of a certain attribute of the object, and the data processing device assigns the set target attribute value to the attribute value of the attribute of the agent and the attribute value of the attribute of the object according to the monitored operation event on the object, and obtains the response result of the operation on the object; wherein the operation event representing the acquisition of the attribute value of the object carries the target attribute value.
[0093] In addition, the proxy of the object of the embodiment of the present disclosure may also be associated with other methods, such as a method for determining access rights, an information encryption method, etc. If the proxy of the object is associated with a method for determining access rights, the data processing device responds to the operation of the object through the proxy based on the acquired user identifier, if the user identifier corresponds to the operation authority of the object; or returns a response result indicating that the response cannot be made if the user identifier does not have the operation authority of the object. If the proxy of the object is associated with an information encryption method, the data processing device encrypts the attribute value of the object after acquiring the attribute value of the object through the proxy according to the operation event, and uses the encrypted attribute value as the response result of the operation of the object.
[0094] It can be understood that in response to detecting an access instruction to an object, the data processing device of the embodiment of the present disclosure generates a proxy for the object according to the type of the object, thereby monitoring operation events on the object according to the proxy of the object and responding to operations on the object. On the one hand, access to the object can be achieved by accessing the proxy of the object, reducing the access pressure of the object while achieving two-way binding between components and data in the client page, protecting objects, etc.; and in the case where the proxy of the object includes the aforementioned access rights judgment method, information encryption method, etc., the object can be enhanced through the proxy. On the other hand, the proxy solution provided by the embodiment of the present disclosure does not need to rely on the underlying proprietary design for Proxy, Object.defineProperty, etc., and can respond to operations on the object through the proxy of the object in a variety of scenarios including translation into C++ code and direct compilation to WASM, and has high universality.
[0095] Figure 2 This is an example of a data processing method flow shown in the embodiment of the present disclosure Figure 2 ,Depend on Figure 2 It can be seen that the following steps are included:
[0096] S1011, in response to detecting an access instruction to an object, declaring a proxy for the object according to the type of the object and the name of the object;
[0097] S1021, generating a property access method of a proxy associated with the object;
[0098] S1022: Based on the attribute access method of the agent associated with the object, monitor the operation event of the attribute of the object;
[0099] S103: Respond to the operation on the object according to the operation event.
[0100] In step S1011, in response to detecting an access instruction to an object, the data processing device declares a proxy for the object according to the type of the object and the name of the object; wherein declaring the proxy of the object includes declaring the type of the proxy and declaring the name of the proxy. The type of the declared proxy may be consistent with the type of the object; or based on the aforementioned preset proxy type correspondence relationship, the type corresponding to the type of the object is determined as the type of the proxy, which is not described in detail here.
[0101] The data processing device of the embodiment of the present disclosure declares the name of the proxy according to the name of the object, wherein the name of the proxy may include the name of the object; or it may be a name converted after processing the name of the object based on a preset naming rule. It can be understood that the name of the proxy in the embodiment of the present disclosure is highly correlated with the name of the object.
[0102] After declaring the proxy of the object, in step S1021 and step S1022, the data processing device generates a property access method of the proxy of the associated object, and based on the property access method of the proxy of the associated object, monitors the operation event of the property of the object, so that in step S103, the data processing device responds to the operation of the object according to the operation event. Among them, the property access method includes a property acquisition method (also called a get accessor), a property setting method (also called a set accessor), a property deletion method, a property generation method, etc.
[0103] Exemplarily, if the attribute access method includes an attribute acquisition method, based on the attribute acquisition method of the associated object, the operation event representing the attribute value of the acquired object is monitored, and according to the operation event, the acquired attribute value of the agent is used as the operation response result of the object. If the attribute access method includes an attribute setting method, based on the attribute setting method of the associated object, the operation event representing the attribute value of the set object is monitored, and according to the operation event, the attribute value of the agent and the attribute value of the object are assigned to the target attribute value, and the attribute value of the agent after the assignment is used as the operation response result of the object; wherein the operation event representing the attribute value of the set object carries the target attribute value. If the attribute access method includes an attribute deletion method, based on the attribute deletion method of the associated object, the operation event representing the attribute of the deleted object is monitored, and according to the operation event, the result representing the successful attribute deletion is used as the operation response result of the object. If the attribute access method includes an attribute generation method, based on the attribute generation method of the associated object, the operation event representing the attribute of the added object is monitored, and according to the operation event, the result representing the successful attribute addition is used as the operation response result of the object.
[0104] It can be understood that, on the one hand, the name of the agent in the embodiment of the present disclosure is highly correlated with the name of the object, thereby improving the convenience of calling the agent through the name of the agent that is highly correlated with the name of the object when the name of the object is known. On the other hand, based on the attribute access method of the agent of the generated associated object, the operation event of the attribute of the object is monitored, and in response to the monitored operation event, the operation of the object is quickly responded to. Compared with notifying the agent after monitoring the operation event based on other monitoring methods, the embodiment of the present disclosure can improve the immediacy of responding to the operation of the object through the agent.
[0105] Figure 3 This is an example of a data processing method flow shown in the embodiment of the present disclosure Figure 3 ,Depend on Figure 3 It can be seen that the following steps are included:
[0106] S1011-1. In response to detecting an access instruction to an object, declaring the agent whose type is consistent with the type of the object and whose name includes the name of the object;
[0107] S1021, generating a property access method of a proxy associated with the object;
[0108] S1022: Based on the attribute access method of the agent associated with the object, monitor the operation event of the attribute of the object;
[0109] S103: Respond to the operation on the object according to the operation event.
[0110] In the embodiment of the present disclosure, steps S1021, S1022 and S103 are understood by referring to the above, and are not described here. In step S1011-1, in response to detecting an access instruction to an object, the type of the declared proxy is consistent with the type of the object, and the name of the proxy includes the name of the object. The name of the proxy can be obtained by adding one or more preset characters before and / or after the name of the object, such as adding an underscore after the name of the object, adding the characters "Typed" before the name of the object, adding the characters "Proxy" after the name of the object, etc.
[0111] It can be understood that the proxy declared in the embodiment of the present disclosure, whose type is consistent with the type of the object and whose name includes the name of the object, can implement access to the properties of the proxy based on the way of accessing the properties of the object, thereby improving the convenience of accessing the properties of the proxy; in addition, since the name of the proxy includes the name of the object, when the operation event of the object is monitored, the name of the proxy can be quickly determined through the name of the object, thereby improving the immediacy of calling the proxy.
[0112] In some embodiments, the declared type is consistent with the type of the object, and the proxy whose name includes the name of the object includes:
[0113] In the case where the type of the object includes a basic data type, declaring a proxy variable of the basic data type; wherein the variable name of the proxy variable includes the name of the object, and the proxy variable has a variable value consistent with the object; the basic data type includes at least one of the following: character type, numeric type, Boolean type, time type;
[0114] The method for generating a property access method of a proxy associated with the object comprises:
[0115] Generates attribute access methods for the proxy variable.
[0116] In the embodiment of the present disclosure, if the type of the object includes a basic data type, a proxy variable whose type is the basic data type and whose name includes the name of the object is declared. The basic data type includes at least one of the following: character type (string), numeric type (number), Boolean type (boolean), and time type (Date); if the type of the object is a character type, the type of the proxy variable of the object is a character type; if the type of the object is a numeric type, the type of the proxy variable of the object is a numeric type; if the type of the object is a Boolean type, the type of the proxy variable of the object is a Boolean type; if the type of the object is a time type, the type of the proxy variable of the object is a time type.
[0117] When declaring a proxy variable, the disclosed embodiment assigns the attribute value of the object to the proxy variable. For example, the object is of character type, and the attribute value of the object is "Beijing City". Correspondingly, the proxy variable of the object is of character type, and the variable value is "Beijing City".
[0118] After declaring the proxy variable, the data processing device generates the attribute access method of the proxy variable. For example, for the proxy variable of the basic data type, the attribute access method is generated, including the attribute acquisition method that can directly return the variable value of the proxy variable, the attribute setting method that can directly set (assign) the variable value of the proxy variable, etc., so as to access the variable value of the proxy variable through the attribute access method of the proxy variable, which has the advantage of being simple and easy to implement.
[0119] In some embodiments, the declared type is consistent with the type of the object, and the proxy whose name includes the name of the object includes:
[0120] In the case where the type of the object includes a class, declaring a proxy class of the class type; wherein the class name of the proxy class includes the name of the object, and the proxy class has attributes consistent with those of the object;
[0121] The method for generating a property access method of a proxy associated with the object comprises:
[0122] For each attribute in the proxy class, an attribute access method associated with the attribute of the proxy class is generated in the declaration body of the proxy class.
[0123] In the disclosed embodiment, if the type of the object is a class, a proxy class whose type is a class and whose name includes the name of the object is declared. When declaring the proxy class, the properties of the declared proxy class are consistent with the properties of the object; for example, the object is a class named child, having name and age properties, and correspondingly, the proxy of the object is a class named childProxy, having name and age properties, and the property values are consistent.
[0124] After declaring the proxy class, the data processing device of the disclosed embodiment generates, for each attribute in the proxy class, an attribute access method of the attribute associated with the proxy class in the declaration body of the proxy class. For example, for the age attribute of the proxy class, an attribute access method including an attribute acquisition method returning the age attribute of the proxy class (such as return childProxy.age) and an attribute setting method assigning the age attribute value of the proxy class (such as childProxy.age=20) is generated, thereby achieving access to the attributes of the proxy class through the attribute access method of the attribute of the proxy class, and obtaining a response result including the attribute values of each object, which has the advantage of being convenient and fast.
[0125] In some embodiments, the declared type is consistent with the type of the object, and the proxy whose name includes the name of the object includes:
[0126] In the case where the type of the object includes a set, declaring a proxy set of a set type; wherein the set name of the proxy set includes the name of the object, and the proxy set has set elements consistent with the object;
[0127] The method for generating a property access method of a proxy associated with the object comprises:
[0128] Generate a property access method associated with all set elements of the proxy set in the declaration body corresponding to the proxy set.
[0129] In the embodiment of the present disclosure, if the type of the object is a collection, a proxy collection whose type is a collection and whose name includes the name of the object is declared, and the proxy collection has collection elements consistent with the object; wherein the collection type is, for example, an array type (Array), Set, Map, etc. For example, if the object is an Array <t>The collection type is strArr, and the proxy of the declared object is TypedArrayProxy <t>A proxy collection of type strArr_; if the object is a Set <t>The type name is strSet, and the proxy of the declared object is TypedSetProxy <t>A proxy set of type strSet_; if the object is a Map<K,V> The collection type is strMap, and the proxy of the declared object is TypedMapProxy<K,V> A collection of proxies of type strMap_.
[0130] After declaring a proxy set, the data processing device of the disclosed embodiment generates attribute access methods of all collection elements of the associated proxy set in the declaration body of the proxy set. For example, for the proxy set, attribute access methods such as attribute acquisition methods returning collection elements of the proxy set (such as return this.strArr_) and attribute setting methods assigning attribute values of elements of the proxy set (such as this.strArr_=20) are generated in the declaration body of the proxy set, thereby accessing the proxy set through the attribute access methods of the collection elements of the proxy set, and obtaining a response result including the attribute values of each object, which has the advantages of being convenient and fast.
[0131] In some embodiments, the declared type is consistent with the type of the object, and the proxy whose name includes the name of the object includes:
[0132] In the case where the type of the object includes a key-value pair, declaring a proxy key-value pair whose type is a key-value pair; wherein the name of the proxy key-value pair includes the name of the object, and the proxy key-value pair has a key-value pair consistent with that of the object;
[0133] The method for generating a property access method of a proxy associated with the object comprises:
[0134] For each key of the proxy, a property access method associated with the key of the proxy key-value pair is generated in a declaration body corresponding to the proxy.
[0135] In the disclosed embodiment, if the type of the object is a key-value pair (Json), a proxy key-value pair whose type is a key-value pair and whose name includes the name of the object is declared. When declaring a proxy key-value pair (which can also be converted into an interface), the proxy key-value pair is declared to have a key-value pair that is consistent with the key-value pair of the object. For example, the object SimpleJson has keys including name and age, and correspondingly, the object's proxy (proxy key-value pair) SimpleJsonProxy has name and age keys, and the key values are consistent.
[0136] After declaring a proxy key-value pair, the data processing device of the disclosed embodiment generates, for each key in the proxy key-value pair, a property access method (key value corresponding to the key) of the associated proxy key-value pair in the declaration body of the proxy key-value pair. For example, for the age attribute of the proxy key-value pair, a property access method is generated, including a property acquisition method that returns the key value of the age key of the proxy key-value pair (such as return SimpleJsonProxy.age), a property setting method that assigns the key value of the age key of the proxy key-value pair (such as SimpleJsonProxy.age=20), etc., thereby accessing the properties of the key of the proxy key-value pair through the property access method of the key of the proxy key-value pair, and obtaining a response result including the values of each property of the object, which has the advantage of being convenient and fast.
[0137] In an embodiment of the present disclosure, the attribute access method of generating a proxy associated with the object includes:
[0138] The attribute access method is generated, the method name including the name of the object and associating the proxy of the object.
[0139] In the disclosed embodiment, the method name of the attribute access method of the proxy of the associated object includes the name of the object. Exemplarily, the name of the object is str, the attribute acquisition method is such as get str(), and the attribute setting method is such as set str(). Through this scheme, when the name of the object is known, the operation event of the object can be monitored by directly calling the attribute access method including the name of the object, and then responding to the operation of the object, which has the advantage of being simple and easy to implement.
[0140] In some embodiments, the attribute access method includes an attribute acquisition method and / or an attribute setting method; and the responding to the operation on the object according to the operation event includes:
[0141] In the case where an operation event representing obtaining the attribute of the object is monitored through the attribute obtaining method, the attribute value of the proxy of the object is returned;
[0142] or,
[0143] When an operation event representing setting the property of the object is monitored by calling the property setting method, the property values of the object and the agent are set.
[0144] In the disclosed embodiment, the attribute access method includes an attribute acquisition method and / or an attribute setting method. In the case where the data processing device of the disclosed embodiment monitors an operation event of an object according to the object's proxy, if the operation event represents the acquisition of the object's attribute, the attribute acquisition method is called to return the attribute value of the object's proxy. As can be seen from the foregoing, the attribute of the object's proxy is consistent with the attribute of the object, so the attribute value of the returned proxy is the same as the attribute value of the object, and the operation on the object is achieved by accessing the proxy response.
[0145] Or, if the monitored operation event represents the property of the setting object, the property setting method is called to set the property values of the object and the agent. For example, the property values of the object and the agent are set to the preset values corresponding to the operation event (such as the preset reset values), or when the operation event carries a target property value, the property values of the object and the agent are set to the target property value.
[0146] Through this solution, on the one hand, the proxy of the object can be realized to improve the protection and enhancement of the object; on the other hand, when the operation event represents the attribute of the device object, the attribute values of the object and the agent are set at the same time, so that the attribute values of the object and the agent are set consistently, which is convenient for subsequent operations such as obtaining the attributes of the object through the proxy response representation.
[0147] In some embodiments, the operation event carries a target attribute value; and when the operation event representing setting the attribute of the object is monitored by calling the attribute setting method, setting the attribute values of the object and the agent includes:
[0148] When an operation event representing setting the property of the object is monitored by calling the property setting method, in response to the property value of the agent before setting being inconsistent with the target property value, the property values of the object and the agent are set to the target property value.
[0149] In the embodiment of the present disclosure, the operation event carries a target attribute value. It can be understood that the operation event represents an attribute event of setting an object.
[0150] When the data processing device of the disclosed embodiment monitors an operation event representing the setting of the attributes of an object by calling the attribute setting method, if the attribute value of the agent before setting is inconsistent with the target attribute value, the attribute value of the object and the agent is set to the target attribute value; if the attribute value of the agent before setting is consistent with the target attribute value, the attribute value of the object and the agent is not reset.
[0151] For example, if the attribute value before the proxy is set is consistent with the target attribute value, the attribute access method ends by returning; if the attribute value before the proxy is set is inconsistent with the target attribute value, the attribute values of the object and the proxy are assigned. Through this solution, when the attribute value before the proxy is set is consistent with the target attribute value, the access pressure on the object and the proxy can be reduced, and the necessity of setting the attribute value can be increased.
[0152] In some embodiments, the object includes an object in a page; and responding to an operation on the object according to the operation event includes:
[0153] In the case where an operation event representing setting the property of the object is monitored by calling the property setting method, sending a property setting notification to the object;
[0154] According to the property setting notification, in response to the property value of the object after setting being inconsistent with the property value of the object before setting, the object in the page is rendered according to the property value of the object after setting.
[0155] In the embodiment of the present disclosure, the object includes objects in the page, such as components, pictures, texts, etc. in the page; correspondingly, the attributes of the object include the attribute value (value) of the component, the style of the component, etc.
[0156] In the case where the data processing device of the disclosed embodiment monitors the operation event representing the property of the object to be set by calling the property setting method, it sends a property setting notification to the object; thus, according to the property setting notification, when the property value of the object after setting is inconsistent with the property value of the object before setting, the object in the page is rendered according to the property value of the object after setting. Taking the object as a name edit box component in the page as an example, if the value of the name edit box before setting is "Zhang", after the user edits the text in the name edit box, the value of the name edit box after setting is "Li", thereby rendering the property value of the name edit box in the page, such as displaying "Li" in the name edit box; in addition, the gender edit box associated with the name edit box can also be rendered in conjunction, such as rendering from "male" to "female".
[0157] In addition, when the data processing device of the disclosed embodiment monitors the operation event of the attribute of the acquired object by calling the attribute setting method, it can send an attribute acquisition notification to the object and record the attribute value of the acquired object; thus, when the attribute value of the object after setting is inconsistent with the attribute value of the object before setting (recording the attribute value of the acquired object) according to the attribute setting notification issued after monitoring, the object in the page is rendered according to the attribute value of the object after setting. Through this scheme, it is possible to realize the two-way binding of the client page and data through the proxy, improve the necessity of page rendering, and have high universality.
[0158] Figure 4 is a diagram of a data processing device shown in an embodiment of the present disclosure, comprising Figure 4 It is known that, including:
[0159] A generating module 401, configured to generate a proxy for the object according to the type of the object in response to detecting an access instruction to the object;
[0160] A monitoring module 402, configured to monitor operation events on the object according to the agent of the object;
[0161] The response module 403 is used to respond to the operation on the object according to the operation event.
[0162] In some embodiments, the generating module 401 is used to declare the proxy of the object according to the type of the object and the name of the object;
[0163] The monitoring module 402 is used to generate a property access method of a proxy associated with the object; and monitor operation events on the properties of the object based on the property access method of the proxy associated with the object.
[0164] In some embodiments, the generating module 401 is used to declare the proxy whose type is consistent with the type of the object and whose name includes the name of the object.
[0165] In some embodiments, the generating module 401 is used to declare a proxy variable of a type of the basic data type when the type of the object includes a basic data type; wherein the variable name of the proxy variable includes the name of the object, and the proxy variable has a variable value consistent with the object; the basic data type includes at least one of the following: character type, numeric type, Boolean type, time type;
[0166] The monitoring module 402 is used to generate a property access method for the proxy variable.
[0167] In some embodiments, the generating module 401 is used to declare a proxy class of the class type when the type of the object includes a class; wherein the class name of the proxy class includes the name of the object, and the proxy class has properties consistent with the object;
[0168] The monitoring module 402 is used to generate, for each attribute in the proxy class, an attribute access method associated with the attribute of the proxy class in the declaration body of the proxy class.
[0169] In some embodiments, the generating module 401 is used to declare a proxy set of type set when the type of the object includes set; wherein the set name of the proxy set includes the name of the object, and the proxy set has set elements consistent with the object;
[0170] The monitoring module 402 is used to generate a property access method associated with all set elements of the proxy set in the declaration body corresponding to the proxy set.
[0171] In some embodiments, the generating module 401 is used to declare a proxy key-value pair whose type is a key-value pair when the type of the object includes a key-value pair; wherein the name of the proxy key-value pair includes the name of the object, and the proxy key-value pair has a key-value pair consistent with the object;
[0172] The monitoring module 402 is used to generate, for each key of the proxy, a property access method associated with the key of the proxy key-value pair in the declaration body corresponding to the proxy.
[0173] In some embodiments, the monitoring module 402 is used to generate the property access method whose method name includes the name of the object and is associated with the proxy of the object.
[0174] In some embodiments, the property access method includes a property acquisition method and / or a property setting method; the response module 403 is used to return the property value of the agent of the object when an operation event representing the acquisition of the property of the object is monitored through the property acquisition method; or, when an operation event representing the setting of the property of the object is monitored by calling the property setting method, set the property values of the object and the agent.
[0175] In some embodiments, the operation event carries a target attribute value; the response module 403 is used to set the attribute values of the object and the agent to the target attribute value in response to the attribute value of the agent before setting being inconsistent with the target attribute value when an operation event representing setting the attribute of the object is monitored by calling the attribute setting method.
[0176] In some embodiments, the object includes an object in a page; the response module 403 is used to send a property setting notification to the object when an operation event representing setting the property of the object is monitored by calling the property setting method; according to the property setting notification, in response to the property value of the object after setting being inconsistent with the property value of the object before setting, render the object in the page according to the property value of the object after setting.
[0177] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0178] Figure 5 8 is a block diagram of an electronic device 800 shown in an embodiment of the present disclosure. For example, the electronic device 800 may be a mobile phone, a mobile computer, etc.
[0179] Reference Figure 5 , the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .
[0180] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0181] The memory 804 is configured to store various types of data to support operations on the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0182] The power supply component 806 provides power to the various components of the electronic device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 800.
[0183] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the electronic device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0184] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0185] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0186] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the electronic device 800, the relative positioning of the components, such as the display and keypad of the electronic device 800, and the sensor assembly 814 can also detect the position change of the electronic device 800 or a component of the electronic device 800, the presence or absence of contact between the user and the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0187] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as Wi-Fi, 4G or 5G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0188] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0189] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by a processor 820 of an electronic device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0190] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the aforementioned data processing method.
[0191] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims above.
[0192] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.< / t> < / t> < / t> < / t>
Claims
1. A data processing method, characterized in that: The method comprises: In response to detecting an access instruction of an object, generating a proxy for the object according to a type of the object; According to the agent of the object, monitoring the operation events of the object; According to the operation event, respond to the operation on the object.
2. The method according to claim 1, characterized in that Generating a proxy for the object according to the type of the object includes: Declare a proxy for the object according to the type of the object and the name of the object; The step of monitoring the operation event on the object according to the proxy of the object includes: generating attribute access methods of a proxy associated with the object; Based on the attribute access method of the proxy associated with the object, operation events on the attributes of the object are monitored.
3. The method according to claim 2, characterized in that Declaring a proxy of the object according to the type of the object and the name of the object includes: Declare the proxy with a type consistent with the type of the object and a name including the name of the object.
4. The method according to claim 3, characterized in that The proxy, whose declared type is consistent with the type of the object and whose name includes the name of the object, comprises: In the case where the type of the object includes a basic data type, declaring a proxy variable of the basic data type; wherein the variable name of the proxy variable includes the name of the object, and the proxy variable has a variable value consistent with the object; the basic data type includes at least one of the following: character type, numeric type, Boolean type, time type; The method for generating a property access method of a proxy associated with the object comprises: Generates attribute access methods for the proxy variable.
5. The method according to claim 3, characterized in that: The proxy, whose declared type is consistent with the type of the object and whose name includes the name of the object, comprises: In the case where the type of the object includes a class, declaring a proxy class of the class type; wherein the class name of the proxy class includes the name of the object, and the proxy class has attributes consistent with those of the object; The method for generating a property access method of a proxy associated with the object comprises: For each attribute in the proxy class, an attribute access method associated with the attribute of the proxy class is generated in the declaration body of the proxy class.
6. The method according to claim 3, characterized in that The proxy, whose declared type is consistent with the type of the object and whose name includes the name of the object, comprises: In the case where the type of the object includes a set, declaring a proxy set of a set type; wherein the set name of the proxy set includes the name of the object, and the proxy set has set elements consistent with the object; The method for generating a property access method of a proxy associated with the object comprises: Generate a property access method associated with all set elements of the proxy set in the declaration body corresponding to the proxy set.
7. The method according to claim 3, characterized in that The proxy, whose declared type is consistent with the type of the object and whose name includes the name of the object, comprises: In the case where the type of the object includes a key-value pair, declaring a proxy key-value pair whose type is a key-value pair; wherein the name of the proxy key-value pair includes the name of the object, and the proxy key-value pair has a key-value pair consistent with that of the object; The method for generating a property access method of a proxy associated with the object comprises: For each key of the proxy, a property access method associated with the key of the proxy key-value pair is generated in a declaration body corresponding to the proxy.
8. The method according to claim 2, characterized in that: The method for generating a property access method of a proxy associated with the object comprises: The attribute access method is generated, the method name including the name of the object and associating the proxy of the object.
9. The method according to claim 2, characterized in that: The attribute access method includes an attribute acquisition method and / or an attribute setting method; the responding to the operation on the object according to the operation event includes: In the case where an operation event representing obtaining the attribute of the object is monitored through the attribute obtaining method, the attribute value of the proxy of the object is returned; or, When an operation event representing setting the property of the object is monitored by calling the property setting method, the property values of the object and the agent are set.
10. The method according to claim 9, characterized in that The operation event carries a target attribute value; and when the operation event representing setting the attribute of the object is monitored by calling the attribute setting method, setting the attribute values of the object and the agent includes: When an operation event representing setting the property of the object is monitored by calling the property setting method, in response to the property value of the agent before setting being inconsistent with the target property value, the property values of the object and the agent are set to the target property value.
11. The method according to claim 9, characterized in that The object includes an object in a page; and responding to an operation on the object according to the operation event includes: In the case where an operation event representing setting the property of the object is monitored by calling the property setting method, sending a property setting notification to the object; According to the property setting notification, in response to the property value of the object after setting being inconsistent with the property value of the object before setting, the object in the page is rendered according to the property value of the object after setting.
12. A data processing device, characterized in that: The device comprises: A generating module, configured to generate a proxy for the object according to the type of the object in response to detecting an access instruction to the object; A monitoring module, used for monitoring operation events on the object according to the agent of the object; The response module is used to respond to the operation on the object according to the operation event.
13. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the method as claimed in any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method as claimed in any one of claims 1 to 11.