A method and device for setting Windows system components

By using V8 static library and precompiled scripts to generate registration modules in Windows system, executing business scripts to update function pointers, the independent settings and modification of widgets are realized, the problems of high coupling and low output of code are solved, and the development efficiency is improved .

CN114296718BActive Publication Date: 2024-11-22ZHUHAI BAOQU TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111629969.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-28
Publication Date
2024-11-22
Estimated Expiration
2041-12-28

AI Technical Summary

Technical Problem

When setting widgets in Windows system wallpapers, the existing technology leads to high coupling of code and low output. Modifying widgets requires modifying the main program logic of the wallpaper engine, resulting in unnecessary code modules and inefficient development.

Method used

By obtaining the V8 static library, the global class, global objects and global functions of the target component are generated, the precompiled scripts are obtained and the registration module is generated, the business script is executed in the registration module, the function pointer of the target component is updated, and the independent settings of the target component are achieved. and modify.

Benefits of technology

It solves the problems of high coupling and low output of code, making the addition or modification of widgets completely independent of the main framework of the wallpaper engine, and greatly improves the development efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114296718B_ABST
    Figure CN114296718B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a method and device for setting Windows system components, which relates to the field of communication technology. The method includes: obtaining a V8 static library; the V8 static library includes a function template and a property module; generating a global class, a global object and a global function of a target component according to the function template and the property module; obtaining a precompiled script, and generating a registration module according to the precompiled script, the global class, the global object and the global function of the target component; inputting a business script into the registration module; updating the function pointer of the target component according to the business script. In this application, the newly added or modified target component can be completely independent of the main framework of the Windows system wallpaper engine. The business personnel only need to modify the business script corresponding to the target component according to the requirements, and the process can take effect through the background resource replacement, which solves the problem of high code coupling and low output, and greatly improves the development efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to a method and device for setting Windows system components. Background Art

[0002] Currently, when users need to add a new widget to the Windows system wallpaper, the existing practice is to directly write the logic script of each component into the main framework of the wallpaper engine. Doing so will destroy the architectural design of the engine's main framework, and because the logic scripts of each widget are not universal, doing so will also cause the framework project to include many irrelevant code modules. If users want to modify a widget in the Windows system wallpaper, they need to modify the logic of the wallpaper engine main program, because the logic scripts between the widgets are independent and basically have nothing to do with the wallpaper engine main program logic script, but because the code is in the same module, each time a widget is modified, a version of the wallpaper engine main program script needs to be released.

[0003] Therefore, there is an urgent need for a method to solve the existing problem of high code coupling and low output when setting widgets in Windows system wallpapers. Summary of the invention

[0004] In view of this, an embodiment of the present invention provides a method and device for setting Windows system components to solve the problems of high code coupling and low output when setting Windows system components in the prior art.

[0005] In a first aspect, an embodiment of the present invention provides a method for setting a Windows system component, the method comprising:

[0006] Obtain a V8 static library; the V8 static library includes function templates and attribute modules;

[0007] Generate a global class, a global object and a global function of a target component according to the function template and the attribute module;

[0008] Obtain a precompiled script, and generate a registration module according to the precompiled script, the global class, global object and global function of the target component;

[0009] Inputting a business script into the registration module;

[0010] The function pointer of the target component is updated according to the business script.

[0011] Optionally, the step of obtaining the V8 static library is as follows:

[0012] A script engine dynamic library is set, and the V8 static library is linked through the script engine dynamic library, thereby obtaining the V8 static library.

[0013] Optionally, before generating the global class, global object and global function of the target component according to the function template and the property module, the method further includes:

[0014] The initialized V8 static library is initialized, and the execution environment of the V8 static library is set to the first execution environment.

[0015] Optionally, the business script includes an update variable, and the function pointer of updating the target component according to the business script is specifically:

[0016] The function pointer of the target component is updated according to the update variable in the business script.

[0017] Optionally, after updating the function pointer of the target component according to the business script, the method further includes:

[0018] Binding the updated function pointer to the global class of the target component to obtain a bound global class;

[0019] Create a handle in the V8 static library and bind it to the bound global class;

[0020] The handle is registered in the global module of the V8 static library.

[0021] In a second aspect, an embodiment of the present invention provides a device for setting a Windows system component, the device comprising:

[0022] An acquisition unit acquires a V8 static library; the V8 static library includes function templates and attribute modules;

[0023] A first processing unit generates a global class, a global object and a global function of a target component according to the function template and the attribute module;

[0024] The second processing unit obtains a precompiled script, and generates a registration module according to the precompiled script, a global class, a global object, and a global function of the target component;

[0025] An input unit, inputting a business script into the registration module;

[0026] The third processing unit updates the function pointer of the target component according to the business script.

[0027] Optionally, the acquisition unit is further used for:

[0028] A script engine dynamic library is set, and the V8 static library is linked to the script engine dynamic library, thereby obtaining the V8 static library.

[0029] Optionally, the device further includes an initialization unit, wherein the initialization unit is configured to:

[0030] The initialized V8 static library is initialized, and the execution environment of the V8 static library is set to the first execution environment.

[0031] Optionally, the business script includes an update variable, and the third processing unit is further used to:

[0032] The function pointer of the target component is updated according to the update variable in the business script.

[0033] Optionally, the device further includes a fourth processing unit, and the fourth processing unit is configured to:

[0034] Binding the updated function pointer to the global class of the target component to obtain a bound global class;

[0035] Create a handle in the V8 static library and bind it to the bound global class;

[0036] The handle is registered in the global module of the V8 static library.

[0037] In a third aspect, an embodiment of the present disclosure further provides an electronic device, comprising: a housing, a processor, a memory, a circuit board and a power supply circuit, wherein the circuit board is placed inside a space enclosed by the housing, and the processor and the memory are arranged on the circuit board; the power supply circuit is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory is used to store executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the setting method of the Windows system component described in the first aspect above.

[0038] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the method for setting Windows system components described in the first aspect above.

[0039] The embodiment of the present invention provides a method and device for setting a Windows system component, which obtains a V8 static library, generates a registration module according to a precompiled script, a global class, a global object and a global function of a target component, and executes a business script input by a user in the registration module to achieve the setting of the target component. This makes it possible for the newly added or modified target component in the present application to be completely independent of the main framework of the Windows system wallpaper engine. Business personnel only need to modify the business script corresponding to the target component according to requirements, and the process can take effect through background resource replacement, which solves the problem of high code coupling and low output and greatly improves development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0041] Figure 1 A method flow chart of a method for setting a Windows system component provided by an embodiment of the present invention;

[0042] Figure 2 A schematic diagram of the structure of a Windows system component setting device provided by an embodiment of the present invention;

[0043] Figure 3 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0044] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0045] It should be clear that the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0046] The following is combined with Figure 1 , the scheme provided by the embodiment of the present invention is described in detail, Figure 1 The present invention provides a flowchart of a method for setting Windows system components. In the present invention, the implementation subject is an electronic device. The electronic device can be a terminal device, such as a personal computer, a desktop computer, etc. The electronic device can also be a server. Figure 1 As shown, the method of this embodiment specifically includes the following steps:

[0047] Step 110: Get the V8 static library.

[0048] V8 is Google's open source high-performance JavaScript and WebAssembly engine. Generally speaking, static libraries are directly integrated into the target program during compilation, and the successfully compiled executable file can run independently, while dynamic libraries are not put into the linked target program during compilation, that is, the executable file cannot run independently.

[0049] The V8 static library includes function templates and attribute modules. Among them, function templates are a special type of function that can be called using different types. For functions with the same function, there is no need to write code repeatedly, and function templates look very similar to ordinary functions, the difference is that the type can be parameterized; attribute modules can be understood as modules responsible for managing script attribute values ​​in V8, and their function is to customize attributes in C++ code and provide scripts for use.

[0050] In this application, it is necessary to set up a script engine dynamic library, link the V8 static library through the script engine dynamic library, thereby obtaining the V8 static library, and then obtaining the function templates and attribute modules in the V8 static library.

[0051] Preferably, after step 110, the V8 static library needs to be initialized. The execution environment of the V8 static library is set as the first execution environment, and the first execution environment can be understood as an execution environment that can be used to execute the registration module.

[0052] In this application, the registration module can be understood as: a module registered in the Windows system for executing business scripts. The business script can be understood as a script written by the user when setting the target component, that is, the script entered by the caller when updating the function pointer in the subsequent steps. The business script in this application can be specifically a script edited in JavaScript dynamic language. That is to say, in this application, the user can set the target component by entering the business script. Therefore, the first execution environment can also be understood as an execution environment that can be publicly executed by the business script.

[0053] It can be understood that the initialized V8 static library includes function templates and attribute modules.

[0054] Step 120: Generate the global class, global object and global function of the target component according to the function template and the attribute module.

[0055] Among them, the global class can be understood as a data type that can be referenced by any module; the global object can be understood as an object that can be accessed anytime and anywhere by the host environment during the JavaScript running process; the global function can be understood as a function defined outside the class that can be called by functions in other files.

[0056] Step 130: Obtain a precompiled script, and generate a registration module according to the precompiled script, the global class, global object and global function of the target component.

[0057] The precompiled script needs to include all the public functions required by the user. Get the precompiled script and generate a registration module based on the precompiled script in this step, the global class, global object, and global function in the previous step.

[0058] Step 140: Input the business script to the registration module.

[0059] The business script includes update variables. In this application, the function pointer of the target component is updated according to the update variables in the business script.

[0060] Preferably, if a global variable needs to be provided to the business script as a global object, the C++ object needs to be registered in the global of the V8 engine. Therefore, after executing step 140, the updated function pointer needs to be bound to the global class of the target component to obtain the bound global class, and then a handle needs to be created in the V8 static library and bound to the bound global class, and finally the handle needs to be registered in the global module of the V8 static library to register the C++ object in the global of the V8 engine.

[0061] In a specific example, if the caller wants to set a business script in the "Console.log" log module, it is necessary to: 1) obtain the function template and attribute module in the V8 static library, and generate the global class of "Console", the global object of "Console" and the global function of "log" according to the function template and attribute module; 2) pass the function pointer of "log" to the caller to write the business script; 3) bind the function pointer to the global class of "Console"; 4) create a handle in the V8 static library and bind it to the global class of "Console", and 5) register the handle in the global module of the V8 static library.

[0062] Step 150: Update the function pointer of the target component according to the business script.

[0063] A function pointer is a pointer variable pointing to a function, that is, the function pointer itself should first be a pointer variable, but the pointer variable points to the function, so the application can update the function pointer through the update variable in the business script.

[0064] After the function pointer of the target component is updated, the setting of the target component can be completed.

[0065] In a specific example, if the caller needs to set the target component of the "clock widget", the "get" and "set" function pointers of the string "time" can be registered and updated through the registration module to realize the function that the target component obtains the system time in real time and displays it in each frame. The business script includes the value of the update variable of "time", and the "get" and "set" function pointers of the string "time" are updated according to the value of the update variable, which can respond to the "set" function, thereby obtaining the time variable, and then responding to the "get" function.

[0066] The present application provides a method for setting a Windows system component, which obtains a V8 static library, generates a registration module according to a precompiled script, a global class, a global object and a global function of a target component, and executes a business script input by a user in the registration module to achieve the setting of the target component. This allows the newly added or modified target component in the present application to be completely independent of the main framework of the Windows system wallpaper engine. Business personnel only need to modify the business script corresponding to the target component according to demand, and the process can take effect through background resource replacement, which solves the problem of high code coupling and low output and greatly improves development efficiency.

[0067] Correspondingly, an embodiment of the present application also provides a device for setting Windows system components for implementing the above steps 110-150. Figure 2 A schematic diagram of a Windows system component configuration device provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the Windows system component setting device of this embodiment may include: an acquisition unit 210 , a first processing unit 220 , a second processing unit 230 , an input unit 240 and a third processing unit 250 .

[0068] The acquisition unit 210 acquires a V8 static library, wherein the V8 static library includes a function template and an attribute module;

[0069] A first processing unit 220 generates a global class, a global object and a global function of a target component according to the function template and the attribute module;

[0070] The second processing unit 230 obtains a precompiled script, and generates a registration module according to the precompiled script, the global class, the global object and the global function of the target component;

[0071] An input unit 240, inputting a business script into the registration module;

[0072] The third processing unit 250 updates the function pointer of the target component according to the business script.

[0073] Optionally, the acquiring unit 210 is further configured to:

[0074] A script engine dynamic library is set, and the V8 static library is linked to the script engine dynamic library, thereby obtaining the V8 static library.

[0075] Optionally, the device further includes an initialization unit (not shown in the figure), and the initialization unit is used to:

[0076] The initialized V8 static library is initialized, and the execution environment of the V8 static library is set to the first execution environment.

[0077] Optionally, the business script includes an update variable, and the third processing unit 250 is further configured to:

[0078] The function pointer of the target component is updated according to the update variable in the business script.

[0079] Optionally, the device further includes a fourth processing unit (not shown in the figure), and the fourth processing unit is used to:

[0080] Binding the updated function pointer to the global class of the target component to obtain a bound global class;

[0081] Create a handle in the V8 static library and bind it to the bound global class;

[0082] The handle is registered in the global module of the V8 static library.

[0083] The device of this embodiment can be used to perform Figure 1 The technical solution of the method embodiment shown has similar implementation principles and technical effects, which will not be repeated here.

[0084] Accordingly, the Windows system component setting device provided by the embodiment of the present invention can also be implemented with another structure. Figure 3 A schematic diagram of the structure of an electronic device embodiment provided by the present invention can implement the present invention Figure 1 , the process of the embodiment shown in FIG. Figure 3As shown, the electronic device may include: a housing 31, a processor 32, a memory 33, a circuit board 34, and a power supply circuit 35. The circuit board 34 is placed inside the space enclosed by the housing 31, and the processor 32 and the memory 33 are arranged on the circuit board 34; the power supply circuit 35 is used to supply power to various circuits or devices of the electronic device; the memory 33 is used to store executable program codes; the processor 32 runs a program corresponding to the executable program code by reading the executable program code stored in the memory 33, so as to execute the method described in the above embodiment.

[0085] For details on the specific execution process of the above steps by the processor 32 and the steps further executed by the processor 32 by running the executable program code, please refer to the present invention. Figure 1 The description of the illustrated embodiment will not be repeated here.

[0086] The electronic device is a device that provides computing services. The electronic device consists of a processor, hard disk, memory, system bus, etc. The electronic device is similar to the general computer architecture, but because it needs to provide highly reliable services, it has higher requirements in terms of processing power, stability, reliability, security, scalability, manageability, etc.

[0087] It should be noted that, in this article, terms such as "comprises", "includes" 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 includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of more 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.

[0088] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

[0089] In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0090] The logic and / or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be embodied in any computer-readable storage medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, apparatus, or device and execute instructions), or in conjunction with such instruction execution system, apparatus, or device. For purposes of this specification, "computer-readable storage medium" may be any device that can contain, store, communicate, propagate, or transmit a program for use by an instruction execution system, apparatus, or device, or in conjunction with such instruction execution system, apparatus, or device.

[0091] More specific examples of computer-readable storage media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable storage medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or processing in another suitable manner as necessary, and then stored in a computer memory.

[0092] It should be understood that various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof.

[0093] In the above embodiments, multiple steps or methods may be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it may be implemented by any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0094] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0095] For the convenience of description, the above device is described by dividing the functions into various units / modules. Of course, when implementing the present invention, the functions of each unit / module can be implemented in the same or multiple software and / or hardware.

[0096] It can be known from the description of the above implementation methods that those skilled in the art can clearly understand that the present invention can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention or certain parts of the embodiments.

Claims

1. A method for setting a Windows system component, characterized in that: The method comprises: Obtain a V8 static library; the V8 static library includes function templates and attribute modules; Generate a global class, a global object and a global function of a target component according to the function template and the attribute module; Obtain a precompiled script, and generate a registration module according to the precompiled script, the global class, global object and global function of the target component; Inputting a business script into the registration module; Update the function pointer of the target component according to the business script; The business script includes an update variable, and the function pointer of updating the target component according to the business script is specifically: Updating the function pointer of the target component according to the update variable in the business script; After updating the function pointer of the target component according to the business script, the method further includes: Binding the updated function pointer to the global class of the target component to obtain a bound global class; Create a handle in the V8 static library and bind it to the bound global class; The handle is registered in the global module of the V8 static library.

2. The method according to claim 1, characterized in that: The specific steps of obtaining the V8 static library are as follows: A script engine dynamic library is set, and the V8 static library is linked to the script engine dynamic library, thereby obtaining the V8 static library.

3. The method according to claim 1, characterized in that Before generating the global class, global object and global function of the target component according to the function template and the property module, the method further comprises: The V8 static library is initialized, and the execution environment of the V8 static library is set to the first execution environment.

4. A device for setting Windows system components, characterized in that: The device comprises: An acquisition unit acquires a V8 static library; the V8 static library includes function templates and attribute modules; A first processing unit generates a global class, a global object and a global function of a target component according to the function template and the attribute module; The second processing unit obtains a precompiled script, and generates a registration module according to the precompiled script, a global class, a global object, and a global function of the target component; An input unit, inputting a business script into the registration module; A third processing unit updates a function pointer of the target component according to the business script; The business script includes an update variable, and the third processing unit is further used for: Updating the function pointer of the target component according to the update variable in the business script; The device further includes a fourth processing unit, wherein the fourth processing unit is configured to: Binding the updated function pointer to the global class of the target component to obtain a bound global class; Create a handle in the V8 static library and bind it to the bound global class; The handle is registered in the global module of the V8 static library.

5. The device according to claim 4, characterized in that The acquisition unit is also used for: A script engine dynamic library is set, and the V8 static library is linked to the script engine dynamic library, thereby obtaining the V8 static library.

6. The device according to claim 4, characterized in that The device further comprises an initialization unit, wherein the initialization unit is configured to: The V8 static library is initialized, and the execution environment of the V8 static library is set to the first execution environment.

7. An electronic device, characterized in that: The electronic device comprises: a housing, a processor, a memory, a circuit board and a power supply circuit, wherein the circuit board is placed inside the space enclosed by the housing, and the processor and the memory are arranged on the circuit board; the power supply circuit is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory is used to store executable program codes; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the method described in any one of claims 1 to 3.

8. A computer-readable storage medium storing one or more programs, wherein the one or more programs can be executed by one or more processors to implement the method according to any one of claims 1 to 3.