CN112256279A - Source code conversion method and device, computer equipment and readable storage medium - Google Patents

Source code conversion method and device, computer equipment and readable storage medium Download PDF

Info

Publication number
CN112256279A
CN112256279A CN202011045973.9A CN202011045973A CN112256279A CN 112256279 A CN112256279 A CN 112256279A CN 202011045973 A CN202011045973 A CN 202011045973A CN 112256279 A CN112256279 A CN 112256279A
Authority
CN
China
Prior art keywords
source code
driving frame
attribute information
function
initial
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.)
Granted
Application number
CN202011045973.9A
Other languages
Chinese (zh)
Other versions
CN112256279B (en
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.)
Fibocom Wireless Inc
Original Assignee
Fibocom Wireless Inc
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 Fibocom Wireless Inc filed Critical Fibocom Wireless Inc
Priority to CN202011045973.9A priority Critical patent/CN112256279B/en
Priority claimed from CN202011045973.9A external-priority patent/CN112256279B/en
Publication of CN112256279A publication Critical patent/CN112256279A/en
Application granted granted Critical
Publication of CN112256279B publication Critical patent/CN112256279B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/51Source to source
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4411Configuring for operating with peripheral devices; Loading of device drivers

Abstract

The application relates to a source code conversion method, a source code conversion device, a computer device and a readable storage medium. The method comprises the following steps: receiving a source code conversion tool opening instruction, responding to the source code conversion tool opening instruction, identifying the source code of the initial driving frame to obtain an identification result, and converting the source code of the initial driving frame into a source code of a target driving frame according to the identification result; according to the method, the source codes of the initial driving frame can be automatically converted into the source codes of the target driving frame through the source code conversion tool, developers are prevented from manually rewriting the source codes of the driving frame, and therefore conversion efficiency of the source codes of different driving frames is improved.

Description

Source code conversion method and device, computer equipment and readable storage medium
Technical Field
The present application relates to the field of operating systems, and in particular, to a method and an apparatus for source code conversion, a computer device, and a readable storage medium.
Background
Windows and Linux are two most common operating systems at present, and different operating systems only have corresponding functions realized by the source codes of the drive framework under corresponding environments. For a cross-platform operating system, the source code of the Windows driver framework and the source code of the Linux driver framework can be executed, and therefore, in the operating system, the interconversion between the source code of the Windows driver framework and the source code of the Linux driver framework needs to be realized so as to meet the actual requirement of the cross-platform operating system.
In the conventional technology, a current cross-platform operating system is configured with Windows drive framework source codes, and if the cross-platform operating system currently needs to execute Linux drive framework source codes, developers can rewrite the Windows drive framework source codes into the Linux drive framework source codes in a development environment so as to meet the requirements of the current cross-platform operating system. However, the conventional source code conversion method may reduce the conversion efficiency of the source code of different driving frames.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a source code conversion method, a source code conversion apparatus, a computer device, and a readable storage medium, which can improve source code conversion efficiency of different driving frameworks.
A method of source code conversion, the method comprising:
receiving a source code conversion tool opening instruction;
responding to the source code conversion tool opening instruction, and identifying the source code of the initial driving frame to obtain an identification result; wherein the identification result comprises first attribute information of the function and second attribute information of the data contained in the initial driving framework source code;
and converting the source code of the initial driving frame into the source code of the target driving frame according to the identification result.
In one embodiment, the identifying, in response to the source code conversion tool opening instruction, the source code of the initial driving framework to obtain an identification result includes:
identifying and processing an application program interface function in the source code of the initial driving frame to obtain first attribute information;
identifying data in the source code of the initial driving frame to obtain second attribute information;
the first attribute information represents the type of the application program interface function, and the second attribute information represents the type of the data.
In one embodiment, the identifying the application program interface function in the source code of the initial driving framework to obtain the first attribute information includes:
traversing each application program interface function in the source code of the initial driving frame, and identifying the traversed application program interface function to obtain the first attribute information;
the identifying and processing the data in the source code of the initial driving frame to obtain second attribute information includes:
traversing each data in the source code of the initial driving frame, and identifying the traversed data to obtain the second attribute information.
In one embodiment, the converting the initial driving framework source code into the target driving framework source code according to the recognition result includes:
judging whether the identification result meets the source code conversion requirement or not; the source code conversion requirement represents that first attribute information and second attribute information in the identification result conform to a preset conversion standard of the source code of the driving framework to be converted;
and if so, converting the source code of the initial driving frame into the source code of the target driving frame.
In one embodiment, the method further comprises:
and if not, editing and modifying the initial driving frame source code according to the acquired first editing instruction to obtain a first driving frame source code, and converting the first driving frame source code into the target driving frame source code.
In one embodiment, the method further comprises:
editing and modifying the initial drive function file in the first drive frame source code according to the obtained second editing instruction to obtain a second drive frame source code, and converting the second drive frame source code into the target drive frame source code; and the second drive framework source code comprises an edited and modified initial drive function file.
In one embodiment, the method further comprises:
displaying the edited and modified initial drive function file to generate a visual function module;
judging whether the visual function module meets the actual requirement of the driving function file; the actual requirement representation of the drive function file conforms to a preset function standard;
and if not, deleting the visual function module, acquiring a third driving framework source code, and converting the third driving framework source code into the target driving framework source code.
A source code conversion apparatus, the apparatus comprising:
the instruction receiving module is used for receiving a source code conversion tool opening instruction;
the identification module is used for responding to the source code conversion tool opening instruction and identifying the source code of the initial driving frame to obtain an identification result; wherein the identification result comprises first attribute information of the function and second attribute information of the data contained in the initial driving framework source code;
and the conversion module is used for converting the source code of the initial driving frame into the source code of the target driving frame according to the identification result.
A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
receiving a source code conversion tool opening instruction;
responding to the source code conversion tool opening instruction, and identifying the source code of the initial driving frame to obtain an identification result; wherein the identification result comprises first attribute information of the function and second attribute information of the data contained in the initial driving framework source code;
and converting the source code of the initial driving frame into the source code of the target driving frame according to the identification result.
A readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of:
receiving a source code conversion tool opening instruction;
responding to the source code conversion tool opening instruction, and identifying the source code of the initial driving frame to obtain an identification result; wherein the identification result comprises first attribute information of the function and second attribute information of the data contained in the initial driving framework source code;
and converting the source code of the initial driving frame into the source code of the target driving frame according to the identification result.
The method receives a source code conversion tool opening instruction, responds to the source code conversion tool opening instruction, identifies the source code of the initial driving frame to obtain an identification result, and converts the source code of the initial driving frame into the source code of the target driving frame according to the identification result; according to the method, the source codes of the initial driving frame can be automatically converted into the source codes of the target driving frame through the source code conversion tool, developers are prevented from manually rewriting the source codes of the driving frame, and therefore conversion efficiency of the source codes of different driving frames is improved.
Drawings
FIG. 1 is a flow diagram illustrating a method for source code conversion in one embodiment;
FIG. 2 is a flow diagram illustrating the details of the recognition process in one embodiment;
FIG. 3 is a flow chart illustrating a source code conversion method according to another embodiment;
FIG. 4 is a schematic diagram of a detailed flow chart of source code conversion in another embodiment;
FIG. 5 is a diagram illustrating an exemplary source code conversion apparatus;
FIG. 6 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The source code conversion method provided by the application can be applied to computer equipment, the computer equipment can provide a set of independent integrated development environment, a cross-platform operating system is realized, and both Windows drive framework source codes and Linux drive framework source codes can be operated. Optionally, the computer device may be an electronic device with a source code editing function, such as a PC, a portable device, or a server. The specific procedure of the source code conversion method will be specifically described in the following embodiments. In this embodiment, a set of source code conversion tools may be installed in the computer device to implement the source code conversion method through the source code conversion tools, and a specific process of the source code conversion method will be described in the following embodiments.
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
Fig. 1 is a flowchart illustrating a source code conversion method according to an embodiment. The embodiment relates to a process of converting an initial driving framework source code, and the method is applied to a computer device as an example for explanation. As shown in fig. 1, the method includes:
and S1000, receiving a source code conversion tool opening instruction.
Specifically, a source code conversion tool may be installed on the computer device, and the source code conversion tool may be configured to convert source codes of different driving frameworks to each other; under the source code conversion tool, the computer device can be configured with the Windows drive framework source code and the Linux drive framework source code so as to realize the interconversion between the Windows drive framework source code and the Linux drive framework source code. If the project requires that the current computer equipment needs to execute the source code of the target drive frame, the computer equipment can receive a source code conversion tool opening instruction input by a user so as to realize the source code conversion of different drive frames through the source code conversion tool; the source code of the target driving frame is different from the source code of the initial driving frame currently configured by the computer, and the input mode of the source code conversion tool opening instruction can include input modes such as voice broadcasting, function menu triggering and shortcut keys. If the voice broadcast input form can be understood as that a user inputs voice information, the computer equipment identifies the voice information to determine that the voice information is the related information of the source code conversion tool opening instruction; the triggering input form of the function menu can be understood as that a user clicks an open function menu displayed on a source code conversion tool interface on computer equipment through a mouse; the shortcut key input mode may be that a user inputs a shortcut key corresponding to the source code conversion tool opening instruction through a function key on the keyboard.
S2000, responding to the source code conversion tool opening instruction, and identifying the source code of the initial driving frame to obtain an identification result; wherein the identification result includes first attribute information of a function and second attribute information of data included in the initial driving framework source code.
Specifically, the computer device may open a directory of the source code of the initial driving framework currently executed by the computer device, and automatically perform recognition processing on the source code of the initial driving framework through pattern recognition according to a directory structure and a suffix of a file name displayed in the directory in response to a received source code conversion tool opening instruction. The directory for opening the initial driving frame source code executed by the current computer equipment can be displayed in the integrated development environment of the computer equipment; the suffix of the file name displayed in the directory may be obtained by traversing all the subdirectories displayed in the directory structure and all the files under the subdirectories one by one.
The initial drive frame source code includes information such as an application program interface function, data, a key variable name, a macro name, a name of each initial drive function file included in the initial drive frame source code, and a key callback function name, and therefore the identification information may include attribute information of the application program interface function, attribute information of the data, attribute information of the key variable name, and attribute information of the macro name. In this embodiment, the identification result may include first attribute information of a function in the initial driving framework source code and second attribute information of the data; the first attribute information may include information on a type of a function, a function of the function, a parameter included in the function, and the like, and the second attribute information may include information on a type of data, a function of the data, and the like. Optionally, the recognition result may be displayed on a display interface of the computer device, so that the developer knows information corresponding to each initial drive function file included in the current initial drive framework source code. The functions, key variable names, macro names and the like can be displayed on a display interface of the computer device in a grammatical highlighting mode.
And S3000, converting the source code of the initial driving frame into the source code of the target driving frame according to the identification result.
Specifically, the computer device may automatically convert the initial driving framework source code into the target driving framework source code according to the recognition result. The source code of the initial driving frame and the source code of the target driving frame can have different functions and data.
In the source code conversion method, a source code conversion tool opening instruction is received, the source code conversion tool opening instruction is responded, the source code of the initial driving frame is identified to obtain an identification result, and the source code of the initial driving frame is converted into the source code of the target driving frame according to the identification result; according to the method, the source codes of the initial driving frame can be automatically converted into the source codes of the target driving frame through the source code conversion tool, and developers are prevented from manually rewriting the source codes of the driving frame, so that the conversion efficiency of the source codes of different driving frames is improved, convenience is provided for the developers, the conversion time is shortened, and the complexity of source code conversion is reduced.
As an embodiment, as shown in fig. 2, the step of performing, by the S2000, an identification process on the source code of the initial driving frame in response to the source code conversion tool opening instruction to obtain an identification result may be implemented by:
s2100, identifying and processing an application program interface function in the initial driving frame source code to obtain first attribute information. Wherein the first attribute information characterizes a type of an application program interface function.
Specifically, after responding to the source code conversion tool opening instruction, the computer device may perform identification processing on the application program interface function in the initial driving framework source code by using the neural network model, and determine first attribute information of the application program interface function, where the first attribute information of the application program interface function represents the type of the application program interface function. In this embodiment, the type of the application program interface function in the source code of the initial driving framework and the type of the application program interface function in the source code of the target driving framework may be different.
Wherein, the step in S2100 may specifically include: traversing each application program interface function in the initial drive frame source code, and identifying the traversed application program interface function to obtain the first attribute information.
In this embodiment, the computer device may traverse each application program interface function in the source code of the initial driving framework, and perform identification processing on the traversed application program interface function to obtain the first attribute information. Optionally, the traversal mode may be understood as sequential traversal according to a sequence, and may also be sequential traversal according to other preset sequences. Optionally, the source code conversion tool may encapsulate the corresponding recognition processing method to perform step S2100, so as to improve the recognition rate and accuracy of the source code conversion tool recognition processing.
S2200, identifying the data in the source code of the initial driving frame to obtain second attribute information. Wherein the second attribute information characterizes a type of the data.
It can be understood that the computer device may further perform identification processing on the data in the source code of the initial driving framework by using a neural network model to obtain second attribute information of the data, where the second attribute information represents a type of the data. In this embodiment, the type of data in the initial drive frame source code and the type of data in the target drive frame source code may be different. Optionally, the source code conversion tool may also package a corresponding recognition processing method to execute step S2200, so as to improve the recognition rate and accuracy of the recognition processing of the source code conversion tool, where the recognition processing manner in the step of the source code conversion tool packaging and the recognition processing manner in step S2100 of the packaging are different modules, and there may be no association relationship between the two modules.
The step in S2200 may specifically include: traversing each data in the source code of the initial driving frame, and identifying the traversed data to obtain the second attribute information.
Specifically, the computer device may traverse each data in the source code of the initial driving framework, and perform identification processing on the traversed data to obtain the first attribute information. The traversal pattern in this step may be the same as or different from the traversal pattern in step S2100.
In this embodiment, the source code conversion tool may be understood as a function plug-in installed on the computer device, and different function menus of the function plug-in may be displayed in a pull-down menu displayed after the source code conversion tool is opened; the function menu can comprise a driving frame source code opening/closing menu, a project engineering opening/closing menu, an editing menu, a driving function file attribute viewing menu, a driving frame source code compiling menu, a driving frame source code debugging menu, an interactive menu, a setting information menu and the like; the embodiment can realize the source code conversion function by triggering the interactive menu, and can set the information such as the parameters, types and the like of the source code conversion after triggering the setting information menu; after the different function menus are triggered, the results of the corresponding functions can be displayed on a visual interface (namely, a display interface of the computer device). After the source code conversion is finished, a driving framework source code compiling menu and a driving framework source code debugging menu can be triggered, and the target driving framework source code is compiled and debugged; performing source code compilation may compile and link target-driven framework source code to generate a computer executable file, a file with a binary suffix of sys or ko; and further debugging the source code of the target driving framework, and analyzing whether a bug exists in the source code of the target driving framework through single step, breakpoint and other operations. The source code conversion tool has the editing, compiling and debugging functions which can be understood as the editing function of the integrated development environment, and developers can modify, add, delete and the like the source code of the drive framework.
The source code conversion tool has a source code conversion function and also has a function of creating a source code program; after a developer triggers a newly-built source code function menu, a display interface of computer equipment can display a guide interface, information displayed by the guide interface is used for guiding the developer to create a customized driving program, a visual interactive interface is displayed finally, and the customized driving program is edited on the visual interactive interface; when a developer edits a customized driver on a visual interactive interface, a driver function file pre-stored by a computer device is added, the driver function file comprises general-purpose driven basic files such as a drive entry function file, an initialization function file, a PNP management file, a power management file, an interrupt file and the like, and each driver function file comprises a driver with a corresponding function.
It will also be appreciated that the source transcoding tool may also provide various types of related visualization windows, such as: an editing window, a debugging window, a printing information window, a conversion guide window, a drive function file attribute viewing window, a visual function module attribute drag-and-drop window and the like; the windows may be implemented using modal/modeless window information.
In the source code conversion method, after responding to a source code conversion tool opening instruction, the method can automatically identify the attribute information of functions and data contained in the source codes of the initial driving frame, and further determine the type of the source codes of the current initial driving frame according to the attribute information, so that the source codes of the initial driving frame are converted into the source codes of the target driving frame, developers are prevented from manually rewriting the source codes of the driving frame, the conversion efficiency of the source codes of different driving frames is improved, convenience is provided for the developers, the conversion time is shortened, and the complexity of source code conversion is reduced.
In another embodiment, as shown in fig. 3, the step of converting the initial driving frame source code into the target driving frame source code in S3000 according to the identification result may be implemented by:
s3100, judging whether the identification result meets the source code conversion requirement or not; and the source code conversion requirement represents that the first attribute information and the second attribute information in the identification result conform to a preset conversion standard of the source code of the driving framework to be converted.
Specifically, the computer device may determine whether the identification result meets a preset conversion standard of the source code of the driving frame to be converted according to the obtained identification result. That is, before the source code conversion processing of the driving framework, it is required to determine whether information in the source code of the initial driving framework can be directly converted into information in the source code of the target driving framework, if so, the first attribute information and the second attribute information in the characterization recognition result conform to a preset conversion standard of the source code of the driving framework to be converted, and if not, the first attribute information and the second attribute information in the characterization recognition result do not conform to the preset conversion standard of the source code of the driving framework to be converted.
And S3200, if so, converting the initial driving frame source code into the target driving frame source code.
It can be understood that, if the computer device determines that the recognition result meets the source code conversion requirement, the initial driving framework source code can be directly converted into the target driving framework source code.
In the source code conversion method, the method can directly convert the source code of the initial driving frame into the source code of the target driving frame, avoids the developers from manually rewriting the source code of the driving frame, improves the conversion efficiency of the source codes of different driving frames, provides convenience for the developers, shortens the conversion time and reduces the complexity of source code conversion.
As another example, with continued reference to fig. 3, after step S3100, the method may further comprise:
and S3300, if the initial driving frame source code does not meet the preset requirement, editing and modifying the initial driving frame source code according to the obtained first editing instruction to obtain a first driving frame source code, and converting the first driving frame source code into the target driving frame source code.
Specifically, if the computer device determines that the recognition result does not satisfy the source code conversion requirement, the computer device may receive a first editing instruction, and respond to the first editing instruction to edit and modify the initial driving frame source code to obtain a first driving frame source code, and when information included in the first driving frame source code satisfies the source code conversion requirement, convert the first driving frame source code into a target driving frame source code. The information included in the first drive framework source code may include attribute information of a function and attribute information of data included in the first drive framework source code. After the computer equipment judges that the identification result does not meet the source code conversion requirement, a window can pop up on a display interface of the computer equipment, the judgment result is displayed, and a developer is prompted to input a first editing instruction so as to edit and modify the source code of the initial driving frame; the input mode of the first editing instruction can be a voice broadcast, function menu triggering, shortcut key and other input modes. Optionally, after the developer inputs the first editing instruction, a visual interface may pop up from a display interface of the computer device to display the initial driving frame source code.
Further, after step S3300, the method may further include: editing and modifying the initial drive function file in the first drive frame source code according to the obtained second editing instruction to obtain a second drive frame source code, and converting the second drive frame source code into the target drive frame source code; and the second drive framework source code comprises an edited and modified initial drive function file.
It can be understood that, when the information included in the source code of the first drive framework does not meet the source code conversion requirement, the computer device may further receive a second editing instruction, and respond to the second editing instruction to edit and modify one or more initial drive function files in the source code of the first drive framework to obtain a source code of the second drive framework, and when the information included in the source code of the second drive framework meets the source code conversion requirement, convert the source code of the second drive framework into a source code of the target drive framework. The information included in the second drive framework source code may include attribute information of a function and attribute information of data included in the second drive framework source code.
In this embodiment, after the computer device determines that the information included in the source code of the first drive frame does not meet the source code conversion requirement, a window may pop up on a display interface of the computer device, display the determination result, and prompt a developer to input a second editing instruction to continue editing and modifying the initial drive function file in the source code of the first drive frame; the input mode of the first editing instruction can be a voice broadcast, function menu triggering, shortcut key and other input modes. The initial driving function file may include basic file items of general driving, such as a driving entry function file, an initialization function file, a PNP management file, and a power management file, and each initial driving function file has a corresponding implementation function. Optionally, after the developer inputs the second editing instruction, a visual interface may pop up from the display interface of the computer device to display the source code of the first driving frame.
In addition, as shown in fig. 4, after the step of performing editing modification on the initial drive function file in the first drive framework source code, the method may further include the steps of:
and S3400, displaying the edited and modified initial drive function file to generate a visual function module.
Specifically, the computer device may display the edited and modified initial drive function file, and may also display the unedited and modified initial drive function file to generate the visualization function module. The visualization function module can be displayed in a corresponding window on a display interface of the computer equipment, and each drive function file corresponds to one visualization function module.
S3500, judging whether the visual function module meets the actual requirement of the drive function file; and the actual requirement representation of the drive function file conforms to a preset function standard.
In this embodiment, the computer device may determine whether each visual function module meets the actual requirement of the driver function file; the actual requirement of the drive function file can be understood as that the visual function module meets the preset function standard of the drive function file to be converted, which is specified in the project requirement. Wherein, the computer equipment can prompt the judgment result; the prompting mode may include a flashing mode of the visualization function module, a mode of displaying the judgment result on the display interface, and the like.
And S3600, if the target driving framework source code does not meet the requirements, deleting the visual function module, acquiring a third driving framework source code, and converting the third driving framework source code into the target driving framework source code.
Specifically, when the computer device determines that the visual function module does not meet the actual requirement of the drive function file, it may receive a deletion instruction of different function modules, delete the visual function module that does not meet the actual requirement of the drive function file, and combine the initial drive function file corresponding to the undeleted visual function module or the edited and modified initial drive function file to generate a third drive frame source code. In this embodiment, the purpose of performing editing and modification before the source code conversion of the driving framework is to obtain a target driving framework source code after the conversion processing as the driving framework source code required by the project, and the computer device can directly run without editing and modifying the converted driving framework source code.
In addition, when the computer device determines that the visual function module does not meet the actual requirement of the drive function file, the computer device may further characterize that the drive function file included in the drive framework source code generated after the current editing and modifying does not meet the actual requirement of the drive function file, add other drive function files meeting the actual requirement of the drive function file into the drive framework source code generated after the editing and modifying, so as to display the added drive function file on the visual interface in a visual manner, or edit and modify the drive function file corresponding to the visual function module not meeting the actual requirement of the drive function file, so that the visual function module corresponding to the modified drive function file meets the actual requirement. The addition of the drive function file can further shorten the source code compiling time and improve the source code conversion efficiency. In this embodiment, the visualization function module may implement the deleting, adding, and modifying functions through a drag-and-drop attribute; the drag-and-drop attribute can be realized in a component form so as to avoid instability of the corresponding driver of the source code conversion tool caused by instability of each component, and the attribute provides easy operation for developers.
According to the source code conversion method, the initial drive frame source codes or the initial drive function files in the initial drive frame source codes can be edited and modified, and then the drive frame source codes generated after editing and modifying are converted to generate the target drive frame source codes, so that developers can be prevented from manually rewriting the drive frame source codes, the conversion efficiency of different drive frame source codes is improved, convenience is provided for the developers, the conversion time is shortened, and the complexity of source code conversion is reduced.
It should be understood that although the various steps in the flow charts of fig. 1-4 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 1-4 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least some of the other steps.
Fig. 5 is a schematic structural diagram of a source code conversion device according to an embodiment. As shown in fig. 5, the apparatus may include: an instruction receiving module 11, an identification module 12 and a conversion module 13.
Specifically, the instruction receiving module 11 is configured to receive a source code conversion tool opening instruction;
the identification module 12 is configured to respond to the source code conversion tool opening instruction, and perform identification processing on the source code of the initial driving frame to obtain an identification result; wherein the identification result comprises first attribute information of the function and second attribute information of the data contained in the initial driving framework source code;
the conversion module 13 is configured to convert the source code of the initial driving framework into the source code of the target driving framework according to the identification result.
The source code conversion apparatus provided in this embodiment may implement the method embodiments described above, and the implementation principle and the technical effect are similar, which are not described herein again.
In one embodiment, the identification module 12 includes: a first recognition unit and a second recognition unit.
Specifically, the first identifying unit is configured to identify an application program interface function in the source code of the initial driving framework to obtain first attribute information;
the second identification unit is used for identifying the data in the source code of the initial driving frame to obtain second attribute information;
the first attribute information represents the type of the application program interface function, and the second attribute information represents the type of the data.
The source code conversion apparatus provided in this embodiment may implement the method embodiments described above, and the implementation principle and the technical effect are similar, which are not described herein again.
In one embodiment, the first identifying unit is specifically configured to traverse each application program interface function in the source code of the initial driving framework, and identify the traversed application program interface function to obtain the first attribute information;
the second identification unit is specifically configured to traverse each data in the source code of the initial driving frame, and perform identification processing on the traversed data to obtain the second attribute information.
The source code conversion apparatus provided in this embodiment may implement the method embodiments described above, and the implementation principle and the technical effect are similar, which are not described herein again.
In one embodiment, the conversion module 13 includes: a judging unit and a first converting unit.
Specifically, the judging unit is configured to judge whether the identification result meets a source code conversion requirement; the source code conversion requirement represents that first attribute information and second attribute information in the identification result conform to a preset conversion standard of the source code of the driving framework to be converted;
and the first conversion unit is used for converting the source code of the initial driving frame into the source code of the target driving frame when the judgment result of the judgment unit is satisfied.
The source code conversion apparatus provided in this embodiment may implement the method embodiments described above, and the implementation principle and the technical effect are similar, which are not described herein again.
In one embodiment, the conversion module 13 further includes: a second conversion unit.
And the second conversion unit is used for editing and modifying the initial driving frame source code according to the acquired first editing instruction to obtain a first driving frame source code and converting the first driving frame source code into the target driving frame source code when the judgment result of the judgment unit is not satisfied.
The source code conversion apparatus provided in this embodiment may implement the method embodiments described above, and the implementation principle and the technical effect are similar, which are not described herein again.
In one embodiment, the conversion module 13 further includes: and a third conversion unit.
The third conversion unit is configured to edit and modify the initial drive function file in the first drive frame source code according to the obtained second editing instruction to obtain a second drive frame source code, and convert the second drive frame source code into the target drive frame source code; and the second drive framework source code comprises an edited and modified initial drive function file.
The source code conversion apparatus provided in this embodiment may implement the method embodiments described above, and the implementation principle and the technical effect are similar, which are not described herein again.
For the specific limitations of the source code conversion device, reference may be made to the limitations of the source code conversion method above, and details are not repeated here. The modules in the source code conversion device can be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the terminal, and can also be stored in a memory in the computer equipment in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 6. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a source code conversion method.
Those skilled in the art will appreciate that the configuration shown in fig. 6 is a block diagram of only a portion of the configuration associated with the present application and does not constitute a limitation on the terminal to which the present application is applied, and that a particular terminal may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the following steps when executing the computer program:
receiving a source code conversion tool opening instruction;
responding to the source code conversion tool opening instruction, and identifying the source code of the initial driving frame to obtain an identification result; wherein the identification result comprises first attribute information of the function and second attribute information of the data contained in the initial driving framework source code;
and converting the source code of the initial driving frame into the source code of the target driving frame according to the identification result.
In one embodiment, a readable storage medium is provided, having stored thereon a computer program which, when executed by a processor, performs the steps of:
receiving a source code conversion tool opening instruction;
responding to the source code conversion tool opening instruction, and identifying the source code of the initial driving frame to obtain an identification result; wherein the identification result comprises first attribute information of the function and second attribute information of the data contained in the initial driving framework source code;
and converting the source code of the initial driving frame into the source code of the target driving frame according to the identification result.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A method of source code conversion, the method comprising:
receiving a source code conversion tool opening instruction;
responding to the source code conversion tool opening instruction, and identifying the source code of the initial driving frame to obtain an identification result; wherein the identification result comprises first attribute information of the function and second attribute information of the data contained in the initial driving framework source code;
and converting the source code of the initial driving frame into the source code of the target driving frame according to the identification result.
2. The method of claim 1, wherein the identifying the source code of the initial driving frame in response to the source code conversion tool opening instruction to obtain an identification result comprises:
identifying and processing an application program interface function in the source code of the initial driving frame to obtain first attribute information;
identifying data in the source code of the initial driving frame to obtain second attribute information;
the first attribute information represents the type of the application program interface function, and the second attribute information represents the type of the data.
3. The method according to claim 2, wherein the identifying the application program interface function in the source code of the initial driving framework to obtain the first attribute information comprises:
traversing each application program interface function in the source code of the initial driving frame, and identifying the traversed application program interface function to obtain the first attribute information;
the identifying and processing the data in the source code of the initial driving frame to obtain second attribute information includes:
traversing each data in the source code of the initial driving frame, and identifying the traversed data to obtain the second attribute information.
4. The method of claim 1, wherein converting the initial driving framework source code into a target driving framework source code according to the recognition result comprises:
judging whether the identification result meets the source code conversion requirement or not; the source code conversion requirement represents that first attribute information and second attribute information in the identification result conform to a preset conversion standard of the source code of the driving framework to be converted;
and if so, converting the source code of the initial driving frame into the source code of the target driving frame.
5. The method of claim 4, further comprising:
and if not, editing and modifying the initial driving frame source code according to the acquired first editing instruction to obtain a first driving frame source code, and converting the first driving frame source code into the target driving frame source code.
6. The method according to any one of claims 1-5, further comprising:
editing and modifying the initial drive function file in the first drive frame source code according to the obtained second editing instruction to obtain a second drive frame source code, and converting the second drive frame source code into the target drive frame source code; and the second drive framework source code comprises an edited and modified initial drive function file.
7. The method of claim 6, further comprising:
displaying the edited and modified initial drive function file to generate a visual function module;
judging whether the visual function module meets the actual requirement of the driving function file; the actual requirement representation of the drive function file conforms to a preset function standard;
and if not, deleting the visual function module, acquiring a third driving framework source code, and converting the third driving framework source code into the target driving framework source code.
8. A source code conversion apparatus, the apparatus comprising:
the instruction receiving module is used for receiving a source code conversion tool opening instruction;
the identification module is used for responding to the source code conversion tool opening instruction and identifying the source code of the initial driving frame to obtain an identification result; wherein the identification result comprises first attribute information of the function and second attribute information of the data contained in the initial driving framework source code;
and the conversion module is used for converting the source code of the initial driving frame into the source code of the target driving frame according to the identification result.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 7.
10. A readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN202011045973.9A 2020-09-29 Source code conversion method, source code conversion device, computer equipment and readable storage medium Active CN112256279B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011045973.9A CN112256279B (en) 2020-09-29 Source code conversion method, source code conversion device, computer equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011045973.9A CN112256279B (en) 2020-09-29 Source code conversion method, source code conversion device, computer equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN112256279A true CN112256279A (en) 2021-01-22
CN112256279B CN112256279B (en) 2024-05-14

Family

ID=

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107247603A (en) * 2017-04-18 2017-10-13 深圳市广和通无线股份有限公司 Support the remote upgrade method and system of firmware auto restore facility
CN107861728A (en) * 2017-10-25 2018-03-30 深圳四方精创资讯股份有限公司 Method from traditional program language to modern procedures language conversion and its system for
CN109598107A (en) * 2018-11-20 2019-04-09 江苏通付盾信息安全技术有限公司 A kind of code conversion method and device based on application installation package file
CN110543297A (en) * 2018-05-28 2019-12-06 北京京东尚科信息技术有限公司 method and apparatus for generating source code
CN111309486A (en) * 2018-08-10 2020-06-19 中科寒武纪科技股份有限公司 Conversion method, conversion device, computer equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107247603A (en) * 2017-04-18 2017-10-13 深圳市广和通无线股份有限公司 Support the remote upgrade method and system of firmware auto restore facility
CN107861728A (en) * 2017-10-25 2018-03-30 深圳四方精创资讯股份有限公司 Method from traditional program language to modern procedures language conversion and its system for
CN110543297A (en) * 2018-05-28 2019-12-06 北京京东尚科信息技术有限公司 method and apparatus for generating source code
CN111309486A (en) * 2018-08-10 2020-06-19 中科寒武纪科技股份有限公司 Conversion method, conversion device, computer equipment and storage medium
CN109598107A (en) * 2018-11-20 2019-04-09 江苏通付盾信息安全技术有限公司 A kind of code conversion method and device based on application installation package file

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
A.T. LAWNICZAK等: "Netzwerk: migration of a packet-switching network simulation environment from MS Windows PC to Linux PC and to HPC", 《19TH INTERNATIONAL SYMPOSIUM ON HIGH PERFORMANCE COMPUTING SYSTEMS AND APPLICATIONS (HPCS\'05)》, pages 280 *
李世峰等: "一种基于模型的应用程序跨平台转换方法", 《计算机与数字工程》, no. 10, pages 1549 - 1551 *

Similar Documents

Publication Publication Date Title
US8091071B2 (en) Method and system for template-based code generation
CN108984161B (en) Unified and classifiable extensible software installation package construction method and device
CN109725896A (en) A kind of method and electronic equipment of online editing python code
CN111897553B (en) Project system building method, device, equipment and readable storage medium
CN112650487A (en) Hybrid application development method, system, computer device and storage medium
CN111078217A (en) Brain graph generation method, apparatus and computer-readable storage medium
CN109086038B (en) Spark-based big data development method and device, and terminal
CN112256279B (en) Source code conversion method, source code conversion device, computer equipment and readable storage medium
CN112256279A (en) Source code conversion method and device, computer equipment and readable storage medium
CN111124423B (en) Compiling detection method, device, server and medium based on multiple platforms
CN115268918A (en) Automatic conversion method from C + + code to C code based on rule template
KR101476536B1 (en) The method and system for inspecting program
CN113485710A (en) Low code script implementation method and terminal
CN114356783A (en) Method and device for automatically generating unit test code, storage medium and equipment
CN113807698A (en) Work order generation method and device, electronic equipment and readable storage medium
CN113238746A (en) Hybrid programming control method, device, equipment and storage medium
CN114371986A (en) User interface test case updating method, device and storage medium
CN112200490A (en) Information method and system for engineering quality safety manual
US20180267680A1 (en) Screen creation apparatus, simulation apparatus and recording medium
CN106897104B (en) Program editing platform and program editing method
CN114398290B (en) Program debugging method, device, equipment and medium
CN112199097B (en) Installation package generation method, installation package generation device, computer equipment and storage medium
CN113126979B (en) Visual business building system capable of achieving secondary programming by separating from server
CN116400927B (en) Code block translation method and device, electronic equipment and storage medium
CN117472344A (en) Code generation 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
GR01 Patent grant