Method, device, electronic device and medium for generating code declaration of configuration table
By automatically parsing and writing the header information and reference relationships of the configuration table, a code declaration file is generated, which solves the problem of tedious modification of the configuration table code declaration, improves the accuracy and efficiency of the modification, and reduces program errors.
Patent Information
- Application Number
- CN202210458922.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-27
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2042-04-27
AI Technical Summary
In the prior art, the modification operation of the code declaration corresponding to the configuration table is cumbersome and prone to program errors due to untimely notification or inaccurate modification.
By obtaining the header information of the configuration table called by the target project, resolving its reference relationship, and automatically writing the declaration data corresponding to the header information into the code declaration file, a code declaration file for the target project is generated.
It realizes the automatic update of configuration table code declaration, avoids the inaccuracy and omission of manual modification, improves the accuracy and efficiency of code declaration modification, and reduces the error probability during program runtime.
Smart Images

Figure CN114895958B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure belongs to the technical field of software development, and particularly relates to a method, device, electronic device, and medium for generating a code declaration of a configuration table. Background Art
[0002] With the advancement of software development technology, developers can develop increasingly powerful projects. However, these projects rely on extensive configuration data for operation. Using configuration tables, developers can configure the project's configurable data in a tabular format. Dynamically adding, deleting, or modifying data in the configuration table allows for simultaneous changes to project data, making this an essential step in the project development process. Configuration tables typically contain information such as the field names and field types of the configuration data. Programmers need to access these fields when writing code. Without code prompts, reading configuration fields is inconvenient, so it's necessary to declare these fields in the code.
[0003] Typically, a project requires calling data from several configuration tables, and the data in the configuration tables is changeable. After developers update the data in the configuration tables, if the modified data includes field declarations in the configuration tables, programmers need to simultaneously modify the corresponding field declarations in the code so that the program application can accurately read the field information in the configuration tables through the code declarations at runtime. Currently, after developers update the configuration tables, they usually manually notify programmers to manually update the corresponding code declarations, or if a code error is found during the program application runtime, they notify programmers to manually update the corresponding code declarations.
[0004] However, if the R&D personnel fail to notify the programmers to make modifications in a timely manner, or the programmers make inaccurate modifications, a code error may occur after the program is run. At this time, it is difficult to find the error location again, which may result in a long time to repair the error. Therefore, the modification operation of the code declaration corresponding to the current configuration table is cumbersome. Summary of the Invention
[0005] The purpose of the embodiments of the present disclosure is to provide a method, device, electronic device, and medium for generating a code declaration of a configuration table, which can solve the problem of cumbersome modification operations of the code declaration corresponding to the configuration table.
[0006] In order to solve the above technical problems, the present disclosure is implemented as follows:
[0007] In a first aspect, an embodiment of the present disclosure provides a method for generating a code declaration for a configuration table, the method comprising: obtaining header information of each configuration table in M configuration tables called by a target project, where M is a positive integer; parsing the reference relationship of the configuration tables in the M configuration tables; based on the reference relationship of the configuration tables, writing the declaration data corresponding to the header information of each configuration table into a code declaration file corresponding to each configuration table; saving the code declaration file corresponding to each configuration table in the M configuration tables to the code declaration file directory of the target project to generate a code declaration file for the configuration table called by the target project.
[0008] Optionally, based on the reference relationship of the configuration table, the declaration data corresponding to the header information of each configuration table is written into the code declaration file corresponding to each configuration table, including: if there is a reference relationship in the target field of the target configuration table, then sorting out the reference relationship of the target field; determining the data referenced by the target field according to the sorted reference relationship of the target field; writing the declaration data determined according to the data referenced by the target field into the code declaration file corresponding to the target configuration table; wherein, the target configuration table is any one of the configuration tables called by the target project.
[0009] Optionally, parsing the reference relationship of the configuration tables in the M configuration tables includes: traversing and parsing the reference relationship of the tabs in each configuration table in the M configuration tables; traversing and parsing the reference relationship between each configuration table in the M configuration tables.
[0010] Optionally, before reading the header information of each configuration table in the M configuration tables called by the target project, the method further includes: obtaining a directory of the configuration tables called by the target project; and downloading the M configuration tables called by the target project according to the directory of the configuration tables called by the target project.
[0011] Optionally, before reading the header information of each configuration table in the M configuration tables called by the target project, the method also includes: updating the directory of the configuration table of the target project stored locally; and updating the configuration table called by the target project stored locally based on the updated directory of the configuration table of the target project.
[0012] Optionally, before reading the header information of each configuration table in the M configuration tables called by the target project, the method further includes: detecting whether there is a changed configuration table in the configuration table called by the target project; reading the header information of each configuration table in the M configuration tables called by the target project includes: if there is a changed configuration table, reading the header information of the changed configuration table and the header information of the referenced configuration table in the configuration table called by the target project; parsing the reference relationship of the configuration tables in the M configuration tables includes: if there is a changed configuration table, parsing the changed reference relationship in the called configuration table.
[0013] Optionally, before reading the header information of each configuration table in the M configuration tables called by the target project, the method also includes: detecting whether there is a target configuration file, the target configuration file indicating the local storage location of the code declaration of the target project and the local storage location of the configuration table called by the target project; reading the header information of each configuration table in the M configuration tables called by the target project includes: if the target configuration file exists, reading the header information of each configuration table in the M configuration tables called by the target project based on the target configuration file.
[0014] Optionally, after detecting whether the target configuration file exists, the method further includes: if the target configuration file does not exist, prompting the first local storage location of the code declaration file for configuring the configuration table of the target project and the second local storage location of the configuration table called by the target project; after configuring the first local storage location and the second local storage location, reading the table name information of each configuration table in the configuration table called by the target project based on the first storage location; generating a code declaration file corresponding to each configuration table at the second local storage location, and naming the code declaration file corresponding to each configuration table according to the table name information of each configuration table.
[0015] Optionally, the method further includes: after generating a code declaration file of the configuration table called by the target project, calling the code declaration file of the target project, compiling and running the code of the target project; and prompting an error location of the code of the target project.
[0016] In a second aspect, an embodiment of the present disclosure provides a device for generating a code declaration, and the device for generating a code declaration includes: a reading module, a parsing module, a writing module and a saving module; the reading module is used to read the header information of each configuration table in the M configuration tables called by the target project, where M is a positive integer; the parsing module is used to parse the reference relationship of the configuration tables in the M configuration tables; the writing module is used to write the declaration data corresponding to the header information of each configuration table read by the reading module into the code declaration file corresponding to each configuration table based on the reference relationship of the configuration tables parsed by the parsing module; the saving module is used to save the code declaration file corresponding to each configuration table in the M configuration tables to the code declaration file directory of the target project to generate a code declaration file for the configuration table called by the target project.
[0017] Optionally, the writing module is specifically used to: if there is a reference relationship in the target field of the target configuration table, then sort out the reference relationship of the target field and determine the data referenced by the target field; write the declaration data determined based on the data referenced by the target field into the code declaration file corresponding to the target configuration table; wherein, the target configuration table is any one of the configuration tables called by the target project.
[0018] Optionally, the parsing module is specifically used to: traverse and parse the reference relationship between the tabs in each of the M configuration tables; traverse and parse the reference relationship between the configuration tables in the M configuration tables.
[0019] Optionally, the code declaration generation device also includes: an acquisition module and a download module; the acquisition module is used to obtain the directory of the configuration table called by the target project before the reading module reads the header information of each configuration table in the M configuration tables called by the target project; the download module is used to download the M configuration tables called by the target project according to the directory of the configuration table called by the target project obtained by the acquisition module.
[0020] Optionally, the code declaration generation device also includes: an update module; the update module is used to update the directory of the configuration table of the target project stored locally before the reading module reads the header information of each configuration table in the M configuration tables called by the target project; based on the updated directory of the configuration table of the target project, update the configuration table called by the target project stored locally.
[0021] Optionally, the code declaration generation device also includes: a detection module; the detection module is used to detect whether there is a changed configuration table in the configuration table called by the target project before the reading module reads the header information of each configuration table in the M configuration tables called by the target project; the reading module is specifically used to: if the detection module detects that there is a changed configuration table, then read the header information of the changed configuration table and the header information of the referenced configuration table in the configuration table called by the target project; the parsing module is specifically used to: if the detection module detects that there is a changed configuration table, then parse the changed reference relationship in the called configuration table.
[0022] Optionally, the code declaration generation device also includes: a detection module; the detection module is used to detect whether there is a target configuration file before the reading module reads the header information of each configuration table in the M configuration tables called by the target project, the target configuration file indicating the local storage location of the code declaration of the target project and the local storage location of the configuration table called by the target project; the reading module is specifically used to: if the detection module detects the existence of the target configuration file, then read the header information of each configuration table in the M configuration tables called by the target project based on the target configuration file.
[0023] Optionally, the code declaration generation device also includes: a prompt module, a generation module and a naming module; the prompt module is used to prompt the first local storage location of the code declaration file of the configuration table of the target project and the second local storage location of the configuration table called by the target project if the detection module detects that the target configuration file does not exist; the reading module is also used to read the table name information of each configuration table in the configuration table called by the target project based on the first storage location after configuring the first local storage location and the second local storage location; the generation module is used to generate the code declaration file corresponding to each configuration table in the second local storage location; the naming module is used to name the code declaration file corresponding to each configuration table according to the table name information of each configuration table.
[0024] Optionally, the code declaration generation device also includes: a compilation module and a prompt module; the compilation module is used to call the code declaration file of the target project after the generation module generates the code declaration file of the configuration table called by the target project, compile and run the code of the target project; the prompt module is used to prompt the error location of the code of the target project.
[0025] In a third aspect, an embodiment of the present disclosure provides an electronic device comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method for generating a code declaration of a configuration table as described in the first aspect.
[0026] In a fourth aspect, an embodiment of the present disclosure provides a readable storage medium storing a program or instruction, which, when executed by a processor, implements the steps of the method for generating a code declaration of a configuration table as described in the first aspect.
[0027] In a fifth aspect, an embodiment of the present disclosure provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method for generating a code declaration of the configuration table as described in the first aspect.
[0028] In a sixth aspect, an embodiment of the present disclosure provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the steps of the method for generating a code declaration of a configuration table as described in the first aspect.
[0029] In the embodiment of the present disclosure, first, a code declaration generating device can read the header information of each configuration table in the M configuration tables called by the target project; parse the reference relationship of the configuration tables of the M configuration tables; then, based on the reference relationship of the configuration tables, write the declaration data corresponding to the header information of each configuration table into the code declaration file corresponding to each configuration table; finally, save the code declaration file corresponding to each configuration table in the M configuration tables to the code declaration file directory of the target project to generate the code declaration file of the configuration table called by the target project. That is, the header information and reference relationship can be automatically read according to the configuration table called by the code, and the declaration data can be determined according to the header information and reference relationship, and the determined declaration data can be automatically written into the corresponding code declaration file. The code declaration can be automatically updated as the configuration table is updated, without the need for manual modification of the code declaration file. The problem of the code declaration file not being modified in time due to the developer's failure to notify the programmer in time during the modification process of the code declaration can be avoided, and the problem of inaccurate or omitted code declaration modification caused by manual modification by the programmer can be avoided. The accuracy and efficiency of the code declaration modification are improved, and the probability of error reporting during the runtime due to inaccurate program modification caused by inaccurate code declaration is reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 A flowchart of a method for generating a code declaration of a configuration table provided in an embodiment of the present disclosure;
[0031] Figure 2A configuration table part content schematic diagram provided by the embodiment of the present disclosure;
[0032] Figure 3 A configuration table code declaration schematic diagram provided by the embodiment of the present disclosure;
[0033] Figure 4 A multi-segment program calls the same code declaration file schematic diagram provided by the embodiment of the present disclosure;
[0034] Figure 5 A prompt configuration target configuration file schematic diagram provided by the embodiment of the present disclosure;
[0035] Figure 6 A storage location configuration schematic diagram provided by the embodiment of the present disclosure;
[0036] Figure 7 A configuration table code declaration tool processing logic schematic diagram provided by the embodiment of the present disclosure;
[0037] Figure 8 A code declaration generation device possible structure schematic diagram provided by the embodiment of the present disclosure;
[0038] Figure 9 An electronic device possible structure schematic diagram provided by the embodiment of the present disclosure;
[0039] Figure 10 A hardware schematic diagram of an electronic device provided by the embodiment of the present disclosure. DETAILED DESCRIPTION
[0040] First, the explanation of the related technical terms involved in this patent application is introduced.
[0041] 1, code declaration
[0042] When writing code, programmers can create variables and constants in the code, and statements that identify variable names, variable types, constants, and constant values, to indicate the names and types of variables, constants, and constant values to the program table.
[0043] 2, variable and constant
[0044] A variable is a storage area in memory, which has its own name and data type, and the data in this area can change continuously within the same data type range. Each variable needs to be declared before use.
[0045] A constant is a special variable, the value of which is set and cannot be changed during program execution.
[0046] 3, data type
[0047] Data types can include: basic data types and reference data types.
[0048] Reference data types include classes, interfaces, and arrays. Basic data types include Boolean, character, and numeric types. Numeric types include integer types (byte, short, int, long) and floating-point types (float, double). Different memory sizes are allocated to different data types.
[0049] 4. ".bat" file
[0050] A .bat file is a batch file that automatically executes multiple commands in succession. In DOS and Windows systems, a .bat file is an executable file consisting of a series of commands, including calls to other programs. Each line of a .bat file can be a DOS command. Batch files can be created and modified using a text file editing tool.
[0051] 5. ".py" files
[0052] ".py" files are Python script files. Python is an object-oriented, interpreted computer programming language. Python has a wide range of applications, and this device primarily uses it as an automation tool.
[0053] The following will clearly and completely describe the technical solutions in the embodiments of the present disclosure in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present disclosure without making any creative efforts shall fall within the scope of protection of the present disclosure.
[0054] The terms "first", "second", etc. in the specification and claims of the present disclosure are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present disclosure can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects related to each other are in an "or" relationship.
[0055] The method for generating a code declaration of a configuration table provided by the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings through specific embodiments and application scenarios.
[0056] Figure 1 A flow chart of a method for generating a code declaration of a configuration table provided in an embodiment of the present disclosure is shown as follows: Figure 1 As shown in , the method may include the following S101 to S104:
[0057] S101. A code declaration generating device reads header information of each configuration table in M configuration tables called by a target project.
[0058] Wherein, M is a positive integer.
[0059] In the embodiment of the present disclosure, the target project may correspond to any code file that can call a configuration table.
[0060] Typically, in a large project, the project code may call dozens or even hundreds of configuration tables.
[0061] For example, taking the target project as a large-scale game project, in the game project, a building information configuration table, a reward configuration table, a prop configuration table, etc. can be called in different game scenes.
[0062] For example, the storage location of a configuration table called by a target project can be obtained first, and then the header information of each configuration table under the storage location can be read in sequence. Alternatively, the configuration table directory of the configuration table called by a target project can be obtained, and then the header information of each configuration table in the configuration table directory can be read in sequence.
[0063] Typically, the header information of a configuration table may include: variable name, variable data type, constant name, and constant value.
[0064] For example, Figure 2 A schematic diagram of part of the contents of a configuration table provided in an embodiment of the present disclosure, from Figure 2 As can be seen, the information in rectangular box 21 is the table header information, which may include field descriptions, field names, data types, etc. The data in rectangular box 22 is the variable field "name" and the data type "str" of the field "name", and the data in rectangular box 23 is the table name information "BuildingProto" of the data table.
[0065] It should be noted that, in the embodiment of the present disclosure, the device for generating the code declaration generates a code declaration file of the configuration table according to the configuration table called by the target project.
[0066] Optionally, the code of the target project may be a completed code or an uncompleted code, which is not specifically limited in the embodiments of the present disclosure.
[0067] Illustratively, when a preset condition is met, S101 in the above method may be executed.
[0068] For example, the preset condition can be any one of the following: detecting that the configuration table called by the target project is updated, detecting an update operation instruction of the code declaration triggered by the programmer, detecting that the time point is the time point of periodic detection, and detecting that the user manually calls the code declaration generation device to execute the code declaration generation instruction for the target project.
[0069] Among them, updating the configuration table called by the target project may include: adding, deleting, replacing, renaming the configuration table and modifying the content of the configuration table; modifying the content of the configuration table may include adding, deleting and modifying the data in the configuration table.
[0070] S102: The code declaration generating device parses the reference relationship between the configuration tables in the M configuration tables.
[0071] The reference relationship of the configuration table may include: the reference relationship between configuration tables and the reference relationship between various tabs in the configuration table.
[0072] Exemplarily, after parsing, a calling relationship can be obtained in which the first field in the first configuration table calls the second field in the second configuration table. The first configuration table and the second configuration table are any two configuration tables among the above M configuration tables.
[0073] It should be noted that in this scenario, the execution order of the above-mentioned S101 and S102 is not limited. The device for generating the code declaration can first parse the reference relationship or obtain the header information. The embodiment of the present disclosure does not make specific limitations on this.
[0074] S103. The code declaration generating device writes the declaration data corresponding to the header information of each configuration table into the code declaration file corresponding to each configuration table based on the reference relationship of the configuration tables.
[0075] For example, a code declaration file may include a variable declaration file, a constant declaration file, and a table name enumeration file. The data declared in the variable declaration file includes the variable name and data type; the data declared in the constant declaration file includes the constant name and constant value; and the table name enumeration file declares the table name information for each configuration table.
[0076] It should be noted that the code declaration generating device writes the declaration information in the table name enumeration file according to the table name information of each configuration table.
[0077] In the embodiments of the present disclosure, the code declaration generation apparatus can read different declaration information (field name and field value) according to different configuration tables and write the information into corresponding code declaration files.
[0078] It should be noted that the configuration table data can be read by a client (for example, the project client uses the TypeScript language) or a server (for example, the project server uses the Python language). Therefore, the code declaration generation apparatus can convert the field name and field type data in the table header information into a string in a specified format according to the language requirement and write the string into the code declaration file.
[0079] For example, Figure 2 The configuration table data of max_level in the middle rectangle 24 is of the type int, and the code declaration generation apparatus can automatically convert the data type to the data type number in the code. The data type corresponding to max_level in the finally generated code declaration file is number. Other data types are similar, for example, the code declaration generation apparatus can automatically convert the data type of the name field from str to string.
[0080] For example, in the case of code written in the TypeScript language, the above-mentioned conversion format is to convert the data type of the configuration table to the data type supported by the TypeScript language. Different programming languages have different data type writing methods, and the data type in the configuration table can be automatically converted according to the requirement.
[0081] Optionally, the configuration table named according to the preset rule can be a configuration table for reading the table header information and the field information, and the configuration table not named according to the preset rule can be a configuration table for reading the table header information. Alternatively, the configuration table carrying the target identifier can be a configuration table for reading the table header information, and the configuration table not carrying the target identifier can be a configuration table for reading the table header information and the field information. The embodiments of the present disclosure do not make specific limitations in this regard.
[0082] Specifically, if a configuration table is a variable configuration table, the code declaration file corresponding to the configuration table is a code declaration file for writing variable declaration; if a configuration table is a constant configuration table, the code declaration file corresponding to the configuration table is a code declaration file for writing constant declaration.
[0083] For example, the configuration table used for extracting constants can be configured to carry a target identifier in advance. The code declaration generation apparatus can determine the type of the configuration table. If the configuration table does not carry the target identifier, the code declaration generation apparatus can read the table header information to obtain the variable name and the data type of the variable. If the configuration table carries the target identifier, the code declaration generation apparatus can read the table header information and obtain the constant name and the constant value of the constant.
[0084] Exemplarily, the code declaration generating device may traverse the header information of each configuration table, obtain corresponding declaration data, automatically convert the corresponding declaration data into a string of a specified format, and then automatically write it into the code declaration file of each configuration table.
[0085] It should be noted that code declarations can be placed anywhere in the project code, and their placement can be adjusted adaptively based on the language used. For example, code declarations for C can be placed at the very beginning of the code, while code declarations for TypeScript can be placed anywhere in the code and can even be stored as a separate file from the project code.
[0086] In the embodiment of the present disclosure, generating or updating a code declaration file independent of the project code is taken as an example for explanation. When the project code is running, the code declaration file can be called and the configuration table corresponding to the code declaration file can be read.
[0087] It should be noted that, in the case where the code declaration is written into the code text of the project, the code declaration of the configuration table written into the code text may include variable declarations and constant declarations.
[0088] S104. The code declaration generating device saves the code declaration file corresponding to each of the M configuration tables to the code declaration file directory of the target project to generate a code declaration file for the configuration table called by the target project.
[0089] It should be noted that in the embodiment of the present disclosure, the method for generating the code declaration of the above-mentioned configuration table can automatically generate a code declaration file corresponding to the configuration table for the target project, or can update the code declaration file corresponding to the configuration table for the target project. The embodiment of the present disclosure does not make specific limitations on this.
[0090] It can be understood that if the code declaration generating device writes the declaration data of each configuration table into the code declaration file and saves it in the code declaration file directory, it can be said that the code declaration generating device has generated the code declaration file of the configuration table called by the target project.
[0091] For example, a configuration table can correspond to a code declaration file, and a code declaration file can correspond to a code declaration interface class. A code declaration interface class file (corresponding to a configuration table's code declaration file) can correspond to an interface class (corresponding to a configuration table's code declaration), and to the data type contained in the interface class (corresponding to a configuration table's code declaration data). The code can call the configuration table's code declaration data by calling the interface class file's code declaration data.
[0092] For example, Figure 3A schematic diagram of a code declaration of a configuration table provided in an embodiment of the present disclosure, such as Figure 3 As shown in the figure, the rectangular box 31 represents the code declaration file SBuildingConf.ts interface class file corresponding to the configuration table SBuilding in the code declaration file target, and the rectangular box 32 represents the content of the code declaration file SBuildingConf.ts interface class file, wherein the content in the rectangular box 33 represents the code declaration SBuildingConf interface class for calling the configuration table SBuilding through the interface interface, and the content in the rectangular box 34 is the declaration data in the code declaration SBuildingConf interface class corresponding to the configuration table SBuilding, including variables and variable names.
[0093] In the embodiment of the present disclosure, one configuration table may correspond to a group of code declaration files, and the same group of code declaration files may be called by one segment of code or repeatedly called by multiple segments of code.
[0094] For example, the first configuration table corresponds to a first code declaration file, the first code declaration file corresponds to a first code declaration interface class, and multiple code segments in the project can call the first code declaration interface class.
[0095] Figure 4 A schematic diagram of a multi-segment program calling the same code declaration file provided in an embodiment of the present disclosure is shown as follows: Figure 4 As shown in FIG, the rectangular box 41 contains the code declaration of SBuilding, the SBuildingConf interface class, and the rectangular box 42 contains the calling code declaration, which contains multiple code segments that can be called by the SBuildingConf interface class.
[0096] Optionally, the code declaration file of the configuration table generated by the code declaration generating device may be stored remotely or locally, which is not specifically limited in the embodiment of the present disclosure.
[0097] It should be noted that, when the generated code declaration files are stored locally, the code declaration generating device may also upload the code declaration files of the M configuration tables of the target project that are finally generated or updated to a remote preset storage location.
[0098] An embodiment of the present disclosure provides a method for generating a code declaration of a configuration table. First, a code declaration generating device can read the header information of each configuration table in M configuration tables called by a target project; parse the reference relationship of the configuration tables of the M configuration tables; then, based on the reference relationship of the configuration tables, write the declaration data corresponding to the header information of each configuration table into a code declaration file corresponding to each configuration table; finally, save the code declaration file corresponding to each configuration table in the M configuration tables to the code declaration file directory of the target project to generate a code declaration file for the configuration table called by the target project. That is, it can automatically read the header information and parse the reference relationship according to the configuration table that the code needs to call, determine the declaration data according to the header information and the reference relationship, and automatically write the determined declaration data into the corresponding code declaration file. The code declaration can be automatically updated as the configuration table is updated, without the need to manually modify the code declaration file. This can avoid the problem of the code declaration file not being modified in time due to the developer's failure to notify the programmer in time during the code declaration modification process, and can also avoid the problems of inaccurate code declaration modification, omissions, etc. caused by manual modification by the programmer, thereby improving the accuracy and modification efficiency of the code declaration modification, and reducing the probability of errors reported during runtime due to inaccurate program modification caused by inaccurate code declaration.
[0099] Optionally, in the method for generating a code declaration of a configuration table provided in an embodiment of the present disclosure, the above S103 may be specifically performed by the following S13a to S13c:
[0100] S13a. If there is a reference relationship between the target fields in the target configuration table, the code declaration generating device arranges the reference relationship between the target fields.
[0101] For example, table 1 can reference table 2, table 1 can reference fields in table 2, and field 1 in table 1 can reference field 2 in table 2. The reference relationship after sorting is: the field in tab 1 of table 1 can reference the field in tab 2 of table 2.
[0102] It can be understood that the reference relationship of the configuration table after final arrangement is that a field of a configuration table references another field, and the original field and the referenced field can be fields in the same configuration table or fields in different configuration tables.
[0103] S13b. The code declaration generating device determines the data referenced by the target field according to the reference relationship after the target field is sorted.
[0104] In the embodiment of the present disclosure, the device for generating a code declaration can traverse all reference relationships of the target field and sort out the data ultimately referenced by the target field, thereby determining the declaration data actually corresponding to the target field.
[0105] For example, assuming that field 1 of table 1 references field 2 of table 2, and field 2 of table 2 references field 3 of table 3, it is determined that field 1 of table 1 ultimately references field 3 of table 3.
[0106] S13c. The code declaration generating device writes the declaration data determined according to the data referenced by the target field into the code declaration file corresponding to the target configuration table.
[0107] The target configuration table may be any configuration table in the configuration tables called by the target project, and the target field may be any field to be declared in the target configuration table.
[0108] Specifically, if a field ultimately references a variable, the referenced variable name and the variable's data type are written into the code declaration file as the field's declaration data; if a field references a constant, the referenced constant name and the constant's value are written into the code declaration file as the field's declaration data.
[0109] It should be noted that if a field in a table header does not reference other fields, the data type or specific value of the field shall be written into the code declaration file of the corresponding data table.
[0110] Based on this solution, the code declaration generation device can automatically parse the reference relationship. When a reference relationship exists in the target field, the reference relationship of the target field can be sorted out, the data ultimately referenced by the target field can be automatically determined, and the declaration data can be determined based on the data ultimately referenced by the target field. The declaration data can be automatically written into the code declaration file of the target configuration table. There is no need for programmers to manually search for reference relationships based on the modified configuration table, and there is no need to manually browse the code declaration file directory to find the corresponding code declaration file and modify it, which improves the efficiency of code declaration file modification.
[0111] Optionally, in the method for generating a code declaration of a configuration table provided in an embodiment of the present disclosure, the above-mentioned S102 may be specifically performed by the following S12a and S12b:
[0112] S12a. The code declaration generating device traverses and parses the M configuration tables called by the target project, and the reference relationship between the tabs in each configuration table.
[0113] For example, a field on the first tab in the first data sheet can also reference a field on the second tab in the first data sheet. In other words, you need to determine the reference relationship between individual configuration sheet tabs. For example, if field A actually references field B on another tab, you need to find the name and type of field B. This can be thought of as finding the name and type of the referenced field. Because field A references field B, the contents of field B should be read, not the contents of field A.
[0114] S12b. The code declaration generating device traverses and parses the reference relationships between the M configuration tables called by the target project.
[0115] For example, a field in the first data table can call a field in the second data table, that is, find the reference relationship (name and type of the referenced field) between all configuration tables.
[0116] Based on this solution, the code declaration generation device can automatically traverse and parse the various reference relationships of the M configuration tables called by the target project, so that the field name and field type that need to be declared for each field, or the field name and field value that need to be declared can be accurately determined based on the reference relationships of each field obtained by the analysis, avoiding omissions or reference relationship organization errors caused by manual organization of reference relationships.
[0117] Optionally, in the method for generating a code declaration of a configuration table provided in an embodiment of the present disclosure, before the above-mentioned S101, the following S105 and S106 may be further included:
[0118] S105. The code declaration generating device obtains a directory of the configuration table called by the target project.
[0119] Optionally, the configuration table called by the target project may be stored in a local device where the device for generating the code declaration is located, or in a remote device, which is not specifically limited in the embodiment of the present disclosure.
[0120] S106. The code declaration generating device downloads M configuration tables called by the target project according to the directory of the configuration tables called by the target project.
[0121] In a possible example, the device for generating the code declaration may first obtain the directory of the configuration table called by the target project from the remote end according to the project selected for generating the code file, and download the latest configuration table called by the target project from the remote end.
[0122] It should be noted that after the code declaration file of the configuration table of the target project is generated, the code declaration file can be uploaded to the server, so that the code declaration file called by the code of the remote target project can be kept as the latest code declaration file.
[0123] It should be noted that, in this solution, the local device where the code declaration generating apparatus is located may store the configuration table of the target project, or may not store the configuration table of the target project, and this embodiment of the present disclosure does not specifically limit this.
[0124] Based on this solution, after the R&D personnel updates the configuration table, the code declaration generation device can obtain the configuration table directory after the updated configuration table called by the target project, and then download all the configuration tables newly called by the target project, and then read the header information of each updated configuration table, parse the reference relationship of each updated configuration table, and then based on the reference relationship of the updated configuration table, and the declaration data corresponding to the header information of each updated configuration table, rewrite the code declaration file corresponding to each configuration table, so that the generated code declaration file is a code declaration file that matches the latest configuration table of the target project.
[0125] Optionally, if a configuration table called by the target project is stored in the local device where the code declaration generating apparatus is located, the method for generating a code declaration of the configuration table provided in the embodiment of the present disclosure may further include the following S107 and S108 before the above S101:
[0126] S107: The code declaration generating device updates the directory of the configuration table of the target project stored locally.
[0127] The directory of the configuration table includes the version information of the configuration table and the name of the configuration table.
[0128] It should be noted that if the method for generating the code declaration of the configuration table provided by the embodiment of the present disclosure is not executed locally for the target project for the first time, the code declaration generating device may automatically update the directory of the configuration table before updating the code declaration of the configuration table of the target project.
[0129] S108. The code declaration generating device updates the locally stored calling configuration table of the target project based on the updated directory of the configuration table of the target project.
[0130] Exemplarily, if the updated configuration table directory indicates that the first configuration table has been updated compared to the local configuration table, the first configuration table can be downloaded again; if the updated configuration table directory indicates that the first configuration table is a new configuration table compared to the local configuration table, the first configuration table can be downloaded; if the updated configuration table directory indicates that the local first configuration table has been deleted, the locally stored first configuration table is deleted.
[0131] Based on this solution, after the configuration table is updated, the code declaration generation device can first update the configuration table directory of the locally stored target project; then update the locally stored configuration table based on the updated directory; finally, based on the updated locally stored configuration table, update the code declaration file of the configuration table of the target project, so that the generated code declaration file is a code declaration file that matches the latest configuration table of the target project.
[0132] Optionally, the method for generating a code declaration of a configuration table provided in an embodiment of the present disclosure may further include the following step S109 before the above-mentioned step S101:
[0133] S109. The code declaration generating device detects the configuration table called by the target project to see if there is a changed configuration table.
[0134] Exemplarily, whether each configuration table has been changed may be determined based on the version number, upload timestamp, md5 value (Message Digest Algorithm 5, Message Digest Algorithm Version 5) and the like of each configuration table.
[0135] It can be understood that the change of the configuration table may include modification of the configuration table, deletion of the configuration table, and addition of the configuration table.
[0136] Furthermore, the above-mentioned S101 can be executed by the following S11a, and the above-mentioned S102 can be executed by the following S12c:
[0137] S11a. If there is a changed configuration table, the code declaration generating device reads the header information of the changed configuration table and the header information of the configuration table referenced by the changed configuration table in the configuration table called by the target project.
[0138] S12c. If there is a changed configuration table, the code declaration generating device parses the changed reference relationship in the configuration table called by the target project.
[0139] Specifically, in the embodiment of the present disclosure, the above-mentioned S12c may be executed before S11a.
[0140] It should be noted that, in the embodiment of the present disclosure, the changed reference relationship includes: a reference relationship referencing the changed configuration table, and a reference relationship of a configuration table referenced by the changed configuration table.
[0141] Furthermore, the code declaration generation device regenerates the code declaration file corresponding to the changed configuration table and the code declaration file of the configuration table that references the changed configuration table based on the header information of each changed configuration table, the header information of the configuration table that references each changed configuration table, and the changed reference relationship.
[0142] For example, Table 1-2 is the updated configuration table of Table 1-1. First, determine the reference relationship 1 of Table 2-1 referenced by the updated configuration Table 1-2. Then obtain the header information 1 of Table 1-2 and the header information 2 of Table 2 that references Table 1-2. Update the code declaration files corresponding to Table 1-2 and Table 2 according to the reference relationship 1, header information 1, and header information 2.
[0143] Based on this solution, another method for updating the code declaration of the configuration table can be provided. The code declaration generation device can, after starting to run, first detect the configuration table called by the target project to see whether there is an updated configuration table. If there is an updated configuration table, the code declaration generation device can parse the changed reference relationship, read the header information of the changed configuration table and the header information of the configuration table that references the changed configuration table; then, based on the changed reference relationship, determine the code declaration data in the header information of the changed configuration table and the configuration table that references the changed configuration table, update the code declaration file corresponding to the changed configuration table and the code declaration file corresponding to the configuration table that references the changed configuration table. Compared with the method of regenerating the code declaration files of all configuration tables during the update, the update speed is faster.
[0144] Optionally, in the method for generating a code declaration of a configuration table provided in an embodiment of the present disclosure, before executing the above-mentioned S101, the following S110 and S11b may be further included, or the following S110, and S111 to S113 may be included:
[0145] S110 , the code declaration generating device detects whether there is a local storage path of the target code declaration file.
[0146] The target code declaration file is a code declaration file corresponding to the configuration table called by the target project.
[0147] S11b. If there is a local storage path for the target code declaration file, the code declaration generating device reads the header information of each configuration table in the configuration table called by the target project.
[0148] Specifically, in an embodiment of the present disclosure, when executing the method, the code declaration generating device may first determine whether there is a storage path of the code declaration file of the configuration table corresponding to the target project locally. If so, it may indicate that the code declaration generating device is not executing the code generation method of the configuration table locally for the first time, and may read the configuration table called by the target project to generate the corresponding code declaration file. If the storage path of the code declaration file does not exist, it indicates that this is the first time that the user-triggered code declaration generating device has generated the code declaration of the configuration table locally, and the following S111 to S113 may be executed.
[0149] S111. If the local storage path of the target code declaration does not exist, the code declaration generating device prompts the local storage location of the code declaration file of the configuration table called by the configuration target project.
[0150] Exemplarily, the device for generating the code declaration may display an interface in which the user is prompted to configure a local storage location for the code declaration.
[0151] It should be noted that in the scheme, whether the local includes the storage location of the configuration table is not limited, the configuration table can be stored in the local, or can be automatically obtained or downloaded from the remote to the local according to the selected project according to the user demand, and the embodiment of the present disclosure does not make specific limitation.
[0152] In S112, after inputting the local storage location, the code declaration generation device reads the table name information of each configuration table in the configuration table called by the target project.
[0153] In S113, the code declaration generation device names the code declaration file corresponding to each configuration table according to the table name information of each configuration table.
[0154] Exemplarily, the table name information can be “***Proto”, and the name of the corresponding code declaration file can correspond to “S***Conf”.
[0155] It can be understood that based on the table name information of the configuration table, the code declaration file corresponding to the configuration table can be automatically named, so that the code declaration file and the corresponding configuration table can be mapped, so that the program can quickly query the corresponding configuration table based on the naming of the code declaration file when calling the code declaration file, and the efficiency of calling the configuration table by the code can be improved, and the running of the code is accelerated.
[0156] Based on the scheme, whether it is the first execution can be determined based on whether the local storage location of the code declaration file of the configuration table exists, if it is the first execution, the local storage location of the code declaration file is prompted, then the table header information of the configuration table called by the target project is read, the code declaration file corresponding to each configuration table is named based on the table header information of each configuration table, then the declaration data obtained is written into the corresponding declaration file, so that the code declaration file of each configuration table called by the target project is generated.
[0157] Optionally, the code declaration generation method of the configuration table provided by the embodiment of the present disclosure can further include S114 and S11c before S101 described above, or can further include S114 and S115 to S117.
[0158] In S114, the code declaration generation device detects whether the target configuration file exists.
[0159] The target configuration file indicates the local storage location of the code declaration of the target project and the local storage location of the configuration table called by the target project.
[0160] It can be understood that different programmer users can store the configuration table and generated code declaration file of the same project in different local storage locations. For example, programmer A stores the configuration table and code declaration file of project 1 in the D disk of device A, and programmer B stores the configuration table and code declaration file of project 1 in the F disk of device B. After generating the code declaration file, the local code declaration file can be uploaded to the remote end, so that other programmer users can obtain the latest code declaration file through the remote end, avoiding code errors caused by different programmer users updating the code declaration file, which leads to other programmers not calling the latest code declaration file during runtime.
[0161] S11c. If the target configuration file exists, the code declaration generating device reads the header information of each configuration table in the M configuration tables called by the target project based on the target configuration file.
[0162] For example, the target configuration file can be named conf.config file, and the code declaration generation device can first detect whether the conf.config file exists locally. If the conf.config file exists locally, the configuration table called can be parsed based on the storage address configured in the conf.config file, the header information of each configuration table and the reference relationship between the configuration tables can be obtained, and the code declaration file can be generated.
[0163] S115. If the target configuration file does not exist, the code declaration generating device prompts the first local storage location of the code declaration file that configures the configuration table of the target project and the second local storage location of the configuration table called by the target project.
[0164] It can be understood that if the code declaration generation device does not detect the target configuration file, it may indicate that the data for executing the method and the storage location of the output data after executing the method are not configured locally, that is, this is the first time that the code declaration generation method of the configuration table provided in the embodiment of the present disclosure is executed.
[0165] For example, when generating a code declaration file, the code declaration generation device can generate the code declaration file by parsing the locally stored configuration table (when the configuration table is updated, the locally stored configuration table is updated), or downloading the remote configuration table to the local and then parsing and generating the code declaration file (when the configuration table is updated, it can be downloaded again to the local). Therefore, when a project executes the code declaration generation method for the configuration table for the first time, it can detect whether there is a local storage location for the configuration table and whether there is a local storage location for the code declaration file. If at least one does not exist, the user can be prompted to configure the storage location.
[0166] For example, Figure 5This is a schematic diagram of a prompt configuration target configuration file provided by the embodiment of the present disclosure. When a project runs the method for the first time, if the code declaration generating device cannot find the target configuration file, it can be displayed on the display interface. Figure 5 The prompt message shown tells the user that "The system cannot find the file conf.config. One file has been copied. Please configure conf.config and try again." Figure 6 A schematic diagram of a storage location configuration provided by an embodiment of the present disclosure. A user can select the storage path of the configuration table called by a project and the storage path of the code declaration file generated for the configuration table called by the project.
[0167] S116. After configuring the first local storage location and the second local storage location, the code declaration generating device reads the table name information of each configuration table in the configuration table called by the target project based on the first storage location.
[0168] S117. The code declaration generating device generates a code declaration file corresponding to each configuration table in the second local storage location, and names the code declaration file corresponding to each configuration table according to the table name information of each configuration table.
[0169] It should be noted that when updating a code declaration file, if it is determined that a new configuration table has been added, the code declaration generation device can automatically create a new code declaration file and name the corresponding code declaration file with the table name information of the newly added configuration table. Similarly, when updating a code declaration file, if it is determined that an old configuration table has been deleted, the code declaration generation device can delete the original code declaration file corresponding to the configuration table.
[0170] Based on this solution, it is possible to determine whether it is the first time that a code declaration file for a configuration table is generated by detecting whether a target configuration file exists. When the method for generating a code declaration for a configuration table provided by an embodiment of the present disclosure is executed for the first time, a prompt may be provided to configure the target configuration file, that is, to configure the storage path of the configuration table used to generate the declaration file, and the storage path of the generated code declaration file. After the storage path configuration is completed, the table name information of the configuration table in the first storage location may be automatically read, and the code declaration files corresponding to each configuration table may be automatically generated in the second storage location, and named with the table name information of each configuration, so as to quickly establish a mapping relationship between the configuration table and the code declaration file.
[0171] Optionally, in the method for generating a code declaration of a configuration table provided in an embodiment of the present disclosure, after the above-mentioned S104, the following S118 and S119 may be further included:
[0172] S118. After generating the code declaration file of the configuration table called by the target project, the code declaration generating device calls the code declaration file of the target project, compiles and runs the code of the target project.
[0173] For example, after determining that a code declaration file for each configuration table has been generated, or after updating the code declaration file associated with the changed configuration table, the code declaration generation device can determine that the code declaration file for the target project has been generated. The code declaration generation device then automatically compiles and runs the target project's code based on the generated code declaration file, thereby determining whether any errors are reported.
[0174] S119. The code declaration generating device prompts the error location of the target project code.
[0175] For example, if the field "name" in the code declaration file generated based on the configuration table is modified to "name2", when the code is compiled, an error is reported after calling the value of the "name" field, indicating that the "name" field in the code segment has changed.
[0176] It is understandable that if the configuration table called by a project has changed, the code may not be able to find the corresponding field value when calling the fields in the original configuration table, which will cause the program to fail to run correctly. Therefore, displaying the location of the code based on the configuration table called by the program can help programmers quickly determine the location to be modified and modify the fields and field values in the code text in a timely manner.
[0177] Based on this solution, after generating or updating the code declaration file of the configuration table, the code declaration generation device can automatically compile and run the code of the target project, and then based on the generated or updated code declaration file, prompt the location of the error in the code of the target project, so that the program can quickly find the corresponding modification location for adjustment. Since the code declaration file is generated or updated based on the latest configuration table, the code declaration file can accurately represent the changes in the configuration table. Therefore, compiling and running the code based on the code declaration file can improve the accuracy of the error location display, shorten the time to modify the code, and improve the efficiency of code updates.
[0178] Example:
[0179] In an embodiment of the present disclosure, the aforementioned method for generating a configuration table code declaration can be integrated into a one-click configuration table code declaration tool. After parameterizing the configuration table code declaration tool, a script can be configured and executed with one click to generate a configuration table declaration file. For example, the configuration table code declaration tool can include two executable files: the GenConfInterface.bat file and the gen_conf_interface.py file. Figure 7 This figure shows the processing logic of a configuration table code declaration tool. The processing phase of the configuration table code declaration tool can include four processing stages: tool initialization phase, configuration table parsing phase, data conversion phase, and file saving phase. The tool initialization phase and configuration table parsing phase can be implemented by the GenConfInterface.bat file in the configuration table code declaration tool, and the data conversion phase and file saving phase can be implemented by the gen_conf_interface.py file in the configuration table code declaration tool.
[0180] (1) Tool initialization phase
[0181] When the user clicks to run the configuration table code declaration tool, the configuration table code declaration tool supports automatically entering the script directory to update the script file of the tool, thereby ensuring that the script file of the tool is the latest script file.
[0182] The configuration table code declares that the tool retrieves and automatically generates the conf.config file for configuring the tool parameters for the first time.
[0183] For example, configuration tool parameters may include: selecting a target project, selecting a configuration table, and selecting a storage location for a code declaration file.
[0184] It should be noted that if the configuration table code declaration tool is built into the project, when configuring the parameters of the configuration table code declaration tool for the first time, you can only select the folder where the configuration table is located and the storage location of the generated code declaration.
[0185] After configuring the configuration table code declaration tool parameters, it automatically updates all configuration tables in the project according to the configuration table directory, so that the configuration tables used in the generated code declaration files are the latest updated configuration tables. The tool can also automatically update scripts.
[0186] (2) Configuration table parsing stage
[0187] The configuration table code declaration tool can automatically read configuration tables, that is, automatically traverse and read all configuration table references according to the configuration table directory. For example, it traverses and resolves the references between the tabs of a single configuration table, and traverses and resolves the references between all configuration tables. It also obtains the table name and header information of each configuration table.
[0188] (3) Data conversion stage
[0189] The configuration table code declaration tool can convert the parsed data into text data required for code declaration and write the text data into a code declaration file.
[0190] When generating a code declaration file, name the table name information as the file name of the code declaration file, and write the table header information into the code declaration file.
[0191] Specifically, it can automatically generate the variable declaration interface file S[ConfName]Conf.ts and automatically configure the variable declaration with table header information. It can also automatically generate the constant declaration interface file SConstValConf.ts and write the table header and field information into the code declaration file. It can also automatically generate the table name enumeration interface file GConfName.ts to declare each table name, making it easier for the code to load the configuration table file based on the table name.
[0192] (4) File preservation stage
[0193] The configuration table code declaration tool can save the generated code declaration file to a code declaration file storage location.
[0194] It should be noted that the processing flow of the above-mentioned integrated tool is only described by taking the example of regenerating the code declaration files of all configuration tables each time, and the processing flow of the integrated tool corresponding to other implementations of the above-mentioned embodiment will not be repeated.
[0195] It should be noted that the method for generating a code declaration for a configuration table provided in the embodiments of the present disclosure can be executed by a device for generating a code declaration, or by a control module within the device for generating a code declaration for executing the method for generating a code declaration for a configuration table. In the embodiments of the present disclosure, the method for generating a code declaration for a configuration table performed by the device for generating a code declaration for a configuration table is used as an example to illustrate the device for generating a code declaration provided in the embodiments of the present disclosure.
[0196] Figure 8 A possible structural diagram of a device for generating a code declaration provided in an embodiment of the present disclosure is shown in FIG. Figure 8As shown in , the code declaration generation device 800 includes: a reading module 801, a parsing module 802, a writing module 803 and a saving module 804; the reading module 801 is used to read the header information of each configuration table in the M configuration tables called by the target project, where M is a positive integer; the parsing module 802 is used to parse the reference relationship of the configuration tables in the M configuration tables; the writing module 803 is used to write the declaration data corresponding to the header information of each configuration table read by the reading module 801 into the code declaration file corresponding to each configuration table based on the reference relationship of the configuration tables parsed by the parsing module 802; the saving module 804 is used to save the code declaration file corresponding to each configuration table in the M configuration tables to the code declaration file directory of the target project to generate the code declaration file of the configuration table called by the target project.
[0197] Optionally, the writing module is specifically used to: if there is a reference relationship in the target field of the target configuration table, then sort out the reference relationship of the target field and determine the data referenced by the target field; write the declaration data determined based on the data referenced by the target field into the code declaration file corresponding to the target configuration table; wherein, the target configuration table is any one of the configuration tables called by the target project.
[0198] Optionally, the parsing module is specifically used to: traverse and parse the reference relationship between the tabs in each of the M configuration tables; traverse and parse the reference relationship between the configuration tables in the M configuration tables.
[0199] Optionally, the code declaration generation device also includes: an acquisition module and a download module; the acquisition module is used to obtain the directory of the configuration table called by the target project before the reading module reads the header information of each configuration table in the M configuration tables called by the target project; the download module is used to download the M configuration tables called by the target project according to the directory of the configuration table called by the target project obtained by the acquisition module.
[0200] Optionally, the code declaration generation device also includes: an update module; the update module is used to update the directory of the configuration table of the target project stored locally before the reading module reads the header information of each configuration table in the M configuration tables called by the target project; based on the updated directory of the configuration table of the target project, update the configuration table called by the target project stored locally.
[0201] Optionally, the code declaration generation apparatus further comprises a detection module; the detection module is configured to detect, before the table header information of each configuration table in the M configuration tables called by the target project, whether there is a changed configuration table in the configuration tables called by the target project; the reading module is specifically configured to read the table header information of the changed configuration table and the table header information referring to the changed configuration table in the configuration tables called by the target project if the detection module detects that there is a changed configuration table; and the analysis module is specifically configured to analyze the changed reference relationship in the called configuration table if the detection module detects that there is a changed configuration table.
[0202] Optionally, the code declaration generation apparatus further comprises a detection module; the detection module is configured to detect, before the table header information of each configuration table in the M configuration tables called by the target project, whether there is a changed configuration table in the configuration tables called by the target project; the reading module is specifically configured to read the table header information of the changed configuration table and the table header information referring to the changed configuration table in the configuration tables called by the target project if the detection module detects that there is a changed configuration table; and the analysis module is specifically configured to analyze the changed reference relationship in the called configuration table if the detection module detects that there is a changed configuration table.
[0203] Optionally, the code declaration generation apparatus further comprises a prompting module, a generation module and a naming module; the prompting module is configured to prompt to configure the first local storage position of the code declaration file of the configuration table of the target project and the second local storage position of the configuration table called by the target project if the detection module detects that there is no target configuration file; the reading module is further configured to read the table name information of each configuration table in the configuration tables called by the target project based on the first storage position after the first local storage position and the second local storage position are configured; the generation module is configured to generate the code declaration file corresponding to each configuration table in the second local storage position; and the naming module is configured to name the code declaration file corresponding to each configuration table according to the table name information of each configuration table.
[0204] Optionally, the code declaration generation apparatus further comprises a compilation module and a prompting module; the compilation module is configured to compile and run the code of the target project after the generation module generates the code declaration file of the configuration table called by the target project; and the prompting module is configured to prompt the error position of the code of the target project.
[0205] The disclosed embodiment provides a device for generating a code declaration. First, the device can read the header information of each configuration table in M configuration tables called by a target project; parse the reference relationship of the configuration tables of the M configuration tables; then, based on the reference relationship of the configuration tables, write the declaration data corresponding to the header information of each configuration table into the code declaration file corresponding to each configuration table; finally, save the code declaration file corresponding to each configuration table in the M configuration tables to the code declaration file directory of the target project to generate a code declaration file for the configuration table called by the target project. That is, the device can automatically read the header information and parse the reference relationship according to the configuration table called by the code, determine the declaration data according to the header information and the reference relationship, and automatically write the determined declaration data into the corresponding code declaration file. The device can automatically update the code declaration along with the update of the configuration table, without the need to manually modify the code declaration file. The device can avoid the problem of the code declaration file not being modified in time due to the developer's failure to notify the programmer in time during the modification process of the code declaration, and can also avoid the problem of inaccurate or omitted code declaration modification caused by the programmer's manual modification. The device improves the accuracy and efficiency of code declaration modification and reduces the probability of error reporting during runtime due to inaccurate program modification caused by inaccurate code declaration.
[0206] The device for generating the code declaration in the embodiment of the present disclosure may be a device, or a component, integrated circuit, or chip in a terminal. The device for generating the code declaration may be a mobile electronic device or a non-mobile electronic device. For example, the mobile electronic device may be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, a UMPC (ultra-mobile personal computer), a netbook, or a PDA (personal digital assistant), etc. The non-mobile electronic device may be a server, a NAS (Network Attached Storage), a PC (personal computer), a TV (television), an ATM, or an kiosks, etc., which are not specifically limited in the embodiment of the present disclosure.
[0207] The code declaration generation device provided by the embodiment of the present disclosure can achieve Figures 1 to 7 To avoid repetition, the various processes implemented in the method embodiment are not described here.
[0208] Alternatively, as Figure 9As shown, the embodiment of the present disclosure also provides an electronic device 900, including a processor 901, a memory 902, and a program or instruction stored in the memory 902 and executable on the processor 901. When the program or instruction is executed by the processor 901, each process of the embodiment of the method for generating the code declaration of the above-mentioned configuration table is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0209] It should be noted that the electronic devices in the embodiments of the present disclosure include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0210] Figure 10 A schematic diagram of the hardware structure of an electronic device implementing an embodiment of the present disclosure.
[0211] The electronic device 1000 includes but is not limited to components such as a radio frequency unit 1001 , a network module 1002 , an audio output unit 1003 , an input unit 1004 , a sensor 1005 , a display unit 1006 , a user input unit 1007 , an interface unit 1008 , a memory 1009 , and a processor 1010 .
[0212] Those skilled in the art will understand that the electronic device 1000 may also include a power source (such as a battery) to power each component, and the power source may be logically connected to the processor 1010 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system. Figure 10 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be repeated here.
[0213] The disclosed embodiment provides an electronic device, which first reads the header information of each configuration table in M configuration tables called by a target project; parses the reference relationship of the configuration tables in the M configuration tables; then, based on the reference relationship of the configuration tables, writes the declaration data corresponding to the header information of each configuration table into the code declaration file corresponding to each configuration table; and finally, saves the code declaration file corresponding to each configuration table in the M configuration tables to the code declaration file directory of the target project to generate the code declaration file of the configuration table called by the target project. That is, the electronic device can automatically read the header information and parse the reference relationship according to the configuration table called by the code, determine the declaration data according to the header information and the reference relationship, and automatically write the determined declaration data into the corresponding code declaration file. The code declaration can be automatically updated as the configuration table is updated, without the need for manual modification of the code declaration file. The problem of the code declaration file not being modified in time due to the developer's failure to notify the programmer in time during the modification of the code declaration can be avoided, and the problem of inaccurate or omitted code declaration modification caused by manual modification by the programmer can be avoided. The accuracy and efficiency of the code declaration modification are improved, and the probability of error reporting during the runtime due to inaccurate program modification caused by inaccurate code declaration is reduced.
[0214] It should be understood that in the embodiment of the present disclosure, the input unit 1004 may include a GPU (Graphics Processing Unit) 1041 and a microphone 1042, and the graphics processor 1041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 1006 may include a display panel 1061, and the display panel 1061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1007 includes a touch panel 1071 and other input devices 1072. The touch panel 1071 is also called a touch screen. The touch panel 1071 may include two parts: a touch detection device and a touch controller. Other input devices 1072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and an operating stick, which will not be repeated here. The memory 1009 can be used to store software programs and various data, including but not limited to applications and operating systems. The processor 1010 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understood that the modem processor may not be integrated into the processor 1010.
[0215] The embodiment of the present disclosure also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the embodiment of the method for generating the code declaration of the above-mentioned configuration table is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0216] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer-readable storage medium, such as a computer ROM (Read-Only Memory), RAM (Random Access Memory), a magnetic disk, or an optical disk.
[0217] An embodiment of the present disclosure further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the embodiment of the method for generating the code declaration of the above-mentioned configuration table, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0218] It should be understood that the chip mentioned in the embodiments of the present disclosure can also be called a system-level chip, a system chip, a chip system, or a system-on-chip chip, etc.
[0219] The embodiment of the present disclosure provides a computer program product containing instructions. When the computer is run on a computer, the computer implements the various processes of the embodiment of the method for generating the code declaration of the above-mentioned configuration table and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0220] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present disclosure is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in the opposite order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0221] Those skilled in the art can clearly understand the above-mentioned embodiment method can be realized by means of software and the necessary general hardware platform, of course, it can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present disclosure can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes a plurality of instructions for making a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) execute the method described in various embodiments of the present disclosure.
[0222] The embodiments of the present disclosure are described above in combination with the drawings, but the present disclosure is not limited to the specific embodiments described above, and the specific embodiments described above are only illustrative, not limiting, and those of ordinary skill in the art can make many forms without departing from the purpose of the present disclosure and the scope protected by the claims under the inspiration of the present disclosure, which all belong to the protection of the present disclosure.
Claims
1. A method for generating a code declaration of a configuration table, characterized in that: The method comprises: Read the header information of each configuration table in the M configuration tables called by the target project, where M is a positive integer; Parsing reference relationships among the M configuration tables; Based on the reference relationship of the configuration tables, the declaration data corresponding to the header information of each configuration table is written into the code declaration file corresponding to each configuration table; Saving the code declaration file corresponding to each configuration table in the M configuration tables to the code declaration file directory of the target project to generate a code declaration file for the configuration table called by the target project; After generating a code declaration file of the configuration table called by the target project, calling the code declaration file of the target project, and compiling and running the code of the target project; Prompt the error location of the code of the target project; The parsing of the reference relationship between the configuration tables in the M configuration tables includes: Traverse and parse the reference relationship between the tabs in each of the M configuration tables; Traverse and parse the reference relationships between the M configuration tables.
2. The method according to claim 1, characterized in that The step of writing the declaration data corresponding to the header information of each configuration table into the code declaration file corresponding to each configuration table based on the reference relationship of the configuration table includes: If there is a reference relationship between the target fields in the target configuration table, sort out the reference relationship between the target fields; Determining the data referenced by the target field according to the reference relationship sorted by the target field; Writing the declaration data determined according to the data referenced by the target field into the code declaration file corresponding to the target configuration table; The target configuration table is any one of the configuration tables called by the target project.
3. The method according to claim 1, characterized in that Before reading header information of each configuration table in the M configuration tables called by the target project, the method further includes: Obtain the directory of the configuration table called by the target project; According to the directory of the configuration table called by the target project, M configuration tables called by the target project are downloaded.
4. The method according to claim 3, characterized in that Before reading header information of each configuration table in the M configuration tables called by the target project, the method further includes: Update the directory of the configuration table of the target project stored locally; Based on the updated directory of the configuration table of the target project, the locally stored configuration table called by the target project is updated.
5. The method according to any one of claims 1 to 4, characterized in that Before reading header information of each configuration table in the M configuration tables called by the target project, the method further includes: Detecting the configuration table called by the target project to see if there is a changed configuration table; The header information of each configuration table in the M configuration tables called by the target project is read, including: If there is a changed configuration table, read the header information of the changed configuration table and the header information of the configuration table that references the changed configuration table in the configuration table called by the target project; The parsing of the reference relationship of the configuration tables in the M configuration tables includes: If there is a changed configuration table, the changed reference relationship in the called configuration table is parsed.
6. The method according to any one of claims 1 to 3, characterized in that Before reading the header information of each configuration table in the M configuration tables called by the target project, the method further includes: Detecting whether a target configuration file exists, the target configuration file indicating a local storage location of a code declaration of the target project and a local storage location of a configuration table called by the target project; The header information of each configuration table in the M configuration tables called by the target project is read, including: If the target configuration file exists, the header information of each configuration table in the M configuration tables called by the target project is read based on the target configuration file.
7. The method according to claim 6, characterized in that After detecting whether the target configuration file exists, the method further includes: If the target configuration file does not exist, prompting a first local storage location of a code declaration file configuring the configuration table of the target project and a second local storage location of the configuration table called by the target project; After configuring the first local storage location and the second local storage location, reading table name information of each configuration table in the configuration table called by the target project based on the first local storage location; A code declaration file corresponding to each configuration table is generated in the second local storage location, and the code declaration file corresponding to each configuration table is named according to the table name information of each configuration table.
8. A device for generating a code statement, characterized in that: The device includes: a reading module, a parsing module, a writing module, a saving module, a compiling module and a prompting module; The reading module is used to read the header information of each configuration table in the M configuration tables called by the target project, where M is a positive integer; The parsing module is used to parse the reference relationship of the configuration tables in the M configuration tables; The writing module is configured to write the declaration data corresponding to the header information of each configuration table into the code declaration file corresponding to each configuration table based on the reference relationship of the configuration table parsed by the parsing module; The saving module is configured to save the code declaration file corresponding to each of the M configuration tables to the code declaration file directory of the target project to generate the code declaration files for the M configuration tables; The compiling module is configured to, after generating a code declaration file of the configuration table called by the target project, call the code declaration file of the target project, and compile and run the code of the target project; The prompt module is used to prompt the error location of the code of the target project; Wherein, the parsing module is configured as follows: Traverse and parse the reference relationship between the tabs in each of the M configuration tables; Traverse and parse the reference relationships between the M configuration tables.
9. An electronic device, characterized in that: The method comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method for generating a code declaration of a configuration table according to any one of claims 1 to 7.
10. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the method for generating a code declaration of a configuration table according to any one of claims 1 to 7 are implemented.