[go: up one dir, main page]

CN120196327A - Object model code generation method, device, equipment and storage medium - Google Patents

Object model code generation method, device, equipment and storage medium Download PDF

Info

Publication number
CN120196327A
CN120196327A CN202510102051.3A CN202510102051A CN120196327A CN 120196327 A CN120196327 A CN 120196327A CN 202510102051 A CN202510102051 A CN 202510102051A CN 120196327 A CN120196327 A CN 120196327A
Authority
CN
China
Prior art keywords
code
model
object model
attribute
editable
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202510102051.3A
Other languages
Chinese (zh)
Inventor
周立功
许朝泽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Zhiyuan Electronics Co Ltd
Original Assignee
Guangzhou Zhiyuan Electronics Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Zhiyuan Electronics Co Ltd filed Critical Guangzhou Zhiyuan Electronics Co Ltd
Priority to CN202510102051.3A priority Critical patent/CN120196327A/en
Publication of CN120196327A publication Critical patent/CN120196327A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/34Graphical or visual programming

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The application discloses a code generation method, a device, equipment and a storage medium of an object model. The method comprises the steps of obtaining the latest configuration information and a code template of an object model, generating an uneditable code of the object model according to the latest configuration information and the code template, storing the uneditable code into a first file corresponding to the object model, judging whether a second file corresponding to the object model stores the editable code or not, binding the first file and the second file through a file containing instruction, determining the change condition of the object model under the condition that the second file stores the editable code, and adjusting the editable code stored in the second file according to the change condition. By the technical means, the situation that the editable code covers the manual editing code when the editable code is regenerated by adopting the code template can be avoided, the manual editing code is reserved, and the code development efficiency and the practicability of the object model are improved.

Description

Code generation method, device, equipment and storage medium of object model
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for generating a code of an object model.
Background
A code template is a predefined code structure or pattern that contains common code fragments, notes, variable names, method names, etc. placeholders. The developer may populate these placeholders as needed to generate code that meets the requirements of a particular specification or framework. Code templates may be applied to a variety of code structures such as functions, classes, modules, interfaces, etc., and may be used in different programming languages.
In generating the code of the object model, the corresponding code blocks may be generated in accordance with predefined code templates, in combination with configurable input parameters. If the template processing mode, the type of the generated code or the programming language of the code is different, the generated mode and the output result are different. The generated code does not need to manually edit some actual logic. After manual editing, the machine-generated code and the manually edited code are easily hybridized together, so that the code of the object model becomes disposable. If the configurable input parameters change, when the code of the object model is regenerated, part of the codes edited manually can be covered, so that the codes can be put into use again after the part of the codes are edited again manually, and the code development efficiency of the object model is low and the practicability is poor.
Disclosure of Invention
The application provides a code generation method, a device, equipment and a storage medium of an object model, which are used for determining the change condition of the object model based on the configuration information of the object model, adjusting the existing editable code of the object model based on the change condition, avoiding the coverage of the editable code by the editable code when the editable code is regenerated by adopting a code template, realizing the reservation of the manual editing code, solving the problem that the code logic of the object model needs to be manually edited again in the prior art, and improving the code development efficiency and the practicability of the object model.
In a first aspect, the present application provides a code generation method of an object model, including:
obtaining the latest configuration information and a code template of an object model, and generating a non-editable code of the object model according to the latest configuration information and the code template;
storing the non-editable code into a first file corresponding to the object model;
Judging whether a second file corresponding to the object model stores an editable code or not, wherein the first file and the second file are bound through a file containing instruction;
and under the condition that the second file stores the editable code, determining the change condition of the object model, and adjusting the editable code stored in the second file according to the change condition.
In a second aspect, the present application provides a code generating apparatus of an object model, including:
the first code generation module is configured to acquire the latest configuration information of the object model and a code template, and generate non-editable codes of the object model according to the latest configuration information and the code template;
The code storage module is configured to store the non-editable code into a first file corresponding to the object model;
the file judging module is configured to judge whether a second file corresponding to the object model stores an editable code or not, and the first file and the second file are bound through a file containing instruction;
And the code adjustment module is configured to determine the change condition of the object model when the editable code is stored in the second file, and adjust the editable code stored in the second file according to the change condition.
In a third aspect, the present application provides a code generation apparatus of an object model, comprising:
And a storage device storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the code generation method of the object model as described in the first aspect.
In a fourth aspect, the present application provides a storage medium containing computer executable instructions for performing the code generation method of the object model according to the first aspect when executed by a computer processor.
The method comprises the steps of obtaining the latest configuration information and a code template of an object model, generating an uneditable code of the object model according to the latest configuration information and the code template, storing the uneditable code into a first file corresponding to the object model, judging whether a second file corresponding to the object model stores the uneditable code or not, binding the first file and the second file through a file containing instruction, determining the change condition of the object model under the condition that the second file stores the uneditable code, and adjusting the uneditable code stored in the second file according to the change condition. By the technical means, the codes of the object model are divided into the editable codes and the non-editable codes, the non-editable codes are stored in the first file to cover the old non-editable codes after the non-editable codes are generated based on the latest configuration information and the code template, the old editable codes in the second file are pertinently adjusted based on the change condition of the object model, so that the manual editing codes in the old editable codes are prevented from being covered, the reservation of the manual editing codes is realized, the problem that the object model can only be used by the codes of the object model manually required to be edited again in the prior art is solved, and the code editing efficiency and the practicability of the object model are improved.
Drawings
FIG. 1 is a flow chart of a code generation method of an object model according to an embodiment of the present application;
FIG. 2 is a flow chart of determining a change in an object model based on updated configuration information and historical configuration information provided by an embodiment of the present application;
FIG. 3 is a flow chart of a delete or annotation prompt for adding a second model attribute provided by an embodiment of the present application;
FIG. 4 is a flow chart of a modification hint for adding a third model attribute provided by an embodiment of the present application;
FIG. 5 is a flow chart of a delete or comment prompt for adding a second model command provided by an embodiment of the present application;
FIG. 6 is a flow chart of a modification hint for adding a third model command provided by an embodiment of the present application;
FIG. 7 is a flow chart of a modification hint to add a model name or model description of an object model provided by an embodiment of the present application;
FIG. 8 is a flow chart for adjusting editable code provided by an embodiment of the application;
FIG. 9 is a schematic diagram of a code generating apparatus of an object model according to an embodiment of the present application;
fig. 10 is a schematic structural diagram of a code generating apparatus of an object model according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the following detailed description of specific embodiments of the present application is given with reference to the accompanying drawings. It is to be understood that the specific embodiments described herein are merely illustrative of the application and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the matters related to the present application are shown in the accompanying drawings. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart depicts operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently, or at the same time. Furthermore, the order of the operations may be rearranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figures. The processes may correspond to methods, functions, procedures, subroutines, and the like.
The terms first, second and the like in the description and in the claims, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged, as appropriate, such that embodiments of the present application may be implemented in sequences other than those illustrated or described herein, and that the objects identified by "first," "second," etc. are generally of a type, and are not limited to the number of objects, such as the first object may be one or more. Furthermore, in the description and claims, "and/or" means at least one of the connected objects, and the character "/", generally means that the associated object is an "or" relationship.
In the existing similar implementation mode, code blocks of the object model can be generated according to a predefined code template of the object model and input parameters correspondingly configured by the object model. When the code blocks of the object model do not meet the user's needs, the user manually edits the actual logic of the code blocks. After manual editing, the machine-generated code and the manually edited code are hybridized together, so that the code of the object model becomes a disposable code. If the input parameters of the object model corresponding configuration change, when the code is regenerated based on the input parameters and the code template, the code can cover part of the codes edited manually, so that the actual logic of the object model is manually edited again, and the code development efficiency of the object model is low and the practicability is poor.
In order to solve the above problems, the present embodiment provides a code generation method of an object model, so as to determine a change condition of the object model based on configuration information of the object model, adjust an existing editable code of the object model based on the change condition, avoid covering a manual editing code with the editable code when the editable code is regenerated by using a code template, implement reservation of the manual editing code, and improve code development efficiency and practicality of the object model without requiring a user to manually edit actual logic of the object model again.
The method for generating the code of the object model provided in the embodiment may be executed by a code generating device of the object model, where the code generating device of the object model may be implemented in a software and/or hardware manner, and the code generating device of the object model may be configured by two or more physical entities or may be configured by one physical entity. For example, the code generating device of the object model may be an intelligent terminal with a relatively high processing capability, such as a computer and a server. The server may be implemented as a stand-alone server or as a server cluster formed by a plurality of servers.
The code generating device of the object model is provided with at least one type of operating system, and can be used for installing at least one application program based on the operating system, wherein the application program can be an application program of the operating system, or can be an application program downloaded from a third party device or a server. In this embodiment, the code generating apparatus of the object model is installed with at least an application program that can execute the code generating method of the object model.
For easy understanding, the present embodiment will be described taking the main body of a code generation method of a computer-implemented object model as an example.
Fig. 1 is a flowchart of a code generation method of an object model according to an embodiment of the present application.
Referring to fig. 1, the code generation method of the object model specifically includes:
S110, obtaining the latest configuration information and the code template of the object model, and generating the non-editable code of the object model according to the latest configuration information and the code template.
The latest configuration information is input parameters of the latest configured object model, codes of the object model need to be correspondingly updated when the input parameters of the object model are updated, and for this purpose, each time the user reconfigures the input parameters of the object model, the computer can regenerate the codes of the object model based on the reconfigured input parameters.
For example, the computer may display a configuration interface in the display screen, and the user may fill in configuration information of the object model in the configuration interface, and after filling in, the computer obtains the latest configuration information of the object model. In addition, the user can edit the JSON configuration of the object model by using a text editor, and the computer obtains the latest configuration information of the object model in the JSON configuration.
Optionally, the model identifier of the object model is associated with the code template and stored in the template database, and the code template stored in the corresponding association is obtained from the template database according to the model identifier of the object model.
In the present embodiment, the code templates of the object model are divided into an editable code template and a non-editable code template according to the part codes that are manually edited and the part codes that are not edited in the object model. The editable codes generated by the editable code templates can be modified by manual editing, and the non-editable codes generated by the non-editable code templates cannot be modified by manual editing.
It should be noted that, when the configuration information of the object model is updated, both the editable code and the non-editable code of the object model are changed, and because the non-editable code of the object model does not include the manual editing code, when the non-editable code generated based on the latest configuration information and the non-editable code template covers the non-editable code generated last time on the object model, the problem that the manual editing code is covered does not occur, so the non-editable code can be generated based on the latest configuration information of the object model and the non-editable code template first. The last generated editable code of the object model may contain a manual editing code, so as to avoid that the editable code generated based on the editable code template covers the manual editing code, and the last generated editable code of the object model is modified according to the configuration change condition of the editable code, thereby retaining the manual editing code in the editable code.
The code template of the object model can be a general template or a template customized according to actual business. But regardless of how the code templates of the object model change, they generally include a structure body template, a constructor template, a destructor template, an attribute declaration template, a command declaration template, an attribute distribution function template, a command distribution function template, an attribute function template, and a command function template of the object model. The attribute distribution function templates comprise an attribute get distribution function template and an attribute set distribution function template, and the attribute function templates comprise an attribute get function template and an attribute set function template. When editing the actual logic of the object model, the general user adjusts the codes of the attribute function and the command function of the object model, so that the embodiment divides the structural body template, the constructor template, the destructor template, the attribute declaration template, the command declaration template, the attribute distribution function template and the command distribution function template into non-editable code templates and divides the attribute function template and the command function template into editable code templates.
The configuration information of the object model includes model names, model descriptions, model properties, and model commands. When generating the non-editable code based on the latest configuration information and the non-editable code template, codes of a structure, a constructor, a destructor, an attribute declaration, a command declaration, an attribute distribution function, and a command distribution function of the object model may be correspondingly generated based on the model name, the model description, the model attribute, and the model command in the latest configuration information, and the structure template, the constructor template, the destructor template, the attribute declaration, the command declaration, the attribute distribution function, and the command distribution function in the non-editable code template.
S120, storing the non-editable code into a first file corresponding to the object model.
Illustratively, since the present embodiment divides the code of the object model into the non-editable code and the editable code, in order to effectively distinguish the codes of the two parts, the codes of the two parts may be stored separately in different files, and the codes of the two parts may be bound together by a file containing instruction to merge the editable code and the non-editable code contained in the two files into the code of the object model at the time of execution.
Specifically, the first file is a file for storing non-editable codes of the object model, the second file is a file for storing editable codes of the object model, and the first file and the second file are bound through file containing instructions. If the current time is the code for generating the object model for the first time, the first file does not contain any code, and if the current time is not the code for generating the object model for the first time, the first file contains the non-editable code of the object model generated last time. However, in any case, the direct storing of the non-editable code generated based on the latest configuration information and the non-editable code template into the first file does not cover the manual editing code, and therefore the non-editable code can be directly stored into the first file after the latest non-editable code is generated.
It should be noted that, since the first file and the second file are to be bound together by the file containing instruction, the programming language to which the code of the object model belongs is to support file containing, such as #include in C/c++. In addition, the programming language to which the code of the object model belongs supports that the constraint function is only visible in the file it declares and cannot be used by other files, such as static functions in C/C++.
S130, judging whether a second file corresponding to the object model stores editable codes or not, and binding the first file and the second file through a file containing instruction.
For example, if the current time is the code for generating the object model for the first time, the second file does not contain any code, and if the current time is not the code for generating the object model for the first time, the second file contains the editable code of the object model generated last time.
Storing the editable code generated based on the latest configuration information and the editable code template in the second file does not cause an override of the manual editing code in case the second file does not contain any code. In this regard, in the case where the second file does not store the editable code, the editable code may be generated from the latest configuration information and the editable code template among the code templates, and stored in the second file. For example, the editable code templates include an attribute function template and a command function template, and the attribute function codes of the object model can be generated according to the model attribute in the latest configuration information and the attribute function template, and the command function codes of the object can be generated according to the model command in the latest configuration information and the command function template. The attribute function code and the command function code are stored in a second file, and then the second file is included in the first file by a file inclusion instruction, so that the non-editable code and the editable code stored in the first file and the second file, respectively, are combined into the code of the object model.
In the case that the second file contains an editable code, the editable code may contain a manual editing code, which would be covered if the editable code generated based on the latest configuration information and the editable code template was stored in the second file. In this regard, when the second file stores the editable code, the editable code generated based on the latest configuration information and the editable code template is not stored in the second file, but the change condition of the object model is determined, the editable code stored in the second file is adjusted according to the change condition of the object model, and the adjusted code does not involve a manual editing part, so that the complete reservation of the manual editing code is realized.
And S140, determining the change condition of the object model under the condition that the second file stores the editable code, and adjusting the editable code stored in the second file according to the change condition.
By way of example, the editable code of the object model includes attribute function code and command function code, and when the configuration information of the object model changes, the corresponding attribute function and command function may change, the attribute function codes and the command function codes stored in the second file can be adjusted in a targeted manner based on the change conditions of the attribute function and the command function, so that the manual editing codes in the second file are prevented from being covered, and the manual editing codes are reserved.
The change situation of the object model may be divided according to configuration information of the object model, for example, the configuration information of the object model includes a model name, a model description, a model attribute, and a model command, and accordingly, the change situation of the object model may be divided into a model name change, a model description change, a model attribute change, and a model command change.
It should be noted that since the editable code is generated based on the model properties and the model commands in the configuration information, the editable code will change if and only if the model properties change and/or the model commands change, at which point the editable code in the second file needs to be correspondingly adjusted. In this regard, after determining the change condition of the object model, the editable code in the second file is not adjusted without the change of the model attribute and the model command of the object model. When the model attribute and the model command are not changed, the attribute function and the command function generated based on the latest configuration information and the attribute function template and the command function template are identical to the attribute function and the command function stored in the second file, so that the editable code in the second file is not required to be adjusted, and the code generation efficiency of the object model is improved.
In one embodiment, the change condition of the object model can be determined based on the latest configuration information and the historical configuration information of the object model and is classified into a model name change, a model description change, a model attribute change and a model command change. The history configuration information is the configuration information of the object model input last time. In another embodiment, the latest non-editable code and the editable code can be generated based on the latest configuration information of the object model and the non-editable code template and the editable code template, the latest non-editable code and the non-editable code stored in the first file are compared to determine the change condition of the object model, and the latest editable code and the editable code stored in the second file are compared to determine the change condition of the comparison model.
Since the second method for determining the transformation condition also needs to generate the latest editable code, the time required for determining the transformation condition is longer, and the operation of comparing the codes is more troublesome than the operation of comparing the configuration information, the execution efficiency of the second method for determining the transformation condition is lower, and the first method for determining the transformation condition can be selected to determine the transformation condition of the object model.
Optionally, since the change condition of the object model is mainly used for purposefully adjusting the attribute function code and the command function code of the change occurring in the second file, when determining the change condition of the object model based on the latest configuration information and the historical configuration information of the object model, whether the model attribute and the model command in the configuration information of the object model are changed or not can be analyzed, thereby improving the determination efficiency of the change condition. Fig. 2 is a flowchart illustrating a method for determining a change situation of an object model based on latest configuration information and historical configuration information according to an embodiment of the present application. As shown in fig. 2, the step of determining the change condition of the object model based on the latest configuration information and the history configuration information specifically includes S1401-S1404:
S1401, comparing the model attribute and the model command in the latest configuration information of the object model with the model attribute and the model command in the historical configuration information of the object model correspondingly.
Illustratively, the model attribute in the most recent configuration information is compared to the model attribute in the historical configuration information to determine whether the model attribute in the most recent configuration information is an increase, decrease, or modification as compared to the model attribute in the historical configuration information. And comparing the model commands in the latest configuration information with the model commands in the historical configuration information to determine whether the model attributes in the latest configuration information are increased, decreased or modified as compared to the model commands in the historical configuration information.
S1402, when the latest configuration information includes the first model attribute or the first model command not included in the history configuration information, determining the change condition of the object model includes adding the first model attribute or the first model command.
The first model attribute is a model attribute that the latest configuration information contains but the history configuration information does not contain, and the first model command is a model command that the latest configuration information contains but the history configuration information does not contain. For example, the latest configuration information includes a model attribute a, a model attribute B, and a model attribute C, and the history configuration information includes the model attribute a and the model attribute B, then the model attribute C is the first model attribute. When the first model attribute or the first model command exists, the first model attribute or the first model command can be regarded as the newly added model attribute or model command of the object model, and the change condition of the object model can be determined to comprise the newly added first model attribute or the newly added first model command. For example, after determining model attribute C as the first model attribute, a change in the object model may be determined to include the newly added model attribute C.
S1403, in a case where the history configuration information includes the second model attribute or the second model command not included in the latest configuration information, determining the change condition of the object model includes deleting the second model attribute or deleting the second model command.
The second model attribute is a model attribute that the history configuration information contains but the latest configuration information does not contain, and the second model command is a model command that the history configuration information contains but the latest configuration information does not contain. For example, the history configuration information includes a model attribute a, a model attribute B, and a model attribute C, and the latest configuration information includes the model attribute a and the model attribute C, and then the model attribute B is the second model attribute. When the second model attribute or the second model command exists, the second model attribute or the second model command can be regarded as the model attribute or the model command which is deleted by the object model recently, and the change condition of the object model can be determined to comprise deleting the second model attribute or deleting the second model command. For example, after determining model attribute B as the second model attribute, a change in the object model may be determined including deleting model attribute B.
S1404, in a case where the history configuration information is different from the third model attribute or the information of the third model command in the latest configuration information, determining the change condition of the object model includes modifying the third model attribute or modifying the third model command.
The third model attribute is a model attribute with different information contained in the model attribute in the history configuration information and the latest configuration information, and the third model command is a model command with different information contained in the model command in the history configuration information and the latest configuration information. For example, the model attribute includes information such as name, type, description, default value, read-write authority, etc., and when the history configuration information is different from any one of the name, type, description, default value, and read-write authority of the model attribute a in the latest configuration information, the model attribute a can be determined to be the third model attribute. When a third model attribute or third model command is present, the third model attribute or third model command may be considered a newly modified model attribute or model command for the object model, at which time the determination of the change in the object model may include modifying the third model attribute or modifying the third model command. For example, after determining model attribute A as the third model attribute, a change in the object model may be determined including modifying model attribute A.
It should be noted that the adding, deleting and modifying are specific to different model attributes or model commands, so the changing situation of the object model may include changing situations of adding, deleting or modifying of multiple model attributes or multiple model commands. In this embodiment, the model attribute in the latest configuration information and the model attribute in the historical configuration information are compared with the model command, and the model attribute or model command and the change type which change in the object model can be rapidly determined, so that the attribute function code or command function code in the second file can be pertinently adjusted, the precise adjustment of the editable code is realized, and the adjustment efficiency of the editable code is improved.
Further, if the change condition of the object model is adding, deleting or modifying the model attribute, the attribute function code in the second file is added, deleted or modified in a targeted manner.
For example, if the change condition is that the first model attribute is newly added, generating a first attribute function code according to the information of the first model attribute in the latest configuration information and the attribute function template, and inserting the first attribute function code into the editable code. The first attribute function code is an attribute function code corresponding to the attribute of the first model, and comprises an attribute get function code and an attribute set function code. For example, when the model attribute C is the first model attribute, according to the information such as the name, the type, the description, the default value, the read-write permission and the like of the model attribute C in the latest configuration information, and the attribute get function code and the attribute set function code corresponding to the model attribute C are correspondingly generated by the attribute get function template and the attribute get function template, the attribute get function code and the attribute set function code corresponding to the model attribute C are inserted into the editable code stored in the second file, so that the model attribute of the object model is newly added.
Alternatively, to reduce the differences in the editable code and facilitate code generation, it may be agreed that the functions in the editable code use a generalized naming scheme to formulate the corresponding naming convention. For example, the attribute get function is named "prefix_get_attribute name", the attribute set function is named "prefix_set_attribute name", the command function is named "prefix_command name", and the "prefix" may be a character string beginning with any letter. It should be noted that, in order to avoid conflict in naming functions of the editable code between different object models, the function limitations of the editable code can only be seen in the file containing the part of the code. In this regard, when generating the attribute function code corresponding to the newly added first model attribute, the first attribute function code may be generated based on the information of the first model attribute in the latest configuration information, the attribute function template, and the preset naming rule. The name of the attribute function is defined by the preset naming rule and consists of a preset prefix character string, an attribute function type and an attribute name.
If the change condition is deleting the second model attribute, determining a corresponding second attribute function code in the editable code according to the information of the second model attribute in the history configuration information, and deleting or annotating the second attribute function code in the editable code. The second attribute function code is an attribute function code corresponding to the second model attribute, and comprises an attribute get function code and an attribute set function code. For example, when the model attribute B is the second model attribute, the attribute get function code and the attribute set function code of the model attribute B in the editable code stored in the second file may be determined according to the attribute name of the model attribute B in the history configuration information, and the attribute get function code and the attribute set function code of the model attribute B are deleted or annotated from the editable code, thereby realizing deletion of the model attribute of the object model.
Optionally, after deleting or annotating the second attribute function code of the second model attribute, other object models using the second model attribute and code positions of the attribute function codes corresponding to the second model attribute in the object model can be counted, so as to generate statistical reference information, so that a developer can quickly inquire the attribute function codes of the second model attribute in other object models based on the statistical reference information, and further, the attribute function codes of the second model attribute in other object models are reserved, deleted or annotated according to actual requirements, and code development efficiency is improved. Illustratively, FIG. 3 is a flow chart of generating first reference statistics for a second model attribute provided by an embodiment of the present application. As shown in fig. 3, the step of generating the reference statistics of the second model attribute specifically includes S1501-S1502:
s1501, searching a first object model referencing the second model attribute through regular search or grammar tree, and determining a fourth attribute function code corresponding to the second model attribute in the editable code of the first object model.
The first object model is an object model referencing the second model attribute, for example, if the model attribute B is the second model attribute, when the configuration information of the object model a also includes the model attribute B, it may be determined that the object model a is the first object model. All first object models referencing the second model attribute can be searched through regular search or grammar tree, and fourth attribute function codes of the second model attribute can be searched in the editable codes of the first object model according to the attribute name of the second model attribute. The fourth attribute function code is the attribute function code of the second model attribute in the corresponding first object model.
S1502, generating first reference statistical information of the second model attribute according to the code position of the fourth attribute function code in the editable code of the first object model.
In an exemplary embodiment, after searching the fourth attribute function code in the editable code of the first object model, determining a code position of the fourth attribute function code in the first object model, and then generating the first reference statistics of the second model attribute according to the first object model of all the second model attributes and the code positions of the fourth function attribute code corresponding to the second model attribute in the corresponding first object model. The first reference statistical information may be a statistical list or a statistical text, in which a model name of a first object model referencing the fourth attribute function code and a code position of the fourth attribute function code in the corresponding first object model are recorded, and the model name of the first object model and the code position of the corresponding fourth attribute function code are stored in association in the statistical list and the statistical text. A developer can confirm which second model attributes referenced by the first object model and the code positions of the fourth attribute function codes corresponding to the second model attributes in the corresponding first object model through the first reference statistical information, so that when the developer needs to delete or annotate the fourth attribute function codes in the first object model in the same way, the developer can quickly inquire the code positions of the fourth attribute function codes in the first object model through the first reference statistical information, the development convenience of the developer is improved, and the code development efficiency is improved.
Optionally, when generating the first reference statistic information, the first reference statistic information may include first reference statistic information of which second model attribute of the object model is deleted or annotated, for example, when the second model attribute of the object model B is deleted or annotated, if the object model a and the object model C also reference the second model attribute, a code position of the object model a and a fourth attribute function code corresponding to the second model attribute in the object model a is generated, and the first reference statistic information may also record prompt information of the second model attribute of the object model B deleted or annotated and a code position of the second attribute function code corresponding to the second model attribute in the object model B.
If the change condition is modification of the third model attribute, determining a corresponding third attribute function code in the editable code according to the information of the third model attribute in the historical configuration information, and adjusting the third attribute function code in the editable code according to the information of the third model attribute in the latest configuration information. The third attribute function code is an attribute function code of a third model attribute in the editable code, and comprises a get function code and an attribute set function code. For example, when the model attribute a is the third model attribute, the name, type, description, default value, read-write authority of the attribute get function code and the attribute set function code corresponding to the model attribute a can be correspondingly adjusted according to the information such as the name, type, description, default value, read-write authority and the like of the model attribute a in the latest configuration information, so that the modification of the model attribute of the object model is realized.
Optionally, after modifying the third attribute function code of the third model attribute, other object models using the third model attribute and code positions of the attribute function codes corresponding to the third model attribute in the object model may be counted, so as to generate statistical reference information, so that a developer can quickly query the attribute function codes of the third model attribute in other object models based on the statistical reference information, and further keep or modify the attribute function codes of the third model attribute in other object models according to actual requirements, thereby improving code development efficiency. Illustratively, FIG. 4 is a flow chart of generating second reference statistics for a third model attribute provided by an embodiment of the present application. As shown in fig. 4, the step of generating the second reference statistical information of the third model attribute specifically includes S1503-S1504:
S1503, searching a second object model referencing the third model attribute through regular searching or grammar tree, and determining a fifth attribute function code corresponding to the third model attribute in the editable code of the second object model.
The second object model is an object model referencing the third model attribute, for example, if the model attribute a is the third model attribute, when the configuration information of the object model B also includes the model attribute a, it may be determined that the object model B is the second object model. All second object models referencing the third model attribute can be searched through regular search or grammar tree, and fifth attribute function codes of the third model attribute can be searched in the editable codes of the second object model according to the attribute name of the third model attribute. The fifth attribute function code is the attribute function code of the third model attribute in the corresponding second object model.
S1504, generating second reference statistical information of the third model attribute according to the code position of the fifth attribute function code in the editable code of the second object model.
In an exemplary embodiment, after searching the fifth attribute function code in the editable code of the second object model, determining a code position of the fifth attribute function code in the second object model, and generating second reference statistical information of the third model attribute according to all the second object models referring to the third model attribute and the code positions of the fifth attribute function codes corresponding to the third model attribute in the corresponding second object model. The second reference statistical information may be a statistical list or a statistical text, in which a model name of the second object model referencing the third model attribute and a code position of the fifth attribute function code in the corresponding second object model are recorded, and the model name of the second object model and the code position of the corresponding fifth attribute function code are stored in association in the statistical list and the statistical text. A developer can confirm which third model attributes are referred to by the second object model and the code positions of the fifth attribute function codes corresponding to the third model attributes in the corresponding second object model through the second reference statistical information, so that when the developer needs to carry out the same modification treatment on the fifth attribute function codes in the second object model, the developer can quickly inquire the code positions of the fifth attribute function codes in the second object model through the second reference statistical information, the development convenience of the developer is improved, and the code development efficiency is improved.
Optionally, when generating the second reference statistical information, the second reference statistical information may include second reference statistical information of which third model attribute of the object model is modified, for example, when the second model attribute of the object model C is modified, if the object model D and the object model E also reference the third model attribute, a code position of a model name of the object model D and a fifth attribute function code corresponding to the third model attribute in the object model D is generated, a model name of the object model E and second reference statistical information of a code position of a fifth attribute function code corresponding to the third model attribute in the object model E is generated, and the second reference statistical information may also record hint information that the third model attribute of the object model C is modified and a code position of a third attribute function code corresponding to the third model attribute in the object model C.
From the above, when it is confirmed that the model attribute of the object model changes in addition, deletion or modification, the corresponding attribute function code can be added, deleted or modified in the editable code of the second file in a targeted manner, so that the attribute function code included in the editable code can meet the model attribute in the latest configuration information, and accurate adjustment of the editable code can be realized while the manual editing code is maintained.
Further, if the change condition of the object model is adding, deleting or modifying the model command, the command function code in the second file is added, deleted or modified in a targeted manner.
For example, if the change condition is a new first model command, a first command function code is generated according to the information of the first model command in the latest configuration information and the command function template, and the first command function code is inserted into the editable code. The first command function code is a command function code corresponding to the first model command. For example, when the model command C is the first model command, the command function code corresponding to the command function template for generating the model command C is inserted into the editable code stored in the second file according to the information such as the name and description of the model command C in the latest configuration information, so as to realize the new addition of the model command of the object model.
Similarly, if a naming rule of a function in the editable code is predefined, when a command function code corresponding to a new first model command is generated, the first command function code may be generated based on information of the first model command in the latest configuration information, a command function template and a preset naming rule. The name of the command function is defined by the preset naming rule and consists of a preset prefix character string, a command function type and a command name.
If the change condition is that the second model command is deleted, determining a corresponding second command function code in the editable code according to the information of the second model command in the history configuration information, and deleting or annotating the second command function code in the editable code. The second command function code is a command function code corresponding to the second model command. For example, when the model command B is the second model command, the command function code of the model command B in the editable code stored in the second file may be determined according to the command name of the model command B in the history configuration information, and the command function code of the model command B is deleted or annotated from the editable code, thereby realizing the deletion of the model command of the object model.
Optionally, after deleting or annotating the second command function code of the second model command, other object models using the second model command and code positions of the corresponding command function codes of the second model command in the object model can be counted, so as to generate statistical reference information, so that a developer can quickly inquire the command function codes of the second model command in other object models based on the statistical reference information, and further, the code development efficiency is improved according to the command function codes of the second model command in other object models which are reserved, deleted or annotated according to actual requirements. Fig. 5 is a flowchart illustrating generation of third reference statistics for a second model command according to an embodiment of the present application. As shown in fig. 5, the step of generating the third reference statistics of the second model command specifically includes S1505-S1506:
S1505, searching a third object model referencing the second model command through a regular search or a grammar tree, and determining a fourth command function code corresponding to the second model command in the editable codes of the third object model.
The third model object is an object model referencing the second model command, for example, if the model command B is the second model command, when the configuration information of the object model a also includes the model command B, it may be determined that the object model a is the third object model. All third object models referencing the second model commands can be searched by a regular search or syntax tree, and fourth command function codes of the second model commands can be searched in the editable codes of the third object models according to the command names of the second model commands.
S1506, third reference statistical information of the second model command is generated according to the code position of the fourth command function code in the editable code of the third object model.
In an exemplary embodiment, the code positions of the fourth command function codes in the third object model are determined, and then third reference statistics of the second model commands are generated according to the third object model of all the second model commands and the code positions of the fourth function command codes corresponding to the second model commands in the corresponding third object model. The third reference statistical information may be a statistical list or a statistical text, in which a model name of a third object model referencing the fourth command function code and a code position of the fourth command function code in the corresponding third object model are recorded, and the model name of the third object model and the code position of the corresponding fourth command function code are stored in association in the statistical list and the statistical text. The developer can confirm the second model commands referenced by the third object models and the code positions of the fourth command function codes corresponding to the second model commands in the corresponding third object models through the third reference statistical information, so that when the developer needs to delete or annotate the fourth command function codes in the third object models in the same way, the developer can quickly inquire the code positions of the fourth command function codes in the third object models through the third reference statistical information, thereby improving the development convenience of the developer and the code development efficiency.
Optionally, when generating the third reference statistics, the third reference statistics may include third reference statistics of which second model command of the object model is deleted or annotated, for example, when the second model command of the object model B is deleted or annotated, if the object model a and the object model C also reference the second model command, a code position of the object model a and a code position of the fourth command function code corresponding to the second model command in the object model a is generated, and third reference statistics of the object model C and a code position of the fourth command function code corresponding to the second model command in the object model C may also record prompt information that the second model command of the object model B is deleted or annotated and a code position of the second command function code corresponding to the second model command in the object model B.
If the change condition is that the third model command is modified, determining a corresponding third command function code in the editable code according to the information of the third model command in the historical configuration information, and adjusting the third command function code in the editable code according to the information of the third model command in the latest configuration information. The third command function code is a command function code of the third model command in the editable code. For example, when the model command a is the third model command, the name and description of the command function code corresponding to the model command a may be correspondingly adjusted according to the name and description of the model attribute a in the latest configuration information, so as to implement modification of the model command of the object model.
Optionally, after modifying the third command function code of the third model command, other object models using the third model command and code positions of the command function codes corresponding to the third model command in the object model may be counted, so as to generate statistical reference information, so that a developer can quickly query the command function codes of the third model command in other object models based on the statistical reference information, and further reserve or modify the command function codes of the third model command in other object models according to actual requirements, thereby improving code development efficiency. Illustratively, FIG. 6 is a flow chart of generating fourth reference statistics for a third model command provided by an embodiment of the present application. As shown in fig. 6, the step of generating the fourth reference statistics of the third model command specifically includes S1507-S1508:
S1507, searching a fourth object model referencing the third model command through a regular search or a grammar tree, and determining a fifth command function code corresponding to the third model command in the editable codes of the fourth object model.
The fourth object model is an object model referencing the third model command, for example, if the model command a is the third model command, when the configuration information of the object model B also includes the model command a, it may be determined that the object model B is the fourth object model. All fourth object models referencing the third model commands can be searched by a canonical lookup or syntax tree, and the fifth command function code of the third model commands can be searched in the editable codes of the fourth object models according to the command names of the third model commands. The fifth command function code is the command function code of the third model command in the corresponding second object model.
S1508 generates fourth reference statistics for the third model command based on the code locations of the fifth command function code in the editable code of the fourth object model.
In an exemplary embodiment, after searching the fifth command function code in the editable code of the fourth object model, determining a code position of the fifth command function code in the fourth object model, and generating fourth reference statistics of the third model command according to all the fourth object models referring to the third model command and the code positions of the fifth command function code corresponding to the third model command in the corresponding fourth object model. The fourth reference statistical information may be a statistical list or a statistical text, in which a model name of the fourth object model and a code position of the fifth command function code corresponding to the third model command are recorded, and the model name of the fourth object model and the code position of the fifth command function code corresponding to the fourth object model are stored in association in the statistical list and the statistical text. The developer can confirm which third model commands are referenced by the fourth object model and the code positions of the fifth command function codes corresponding to the third model commands in the corresponding fourth object model through the fourth reference statistical information, so that when the developer needs to carry out the same modification treatment on the fifth command function codes in the fourth object model, the developer can quickly inquire the code positions of the fifth command function codes in the fourth object model through the fourth reference statistical information, the development convenience of the developer is improved, and the code development efficiency is improved.
Optionally, when generating the fourth reference statistic information, which third model command of the object model is modified, for example, when the second model command of the object model C is modified, if the object model D and the object model E also reference the third model command, a code position of the fifth command function code corresponding to the third model command and the model name of the object model D in the object model D is recorded, a fourth reference statistic information of the code position of the fifth command function code corresponding to the third model command and the model name of the object model E in the object model E is generated, and the fourth reference statistic information may also record prompt information that the third model command of the object model C is modified and a code position of the third command function code corresponding to the third model command in the object model C.
From the above, when the model command of the object model is confirmed to have a change condition of new addition, deletion or modification, the corresponding command function code can be added, deleted or modified in the editable code of the second file in a targeted manner, so that the command function code contained in the editable code can meet the model command in the latest configuration information, and accurate adjustment of the editable code can be realized while the manual editing code is reserved.
The configuration information of the object model further comprises a model name and a model description, and under the condition that the model name or the model description is changed, other object codes using the object model and the code positions of the object model in the using codes can be counted to generate statistical reference information, so that developers can quickly inquire the code positions of the object model in the object code based on the statistical reference information, and further the model name or the model description of the object model in the object code can be reserved or modified according to actual requirements. Fig. 7 is a flowchart illustrating generation of fifth statistical reference information of an object model according to an embodiment of the present application. As shown in fig. 7, the step of generating the fifth statistical reference information of the object model specifically includes S1509-S1510:
S1509, in the case that the change condition of the object model is to modify the model name and/or the model description, searching the object code referencing the object model through a regular search or a grammar tree.
For example, the model name in the latest configuration information of the object model is compared with the model name in the historical configuration information, if the model name is the same, the model name is determined to be unmodified, and if the model name is different, the model name is determined to be modified. And comparing the model description in the latest configuration information of the object model with the model description in the historical configuration information, if the model description is the same, determining that the model description is not modified, and if the model description is different, determining that the model description is modified.
Thereafter, upon determining that the model description or model name is modified, the code of the other application may be searched for object code referencing the object model using a canonical lookup and syntax tree based on the model name in the historical configuration information. The object code is the application program code referencing the object model.
S1510, generating reference statistical information of the object model according to the code position of the object model in the object code.
Illustratively, the object model code is searched in the object code according to the model name of the object model, and after the object model code in the object code is searched, the code position of the object model code in the object code is determined. And generating fifth reference statistical information of the object model according to all the object codes referring to the object model and the code positions of the object model codes in the corresponding object codes. The fifth reference statistic information may be a statistic list or a statistic text, in which a code identifier of an object code referring to the object model and a code position of the object model in a corresponding object code are recorded, and the code identifier of the object code and the code position of the corresponding object model are stored in association in the statistic list and the statistic text. The developer can confirm which object models are referenced by the object codes and the code positions of the object models in the object codes through the fifth reference statistical information, so that when the developer needs to modify the object models in the object codes, the developer can quickly inquire the code positions of the object models in the object codes through the fifth reference statistical information, the development convenience of the developer is improved, and the code development efficiency is improved.
Of course, when modifying the model name or model description of the object model in the object code, the code of the object model is correspondingly modified by adjusting the configuration information of the object model, so as to modify the model name or model description of the object model. That is, after adjusting the configuration information of the object model, steps S110-S140 are performed to regenerate the code of the object model in the object code.
In an embodiment, in order to make the adjustment flow of the editable code clearer, the present embodiment is described by taking the flowchart of adjusting the editable code shown in fig. 8 as an example. As shown in fig. 8, the latest configuration information of the object model is acquired, and then it is judged whether or not the second file of the object model stores editable code. If the second file does not store the editable code, generating the editable code according to the latest configuration information, the preset naming rule and the editable code template, and storing the editable code into the second file. If the second file stores the editable code, judging whether the model attribute of the object model changes according to the latest configuration information and the historical configuration information. If the model attribute changes, judging that the model attribute is newly added, deleted and/or modified, if the model attribute is newly added, inserting a new attribute function code into a second file according to the latest configuration information, a preset naming rule and an attribute function template, if the model attribute is newly added, deleting the corresponding attribute function code in the second file, generating first reference statistic information of the model attribute according to an object model related to the attribute function code and a code position of the attribute function code in the object model, and if the model attribute is modified, modifying the corresponding attribute function code in the second file according to the latest configuration information, and generating second reference statistic information of the model attribute according to the object model related to the attribute function code and a code position of the attribute function code in the object model. And if the model attribute is unchanged or the attribute function code is adjusted, judging whether the model command of the object model is changed. If the model command changes, judging that the model command is newly added, deleted and/or modified, if the model command changes, inserting a new command function code into a second file according to the latest configuration information, a preset naming rule and a command function template, if the model command changes, deleting the corresponding command function code in the second file, generating third reference statistic information of the model command according to an object model related to the command function code and a code position of the command function code in the object model, and if the model command changes, modifying the corresponding command function code in the second file according to the latest configuration information, and generating fourth reference statistic information of the model command according to the object model related to the command function code and a code position of the command function code in the object model.
In summary, the code generation method for the object model provided by the embodiment of the application generates the non-editable code of the object model according to the latest configuration information and the code template by acquiring the latest configuration information and the code template of the object model, stores the non-editable code into a first file corresponding to the object model, judges whether a second file corresponding to the object model stores the editable code or not, binds the first file and the second file through a file containing instruction, and determines the change condition of the object model under the condition that the second file stores the editable code, and adjusts the editable code stored in the second file according to the change condition. By the technical means, the codes of the object model are divided into the editable codes and the non-editable codes, the non-editable codes are stored in the first file to cover the old non-editable codes after the non-editable codes are generated based on the latest configuration information and the code template, the old editable codes in the second file are pertinently adjusted based on the change condition of the object model, so that the manual editing codes in the old editable codes are prevented from being covered, the reservation of the manual editing codes is realized, the problem that the object model can only be used by the codes of the object model manually required to be edited again in the prior art is solved, and the code editing efficiency and the practicability of the object model are improved.
On the basis of the above embodiment, fig. 9 is a schematic structural diagram of a code generating device of an object model according to an embodiment of the present application. Referring to fig. 9, the code generating apparatus of the object model provided in this embodiment specifically includes a first code generating module 21, a code storing module 22, a file judging module 23, and a code adjusting module 24.
Wherein, the first code generating module 21 is configured to obtain the latest configuration information and the code template of the object model, and generate the non-editable code of the object model according to the latest configuration information and the code template;
a code storage module 22 configured to store non-editable code in a first file corresponding to the object model;
a file determining module 23 configured to determine whether a second file corresponding to the object model stores an editable code, the first file and the second file being bound by a file containing instruction;
The code adjustment module 24 is configured to determine a change condition of the object model in the case where the second file stores the editable code, and adjust the editable code stored in the second file according to the change condition.
On the basis of the above embodiment, the code templates comprise non-editable code templates, and the corresponding first code generation module 21 comprises a non-editable code generation unit configured to generate non-editable codes from the latest configuration information and the non-editable code templates, the non-editable code templates comprising a structure body template, a constructor template, a destructor template, an attribute declaration template, a command declaration template, an attribute distribution function template, and a command distribution function template of the object model.
On the basis of the above embodiment, the configuration information of the object model includes model attributes and model commands, the code adjustment module 24 includes a configuration information comparing unit configured to compare model attributes and model commands in the latest configuration information of the object model with model attributes and model commands in the historical configuration information of the object model, a first change condition determining unit configured to determine that a change condition of the object model includes a newly added first model attribute or a newly added first model command if the latest configuration information includes a first model attribute or a first model command not included in the historical configuration information, and a second change condition determining unit configured to determine that a change condition of the object model includes a modified third model attribute or a modified third model command if the historical configuration information includes a second model attribute or a second model command not included in the latest configuration information, and a third change condition determining unit configured to determine that the change condition of the object model includes a modified third model attribute or a modified third model command if the historical configuration information is different from the information of the third model attribute or the third model command in the latest configuration information.
On the basis of the embodiment, the code templates comprise an editable code template, the editable code template comprises an attribute function template, the corresponding code adjustment module 24 comprises an attribute function adding unit and an attribute function modifying unit, the attribute function adding unit is configured to generate a first attribute function code according to information of the first model attribute in the latest configuration information and the attribute function template if the change condition is new first model attribute, insert the first attribute function code into the editable code, the attribute function deleting unit is configured to determine a corresponding second attribute function code in the editable code according to information of the second model attribute in the historical configuration information if the change condition is deletion of the second model attribute, delete or annotate the second attribute function code in the editable code, and the attribute function modifying unit is configured to determine a corresponding third attribute function code in the editable code according to information of the third model attribute in the latest configuration information if the change condition is modification of the third model attribute.
On the basis of the embodiment, the code templates comprise an editable code template, the editable code template comprises a command function template, the corresponding code adjustment module 24 comprises a command function adding unit, a command function deleting unit and a command function modifying unit, wherein the command function adding unit is configured to generate a first command function code according to information of the first model command in the latest configuration information and the command function template and insert the first command function code into the editable code if the change condition is the new first model command, the command function deleting unit is configured to determine a corresponding second command function code in the editable code according to information of the second model command in the historical configuration information if the change condition is the deletion of the second model command, delete or annotate the second command function code in the editable code, and the command function modifying unit is configured to determine a corresponding third command function code in the editable code according to information of the third model command in the latest configuration information and adjust the third command function code in the editable code according to the information of the third model command in the latest configuration information if the change condition is the modification of the third model command.
On the basis of the embodiment, the code generating device of the object model further comprises a first statistics module, wherein the first statistics module is configured to search the first object model referencing the second model attribute through a regular search or syntax tree after deleting or annotating the second attribute function code in the editable code, determine a fourth attribute function code corresponding to the second model attribute in the editable code of the first object model, and generate first referencing statistics information of the second model attribute according to the code position of the fourth attribute function code in the editable code of the first object model.
On the basis of the embodiment, the code generating device of the object model further comprises a second statistical module, wherein the second statistical module is configured to search the second object model referencing the third model attribute through a regular search or a grammar tree after adjusting the third attribute function code in the editable code according to the information of the third model attribute in the latest configuration information, determine a fifth attribute function code corresponding to the third model attribute in the editable code of the second object model, and generate second referencing statistical information of the third model attribute according to the code position of the fifth attribute function code in the editable code of the second object model.
On the basis of the embodiment, the code generating device of the object model further comprises a third statistical module, wherein the third statistical module is configured to search a third object model referencing the second model command through a regular search or a grammar tree after deleting or annotating the second command function code in the editable code, determine a fourth command function code corresponding to the second model command in the editable code of the third object model, and generate third referencing statistical information of the second model command according to the code position of the fourth command function code in the editable code of the third object model.
The code generating device of the object model further comprises a fourth statistical module, wherein the fourth statistical module is configured to search the fourth object model referencing the third model command through a regular search or a grammar tree after adjusting the third command function code in the editable code according to the information of the third model command in the latest configuration information, determine a fifth command function code corresponding to the third model command in the editable code of the fourth object model, and generate fourth referencing statistical information of the third model command according to the code position of the fifth command function code in the editable code of the fourth object model.
On the basis of the above embodiment, the code generating device of the object model further includes a second code generating module configured to generate an editable code according to the latest configuration information and an editable code template in the code templates, and store the editable code in the second file, after judging whether the second file corresponding to the object model stores the editable code or not, in a case that the second file does not store the editable code.
On the basis of the above embodiment, the code generating apparatus of the object model further includes a code retention module configured to not adjust the editable code in the second file in a case where the model attribute and the model command of the object model do not change after determining the change case of the object model.
On the basis of the embodiment, the configuration information of the object model comprises a model name and a model description, correspondingly, the code generation device of the object model further comprises a fifth statistical module, and the fifth statistical module is configured to search the object code referring to the object model through a regular search or grammar tree under the condition that the change condition of the object model is modification of the model name and/or the model description after the change condition of the object model is determined, and generate the reference statistical information of the object model according to the code position of the object model in the object code.
The code generating device of the object model provided by the embodiment of the application generates the non-editable code of the object model according to the latest configuration information and the code template by acquiring the latest configuration information and the code template of the object model, stores the non-editable code into the first file corresponding to the object model, judges whether the second file corresponding to the object model stores the editable code or not, binds the first file and the second file through the file containing instruction, and determines the change condition of the object model under the condition that the second file stores the editable code, and adjusts the editable code stored in the second file according to the change condition. By the technical means, the codes of the object model are divided into the editable codes and the non-editable codes, the non-editable codes are stored in the first file to cover the old non-editable codes after the non-editable codes are generated based on the latest configuration information and the code template, the old editable codes in the second file are pertinently adjusted based on the change condition of the object model, so that the manual editing codes in the old editable codes are prevented from being covered, the reservation of the manual editing codes is realized, the problem that the object model can only be used by the codes of the object model manually required to be edited again in the prior art is solved, and the code editing efficiency and the practicability of the object model are improved.
The code generating device of the object model provided by the embodiment of the application can be used for executing the code generating method of the object model provided by the embodiment of the application, and has corresponding functions and beneficial effects.
Fig. 10 is a schematic structural diagram of a code generating apparatus for an object model according to an embodiment of the present application, and referring to fig. 10, the code generating apparatus for an object model includes a processor 31, a memory 32, a communication device 33, an input device 34, and an output device 35. The number of processors 31 in the code generating device of the object model may be one or more, and the number of memories 32 in the code generating device of the object model may be one or more. The processor 31, the memory 32, the communication means 33, the input means 34 and the output means 35 of the code generating device of the object model may be connected by a bus or other means.
The memory 32 is a computer-readable storage medium that can be used to store a software program, a computer-executable program, and modules, such as program instructions/modules corresponding to the code generation method of the object model according to any of the embodiments of the present application (e.g., the first code generation module 21, the code storage module 22, the file judgment module 23, and the code adjustment module 24 in the code generation apparatus of the object model). The memory 32 may mainly include a storage program area that may store an operating system, application programs required for at least one function, and a storage data area that may store data created according to the use of the device, etc. In addition, memory 32 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some examples, the memory may further include memory remotely located with respect to the processor, the remote memory being connectable to the device through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The communication means 33 are for data transmission.
The processor 31 executes various functional applications of the apparatus and data processing, that is, implements the code generation method of the object model described above, by executing software programs, instructions, and modules stored in the memory 32.
The input means 34 may be used to receive entered numeric or character information and to generate key signal inputs related to user settings and function control of the device. The output means 35 may comprise a display device such as a display screen.
The code generating device of the object model provided by the embodiment can be used for executing the code generating method of the object model provided by the embodiment, and has corresponding functions and beneficial effects.
The embodiment of the application also provides a storage medium containing computer executable instructions which, when executed by a computer processor, are used for executing a code generation method of an object model, the code generation method of the object model comprises the steps of obtaining the latest configuration information of the object model and a code template, and generating non-editable codes of the object model according to the latest configuration information and the code template; the method comprises the steps of storing an uneditable code in a first file corresponding to an object model, judging whether a second file corresponding to the object model stores the editable code or not, binding the first file and the second file through a file containing instruction, determining the change condition of the object model under the condition that the second file stores the editable code, and adjusting the editable code stored in the second file according to the change condition.
Storage media-any of various types of memory devices or storage devices. The term "storage medium" is intended to include mounting media such as CD-ROM, floppy disk or tape devices, computer system memory or random access memory such as DRAM, DDR RAM, SRAM, EDO RAM, lanbas (Rambus) RAM, etc., non-volatile memory such as flash memory, magnetic media (e.g., hard disk or optical storage), registers or other similar types of memory elements, etc. The storage medium may also include other types of memory or combinations thereof. In addition, the storage medium may be located in a first computer system in which the program is executed, or may be located in a second, different computer system connected to the first computer system through a network such as the internet. The second computer system may provide program instructions to the first computer for execution. The term "storage medium" may include two or more storage media residing in different locations (e.g., in different computer systems connected by a network). The storage medium may store program instructions (e.g., embodied as a computer program) executable by one or more processors.
Of course, the storage medium containing the computer executable instructions provided in the embodiments of the present application is not limited to the above method for generating the code of the object model, and may also perform the related operations in the method for generating the code of the object model provided in any embodiment of the present application.
The code generating device of the object model, the code generating system of the object model, the storage medium, and the code generating apparatus of the object model provided in the above embodiments may perform the code generating method of the object model provided in any embodiment of the present application, and technical details not described in detail in the above embodiments may be referred to the code generating method of the object model provided in any embodiment of the present application.
The foregoing description is only of the preferred embodiments of the application and the technical principles employed. The present application is not limited to the specific embodiments described herein, but is capable of numerous modifications, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the application. Therefore, while the application has been described in connection with the above embodiments, the application is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit of the application, the scope of which is set forth in the following claims.

Claims (15)

1.一种对象模型的代码生成方法,其特征在于,包括:1. A method for generating code for an object model, comprising: 获取对象模型的最新配置信息以及代码模板,根据所述最新配置信息以及所述代码模板生成所述对象模型的不可编辑代码;Acquire the latest configuration information and code template of the object model, and generate the non-editable code of the object model according to the latest configuration information and the code template; 将所述不可编辑代码存入所述对象模型对应的第一文件中;Storing the non-editable code in a first file corresponding to the object model; 判断所述对象模型对应的第二文件是否存储有可编辑代码,所述第一文件和所述第二文件通过文件包含指令绑定;Determining whether a second file corresponding to the object model stores editable code, the first file and the second file being bound by a file inclusion instruction; 在所述第二文件存储有可编辑代码的情况下,确定所述对象模型的变化情况,根据所述变化情况调整所述第二文件中存储的可编辑代码。In the case where the second file stores editable code, a change in the object model is determined, and the editable code stored in the second file is adjusted according to the change. 2.根据权利要求1所述的对象模型的代码生成方法,其特征在于,所述代码模板包括不可编辑代码模板;相应的,所述根据所述最新配置信息以及所述代码模板生成所述对象模型的不可编辑代码,包括:2. The method for generating code for an object model according to claim 1, wherein the code template comprises a non-editable code template; accordingly, generating the non-editable code of the object model according to the latest configuration information and the code template comprises: 根据所述最新配置信息和所述不可编辑代码模板生成不可编辑代码,所述不可编辑代码模板包括对象模型的结构体模板、构造函数模板、析构函数模板、属性声明模板、命令声明模板、属性分发函数模板和命令分发函数模板。Uneditable code is generated according to the latest configuration information and the uneditable code template, wherein the uneditable code template includes a structure template, a constructor template, a destructor template, a property declaration template, a command declaration template, a property dispatch function template and a command dispatch function template of an object model. 3.根据权利要求1所述的对象模型的代码生成方法,其特征在于,所述对象模型的配置信息包括模型属性和模型命令;相应的,所述确定所述对象模型的变化情况,包括:3. The method for generating code for an object model according to claim 1, wherein the configuration information of the object model includes model attributes and model commands; and correspondingly, determining the change of the object model includes: 将所述对象模型的最新配置信息中的模型属性和模型命令,对应与所述对象模型的历史配置信息中的模型属性和模型命令进行对比;Comparing the model attributes and model commands in the latest configuration information of the object model with the model attributes and model commands in the historical configuration information of the object model; 在所述最新配置信息包含有所述历史配置信息未包含的第一模型属性或第一模型命令的情况下,确定所述对象模型的变化情况包括新增第一模型属性或新增第一模型命令;In a case where the latest configuration information includes a first model attribute or a first model command that is not included in the historical configuration information, determining that the change of the object model includes a newly added first model attribute or a newly added first model command; 在所述历史配置信息包含有所述最新配置信息未包含的第二模型属性或第二模型命令的情况下,确定所述对象模型的变化情况包括删除第二模型属性或删除第二模型命令;In a case where the historical configuration information includes a second model attribute or a second model command that is not included in the latest configuration information, determining the change of the object model includes deleting the second model attribute or deleting the second model command; 在所述历史配置信息与所述最新配置信息中的第三模型属性或第三模型命令的信息不同的情况下,确定所述对象模型的变化情况包括修改第三模型属性或修改第三模型命令。In a case where information of a third model attribute or a third model command in the historical configuration information is different from information of the third model attribute or the third model command in the latest configuration information, determining the change of the object model includes modifying the third model attribute or modifying the third model command. 4.根据权利要求3所述的对象模型的代码生成方法,其特征在于,所述代码模板包括可编辑代码模板,所述可编辑代码模板包括属性函数模板;4. The code generation method of the object model according to claim 3, characterized in that the code template comprises an editable code template, and the editable code template comprises a property function template; 相应的,所述根据所述变化情况调整所述第二文件中存储的可编辑代码,包括:Correspondingly, adjusting the editable code stored in the second file according to the change includes: 若所述变化情况为新增第一模型属性,则根据所述最新配置信息中第一模型属性的信息以及所述属性函数模板生成第一属性函数代码,将所述第一属性函数代码插入所述可编辑代码中;If the change is the addition of a first model attribute, generating a first attribute function code according to the information of the first model attribute in the latest configuration information and the attribute function template, and inserting the first attribute function code into the editable code; 若所述变化情况为删除第二模型属性,则根据所述历史配置信息中第二模型属性的信息确定所述可编辑代码中对应的第二属性函数代码,删除或注释所述可编辑代码中的所述第二属性函数代码;If the change is deletion of the second model attribute, determining the corresponding second attribute function code in the editable code according to the information of the second model attribute in the historical configuration information, and deleting or commenting the second attribute function code in the editable code; 若所述变化情况为修改第三模型属性,则根据所述历史配置信息中第三模型属性的信息确定所述可编辑代码中对应的第三属性函数代码,根据所述最新配置信息中第三模型属性的信息调整所述可编辑代码中的第三属性函数代码。If the change is a modification of the third model attribute, the corresponding third attribute function code in the editable code is determined according to the information of the third model attribute in the historical configuration information, and the third attribute function code in the editable code is adjusted according to the information of the third model attribute in the latest configuration information. 5.根据权利要求3所述的对象模型的代码生成方法,其特征在于,所述代码模板包括可编辑代码模板,所述可编辑代码模板包括命令函数模板;5. The code generation method of the object model according to claim 3, characterized in that the code template comprises an editable code template, and the editable code template comprises a command function template; 相应的,所述根据所述变化情况调整所述第二文件中存储的可编辑代码,包括:Correspondingly, adjusting the editable code stored in the second file according to the change includes: 若所述变化情况为新增第一模型命令,则根据所述最新配置信息中第一模型命令的信息以及所述命令函数模板生成第一命令函数代码,将所述第一命令函数代码插入所述可编辑代码中;If the change is the addition of a first model command, generating a first command function code according to the information of the first model command in the latest configuration information and the command function template, and inserting the first command function code into the editable code; 若所述变化情况为删除第二模型命令,则根据所述历史配置信息中第二模型命令的信息确定所述可编辑代码中对应的第二命令函数代码,删除或注释所述可编辑代码中的所述第二命令函数代码;If the change is deletion of the second model command, determining the corresponding second command function code in the editable code according to the information of the second model command in the historical configuration information, and deleting or commenting the second command function code in the editable code; 若所述变化情况为修改第三模型命令,则根据所述历史配置信息中第三模型命令的信息确定所述可编辑代码中对应的第三命令函数代码,根据所述最新配置信息中第三模型命令的信息调整所述可编辑代码中的第三命令函数代码。If the change is to modify the third model command, the corresponding third command function code in the editable code is determined according to the information of the third model command in the historical configuration information, and the third command function code in the editable code is adjusted according to the information of the third model command in the latest configuration information. 6.根据权利要求4所述的对象模型的代码生成方法,其特征在于,在所述删除或注释所述可编辑代码中的所述第二属性函数代码之后,还包括:6. The method for generating code for an object model according to claim 4, characterized in that after deleting or commenting the second property function code in the editable code, it further comprises: 通过正则查找或语法树搜索引用所述第二模型属性的第一对象模型,并在所述第一对象模型的可编辑代码中确定所述第二模型属性对应的第四属性函数代码;Searching the first object model that references the second model attribute through regular expression search or syntax tree, and determining a fourth attribute function code corresponding to the second model attribute in the editable code of the first object model; 根据所述第一对象模型的可编辑代码中所述第四属性函数代码的代码位置,生成所述第二模型属性的第一引用统计信息。First reference statistical information of the second model attribute is generated according to the code position of the fourth attribute function code in the editable code of the first object model. 7.根据权利要求4所述的对象模型的代码生成方法,其特征在于,在所述根据所述最新配置信息中第三模型属性的信息调整所述可编辑代码中的第三属性函数代码之后,还包括:7. The method for generating code for an object model according to claim 4, characterized in that after adjusting the third attribute function code in the editable code according to the information of the third model attribute in the latest configuration information, it further comprises: 通过正则查找或语法树搜索引用所述第三模型属性的第二对象模型,并在所述第二对象模型的可编辑代码中确定所述第三模型属性对应的第五属性函数代码;Searching the second object model that references the third model attribute through regular expression search or syntax tree, and determining a fifth attribute function code corresponding to the third model attribute in the editable code of the second object model; 根据所述第二对象模型的可编辑代码中所述第五属性函数代码的代码位置,生成所述第三模型属性的第二引用统计信息。The second reference statistical information of the third model attribute is generated according to the code position of the fifth attribute function code in the editable code of the second object model. 8.根据权利要求5所述的对象模型的代码生成方法,其特征在于,在所述删除或注释所述可编辑代码中的所述第二命令函数代码之后,还包括:8. The method for generating code for an object model according to claim 5, characterized in that after deleting or commenting the second command function code in the editable code, it further comprises: 通过正则查找或语法树搜索引用所述第二模型命令的第三对象模型,并在所述第三对象模型的可编辑代码中确定所述第二模型命令对应的第四命令函数代码;Searching the third object model that references the second model command through regular expression search or syntax tree, and determining a fourth command function code corresponding to the second model command in the editable code of the third object model; 根据所述第三对象模型的可编辑代码中所述第四命令函数代码的代码位置,生成所述第二模型命令的第三引用统计信息。The third reference statistical information of the second model command is generated according to the code position of the fourth command function code in the editable code of the third object model. 9.根据权利要求5所述的对象模型的代码生成方法,其特征在于,在所述根据所述最新配置信息中第三模型命令的信息调整所述可编辑代码中的第三命令函数代码之后,还包括:9. The method for generating code for an object model according to claim 5, characterized in that after adjusting the third command function code in the editable code according to the information of the third model command in the latest configuration information, it further comprises: 通过正则查找或语法树搜索引用所述第三模型命令的第四对象模型,并在所述第四对象模型的可编辑代码中确定所述第三模型命令对应的第五命令函数代码;Searching a fourth object model that references the third model command through a regular expression search or a syntax tree, and determining a fifth command function code corresponding to the third model command in the editable code of the fourth object model; 根据所述第四对象模型的可编辑代码中所述第五命令函数代码的代码位置,生成所述第三模型命令的第四引用统计信息。Fourth reference statistical information of the third model command is generated according to the code position of the fifth command function code in the editable code of the fourth object model. 10.根据权利要求1所述的对象模型的代码生成方法,其特征在于,在所述判断所述对象模型对应的第二文件是否存储有可编辑代码之后,还包括:10. The method for generating code for an object model according to claim 1, characterized in that after determining whether the second file corresponding to the object model stores editable code, it further comprises: 在所述第二文件未存储有可编辑代码的情况下,根据所述最新配置信息和所述代码模板中的可编辑代码模板生成可编辑代码,将所述可编辑代码存入所述第二文件。In the case that the second file does not store editable code, editable code is generated according to the latest configuration information and an editable code template in the code template, and the editable code is stored in the second file. 11.根据权利要求3所述的对象模型的代码生成方法,其特征在于,在所述确定所述对象模型的变化情况之后,还包括:11. The method for generating code for an object model according to claim 3, characterized in that after determining the change of the object model, it further comprises: 在所述对象模型的模型属性和模型命令不发生变化的情况下,不调整所述第二文件中的可编辑代码。When the model attributes and the model commands of the object model do not change, the editable code in the second file is not adjusted. 12.根据权利要求1所述的对象模型的代码生成方法,其特征在于,所述对象模型的配置信息包括模型名称和模型描述;12. The code generation method of the object model according to claim 1, characterized in that the configuration information of the object model includes a model name and a model description; 相应的,在所述确定所述对象模型的变化情况之后,还包括:Accordingly, after determining the change of the object model, the method further includes: 在所述对象模型的变化情况为修改模型名称和/或模型描述的情况下,通过正则查找或语法树搜索引用所述对象模型的目标代码;When the change of the object model is to modify the model name and/or model description, the target code referencing the object model is searched by regular expression or syntax tree; 根据所述目标代码中所述对象模型的代码位置,生成所述对象模型的引用统计信息。Generate reference statistics of the object model according to the code position of the object model in the target code. 13.一种对象模型的代码生成装置,其特征在于,包括:13. A code generation device for an object model, characterized by comprising: 第一代码生成模块,被配置为获取对象模型的最新配置信息以及代码模板,根据所述最新配置信息以及所述代码模板生成所述对象模型的不可编辑代码;A first code generation module is configured to obtain the latest configuration information and a code template of the object model, and generate a non-editable code of the object model according to the latest configuration information and the code template; 代码存储模块,被配置为将所述不可编辑代码存入所述对象模型对应的第一文件中;A code storage module, configured to store the non-editable code into a first file corresponding to the object model; 文件判断模块,被配置为判断所述对象模型对应的第二文件是否存储有可编辑代码,所述第一文件和所述第二文件通过文件包含指令绑定;A file determination module is configured to determine whether a second file corresponding to the object model stores editable code, the first file and the second file being bound by a file inclusion instruction; 代码调整模块,被配置为在所述第二文件存储有可编辑代码的情况下,确定所述对象模型的变化情况,根据所述变化情况调整所述第二文件中存储的可编辑代码。The code adjustment module is configured to determine the change of the object model when the second file stores editable code, and adjust the editable code stored in the second file according to the change. 14.一种对象模型的代码生成设备,其特征在于,包括:一个或多个处理器;存储装置,存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-12任一所述的对象模型的代码生成方法。14. A code generation device for an object model, characterized in that it comprises: one or more processors; a storage device storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the code generation method for the object model as described in any one of claims 1-12. 15.一种包含计算机可执行指令的存储介质,其特征在于,所述计算机可执行指令在由计算机处理器执行时用于执行如权利要求1-12任一所述的对象模型的代码生成方法。15. A storage medium comprising computer executable instructions, wherein the computer executable instructions are used to execute the code generation method of the object model according to any one of claims 1 to 12 when executed by a computer processor.
CN202510102051.3A 2025-01-22 2025-01-22 Object model code generation method, device, equipment and storage medium Pending CN120196327A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202510102051.3A CN120196327A (en) 2025-01-22 2025-01-22 Object model code generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202510102051.3A CN120196327A (en) 2025-01-22 2025-01-22 Object model code generation method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN120196327A true CN120196327A (en) 2025-06-24

Family

ID=96070561

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202510102051.3A Pending CN120196327A (en) 2025-01-22 2025-01-22 Object model code generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN120196327A (en)

Similar Documents

Publication Publication Date Title
US6407753B1 (en) System and method for integrating entities via user-interactive rule-based matching and difference reconciliation
US8910117B2 (en) Customizing and performing policy in version control
CN112650766A (en) Database data operation method, system and server
US10331735B2 (en) Method and system for controlling a scheduling order per category in a music scheduling system
CN108762743A (en) Data table operation code generation method and device
CN119474363B (en) A method, apparatus, device, and storage medium for document generation
WO2022227409A1 (en) Embedded terminal remote software updating method
US11675748B2 (en) External data repository file integration using a virtual file system
CN120196327A (en) Object model code generation method, device, equipment and storage medium
CN118410077B (en) Data mining method, system, medium and equipment
WO2025145849A1 (en) Application program processing method and apparatus, computer device and storage medium
CN118733017A (en) A low-code development platform design system and method supporting multi-mode forms
WO2024250877A1 (en) Data card application building method and system, electronic device, and storage medium
CN117971259A (en) File reconstruction method, system and medium based on directed graph
CN115857780A (en) Form component processing method and device based on dragging tool, medium and equipment
CN111831262A (en) Mobile terminal portal construction method for government affair service platform
CN113961235A (en) Software management method, software management system and cloud platform
CN112860774A (en) Signal interface matching method and device, computer equipment and readable storage medium
Chandraiah et al. Creating explicit communication in SoC models using interactive re-coding
CN111767070A (en) API document management method and device, computer equipment and storage medium
CN120687430A (en) Visual modeling method, device and electronic equipment based on low-code platform
US8566778B2 (en) Using enterprise management application proxies for developing projects in program development tools
CN119046365A (en) Interface configuration processing method, device, computer equipment and readable storage medium
CN117271114A (en) Audit system, audit system working method, equipment, medium and product
CN118132058A (en) Code generation method, device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination