A code generation method, system, electronic device and storage medium

By converting function configuration tables into code logic tables and constructing graphical trees, displaying an editing interface, and generating extensible markup language files through operations on a programming canvas, the target code is ultimately generated. This solves the problems of repetitive code maintenance and complexity, and improves code generation efficiency.

CN119739370BActive Publication Date: 2026-01-02SHENZHEN LANYOU TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411709169.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-27
Publication Date
2026-01-02
Estimated Expiration
2044-11-27

AI Technical Summary

Technical Problem

In existing technologies, developers need to manually write and maintain repetitive functional modules, which makes it impossible for projects to share common code, increases duplication of work and waste of resources. Furthermore, traditional code development requires developers to master various low-level libraries and tools, which increases the complexity of project development and the difficulty of getting started, and affects the efficiency of code generation.

Method used

By obtaining the function configuration table, converting it into a code logic table, and performing graphical tree construction, the editing interface is displayed, including the function graphical tree and the programming canvas. In response to operation instructions, programming processing is performed in the programming canvas to generate an extensible markup language file, and finally, code generation is performed.

Benefits of technology

It simplifies the function calling process, reduces the workload of developers, improves code generation efficiency, is suitable for both professional and general users, simplifies the project development process, and reduces development difficulty and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119739370B_ABST
    Figure CN119739370B_ABST
Patent Text Reader

Abstract

The application discloses a code generation method and system, electronic equipment and a storage medium. The method comprises the following steps: converting a function configuration table into a code logic table by acquiring the function configuration 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 graph tree and a programming canvas; in response to a target operation instruction, performing programming processing on nodes of the function graph tree in the programming canvas to generate an extensible markup language file; and performing code generation processing on the extensible markup language file to obtain target code. The embodiment of the application can improve the code generation efficiency and can be widely applied to the technical field of computers.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, and particularly relates to a code generation method and system, an electronic device and a storage medium. BACKGROUND

[0002] In the related art, developers need to manually write and maintain repetitive function modules, which leads to the inability to share common code between projects, increases repetitive work and resource waste. In addition, traditional code development requires developers to master various underlying libraries and tools, increasing the complexity and difficulty of project development, limiting the use of non-professionals, and affecting the efficiency of code generation. In summary, the technical problems existing in the related art need to be improved. SUMMARY

[0003] The main purpose of the embodiments of the present application is to provide a code generation method, system, electronic device and storage medium, which can improve the efficiency of code generation.

[0004] To achieve the above-mentioned purpose, one aspect of the embodiments of the present application provides a code generation method, which comprises:

[0005] obtaining a function configuration table and converting the function configuration table into a code logic table;

[0006] performing graph tree construction processing on the code logic table to obtain a function graph tree;

[0007] displaying an editing interface, wherein the editing interface comprises the function graph tree and a programming canvas;

[0008] in response to a target operation instruction, performing programming processing on the nodes of the function graph tree in the programming canvas to generate an extensible markup language file;

[0009] performing code generation processing on the extensible markup language file to obtain target code.

[0010] In some embodiments, the conversion of the function configuration table into a code logic table comprises the following steps:

[0011] performing classification processing on the function configuration table according to function functions and application scenarios to obtain a classified configuration table;

[0012] performing numbering and control logic conversion processing on the classified configuration table to obtain the code logic table.

[0013] In some embodiments, the graph tree construction processing on the code logic table to obtain a function graph tree comprises the following steps:

[0014] performing object conversion processing on the code logic table to obtain a table data structure object;

[0015] sorting the table data structure object to obtain a preprocessed data set;

[0016] adding instances to the preprocessed data set according to the tree control to obtain the function graph tree.

[0017] In some embodiments, the sorting the table data structure object to obtain a preprocessed data set comprises the following steps:

[0018] grading the table data structure object according to the number to obtain graded data;

[0019] performing subclass lookup and serial number sorting on the graded data to obtain the preprocessed data set.

[0020] In some embodiments, the programming the node of the function graph tree in the programming canvas in response to a target operation instruction to generate an extensible markup language file comprises the following steps:

[0021] dragging the tree node of the function graph tree to the programming canvas in response to a drag operation instruction on the function graph tree;

[0022] displaying a function parameter panel in the editing interface in response to a click operation instruction on the tree node;

[0023] performing parameter editing processing on the function parameter panel in response to an editing operation instruction on the function parameter panel to generate the extensible markup language file.

[0024] In some embodiments, the performing parameter editing processing on the function parameter panel to generate the extensible markup language file comprises the following steps:

[0025] performing parameter editing processing on the function parameter panel to obtain a tree control object;

[0026] performing parameter passing processing on the root node of the tree control object to obtain a document object;

[0027] performing saving processing on the document object according to a write function to generate the extensible markup language file.

[0028] In some embodiments, the code generation processing on the extensible markup language file to obtain target code comprises the following steps:

[0029] performing reading processing on the extensible markup language file to obtain an element node object;

[0030] Attribute parsing is performed on the element node object to obtain a function name and a function parameter;

[0031] Code splicing is performed on the function name and the function parameter to generate the target code.

[0032] To achieve the above object, another aspect of the embodiment of the present application provides a code generation system, which comprises:

[0033] A first module is configured to obtain a function configuration table and convert the function configuration table into a code logic table;

[0034] A second module is configured to perform graph tree construction processing on the code logic table to obtain a function graph tree;

[0035] A third module is configured to display an editing interface, wherein the editing interface comprises the function graph tree and a programming canvas;

[0036] A fourth module is configured to perform programming processing on nodes of the function graph tree in the programming canvas to generate an extensible markup language file in response to a target operation instruction;

[0037] A fifth module is configured to perform code generation processing on the extensible markup language file to obtain a target code.

[0038] To achieve the above object, another aspect of the embodiment of the present application provides an electronic device, which comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the method described above when executing the computer program.

[0039] To achieve the above object, another aspect of the embodiment of the present application provides a computer readable storage medium, which stores a computer program, and the computer program implements the method described above when executed by a processor.

[0040] The embodiment of the present application at least has the following beneficial effects: the present application provides a code generation method, system, electronic device and storage medium, which obtains a function configuration table, converts the function configuration table into a code logic table, performs graph tree construction processing on the code logic table to obtain a function graph tree, displays an editing interface, the editing interface comprises the function graph tree and a programming canvas, performs programming processing on nodes of the function graph tree in the programming canvas to generate an extensible markup language file in response to a target operation instruction, and performs code generation processing on the extensible markup language file to obtain a target code. The embodiment of the present application can simplify the calling process of a function and quickly generate code through visual operation and modular design, thereby reducing the workload of developers and improving the efficiency of code generation. BRIEF DESCRIPTION OF DRAWINGS

[0041] Figure 1 is a flowchart of a code generation method provided by an embodiment of the present application;

[0042] Figure 2 is a schematic diagram of a function graph tree provided by an embodiment of the present application;

[0043] Figure 3 is a schematic diagram of an editing interface provided by an embodiment of the present application;

[0044] Figure 4 is a structural schematic diagram of a code generation system provided by an embodiment of the present application;

[0045] Figure 5 is a hardware structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application. When the following description relates to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementation described in the following exemplary embodiments does not represent all the implementations consistent with the embodiments of the present application, but is only an example of systems and methods consistent with some aspects of the embodiments of the present application as detailed in the appended claims.

[0047] It can be understood that the terms "first", "second", and the like used in the present application can be used herein to describe various concepts, but unless specifically stated, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the embodiments of the present application, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information. Depending on the context, the word "if" as used herein can be interpreted as "when" or "when" or "in response to determining".

[0048] The terms "at least one", "multiple", "each", "any" and the like used in the present application include one, two or more than two, multiple includes two or more than two, each refers to each of the corresponding multiple, and any refers to any one of the multiple.

[0049] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as understood by those skilled in the art to which the present application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.

[0050] Before the embodiments of the present application are described in detail, first, some nouns and terms involved in the embodiments of the present application are explained, and the nouns and terms involved in the embodiments of the present application are applicable to the following explanations.

[0051] 1) Extensible Markup Language (XML) is a markup language used for storing and transmitting data, mainly used to define custom data structures so that different applications can share information more easily.

[0052] 2) Graphical User Interface (GUI), also known as graphical user interface, is a computer operation user interface displayed in a graphical manner, which allows users to use input devices such as mouse to manipulate icons or menu options on the screen to select commands, call files, start programs or perform other daily tasks.

[0053] 3) Python is a high-level, general-purpose, interpreted programming language that provides efficient high-level data structures and simple and effective object-oriented programming.

[0054] 4) Integrated Development Environment (IDE) is an application used to provide program development environment, which generally includes code editor, compiler, debugger and graphical user interface tools.

[0055] In the related art, when developing a project using Python, it is usually necessary to rely on an integrated development environment (IDE) to write code. One of the most popular IDEs currently is PyCharm. When creating a project in PyCharm, the project name and storage directory need to be defined first, and the project created at this time is an empty project. Next, various components need to be written or introduced, such as database read-write components and application programming interface components (APIs). Although there are many basic libraries available for use, these libraries often need to be packaged and customized by the project team to meet specific functional requirements. This approach often results in a longer project cycle and makes it difficult to reuse components.

[0056] Exemplarily, in a traditional development, a developer needs to manually write and maintain repetitive function modules, which leads to the inability to share common code among projects, increases repetitive work and resource waste, and often causes application crashes or abnormal termination, resulting in poor stability of the application and affecting the user experience. When multiple project groups use the same function, any changes to the source function must be updated synchronously in all projects, which is not only inefficient but also prone to version inconsistency and errors. Traditional code development requires developers to master various underlying libraries and tools, increasing the complexity and difficulty of project development, and limiting the use of non-professionals.

[0057] Therefore, the embodiments of the present application provide a code generation method and system, electronic equipment and storage medium. The method comprises the following steps: obtaining a function configuration table, 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, the editing interface comprising the function graph tree and a programming canvas; in response to a target operation instruction, performing programming processing on the nodes of the function graph tree in the programming canvas to generate an extensible markup language file; and performing code generation processing on the extensible markup language file to obtain target code. The embodiments of the present application can simplify the calling process of the function and quickly generate code through visual operation and modular design, thereby reducing the workload of the developer and improving the efficiency of code generation.

[0058] The code generation method provided by the embodiments of the present application relates to the technical field of computers. The code generation method provided by the embodiments of the present application can be applied to a terminal, can be applied to a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, a vehicle-mounted terminal, and the like, but is not limited thereto. The server can be configured as a standalone physical server, a server cluster composed of multiple physical servers, or a distributed system, and can also be configured as a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, big data, and artificial intelligence platforms. The server can also be a node server in a blockchain network. The software can be an application that implements the code generation method, but is not limited to the above forms.

[0059] The application is operable in a variety of general purpose or special purpose computing system environments or configurations. Examples of well-known computing systems, environments, and / or configurations that can be suitable for use with the application include personal computers, server computers, handheld or laptop devices, tablet devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The application can 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, and the like, that perform particular tasks or implement particular abstract data types. The application can 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 can be located in both local and remote computer storage media including memory storage devices.

[0060] Figure 1 is an optional flowchart of a code generation method provided by an embodiment of the application, Figure 1 The method in the code generation method provided by an embodiment of the application can include but is not limited to including steps S101 to S105.

[0061] Step S101, acquiring a function configuration table, and converting the function configuration table into a code logic table;

[0062] Step S102, performing graph tree construction processing on the code logic table to obtain a function graph tree;

[0063] Step S103, displaying an editing interface, the editing interface including the function graph tree and a programming canvas;

[0064] Step S104, in response to a target operation instruction, performing programming processing on a node of the function graph tree in the programming canvas to generate an extensible markup language file;

[0065] Step S105, performing code generation processing on the extensible markup language file to obtain target code.

[0066] The steps S101 to S105 shown in the embodiments of the present application, by acquiring the manually maintained function configuration table, the function configuration table includes the related data required for each function configuration, such as function code, category, etc., and then using the python code to convert the function configuration table into the code logic table. The function graph tree is obtained by performing graph tree construction processing on the code logic table, the function graph tree includes a plurality of different functions, and is displayed in the form of a tree. The editing interface of the terminal screen display includes the function graph tree and the programming canvas, the function graph tree can be arranged on the left side of the programming canvas, that is, the left side of the screen, and the programming canvas can be arranged in the center of the screen. In response to the target operation instruction, the nodes of the function graph tree are programmed in the programming canvas to generate an extensible markup language file, the target operation instruction is the operation instruction of the user to the editing interface, which can include mouse dragging, clicking and other operations, and can also include keyboard input editing operations. Finally, the generated extensible markup language file is parsed to generate target code. The embodiments of the present application help developers to drag the nodes of the function graph tree to the canvas according to the rules, can build the process according to the business logic to generate the target code, so as to quickly complete the development of the project, and improve the efficiency of code generation.

[0067] In step S101 of some embodiments, the function configuration table is converted into a code logic table, including the following steps:

[0068] According to the function function and application scene, the function configuration table is classified and processed to obtain a classified configuration table;

[0069] The classified configuration table is numbered and control logic conversion processed to obtain the code logic table.

[0070] In the embodiments of the present application, the preset function can be configured by an Excel file to obtain a function configuration table, which is a manually maintained table and is mainly used for facilitating management, but cannot be directly used to generate a graphical tree. In a feasible embodiment, the function configuration table includes field name, explanation and specific data. For example, the field name can include first-level classification, second-level classification, third-level classification, function code, whether it is active, whether it can be included, and icon. The explanation is used to explain each field name. The first-level classification is the highest level of classification for constructing a tree diagram. The second-level classification is a second-level classification for constructing a graphical tree, which is a subclass of the first-level classification. The third-level classification is the classification of a function, each classification identifies a function. The function code is the unique code of the function. Whether it is active indicates that if it is a third-level classification, it indicates that it is active, otherwise it is not. Whether it can be included indicates whether this activity can be placed in other functions. The icon indicates the icon name or the corresponding save path displayed. Specifically, the "system" is a first-level classification, the "system" includes the "file" of the second-level classification, and the "file" includes the "create folder" and "path exists" of the third-level classification.

[0071] Specifically, the function configuration table is classified and processed according to the function function and the application scenario to obtain a classification configuration table. The classification configuration table is obtained by numbering and control logic conversion processing. The classification configuration table adds id and parent_id fields, which are used to store the relationship between the first-level classification and the second-level classification, and the relationship between the second-level classification and the third-level classification. The specific rules are as follows: the first-level classification is defined with a unique id starting from 1 and increasing sequentially (1, 2, 3...), and their parent_id (parent id) is set to 0. The id of the second-level classification is incremented after the id of the first-level classification, and the id of the third-level classification is incremented after the id of the second-level classification. The parent_id of the second-level classification points to the id of the corresponding first-level classification according to the relationship in the function configuration table, and the parent_id of the third-level classification points to the id of the second-level classification, ensuring that the correct hierarchical relationship is established with the corresponding parent and child nodes. The embodiments of the present application can obtain the classification configuration table by using python code for conversion. The conversion code is as follows:

[0072]

[0073]

[0074] The embodiment of the application needs to group functions according to function categories when configuring functions, set the attributes of each function, and the function attributes can include function name, function code, whether it is active, and whether it can be contained. Among them, the corresponding control logic is set for each field, wherein the first-level classification is the highest level of the function graph tree, the second-level classification is the subcategory under the first-level classification, which is mainly divided according to the function type, for example, under the first-level classification of

application software integration

Excel

PDF

[0075] One of the above technical solutions has the following advantages or beneficial effects: the embodiment of the application obtains a code logic table by classifying and converting the control logic of the function configuration table, can convert the manually configured function configuration table into a format that can be recognized by a programming language, thereby facilitating subsequent code generation processing and improving data processing efficiency.

[0076] In step S102 of some embodiments, the code logic table is subjected to graph tree construction processing to obtain a function graph tree, including the following steps:

[0077] The code logic table is subjected to object conversion processing to obtain a table data structure object;

[0078] The table data structure object is subjected to sorting processing to obtain a preprocessed data set;

[0079] The preprocessed data set is subjected to instance addition processing according to a tree control to obtain the function graph tree.

[0080] In this embodiment, a third-party Python library, such as the Pandas library, can be used to read control configuration data from the code logic table and convert it into a tabular data structure object, i.e., a DataFrame object, which can be processed by the Python language. DataFrame is one of the core data structures in Pandas, used to represent two-dimensional tabular data. It is similar to an Excel spreadsheet or SQL table, with rows and columns. Each column can contain different data types, such as integers, floating-point numbers, strings, or Boolean values. The tabular data structure object is sorted according to its number in the code logic table to obtain a preprocessed dataset. Finally, instances of the preprocessed dataset are added using a tree control to obtain a function graph tree. The tree control can use a QTreeWidget control, and tree nodes are composed of QTreeWidgetItem controls. A QTreeWidget control is a tree control that displays the containment relationships between data (or files) in a tree structure. Each piece of data in the tree structure is conventionally called a node. In a QTreeWidget control, each node is an instance of the QTreeWidgetItem class. In other words, a QTreeWidget object represents the entire tree control, while a QTreeWidgetItem object represents a node within the tree control. Therefore, building a function graph tree is essentially a process of continuously adding QTreeWidgetItem instances to the tree. Based on the preprocessed dataset filtered through preprocessing, fields are extracted, and then QTreeWidgetItem instances are created one by one. Control properties are set for these instances, such as icon path, draggability, and whether they can contain other nodes. When creating a tree node instance, the corresponding parent node instance needs to be passed in, thus automatically establishing the parent-child node binding relationship without manual processing. Once all function nodes have been created recursively, the function graph tree is constructed, as shown below. Figure 2 As shown, Figure 2 This is a schematic diagram of a function graph tree provided in an embodiment of this application. Figure 2 In the attached diagram, 201 indicates a primary classification, 202 indicates a secondary classification, and 203 indicates a tertiary classification.

[0081] One of the above technical solutions has the following advantages or beneficial effects: The embodiments of this application obtain a function graph tree by performing graph tree construction processing on the code logic table, which can display the function in the form of a graph tree, thereby facilitating subsequent visualization operations, enabling the corresponding code to be quickly described based on the function graph tree, and improving code generation efficiency.

[0082] In some embodiments, the sorting processing on the table data structure object obtains a preprocessed data set, including the following steps:

[0083] The table data structure object is hierarchically processed according to the number to obtain hierarchical data.

[0084] The hierarchical data is processed by subclass searching and serial number sorting to obtain the preprocessed data set.

[0085] In the embodiments of the present application, the table data structure object is preprocessed to construct a tree structure, which needs to be constructed layer by layer, starting from the trunk and extending to the branches and leaves. First, the first-level classification table data structure object with parent_id of 0 is screened out, and sorted according to the serial number. The smaller the serial number, the earlier the classification is displayed in the tree. After data screening, the next step of constructing the tree node is entered. After processing the first-level classification, the corresponding subclasses are found according to the id of the first-level classification. The logic of the search is that the parent_id of the subclass is equal to the id of the parent class. Then, the subclass data is sorted and the corresponding tree node is constructed. Repeat this process until all the data of the third-level classification is processed to obtain the preprocessed data set.

[0086] One of the above technical solutions has the following advantages or beneficial effects: the embodiments of the present application can quickly generate corresponding instances by matching when constructing a function graph tree by sorting the table data structure object, thereby improving the efficiency of generating a function graph tree.

[0087] In step S104 of some embodiments, in response to a target operation instruction, the node of the function graph tree is programmed in the programming canvas to generate an extensible markup language file, including the following steps:

[0088] In response to a drag operation instruction on the function graph tree, the tree node of the function graph tree is dragged to the programming canvas.

[0089] In response to a click operation instruction on the tree node, a function parameter panel is displayed in the editing interface.

[0090] In response to an editing operation instruction on the function parameter panel, the function parameter panel is edited to generate the extensible markup language file.

[0091] In the embodiments of the present application, please refer to Figure 3 , Figure 3The reference sign 301 represents a function graph tree, the reference sign 302 represents a programming canvas, and the reference sign 303 represents a function parameter panel. In response to a drag operation instruction of the function graph tree, a tree node of the function graph tree is dragged to the programming canvas. Specifically, the user only needs to hold the left mouse button to generate the drag operation instruction, and drag the node in the tree structure to the right programming canvas, and the operation is completed. This way greatly reduces the complexity of programming, making the function call more intuitive. Then, in response to a click operation instruction of the tree node, a function parameter panel is displayed in the editing interface. When the user clicks the node in the canvas, that is, clicks the corresponding function, the function parameter panel is displayed, which is used to display the required parameters of the function. The function parameter panel needs to be created in advance, and can be designed through a PyQt5 interface editor. In response to an editing operation instruction of the function parameter panel, the function parameter panel is subjected to parameter editing processing to generate an extensible markup language file. The user can input the necessary parameters for the function according to the actual situation. For example, for the function of “opening a browser”, the necessary parameters include the URL and the browser type.

[0092] One of the above technical solutions has the following advantages or beneficial effects: the embodiment of the application helps developers to quickly select and reuse existing function libraries through visual drag-and-drop operation and modular design, avoids repeated wheel-reinventing, and thus simplifies the code writing process. It also enables developers to master the underlying code logic without deep understanding, and only needs to complete the construction of complex functions through an interface operation, thereby improving the efficiency and reliability of project development, minimizing code redundancy, reducing maintenance costs, and improving code generation efficiency.

[0093] In some embodiments, the parameter editing processing of the function parameter panel to generate the extensible markup language file includes the following steps:

[0094] The parameter editing processing of the function parameter panel obtains a tree control object.

[0095] The parameter transmission processing of the root node of the tree control object obtains a document object.

[0096] The saving processing of the document object according to the writing function generates the extensible markup language file.

[0097] In the embodiment of the present application, the program written with the canvas is saved as an XML (Extensible Markup Language) file. Specifically, a tree control object can be obtained by parameter editing processing on the function parameter panel, and the tree control object exists in the form of a QTreeWidget object. A QTreeWidget object contains a plurality of QTreeWidgetItem objects (i.e., functions). The QTreeWidget object is converted into an XML file. It should be noted that the QTreeWidgetItem object stores a required check identification field (required). If the required check identification field is empty, it is not required. If the required check identification field is 1, it is required. A root element is generated by using a third-party Python library, such as an lxml library, and the root element is used as a root node of the XML file. Each HTML tag element is converted into an Element node object on a DOM tree. A recursive method is written, and the root node of the QTreeWidget object and the root node of the XML file are used as parameters of the recursive method. The recursive method generates a complete XML document object. The XML document object has a write function (write method), which can save the document object as an XML file. The write function can be called by inputting a save path to generate an Extensible Markup Language file. Specifically, the code of the recursive method is as follows:

[0098]

[0099]

[0100] One of the above technical solutions has the following advantages or beneficial effects: In the embodiment of the present application, an Extensible Markup Language file is generated in the programming canvas by parameter editing processing on the function parameter panel. The function calling process is significantly simplified through a graphical operation interface, and the development efficiency is greatly improved.

[0101] In some embodiments, the code generation processing on the Extensible Markup Language file to obtain the target code includes the following steps:

[0102] The Extensible Markup Language file is read to obtain an element node object.

[0103] The element node object is subjected to attribute analysis processing to obtain a function name and a function parameter.

[0104] The function name and the function parameter are subjected to code splicing processing to generate the target code.

[0105] In the embodiment of the present application, the XML file of the flowchart is read out by using the third-party library lxml of python, to obtain an operable Element object, i.e., an element node object. Then, attribute analysis processing is performed on the element node object, and the processing result is obtained by reading <action>The code attribute of an element can get the function name and then <action>child of an element <attrs>Reading also occurs in sub-elements <attrs>Among them again contain many <attr>elements, <attr>The element is a function parameter. After obtaining the function name and the function parameter, the function name and the parameter are spliced into Python code. Since the functions are already written, the Python code can be directly run. In the embodiment of the application, the running result of the code can be displayed in the programming canvas.

[0106] One of the technical solutions has the following advantages or beneficial effects: the embodiment of the application generates an extensible markup language file through a graphical programming method, and then converts the extensible markup language file into target code, which can simplify the code writing process and improve the code generation efficiency.

[0107] In the following, the scheme of the embodiment of the application is described and explained in detail in combination with specific application examples:

[0108] The embodiment of the application can be applied to the field of computer technology and is suitable for the generation of code projects. Developers need to edit and generate code. A function graph tree is constructed in advance, and the function graph tree and a programming canvas are displayed in an editing interface. Developers only need to drag the required functions to the programming canvas and then click save to generate a runnable code file. This method is not only suitable for professional software developers but also suitable for ordinary users. The embodiment of the application simplifies the function calling process through graphical operation, significantly improves the development efficiency, and reduces the repeated writing of the same code. The function can be centrally managed and updated, and the function can be quickly and accurately synchronized in the project without modifying the calling code one by one. In addition, the embodiment of the application simplifies the project development process through a visual development method, so that users can complete the project by only dragging and configuring parameters, which greatly reduces the development difficulty.

[0109] Please refer to Figure 4 The embodiment of the application also provides a code generation system, which can implement the code generation method described above. The system comprises:

[0110] The first module 401 is configured to obtain a function configuration table and convert the function configuration table into a code logic table.

[0111] The second module 402 is configured to perform graph tree construction processing on the code logic table to obtain a function graph tree.

[0112] The third module 403 is configured to display an editing interface, wherein the editing interface comprises the function graph tree and a programming canvas.

[0113] The fourth module 404 is configured to perform programming processing on the nodes of the function graph tree in the programming canvas in response to a target operation instruction to generate an extensible markup language file.

[0114] The fifth module 405 is configured to perform code generation processing on the extensible markup language file to obtain target code.

[0115] It can be understood that the content in the above method embodiments is applicable to the present system embodiments, the present system embodiments specifically implement the same functions as the above method embodiments, and achieve the same beneficial effects as the above method embodiments.

[0116] The present application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor implements the above code generation method when executing the computer program. The electronic device can be any smart terminal, such as a tablet computer or a vehicle-mounted computer.

[0117] It can be understood that the content in the above method embodiments is applicable to the present device embodiments, the present device embodiments specifically implement the same functions as the above method embodiments, and achieve the same beneficial effects as the above method embodiments.

[0118] Please refer to Figure 5 , Figure 5 The hardware structure of the electronic device of another embodiment is illustrated, and the electronic device includes:

[0119] The processor 501 can be implemented in the form of a general-purpose CPU (Central Processing Unit), a microprocessor, an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits, and is used to execute related programs to implement the technical solutions provided by the embodiments of the present application.

[0120] The memory 502 can be implemented in the form of a ROM (Read Only Memory), a static storage device, a dynamic storage device, or a RAM (Random Access Memory). The memory 502 can store an operating system and other application programs. When the technical solutions provided by the embodiments of the present application are implemented by software or firmware, the related program codes are stored in the memory 502 and are called and executed by the processor 501 to implement the code generation method of the present application.

[0121] The input / output interface 503 is used to realize information input and output.

[0122] The communication interface 504 is configured to realize the communication interaction between the device and other devices, and can realize the communication through a wired manner (for example, a USB, a network cable, or the like) or a wireless manner (for example, a mobile network, WIFI, Bluetooth, or the like).

[0123] The bus 505 is configured to transmit information between various components (for example, the processor 501, the memory 502, the input / output interface 503, and the communication interface 504) of the device.

[0124] The processor 501, the memory 502, the input / output interface 503, and the communication interface 504 are communicatively connected to each other in the device through the bus 505.

[0125] The embodiment of the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to realize the code generation method.

[0126] It can be understood that the contents in the above method embodiments are applicable to the storage medium embodiments, the storage medium embodiments specifically realize the functions of the above method embodiments, and the beneficial effects achieved by the storage medium embodiments are the same as the beneficial effects achieved by the above method embodiments.

[0127] The memory is a non-transitory computer readable storage medium, and can be used to store a non-transitory software program and a non-transitory computer executable program. In addition, the memory can include a high-speed random access memory, and can further include a non-transitory memory, for example, at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state memory device. In some embodiments, the memory can optionally include a memory remotely arranged relative to the processor, and the remote memory can be connected to the processor through a network. Examples of the network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0128] The code generation method, system, electronic device, and storage medium provided by the embodiment of the present application, the scheme is to obtain a function configuration table, convert the function configuration table into a code logic table; perform graph tree construction processing on the code logic table to obtain a function graph tree; display an editing interface, the editing interface includes the function graph tree and a programming canvas; in response to a target operation instruction, perform programming processing on the nodes of the function graph tree in the programming canvas to generate an extensible markup language file; and perform code generation processing on the extensible markup language file to obtain target code. Through the visual operation and the modular design, the embodiment of the present application can simplify the calling process of the function and quickly generate the code, reduce the workload of the developer, and improve the efficiency of the code generation.

[0129] The embodiments described in the specification are for more clearly illustrating 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. 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 also applicable to similar technical problems.

[0130] Those skilled in the art can understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and can include more or fewer steps than shown in the figures, or combine certain steps, or different steps.

[0131] The system embodiments described above are merely illustrative, and the units described as separate components can or can not be physically separated, i.e., can be located in one place, or can be distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments of the present application.

[0132] Those skilled in the art can understand that all or some of the steps in the above disclosed method, the functional modules / units in the system, and the device can be implemented as software, firmware, hardware, and appropriate combinations thereof.

[0133] The terms "first", "second", "third", "fourth" and the like (if any) in the specification of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0134] It should be understood that, in the application, "at least one" refers to one or more, "multiple" refers to two or more. "And / or", used to describe the association between the associated objects, means that there can be three relationships, for example, "A and / or B" can mean: only A, only B, and A and B exist at the same time, where A, B can be singular or plural. The character " / " generally represents the relationship between the front and rear associated objects as "or". "At least one of the following" or the like refers to any combination of these items, including any combination of single or multiple items. For example, at least one of a, b or c, can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0135] In several embodiments provided in the application, it should be understood that the disclosed system and method can be implemented in other ways. For example, the system embodiments described above are only illustrative, for example, the division of the above units is only a logical functional division, and actual implementation can have another division, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed each other can be through some interface, indirect coupling or communication connection between systems or units, which can be electrical, mechanical or other forms.

[0136] The units described above as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or they can be distributed on multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.

[0137] In addition, each functional unit in each embodiment of the application can be integrated into a processing unit, or each unit can exist physically, or two or more units can be integrated into one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0138] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, essentially or in other words, the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes multiple instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various program storage media.

[0139] The preferred embodiments of the embodiments of the present application are described above with reference to the accompanying drawings, and are not limited to the scope of the embodiments of the present application. Any modifications, equivalent replacements and improvements made by those skilled in the art without departing from the scope and essence of the embodiments of the present application shall be within the scope of the embodiments of the present application.< / attr> < / attr> < / attrs> < / attrs> < / action> < / action>

Claims

1. A code generation method characterized by, The method comprises the following steps: obtaining 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 graph tree and a programming canvas; in response to a target operation instruction, performing programming processing on nodes of the function graph tree in the programming canvas to generate an extensible markup language file; performing code generation processing on the extensible markup language file to obtain target code; the conversion of the function configuration table into the code logic table comprises the following steps: performing classification processing on the function configuration table according to function functions and application scenarios to obtain a classified configuration table; performing numbering and control logic conversion processing on the classified configuration table to obtain the code logic table; the graph tree construction processing on the code logic table to obtain the function graph tree comprises the following steps: performing object conversion processing on the code logic table to obtain a table data structure object; performing sorting processing on the table data structure object to obtain a pretreatment data set; performing instance adding processing on the pretreatment data set according to a tree control to obtain the function graph tree; the programming processing on the nodes of the function graph tree in the programming canvas to generate the extensible markup language file in response to the target operation instruction comprises the following steps: in response to a drag operation instruction for the function graph tree, dragging a tree node of the function graph tree to the programming canvas; in response to a click operation instruction for the tree node, displaying a function parameter panel in the editing interface; in response to an editing operation instruction for the function parameter panel, performing parameter editing processing on the function parameter panel to generate the extensible markup language file.

2. The method of claim 1, wherein, the sorting processing on the table data structure object to obtain the pretreatment data set comprises the following steps: performing hierarchical processing on the table data structure object according to numbering to obtain hierarchical data; performing subclass searching and serial number sorting processing on the hierarchical data to obtain the pretreatment data set.

3. The method of claim 1, wherein, the parameter editing processing on the function parameter panel to generate the extensible markup language file comprises the following steps: performing parameter editing processing on the function parameter panel to obtain a tree control object; performing parameter transmission processing on a root node of the tree control object to obtain a document object; performing saving processing on the document object according to a writing function to generate the extensible markup language file.

4. The method according to any one of claims 1 to 3, characterized in that, the code generation processing on the extensible markup language file to obtain the target code comprises the following steps: performing reading processing on 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; performing code splicing processing on the function name and the function parameter to generate the target code.

5. A code generation system characterized by, The system comprises: a first module configured to obtain a function configuration table, and convert the function configuration table into a code logic table; a second module configured to perform graph tree construction processing on the code logic table to obtain a function graph tree; The third module is configured to display an editing interface, wherein the editing interface comprises the function graph tree and a programming canvas. The fourth module is configured to, in response to a target operation instruction, perform programming processing on nodes of the function graph tree in the programming canvas to generate an extensible markup language file. The fifth module is configured to perform code generation processing on the extensible markup language file to obtain target code. The first module is configured to convert the function configuration table into a code logic table, and the conversion comprises: performing classification processing on the function configuration table according to function functions and application scenarios to obtain a classified configuration table; performing numbering and control logic conversion processing on the classified configuration table to obtain the code logic table. The second module is configured to perform graph tree construction processing on the code logic table to obtain a function graph tree, and the construction processing comprises: performing object conversion processing on the code logic table to obtain a table data structure object; performing sorting processing on the table data structure object to obtain a preprocessed data set; performing instance adding processing on the preprocessed data set according to a tree-shaped control to obtain the function graph tree. The fourth module is configured to, in response to a target operation instruction, perform programming processing on nodes of the function graph tree in the programming canvas to generate an extensible markup language file, and the programming processing comprises: in response to a drag operation instruction on the function graph tree, dragging a tree node of the function graph tree to the programming canvas; in response to a click operation instruction on the tree node, displaying a function parameter panel in the editing interface; in response to an editing operation instruction on the function parameter panel, performing parameter editing processing on the function parameter panel to generate the extensible markup language file.

6. An electronic device, comprising: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method in any one of claims 1 to 4 when executing the computer program.

7. A computer-readable storage medium storing a computer program, wherein the computer program comprises the following steps of: receiving a request for a resource from a client; determining whether the client is authorized to access the resource; and if the client is authorized to access the resource, providing the resource to the client. The computer program, when executed by a processor, implements the method in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Low-code development method and device, equipment and storage medium

    CN115712413A

  • Visualization method for dynamic function call

    CN115952230A