[go: up one dir, main page]

CN119739370A - Code generation method, system, electronic equipment and storage medium - Google Patents

Code generation method, system, electronic equipment and storage medium Download PDF

Info

Publication number
CN119739370A
CN119739370A CN202411709169.4A CN202411709169A CN119739370A CN 119739370 A CN119739370 A CN 119739370A CN 202411709169 A CN202411709169 A CN 202411709169A CN 119739370 A CN119739370 A CN 119739370A
Authority
CN
China
Prior art keywords
function
tree
code
processing
markup language
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
CN202411709169.4A
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.)
Shenzhen Lan You Technology Co Ltd
Original Assignee
Shenzhen Lan You Technology 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 Shenzhen Lan You Technology Co Ltd filed Critical Shenzhen Lan You Technology Co Ltd
Priority to CN202411709169.4A priority Critical patent/CN119739370A/en
Publication of CN119739370A publication Critical patent/CN119739370A/en
Pending legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The application discloses a code generation method, a system, electronic equipment and a storage medium, wherein the method comprises the steps of converting a function configuration table into a code logic table by acquiring the function configuration table; the method comprises the steps of carrying out graphic tree construction processing on a code logic table to obtain a function graphic tree, displaying an editing interface, responding to a target operation instruction, carrying out programming processing on nodes of the function graphic tree in a Cheng Huabu to generate an extensible markup language file, and carrying out code generation processing on the extensible markup language file to obtain a target code. The embodiment of the application can improve the code generation efficiency and can be widely applied to the technical field of computers.

Description

Code generation method, system, electronic equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a code generating method, a system, an electronic device, and a storage medium.
Background
In the related art, a developer needs to write and maintain repeated functional modules manually, so that common codes cannot be shared among all projects, and repeated work and resource waste are increased. In addition, the traditional code development requires developers to master various underlying libraries and tools, increases the complexity and entry difficulty of project development, limits the use of non-professionals, and influences the efficiency of code generation. In summary, the technical problems in the related art are to be improved.
Disclosure of Invention
The embodiment of the application mainly aims to provide a code generation method, a system, electronic equipment and a storage medium, which can improve the code generation efficiency.
To achieve the above object, an aspect of an embodiment of the present application provides a code generation method, including:
acquiring a function configuration table, and converting the function configuration table into a code logic table;
performing graph tree construction processing on the code logic table to obtain a function graph tree;
displaying an editing interface, wherein the editing interface comprises the function graphic tree and a programming canvas;
Responding to a target operation instruction, programming the nodes of the function graphic tree in the programming canvas to generate an extensible markup language file;
and carrying out code generation processing on the extensible markup language file to obtain an object code.
In some embodiments, the converting the function configuration table into a code logic table includes the steps of:
Classifying the function configuration table according to the function and the application scene to obtain a classification configuration table;
and carrying out numbering and control logic conversion processing on the classification configuration table to obtain the code logic table.
In some embodiments, the performing a graph tree construction process on the code logic table to obtain a function graph tree includes the following steps:
Performing object conversion processing on the code logic table to obtain a table data structure object;
sorting the table data structure objects to obtain a preprocessing data set;
And carrying out instance adding processing on the preprocessing data set according to the tree control to obtain the function graph tree.
In some embodiments, the sorting the table data structure objects to obtain a preprocessed data set includes the following steps:
carrying out grading treatment on the table data structure object according to the number to obtain grading data;
and performing subclass searching and sequence number sorting processing on the classified data to obtain the preprocessing data set.
In some embodiments, the responding to the target operation instruction carries out programming processing on the nodes of the function graphic tree in the programming canvas to generate an extensible markup language file, and the method comprises the following steps:
Dragging tree nodes of the function graphic tree to the programming canvas in response to a dragging operation instruction for the function graphic tree;
responding to a clicking operation instruction of the tree node, and displaying a function parameter panel in the editing interface;
and responding to the editing operation instruction of the function parameter panel, carrying out parameter editing processing on the function parameter panel, and generating the extensible markup language file.
In some embodiments, the parameter editing process is performed on the function parameter panel to generate the extensible markup language file, which includes the following steps:
Performing parameter editing processing on the function parameter panel to obtain a tree control object;
performing parameter transfer processing on the root node of the tree control object to obtain a document object;
And storing the document object according to the writing function to generate the extensible markup language file.
In some embodiments, the code generating process is performed on the extensible markup language file to obtain the target code, and the method includes the following steps:
Reading the extensible markup language file to obtain an element node object;
performing attribute analysis processing on the element node object to obtain a function name and a function parameter;
and performing code splicing processing on the function name and the function parameter to generate the target code.
To achieve the above object, another aspect of an embodiment of the present application provides a code generation system, including:
the first module is used for acquiring a function configuration table and converting the function configuration table into a code logic table;
the second module is used for carrying out graphic tree construction processing on the code logic table to obtain a function graphic tree;
A third module for displaying an editing interface comprising the function graphic tree and a programming canvas;
A fourth module, configured to respond to a target operation instruction, and perform programming processing on the nodes of the function graphic tree in the programming canvas to generate an extensible markup language file;
and a fifth module, configured to perform code generation processing on the extensible markup language file to obtain an object code.
To achieve the above object, another aspect of the embodiments of the present application provides an electronic device, including a memory and a processor, where the memory stores a computer program, and the processor implements the method described above when executing the computer program.
To achieve the above object, another aspect of the embodiments of the present application proposes a computer-readable storage medium storing a computer program which, when executed by a processor, implements the method described above.
The embodiment of the application at least has the beneficial effects that the application provides a code generation method, a system, electronic equipment and a storage medium, and the scheme converts the function configuration form into a code logic form by acquiring the function configuration form; the method comprises the steps of carrying out graphic tree construction processing on a code logic table to obtain a function graphic tree, displaying an editing interface, responding to a target operation instruction, carrying out programming processing on nodes of the function graphic tree in a Cheng Huabu to generate an extensible markup language file, and carrying out code generation processing on the extensible markup language file to obtain a target code. The embodiment of the application can simplify the function calling process to quickly generate codes through visual operation and modularized design, reduce the workload of developers and improve the code generation efficiency.
Drawings
FIG. 1 is a flow chart of a code generation method provided by an embodiment of the present application;
FIG. 2 is a schematic diagram of a functional graph tree provided by an embodiment of the present application;
FIG. 3 is a schematic diagram of an editing interface provided by an embodiment of the present application;
FIG. 4 is a schematic diagram of a code generation system according to an embodiment of the present application;
fig. 5 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with embodiments of the application, but are merely examples of systems and methods consistent with aspects of embodiments of the application as detailed in the accompanying claims.
It is to be understood that the terms "first," "second," and the like, as used herein, may be used to describe various concepts, but are not limited by these terms unless otherwise specified. These terms are only used to distinguish one concept from another. For example, the first information may also be referred to as second information, and similarly, the second information may also be referred to as first information, without departing from the scope of embodiments of the present application. The words "if", as used herein, may be interpreted as "when" or "in response to a determination", depending on the context.
The terms "at least one", "a plurality", "each", "any" and the like as used herein, at least one includes one, two or more, a plurality includes two or more, each means each of the corresponding plurality, and any one means any of the plurality.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of the application only and is not intended to be limiting of the application.
Before describing embodiments of the present application in detail, some of the terms and expressions that are referred to in the embodiments of the present application will be described first, and the terms and expressions that are referred to in the embodiments of the present application are applicable to the following explanation.
1) Extensible markup language (Extensible Markup Language, XML) is a markup language for storing and transmitting data, and is mainly used to define custom data structures so that different applications can share information more easily.
2) A graphical user interface (GRAPHICAL USER INTERFACE, GUI), also known as a graphical user interface, refers to a computer-operated user interface that is displayed in a graphical manner, allowing a user to manipulate icons or menu options on a screen using an input device such as a mouse to select commands, call files, launch programs, or perform some other daily task.
3) Python is a high-level, generic, interpreted programming language that provides an efficient, high-level data structure that can also be simply and efficiently programmed toward objects.
4) An integrated development environment (INTEGRATED DEVELOPMENT ENVIRONMENT, IDE) is an application program for providing a program development environment, generally including code editors, compilers, debuggers, and graphical user interfaces, among other tools.
In the related art, when using Python development projects, code writing is generally required depending on an Integrated Development Environment (IDE). One of the most popular IDE is PyCharm. When creating an item in PyCharm, the item name and the inventory first need to be defined, and the item created at this time is an empty item. Next, various components, such as database read-write components and application programming interface components (APIs), need to be written or introduced. While there are many base libraries available, these libraries often need to be packaged and customized by the project team to meet specific functional needs. This approach tends to result in longer project cycles and difficulty in achieving reuse of the components.
For example, in conventional development, a developer needs to write and maintain repeated functional modules manually, so that common codes cannot be shared among projects, repeated work and resource waste are increased, and the situation that an application program crashes or is abnormally terminated often occurs, so that the stability of the application program is poor, and the use experience is affected. When multiple project groups use the same function, any modification of the source function must be updated synchronously in all projects, which is not only inefficient, but also prone to version inconsistencies and errors. Traditional code development requires developers to master various underlying libraries and tools, increases complexity and entry difficulty of project development, and limits use by non-professionals.
In view of this, an embodiment of the present application provides a code generating method, a system, an electronic device, and a storage medium, where the method includes obtaining a function configuration table, converting the function configuration table into a code logic table, performing a graphic tree construction process on the code logic table to obtain a function graphic tree, displaying an editing interface, where the editing interface includes the function graphic tree and a programming canvas, performing a programming process on nodes of the function graphic tree in the programming Cheng Huabu in response to a target operation instruction to generate an extensible markup language file, and performing a code generating process on the extensible markup language file to obtain a target code. The embodiment of the application can simplify the function calling process to quickly generate codes through visual operation and modularized design, reduce the workload of developers and improve the code generation efficiency.
The embodiment of the application provides a code generation method, which relates to the technical field of computers. The code generation method provided by the embodiment of the application can be applied to a terminal, a server and software running in the terminal or the server. In some embodiments, the terminal may be, but not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a vehicle terminal, etc., the server may be configured as an independent physical server, may be configured as a server cluster or a distributed system formed by a plurality of physical servers, may be configured as a cloud server for providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, and basic cloud computing services such as big data and artificial intelligence platform, and the server may be a node server in a blockchain network, and the software may be an application for implementing a code generation method, etc., but is not limited to the above form.
The application is operational with numerous general purpose or special purpose computer system environments or configurations. Such as a personal computer, a server computer, a hand-held or portable device, a tablet device, a multiprocessor system, a microprocessor-based system, a set top box, a programmable consumer electronics, a network PC, a minicomputer, a mainframe computer, a distributed computing environment that includes any of the above systems or devices, and the like. The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
Fig. 1 is an optional flowchart of a code generation method according to an embodiment of the present application, where the method in fig. 1 may include, but is not limited to, steps S101 to S105.
Step S101, a function configuration table is obtained, and the function configuration table is converted into a code logic table;
Step S102, performing graphic tree construction processing on the code logic table to obtain a function graphic tree;
Step S103, displaying an editing interface, wherein the editing interface comprises the function graphic tree and a programming canvas;
Step S104, responding to a target operation instruction, programming the nodes of the function graphic tree in the programming canvas to generate an extensible markup language file;
step S105, code generation processing is carried out on the extensible markup language file, and target codes are obtained.
In steps S101 to S105 shown in the embodiment of the present application, by acquiring a manually maintained function configuration table, the function configuration table includes related data, such as a function code, a class, etc., that each function needs to be configured, and then converting the function configuration table into a code logic table using a python code. The function graph tree is obtained by performing graph tree construction processing on the code logic table, and comprises a plurality of different functions which are displayed in a tree form. An editing interface is displayed on a screen of the terminal, the editing interface including a function graphic tree, which may be disposed at the left side of the button Cheng Huabu, i.e., at the left side of the screen, and a programming canvas, which may be disposed at the center of the screen. In response to a target operation instruction, programming the nodes of the function graphic tree in the program Cheng Huabu to generate an extensible markup language file, wherein the target operation instruction is an operation instruction of a user on an editing interface, and can comprise operations such as dragging and clicking of a mouse, editing operations input by a keyboard and the like. Finally, the generated extensible markup language file is analyzed to generate the target code, and the embodiment of the application helps a developer drag nodes of the function graphic tree to canvas according to rules, so that the target code can be generated according to a business logic construction flow, thereby rapidly completing project development and improving code generation efficiency.
In step S101 of some embodiments, the converting the function configuration table into a code logic table includes the steps of:
Classifying the function configuration table according to the function and the application scene to obtain a classification configuration table;
and carrying out numbering and control logic conversion processing on the classification configuration table to obtain the code logic table.
In the embodiment of the application, the function configuration table is obtained by configuring the preset function through the Excel file, is manually maintained and is mainly used for convenient management, but cannot be directly used for generating the graphic tree. In one possible embodiment, the function configuration table includes field names, paraphrases, and concrete data, for example, the field names may include a first class, a second class, a third class, a function code, whether it is active, whether it may contain and icons, paraphrases for interpreting each field name, where the first class is the class that builds the highest level of the tree graph, the second class is the second class that builds the graph tree, is a subclass of the first class, the third class is the class of the function, each class identifies a function, the function code is the unique code of the function, whether it is an active representation that is a three class representation, or not, whether it may include a representation that the activity may be put into other functions, the icon represents the displayed icon name or the corresponding saved path. Specifically, a "system" is a first-level classification, and includes two three-level classifications of "files" of a second-level classification, "including under" create folders "and" whether paths exist ".
Specifically, the function configuration table is classified according to the function and the application scene to obtain a classification configuration table, and id and parent_id fields are added in the classification configuration table to store the relationship between primary classification and secondary classification and the relationship between secondary classification and tertiary classification through numbering and control logic conversion processing of the classification configuration table. The specific rule is that the primary class defines unique ids starting from 1 and sequentially incrementing (1, 2, 3.) all of their parent_ids (parent ids) are set to 0. The id of the secondary classification is incremented next to the id of the primary classification, and the id of the tertiary classification is then incremented next to the id of the secondary classification. The parent_id of the secondary classification points to the id of the corresponding primary classification according to the relation in the function configuration table, and the parent_id of the tertiary classification points to the id of the secondary classification, so that the correct hierarchical relation is established with the corresponding parent-child node. The embodiment of the application can obtain the classification configuration table by converting the python codes, wherein the conversion codes are as follows:
When the function is configured, the functions are required to be grouped according to the function category, and the attribute of each function is set, wherein the function attribute can comprise the function name, the function code, whether the function is active, whether the function can be contained or not, and the like. The method comprises the steps of setting corresponding control logic for each field, wherein the first class is the highest class of the function graphic tree, the second class is a sub class under the first class, and the first class is mainly classified according to the function type, for example, under the first class of [ application software integration ], the [ Excel ] and the [ PDF ] belong to the second class, and the document types processed by the first class and the second class are different. Three-level classification refers to a callable function that can be dragged directly onto the canvas for graphical programming, while primary and secondary cannot. Function coding defines a unique code for three levels of classification (i.e., specific functions) that is also known as the function name in the Python code. Finally, python codes generated by the flow files written by the canvas can be normally executed, and the core principle is that codes in the graphic tree are in one-to-one correspondence with function names in a written function library, so that the generated codes can accurately call corresponding functions. It should be noted that the primary and secondary classifications are used only for organization and classification and do not involve functional coding. Whether or not it is active can be understood as an identification field of the three-level classification, in the function configuration table, if the three-level classification is identified as "yes" or else left blank, when converted into the code logic table, the activity is identified as 1, otherwise, it is identified as 0. Whether or not the function can be included indicates whether or not the function can be put into other functions in the node after being dragged into the canvas, whether or not the function can be put into other functions can be included, and whether or not the function can not be put into other functions can be included. The icon represents the file name of the icon displayed on the graphic tree by the function, is used for binding the icon when the tree is generated, and improves the recognition degree of the function. A sequence number field may be added to the code logic table to indicate the sequence number at program transition, and is incremented from 0.
The technical scheme has the advantages that the code logic table is obtained by classifying the function configuration table and converting the control logic, the manually configured function configuration table can be converted into a format which can be identified by a programming language, so that the subsequent code generation processing is convenient, and the data processing efficiency is improved.
In step S102 of some embodiments, the performing a graph tree construction process on the code logic table to obtain a function graph tree includes the following steps:
Performing object conversion processing on the code logic table to obtain a table data structure object;
sorting the table data structure objects to obtain a preprocessing data set;
And carrying out instance adding processing on the preprocessing data set according to the tree control to obtain the function graph tree.
In an embodiment of the present application, a third party library in the Python language, such as Pandas library, may be used to read control configuration data from the code logic table, and convert the control configuration data into a table data structure object that can be processed in the Python language, that is, a DATAFRAME object, where DATAFRAME is one of the core data structures in Pandas, and is used to represent two-dimensional table data. It is similar to an Excel spreadsheet or SQL table, with rows and columns. Each column may contain a different data type, such as an integer, floating point number, string, or boolean value. And sorting the table data structure objects through numbers in the code logic table to obtain a preprocessing data set. Finally, performing instance adding processing on the preprocessed data set according to a tree control to obtain a function graphic tree, wherein the tree control can use QTREEWIDGET controls, and the tree node is composed of QTREEWIDGETITEM controls. The QTREEWIDGET control is a tree control, which can show the containing relation between data (or files) in a tree structure, and is used to refer to each piece of data in the tree structure as a node, and in the QTREEWIDGET control, each node is an instance object of QTREEWIDGETITEM types. That is, QTREEWIDGET objects represent the entire tree control, while QTREEWIDGETITEM objects represent nodes in the tree control. Thus, the process of building a function graph tree is actually a process of continuously adding QTREEWIDGETITEM instances to the tree, extracting fields therein according to the preprocessed data set that is preprocessed and screened, then creating QTREEWIDGETITEM instances one by one, and setting some control attributes for these instances, such as icon paths, whether dragging is allowed, whether other nodes can be included, and so on. When creating the tree node instance, the corresponding parent node instance needs to be transmitted in, so that the binding relation of the parent node and the child node is automatically established without manual processing. When all the function nodes are created in a recursive manner, a function graph tree is constructed, as shown in fig. 2, fig. 2 is a schematic diagram of a function graph tree provided by an embodiment of the present application, in fig. 2, reference numeral 201 represents a first class, 202 represents a second class, and 203 represents a third class.
The technical scheme has the advantages that the function graph tree is obtained by performing graph tree construction processing on the code logic table, functions can be displayed in a graph tree mode, visual operation is convenient to follow-up, corresponding codes can be rapidly stated according to the function graph tree, and code generation efficiency is improved.
In some embodiments, the sorting the table data structure objects to obtain a preprocessed data set includes the following steps:
carrying out grading treatment on the table data structure object according to the number to obtain grading data;
and performing subclass searching and sequence number sorting processing on the classified data to obtain the preprocessing data set.
In the embodiment of the application, the tree structure is obtained by preprocessing and constructing the table data structure object, and the tree structure is required to be constructed layer by layer, and the tree structure is firstly started from a trunk and then extends to branches and leaves. First, the data structure object of the first class classification table with parent_id of 0 is screened out, and the data structure object is ordered according to sequence numbers, and the classification with smaller sequence numbers is displayed in the tree at the front. After data screening is completed, the next step is to construct tree nodes. After the first class classification is processed, searching the corresponding subclass according to the id of the first class classification, wherein the searching logic is that the parent_id of the subclass is equal to the id of the parent class. Then, the sub-class data is ordered and corresponding tree nodes are constructed. This process is repeated until all three levels of classified data have been processed, resulting in a preprocessed dataset.
The technical scheme has the advantages that the table data structure objects are ordered, so that corresponding examples can be generated by matching in the process of constructing the subsequent graph tree, and the efficiency of generating the function graph tree is improved.
In step S104 of some embodiments, the step of responding to the target operation instruction, performing programming processing on the node of the function graphic tree in the programming canvas to generate an extensible markup language file, including the following steps:
Dragging tree nodes of the function graphic tree to the programming canvas in response to a dragging operation instruction for the function graphic tree;
responding to a clicking operation instruction of the tree node, and displaying a function parameter panel in the editing interface;
and responding to the editing operation instruction of the function parameter panel, carrying out parameter editing processing on the function parameter panel, and generating the extensible markup language file.
In an embodiment of the present application, referring to FIG. 3, reference numeral 301 in FIG. 3 represents a function graphic tree, reference numeral 302 represents a programming canvas, and reference numeral 303 represents a function parameter panel. And in response to the dragging operation instruction to the function graphic tree, dragging the tree nodes of the function graphic tree to the programming canvas, specifically, a user only needs to press the left mouse button to generate the dragging operation instruction, and drag the nodes in the tree structure to the programming canvas on the right side, so that the operation can be completed. This approach greatly reduces programming complexity, making function calls more intuitive. And then, responding to a clicking operation instruction on the tree node, displaying a function parameter panel in the editing interface, and displaying the function parameter panel when a user clicks the node in the canvas, namely clicking the corresponding function, wherein the function parameter panel is used for displaying parameters required by the function. The function parameter panel needs to be created in advance, and can be designed through a PyQt5 interface editor. And responding to the editing operation instruction of the function parameter panel, and performing parameter editing processing on the function parameter panel to generate an extensible markup language file. The user may input necessary parameters for the function according to actual circumstances, for example, parameters that must be input for the function of "open browser" include a web address (URL), a browser type, and the like.
The technical scheme has the advantages that the embodiment of the application helps a developer to quickly select and reuse the existing function library through visual dragging operation and modularized design, avoids repeated wheel making, and simplifies the code writing process. The method has the advantages that a developer does not need to deeply master the underlying code logic, only needs to complete the construction of complex functions through the interface operation, improves the efficiency and reliability of project development, reduces the code redundancy to the greatest extent, reduces the maintenance cost and improves the code generation efficiency.
In some embodiments, the parameter editing process is performed on the function parameter panel to generate the extensible markup language file, which includes the following steps:
Performing parameter editing processing on the function parameter panel to obtain a tree control object;
performing parameter transfer processing on the root node of the tree control object to obtain a document object;
And storing the document object according to the writing function to generate the extensible markup language file.
In the embodiment of the application, the program encoded by the canvas is saved as an XML (extensible markup language) file, specifically, a tree control object can be obtained by performing parameter editing processing on a function parameter panel, the tree control object exists in the form of QTREEWIDGET objects, one QTREEWIDGET object contains a plurality of QTREEWIDGETITEM objects (i.e. functions), and the QTREEWIDGET objects are converted into the XML file. It should be noted that QTREEWIDGETITEM stores a required-to-be-filled identification field (required), if empty, it is not required to be filled, and if 1, it is required to be filled. A root Element is generated by using an Element object of a third party Python library, such as lxml library, as a root node of the XML file. Wherein the Element object corresponds to an HTML tag Element of the web page. Each HTML tag Element is translated into an Element node object on the DOM tree. A recursion method is written, the root node of QTREEWIDGET objects and the root node of XML files are used as parameters to be transferred into the recursion method, the method can generate a complete XML document object, the XML document object is provided with a write function (write method), the document object can be stored as the XML files, and the XML document can be generated by inputting a storage path and calling the write function. Specifically, the code of the recursive method is as follows:
The technical scheme has the advantages that the embodiment of the application generates the extensible markup language file in the Cheng Huabu by performing parameter editing processing on the function parameter panel, can obviously simplify the function calling process through the graphical operation interface, and greatly improves the development efficiency.
In some embodiments, the code generating process is performed on the extensible markup language file to obtain the target code, and the method includes the following steps:
Reading the extensible markup language file to obtain an element node object;
performing attribute analysis processing on the element node object to obtain a function name and a function parameter;
and performing code splicing processing on the function name and the function parameter to generate the target code.
In the embodiment of the application, the XML file of the flow chart is read out by using the python third party library lxml to obtain an operable Element object, namely an Element node object. Then, the attribute analysis processing is carried out on the element node object, the function name can be obtained by reading the code attribute of the < action > element, then, the sub-element < attrs > of the < action > element is also read, and a plurality of < attr > elements are contained in the sub-element < attrs >, wherein the < attr > element is the function parameter. After the function names and the function parameters are obtained, the function names and the function parameters can be spliced into Python codes, and because the functions are written functions, the Python codes can be directly operated, and in the embodiment of the application, the operation result of the codes can be displayed in a programming canvas.
The technical scheme has the advantages that the embodiment of the application generates the extensible markup language file in a graphical programming mode, and converts the extensible markup language file into the target code, so that the code writing process can be simplified, and the code generating efficiency is improved.
The following describes and illustrates the embodiments of the present application in detail with reference to specific application examples:
The embodiment of the application can be applied to the technical field of computers, is suitable for generating scenes of code projects, is used for generating codes by editing by a developer, and can generate an operable code file by constructing a graphic function tree in advance, displaying the function graphic tree and a programming canvas in an editing interface, and only dragging the required functions onto the programming canvas and clicking and storing the functions. The method is not only suitable for professional software developers, but also suitable for common users. The embodiment of the application simplifies the function calling process through the graphic operation, obviously improves the development efficiency and reduces the repeated writing of the same codes. The functions can be managed and updated in a centralized way, and can be modified in a project rapidly and accurately without modifying call codes one by one. In addition, the embodiment of the application simplifies the project development process through a visual development mode, so that a user can finish the project by only dragging and configuring parameters, and the development difficulty is greatly reduced.
Referring to fig. 4, the embodiment of the present application further provides a code generation system, which may implement the code generation method, where the system includes:
A first module 401, configured to obtain a function configuration table, and convert the function configuration table into a code logic table;
A second module 402, configured to perform a graph tree construction process on the code logic table to obtain a function graph tree;
A third module 403, configured to display an editing interface, where the editing interface includes the function graphic tree and a programming canvas;
a fourth module 404, configured to respond to a target operation instruction, perform programming processing on the nodes of the function graphic tree in the programming canvas, and generate an extensible markup language file;
And a fifth module 405, configured to perform code generation processing on the extensible markup language file to obtain an object code.
It can be understood that the content in the above method embodiment is applicable to the system embodiment, and the functions specifically implemented by the system embodiment are the same as those of the above method embodiment, and the achieved beneficial effects are the same as those of the above method embodiment.
The embodiment of the application also provides electronic equipment, which comprises a memory and a processor, wherein the memory stores a computer program, and the processor realizes the code generation method when executing the computer program. The electronic equipment can be any intelligent terminal including a tablet personal computer, a vehicle-mounted computer and the like.
It can be understood that the content in the above method embodiment is applicable to the embodiment of the present apparatus, and the specific functions implemented by the embodiment of the present apparatus are the same as those of the embodiment of the above method, and the achieved beneficial effects are the same as those of the embodiment of the above method.
Referring to fig. 5, fig. 5 illustrates a hardware structure of an electronic device according to another embodiment, where the electronic device includes:
The processor 501 may be implemented by a general purpose CPU (Central Processing Unit ), a microprocessor, an Application SPECIFIC INTEGRATED Circuit (ASIC), or one or more integrated circuits, etc. for executing related programs to implement the technical solution provided by the embodiments of the present application;
The Memory 502 may be implemented in the form of a Read Only Memory (ROM), a static storage device, a dynamic storage device, or a random access Memory (Random Access Memory, RAM). Memory 502 may store an operating system and other application programs, and when the technical solutions provided in the embodiments of the present disclosure are implemented by software or firmware, relevant program codes are stored in memory 502, and the processor 501 invokes a code generation method for executing the embodiments of the present disclosure;
an input/output interface 503 for implementing information input and output;
The communication interface 504 is configured to implement communication interaction between the device and other devices, and may implement communication in a wired manner (e.g. USB, network cable, etc.), or may implement communication in a wireless manner (e.g. mobile network, WIFI, bluetooth, etc.);
Bus 505 that transfers information between the various components of the device (e.g., processor 501, memory 502, input/output interface 503, and communication interface 504);
Wherein the processor 501, the memory 502, the input/output interface 503 and the communication interface 504 enable a communication connection between each other inside the device via the bus 505.
The embodiment of the application also provides a computer readable storage medium storing a computer program which when executed by a processor realizes the code generation method.
It can be understood that the content of the above method embodiment is applicable to the present storage medium embodiment, and the functions of the present storage medium embodiment are the same as those of the above method embodiment, and the achieved beneficial effects are the same as those of the above method embodiment.
The memory, as a non-transitory computer readable storage medium, may be used to store non-transitory software programs as well as non-transitory computer executable programs. In addition, the memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory optionally includes memory remotely located relative to the processor, the remote memory being connectable to the processor 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 embodiment of the application provides a code generation method, a system, electronic equipment and a storage medium, wherein the scheme converts a function configuration table into a code logic table by acquiring the function configuration table; the method comprises the steps of carrying out graphic tree construction processing on a code logic table to obtain a function graphic tree, displaying an editing interface, responding to a target operation instruction, carrying out programming processing on nodes of the function graphic tree in a Cheng Huabu to generate an extensible markup language file, and carrying out code generation processing on the extensible markup language file to obtain a target code. The embodiment of the application can simplify the function calling process to quickly generate codes through visual operation and modularized design, reduce the workload of developers and improve the code generation efficiency.
The embodiments described in the embodiments of the present application are for more clearly describing the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application, and those skilled in the art can know that, with the evolution of technology and the appearance of new application scenarios, the technical solutions provided by the embodiments of the present application are equally applicable to similar technical problems.
It will be appreciated by persons skilled in the art that the embodiments of the application are not limited by the illustrations, and that more or fewer steps than those shown may be included, or certain steps may be combined, or different steps may be included.
The system embodiments described above are merely illustrative, in that the units illustrated as separate components may or may not be physically separate, i.e., may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
Those of ordinary skill in the art will appreciate that all or some of the steps of the methods, systems, functional modules/units in the devices disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof.
The terms "first," "second," "third," "fourth," and the like in the description of the application and in the above figures, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the application described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be understood that in the present application, "at least one (item)" means one or more, and "a plurality" means two or more. "and/or" is used to describe an association relationship of an associated object, and indicates that three relationships may exist, for example, "a and/or B" may indicate that only a exists, only B exists, and three cases of a and B exist simultaneously, where a and B may be singular or plural. The character "/" generally indicates that the context-dependent object is an "or" relationship. "at least one of" or the like means any combination of these items, including any combination of single item(s) or plural items(s). For example, at least one of a, b or c may represent a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
In the several embodiments provided by the present application, it should be understood that the disclosed systems and methods may be implemented in other ways. For example, the system embodiments described above are merely illustrative, e.g., the division of the above elements is merely a logical functional division, and there may be additional divisions in actual implementation, e.g., multiple elements or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interface, system or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described above as separate components may or may not be physically separate, and components shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied in essence or a part contributing to the prior art or all or part of the technical solution in the form of a software product stored in a storage medium, including multiple instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method of the various embodiments of the present application. The storage medium includes various media capable of storing programs, such as a U disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory RAM), a magnetic disk, or an optical disk.
The preferred embodiments of the present application have been described above with reference to the accompanying drawings, and are not thereby limiting the scope of the claims of the embodiments of the present application. Any modifications, equivalent substitutions and improvements made by those skilled in the art without departing from the scope and spirit of the embodiments of the present application shall fall within the scope of the claims of the embodiments of the present application.

Claims (10)

1. A code generation method, the method comprising the steps of:
acquiring a function configuration table, and converting the function configuration table into a code logic table;
performing graph tree construction processing on the code logic table to obtain a function graph tree;
displaying an editing interface, wherein the editing interface comprises the function graphic tree and a programming canvas;
Responding to a target operation instruction, programming the nodes of the function graphic tree in the programming canvas to generate an extensible markup language file;
and carrying out code generation processing on the extensible markup language file to obtain an object code.
2. The method of claim 1, wherein said converting said function configuration table into a code logic table comprises the steps of:
Classifying the function configuration table according to the function and the application scene to obtain a classification configuration table;
and carrying out numbering and control logic conversion processing on the classification configuration table to obtain the code logic table.
3. The method according to claim 1, wherein said performing a graph tree construction process on said code logic table results in a function graph tree, comprising the steps of:
Performing object conversion processing on the code logic table to obtain a table data structure object;
sorting the table data structure objects to obtain a preprocessing data set;
And carrying out instance adding processing on the preprocessing data set according to the tree control to obtain the function graph tree.
4. A method according to claim 3, wherein said sorting of said table data structure objects results in a preprocessed data set, comprising the steps of:
carrying out grading treatment on the table data structure object according to the number to obtain grading data;
and performing subclass searching and sequence number sorting processing on the classified data to obtain the preprocessing data set.
5. The method of claim 1, wherein the programming the nodes of the function graphic tree in the programming canvas in response to the target operation instruction to generate an extensible markup language file comprises the steps of:
Dragging tree nodes of the function graphic tree to the programming canvas in response to a dragging operation instruction for the function graphic tree;
responding to a clicking operation instruction of the tree node, and displaying a function parameter panel in the editing interface;
and responding to the editing operation instruction of the function parameter panel, carrying out parameter editing processing on the function parameter panel, and generating the extensible markup language file.
6. The method according to claim 5, wherein the performing parameter editing processing on the function parameter panel to generate the extensible markup language file includes the steps of:
Performing parameter editing processing on the function parameter panel to obtain a tree control object;
performing parameter transfer processing on the root node of the tree control object to obtain a document object;
And storing the document object according to the writing function to generate the extensible markup language file.
7. The method according to any one of claims 1 to 5, wherein the performing code generation processing on the extensible markup language file to obtain an object code includes the steps of:
Reading the extensible markup language file to obtain an element node object;
performing attribute analysis processing on the element node object to obtain a function name and a function parameter;
and performing code splicing processing on the function name and the function parameter to generate the target code.
8. A code generation system, the system comprising:
the first module is used for acquiring a function configuration table and converting the function configuration table into a code logic table;
the second module is used for carrying out graphic tree construction processing on the code logic table to obtain a function graphic tree;
A third module for displaying an editing interface comprising the function graphic tree and a programming canvas;
A fourth module, configured to respond to a target operation instruction, and perform programming processing on the nodes of the function graphic tree in the programming canvas to generate an extensible markup language file;
and a fifth module, configured to perform code generation processing on the extensible markup language file to obtain an object code.
9. An electronic device comprising a memory storing a computer program and a processor implementing the method of any of claims 1 to 7 when the computer program is executed by the processor.
10. A computer readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the method of any one of claims 1 to 7.
CN202411709169.4A 2024-11-27 2024-11-27 Code generation method, system, electronic equipment and storage medium Pending CN119739370A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411709169.4A CN119739370A (en) 2024-11-27 2024-11-27 Code generation method, system, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411709169.4A CN119739370A (en) 2024-11-27 2024-11-27 Code generation method, system, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN119739370A true CN119739370A (en) 2025-04-01

Family

ID=95129252

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411709169.4A Pending CN119739370A (en) 2024-11-27 2024-11-27 Code generation method, system, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN119739370A (en)

Similar Documents

Publication Publication Date Title
US7159185B1 (en) Function objects
US6973625B1 (en) Method for creating browser-based user interface applications using a framework
KR101120815B1 (en) Method and apparatus for generating user interfaces based upon automation with full flexibility
CN112199086B (en) Automatic programming control system, method, device, electronic equipment and storage medium
CN110825362A (en) Low-code application software development system and method
US11557088B2 (en) Generating space models from map files
US8839192B2 (en) System and method for presentation of cross organizational applications
US10248386B2 (en) Generating a software complex using superordinate design input
KR102016161B1 (en) Method and system for simplified knowledge engineering
CN110941427B (en) Code generation method and code generator
CN113961183B (en) Visual programming method, device, equipment and storage medium
US9684526B2 (en) Techniques for configuring a generic program using controls
CN112988165A (en) Kubernetes-based interactive modeling method and device, electronic equipment and storage medium
CN114281797A (en) Method for quickly creating basic level data aggregation warehouse based on agile low-code platform
US10776351B2 (en) Automatic core data service view generator
CN112825038A (en) Visual page making method based on general component language specification and related product
Yao et al. Building architectures for data‐intensive science using the ADAGE framework
Tesoriero et al. Transformation architecture for multi-layered WebApp source code generation
CN118152522A (en) Data query method, device, electronic device, storage medium and product
CN117270847A (en) Front-end page generation method and device, equipment and storage medium
CN119739370A (en) Code generation method, system, electronic equipment and storage medium
US20060005174A1 (en) Defining hierarchical structures with markup languages and reflection
Milovanović Python Data Visualization Cookbook
CN112162741A (en) Webpage code generation method, device, equipment and medium
CN104408120A (en) Source code processing method and device

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