CN112685043A - Asynchronous conversion method, device and equipment of callback function and readable storage medium - Google Patents

Asynchronous conversion method, device and equipment of callback function and readable storage medium Download PDF

Info

Publication number
CN112685043A
CN112685043A CN202011631348.2A CN202011631348A CN112685043A CN 112685043 A CN112685043 A CN 112685043A CN 202011631348 A CN202011631348 A CN 202011631348A CN 112685043 A CN112685043 A CN 112685043A
Authority
CN
China
Prior art keywords
function
callback
functions
code
primitive
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011631348.2A
Other languages
Chinese (zh)
Inventor
黄康
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202011631348.2A priority Critical patent/CN112685043A/en
Publication of CN112685043A publication Critical patent/CN112685043A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The application relates to the technical field of research and development management, and discloses an asynchronous conversion method of callback functions, which comprises the following steps: receiving an asynchronous conversion instruction, and acquiring a target code based on the asynchronous conversion instruction; cutting the target code according to the configuration file of the target code to obtain a plurality of primitive functions and a plurality of callback functions; packaging the plurality of primitive functions and the plurality of callback functions according to a target conversion language; and performing chain connection on the packaged original functions and the callback functions to obtain a converted target code. The application also provides a device, computer equipment and a storage medium. The method and the device realize the reduction of the learning cost of the user on the code language and improve the convenience and the accuracy of code conversion.

Description

Asynchronous conversion method, device and equipment of callback function and readable storage medium
Technical Field
The present application relates to the field of research and development management technologies, and in particular, to an asynchronous conversion method for a callback function, an asynchronous conversion device for a callback function, a computer device, and a computer-readable storage medium.
Background
Currently, in the front-end industry, a large amount of codes written by using the ES5 exist, and if a new ES6 code needs to be replaced, one important task is to rewrite a callback function writing method in an original traditional asynchronous executive program into a premium of the ES 6.
The conventional treatment methods include the following three methods:
1. and introducing Babel to compile the upgraded project code. The introduction and use of Babel require configuration file writing, and for a common developer, additional learning of knowledge related to Babel is required.
2. It needs to be very familiar with the relevant syntax and has practical development experience. The threshold of upgrading projects is improved. Developers who cannot do all the levels can participate in the upgrade project.
3. For upgrading and rewriting of asynchronous callback functions between cross-files, nesting and links in business logic need to be combed repeatedly, and the difficulty and workload of upgrading projects are increased.
To sum up, currently, in the front-end industry, there is no tool or product that can systematically solve this problem.
Disclosure of Invention
The application provides an asynchronous conversion method and device of a callback function, a computer device and a storage medium, so that the learning cost of a user on a code language is reduced, and the convenience and the accuracy of code conversion are improved.
In a first aspect, the present application provides an asynchronous conversion method of a callback function, where the method includes:
receiving an asynchronous conversion instruction, and acquiring a target code based on the asynchronous conversion instruction;
cutting the target code according to the configuration file of the target code to obtain a plurality of primitive functions and a plurality of callback functions;
packaging the plurality of primitive functions and the plurality of callback functions according to a target conversion language;
and performing chain connection on the packaged original functions and the callback functions to obtain a converted target code.
In a second aspect, the present application further provides an asynchronous transformation apparatus for callback functions, where the apparatus includes:
the information acquisition module is used for receiving an asynchronous conversion instruction and acquiring a target code based on the asynchronous conversion instruction;
the code cutting module is used for cutting the target code according to the configuration file of the target code to obtain a plurality of original functions and a plurality of callback functions;
the function packaging module is used for packaging the plurality of original functions and the plurality of callback functions according to a target conversion language;
and the code conversion module is used for performing chain connection on the packaged original functions and the callback functions to obtain converted target codes.
In a third aspect, the present application further provides a computer device comprising a memory and a processor; the memory is used for storing a computer program; the processor is used for executing the computer program and realizing the asynchronous conversion method of the callback function when the computer program is executed.
In a fourth aspect, the present application further provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program causes the processor to implement the asynchronous translation method for callback function as described above.
When the grammar of a code needs to be converted, a target code needing to be converted is determined, a callback function needing to be converted in the code is extracted and independent on the basis of an introduced code conversion tool, then all independent functions are packaged by using the converted promise grammar, and the obtained original function and the callback function are subjected to language processing after the independence and the packaging are completed, so that the code which can be used in a new language environment is obtained. The method and the device have the advantages that the learning cost of a user for the code language is reduced when the code is converted, the function in the code is cut, independent and packaged, seamless switching of the code language is achieved, abnormal errors caused by artificial coding are avoided, and convenience and accuracy of code conversion are improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flowchart of an asynchronous conversion method of a callback function according to an embodiment of the present application;
FIG. 2 is a flowchart illustrating steps for obtaining object code according to an embodiment of the present application;
FIG. 3 is a flowchart illustrating the steps of cutting object code according to an embodiment of the present application;
FIG. 4 is a block diagram illustrating an exemplary asynchronous translation device for callback functions in an embodiment of the present application;
FIG. 5 is a block diagram schematically illustrating a computer device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The flow diagrams depicted in the figures are merely illustrative and do not necessarily include all of the elements and operations/steps, nor do they necessarily have to be performed in the order depicted. For example, some operations/steps may be decomposed, combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
It is to be understood that the terminology used in the description of the present application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
Referring to fig. 1, fig. 1 is a schematic flowchart illustrating an asynchronous conversion method of a callback function according to an embodiment of the present application.
As shown in fig. 1, the asynchronous conversion method of the callback function includes steps S101 to S104.
Step S101, receiving an asynchronous conversion instruction, and acquiring a target code based on the asynchronous conversion instruction.
Due to the fact that tools for writing codes are different, when the codes are written by using different tools, the written codes have certain difference, and the written codes cannot be used universally. For example, when upgrading software or a program, a new code tool needs to be compatible, so that a code writing tool used by a previous version is not suitable for being used in the new version, and coding needs to be re-coded in general, that is, when upgrading the software or the program, upgrading optimization or re-coding is performed on the code in the software or the program, so that the software or the program is upgraded.
In one embodiment, when the code needs to be upgraded, that is, when the code needs to be converted, the target code that needs to be converted currently is determined. Therefore, after the automatic conversion tool is loaded, the asynchronous conversion instruction is received first, and then the received asynchronous conversion instruction is identified to obtain the target code to be converted, and then the target code is converted correspondingly.
The asynchronous conversion instruction is triggered by a user through corresponding operation, for example, when code conversion is determined to be needed, the system triggers an own asynchronous conversion function to automatically send out the asynchronous conversion instruction by performing corresponding operation on the system. For example, in the front-end industry, a large amount of codes coded by using ES5 currently need to be converted into new codes coded by ES6, so when code conversion is needed, a code conversion function of a system is triggered through corresponding operation, so that codes coded by ES5 are converted into codes coded by ES 6.
Further, when the target code needing code conversion is determined, the asynchronous conversion instruction is identified to obtain the target code needing conversion currently. Therefore, when the asynchronous conversion instruction is received, the code information contained in the asynchronous conversion instruction is identified, wherein the identified code information comprises address information corresponding to the code and a code identifier corresponding to the code needing to be converted, and then the target code needing to be converted is found according to the identified address information and code identifier.
Specifically, the code to be converted is determined in advance, for example, when the code written in the ES5 is converted into the ES6 code, the code to be converted is determined in advance, that is, corresponding configuration processing is performed, so that the code to be converted is directly obtained for processing when the code to be converted is needed. Wherein, specifically include: writing a configuration file, and storing the written configuration file, wherein the configuration file comprises address information corresponding to the code and a code identifier corresponding to the code to be converted.
In practice, when a configuration file is written, the written configuration file is config. After configuration is completed, when it is determined that code conversion is needed, the configuration file is obtained to obtain function codes that need to be converted, and the obtained function codes that need to be converted are further processed, for example, function codes written in ES5 are converted into ES6 codes.
Referring to fig. 2, fig. 2 is a flowchart illustrating a step of acquiring an object code according to an embodiment of the present application. Wherein step S101 includes steps S201 to S202.
Specifically, step S101 includes:
step S201, receiving an asynchronous conversion instruction, and identifying a configuration file contained in the asynchronous conversion instruction;
step S202, according to the path information contained in the configuration file, acquiring a target code for conversion.
When an asynchronous conversion instruction is received, firstly, a target code which needs to be converted currently needs to be determined, so that when the asynchronous conversion instruction is received, relevant information carried in the asynchronous conversion instruction is identified and acquired, specifically, a configuration file contained in the asynchronous conversion instruction is identified, and then the target code which needs to be converted is acquired in a corresponding storage space according to the acquired configuration file.
Actually, when a code is converted, a tool is configured in advance, that is, configuration information of the code is written, specifically, a corresponding configuration file config.json is written, where the configuration file includes a file name address where a function needs to be converted and a function name that needs to be converted in the corresponding file, and when a user needs to convert the code, a corresponding asynchronous conversion instruction is issued according to the configuration file, so that a target code can be accurately converted when the asynchronous conversion instruction is received.
And S102, continuing to perform cutting processing on the target code according to the configuration file of the target code to obtain a plurality of original functions and a plurality of callback functions.
After the target code is obtained, because the number of codes of the code is huge and some general connection codes exist, after the target code is determined, the code which needs to be processed currently needs to be determined in the target code, and then the code which needs to be processed is processed to complete the conversion of the target code.
Therefore, after the target code is obtained, the target code is cut according to the configuration file corresponding to the target code, and a plurality of primitive functions and a plurality of callback functions are obtained when cutting is completed, wherein the target code is obtained by the obtained primitive functions and callback functions.
In practical applications, the code may include many functions, and similarly, for the callback function, many functions may also be included, and the connection manner between each function is not limited, such as parallel connection and connection inclusion, so that when the target code is cut, all callback functions in the target code are cut and separated, so that each callback function is independent.
Referring to fig. 3, fig. 3 is a flowchart illustrating a step of cutting an object code according to an embodiment of the present application. Step S102 includes steps S301 to S303.
Step S301, according to the configuration file of the target code, performing cutting processing on the target code to obtain a first callback function and a first primitive function, wherein the first primitive function and the first callback function form the target code.
When the target code is reached, the callback function is determined in the target code, and since the number of the callback functions possibly contained in the target code is more than one, the callback functions need to be cut for several times so as to be independent. Therefore, when cutting is performed, firstly, the target code is cut for the first time according to the configuration file to obtain a first callback function and a first primitive function, wherein the first primitive function and the first callback function form the target code.
In practical application, the code is composed of a plurality of functions and related codes, such as specific functions and connection codes, when the target code is processed, the target code is cut through cutting processing, so that the target function is cut into a first callback function and a first primitive function, and when the code is translated, the first callback function is translated, so that the translation of the target code is completed. Specifically, by converting the first callback function into the language form corresponding to the currently used encoding tool, for example, when the code in the form of ES5 is converted into the code in the form of ES6, the callback function needs to be converted into a precision function.
Specifically, when the target code is cut, the method includes: acquiring a callback function identifier corresponding to the target code in the configuration file, and determining a first cut-off character corresponding to the callback function in the target code; and cutting the target code based on the first cutter to obtain a first callback function and a first primitive function corresponding to the target code.
Actually, when the target code is cut, according to the characteristics of the code, for a code string, a plurality of functions are formed, and different functions need to be correspondingly distinguished, brackets are generally used, the functions are wrapped by the brackets, and a left bracket and a right bracket contain one function.
Therefore, when the target code is cut, the cut of the target code is realized by using a function separator (such as a bracket) so as to separate the callback function in the target code.
For the object code, the functions contained in the object code are correspondingly marked when the object code is configured in advance, that is, each function can be accurately positioned and found in the object code. Meanwhile, the relation between each function may be recorded, for example, the first function includes the second function and the third function, and the second function includes the third function, in practice, the obtained cut symbol should be able to separate the first function, the second function, and the third function, but here, because the second function and the third function are included in the first function, when the cut is performed here, the cut will not be directly performed to obtain the first function, the second function, and the third function, but the first function including the second function and the third function, and a partial code not including the first function may be obtained.
In order to avoid the situation that the number of times of segmentation is uncontrollable during segmentation, after the relationship between the functions is limited, the functions are only segmented once each time the segmentation is performed, that is, only one original function and one callback function are obtained, but the obtained callback function may further include other sub callback functions, that is, one callback function.
A callback function is a function called by a function pointer, and if a pointer (address) of a function is passed as a parameter to another function, when the pointer is used to call the function to which it points, it is called a callback function. Since the functions in the code are various, when the callback function is determined, by using the characteristic, the whole callback function can be obtained only by judging the parameters of the functions one by one and finding the data with the data type of the function in the parameters.
Step S302, determining whether the first callback function includes a function separation mark, and performing a cutting process on the first callback function when it is determined that the first callback function includes the separation mark, to obtain a second primitive function and the second callback function, where the second primitive function and the second callback function constitute the first callback function.
After the encapsulation of the first callback function and the first primitive function is completed, since it is determined that the first primitive function does not include the callback function, but the callback function may include the callback function, the first callback function is further determined and processed, so that each callback function is independent.
Therefore, after the first callback function is obtained, it is determined whether the first callback function includes a function separation mark to determine whether the first callback function needs to be further cut, and when it is determined that the first callback function needs to be cut, the first callback function is cut to obtain a second primitive function and a second callback function.
For function separation marks in the code and the function, "each function is closed" according to the characteristic of the function, and therefore, whether the function contains the separation mark can be determined according to the closure of the function. Generally, for each function in the code, a function is wrapped in a certain manner, for example, a function is wrapped in parentheses, so that when determining whether a function separation mark is included, it is possible to determine whether the first callback function includes a parenthesis for wrapping the function, and if so, determine that another segmentation is required, otherwise, determine that the segmentation is completed.
In an embodiment, when the first callback function is processed, the corresponding second primitive function and second callback function are obtained, but since the first callback function is processed, the obtained second primitive function is also actually a callback function, and the obtained second callback function is a combined callback function that may include several callback functions.
Step S303, determining whether the second callback function includes a function separation mark, and determining that the cutting is completed when it is determined that the second callback function does not include the separation mark, so as to obtain a first primitive function, a second primitive function, and a second callback function.
After the second segmentation of the first callback function is completed, a second primitive function and a second callback function are obtained based on the first callback function. Therefore, after the second callback function is obtained, it is determined whether the second callback function includes a function segmentation flag, so as to determine whether to perform a subsequent cutting process. And when the second callback function is determined not to contain the separation mark, the segmentation is completed, and the finally obtained multiple primitive functions and multiple callback functions comprise the first primitive function, the second primitive function and the second callback function.
And S103, packaging the plurality of primitive functions and the plurality of callback functions according to a target conversion language.
After the target code is cut, a plurality of primitive functions and a plurality of callback functions are obtained, and in order to realize the conversion of the target code, the obtained primitive functions and the callback functions are firstly packaged, and when the packaging is carried out, corresponding object examples are constructed according to the target conversion language, and then the primitive functions and the callback functions are packaged according to the constructed object examples.
Specifically, when the obtained primitive function and callback function are encapsulated, the method includes: and constructing a plurality of object examples according to a target conversion language, and encapsulating the plurality of primitive functions and the plurality of callback functions according to the plurality of object examples to obtain a plurality of encapsulated primitive functions and a plurality of callback functions.
In practical application, when the primitive function and the callback function are encapsulated, a newly-created plan object instance is returned to encapsulate the primitive function, and a newly-created plan object instance is also returned to encapsulate the callback function.
It should be noted that, the primitive functions and the callback functions obtained by performing the cutting may be packaged simultaneously, that is, each primitive function and each callback function may not be packaged after the whole cutting process is completed, for example, after the first segmentation is completed to obtain the first primitive function and the first callback function, the first primitive function and the first callback function are packaged, and after the packaging is completed, whether the first callback function needs to be cut twice and the second cut is determined.
And step S104, performing chain connection on the packaged original functions and the callback functions to obtain a converted target code.
After the code is processed, a first primitive function without a callback function and a plurality of callback functions are obtained, wherein the callback functions are obtained by cutting the code for a plurality of times.
According to the above description, when processing the code, first an original function and a first callback function are obtained, then the first callback function is judged and processed, whether the first callback function includes a function division mark of the callback function is determined, and if the first callback function includes the function division mark, the first original function and the first callback function are further processed, and if the first callback function does not include the function division mark, the obtained first original function and the obtained first callback function are processed, so that a converted promise function is obtained when the processing is completed.
Similarly, when the first callback function is judged to further include a callback function, the first callback function is cut, so that the finally obtained callback function does not include the callback function through a plurality of times of cutting. For example, when the first callback function is cut, if the first callback function only includes a callback function (second callback function), then when the first callback function is cut, a callback function and a second callback function are obtained, and since the function to be cut is the callback function, then the obtained second primitive function is also a callback function.
Further, when the cut independence is performed on the callback function included in the target code, the method further includes: and labeling the obtained callback functions based on the cutting independent sequence of the callback functions. Illustratively, three callback functions are contained in one target code, and the callback functions have a containing relationship, for example, a first function contains a second function and a third function, and the second function contains the third function.
When cutting is performed, a first primitive function and a first callback function are obtained firstly, wherein the first callback function comprises a second function and a third function, then the first callback function is divided for the second time, so that an independent first callback function (namely, a second primitive function) and an independent second callback function are obtained, the second callback function is composed of the second function and the third function, then the second callback function is cut, so that a second callback function (namely, a third primitive function) and a third callback function are obtained, wherein the third callback function is independent and is the third function, and when the labels are performed according to the division independent sequence of the callback functions, the first function is one, the second function is two, and the third function is three.
When the obtained primitive function and the callback function are connected to obtain the converted target code, the method specifically includes: acquiring a chain connection function corresponding to a target conversion language; and sequentially connecting the plurality of callback functions according to the sizes of the labels by taking the first primitive function as a starting point according to the chain connection function, and obtaining a converted target code when the connection is finished.
Specifically, when performing connection conversion, first obtaining a chain connection function corresponding to a target language, and then sequentially performing connection according to the size of a label corresponding to a callback function to obtain a converted target code.
When the obtained original function and the callback function are finally processed, all functions are called in a chain mode, so that when calling is carried out, after the original function is called, the obtained callback functions are received in sequence, at the moment, the writing method of the then () is adopted, all the callback functions are connected behind the original function in sequence, the connection sequence of the callback functions is obtained according to the independent sequence of the callback functions, and the converted target function is obtained when connection is finished.
In the asynchronous conversion method for the callback function described above, when the code needs to be converted, the target code that needs to be converted is determined, the callback function that needs to be converted in the code is extracted and independent based on the introduced code conversion tool, then all independent functions are encapsulated by using the converted promise syntax, and the obtained original function and the callback function are subjected to language processing after the independence and encapsulation are completed, so as to obtain a code that can be used in a new language environment. The method and the device have the advantages that the learning cost of a user for the code language is reduced when the code is converted, the function in the code is cut, independent and packaged, seamless switching of the code language is achieved, abnormal errors caused by artificial coding are avoided, and convenience and accuracy of code conversion are improved.
Referring to fig. 4, fig. 4 is a schematic block diagram of an asynchronous transformation apparatus for a callback function according to an embodiment of the present application, the apparatus being configured to execute the asynchronous transformation method for the callback function.
As shown in fig. 4, the asynchronous conversion device 400 of the callback function includes:
the information acquisition module 401 is configured to receive an asynchronous conversion instruction and acquire a target code based on the asynchronous conversion instruction;
a code cutting module 402, configured to cut the target code according to the configuration file of the target code to obtain a plurality of primitive functions and a plurality of callback functions;
a function encapsulation module 403, configured to encapsulate the primitive functions and the callback functions according to a target translation language;
a code conversion module 404, configured to perform chain connection on the packaged multiple primitive functions and multiple callback functions to obtain a converted target code.
Further, in an embodiment, the information obtaining module 401 is further specifically configured to:
receiving an asynchronous conversion instruction, and identifying a configuration file contained in the asynchronous conversion instruction; and acquiring the target code for conversion according to the path information contained in the configuration file.
Further, in an embodiment, the code cutting module 402 is further specifically configured to:
cutting the target code according to the configuration file of the target code to obtain a first callback function and a first primitive function, wherein the first primitive function and the first callback function form the target code; determining whether the first callback function contains a function separation mark, and cutting the first callback function when the first callback function contains the separation mark to obtain a second primitive function and a second callback function, wherein the second primitive function and the second callback function form the first callback function, and the second primitive function is a callback function; and determining whether the second callback function contains a function separation mark, and determining that the cutting is finished when determining that the second callback function does not contain the separation mark, so as to obtain a first primitive function, a second primitive function and a second callback function.
Further, in an embodiment, the code cutting module 402 is further specifically configured to:
acquiring a callback function identifier corresponding to the target code in the configuration file, and determining a first cut-off character corresponding to the callback function in the target code; and cutting the target code based on the first cutter to obtain a first callback function and a first primitive function corresponding to the target code.
Further, in an embodiment, the function encapsulation module 403 is further specifically configured to:
and constructing a plurality of object examples according to a target conversion language, and encapsulating the plurality of primitive functions and the plurality of callback functions according to the plurality of object examples to obtain a plurality of encapsulated primitive functions and a plurality of callback functions.
Further, in an embodiment, the asynchronous conversion apparatus 400 of the callback function is further specifically configured to:
labeling the callback functions based on the cutting independent sequence of the callback functions;
the code conversion module 404 is further specifically configured to:
acquiring a chain connection function corresponding to a target conversion language; and sequentially connecting the plurality of callback functions according to the sizes of the labels by taking the first primitive function as a starting point according to the chain connection function, and obtaining a converted target code when the connection is finished.
Further, in an embodiment, the asynchronous conversion apparatus 400 of the callback function is further specifically configured to:
and running the converted target code, and generating a corresponding running log based on the running state to perform feedback.
It should be noted that, as will be clear to those skilled in the art, for convenience and brevity of description, the specific working processes of the apparatus and the modules described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The apparatus described above may be implemented in the form of a computer program which is executable on a computer device as shown in fig. 5.
Referring to fig. 5, fig. 5 is a schematic block diagram of a computer device according to an embodiment of the present application. The computer device may be a server.
Referring to fig. 5, the computer device includes a processor, a memory, and a network interface connected through a system bus, wherein the memory may include a storage medium and an internal memory.
The storage medium may store an operating system and a computer program. The computer program includes program instructions that, when executed, cause the processor to perform any of the methods for asynchronous translation of callback functions.
The processor is used for providing calculation and control capability and supporting the operation of the whole computer equipment.
The internal memory provides an environment for running a computer program in the storage medium, and the computer program can cause the processor to execute any asynchronous conversion method of the callback function when being executed by the processor.
The network interface is used for network communication, such as sending assigned tasks and the like. Those skilled in the art will appreciate that the architecture shown in fig. 5 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
It should be understood that the Processor may be a Central Processing Unit (CPU), and the Processor may be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, etc. Wherein a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Wherein, in one embodiment, the processor is configured to execute a computer program stored in the memory to implement the steps of:
receiving an asynchronous conversion instruction, and acquiring a target code based on the asynchronous conversion instruction; cutting the target code according to the configuration file of the target code to obtain a plurality of primitive functions and a plurality of callback functions; packaging the plurality of primitive functions and the plurality of callback functions according to a target conversion language; and performing chain connection on the packaged original functions and the callback functions to obtain a converted target code.
In one embodiment, the processor, when implementing the receiving an asynchronous translation instruction and obtaining target code based on the asynchronous translation instruction, is further configured to implement:
receiving an asynchronous conversion instruction, and identifying a configuration file contained in the asynchronous conversion instruction; and acquiring the target code for conversion according to the path information contained in the configuration file.
In an embodiment, when the processor implements the cutting processing on the object code according to the configuration file of the object code to obtain a plurality of primitive functions and a plurality of callback functions, the processor is further configured to implement:
cutting the target code according to the configuration file of the target code to obtain a first callback function and a first primitive function, wherein the first primitive function and the first callback function form the target code; determining whether the first callback function contains a function separation mark, and cutting the first callback function when the first callback function contains the separation mark to obtain a second primitive function and a second callback function, wherein the second primitive function and the second callback function form the first callback function, and the second primitive function is a callback function; and determining whether the second callback function contains a function separation mark, and determining that the cutting is finished when determining that the second callback function does not contain the separation mark, so as to obtain a first primitive function, a second primitive function and a second callback function.
In an embodiment, when the processor implements the cutting processing on the object code according to the configuration file of the object code to obtain the first callback function and the first primitive function, the processor is further configured to implement:
acquiring a callback function identifier corresponding to the target code in the configuration file, and determining a first cut-off character corresponding to the callback function in the target code; and cutting the target code based on the first cutter to obtain a first callback function and a first primitive function corresponding to the target code.
In one embodiment, when the encapsulating the primitive functions and the callback functions according to the target translation language is implemented, the processor is further configured to implement:
and constructing a plurality of object examples according to a target conversion language, and encapsulating the plurality of primitive functions and the plurality of callback functions according to the plurality of object examples to obtain a plurality of encapsulated primitive functions and a plurality of callback functions.
In one embodiment, the processor, when implementing the computer program, is further configured to implement:
labeling the callback functions based on the cutting independent sequence of the callback functions;
the chain connecting the packaged original functions and the callback functions to obtain the converted target code includes:
acquiring a chain connection function corresponding to a target conversion language; and sequentially connecting the plurality of callback functions according to the sizes of the labels by taking the first primitive function as a starting point according to the chain connection function, and obtaining a converted target code when the connection is finished.
In an embodiment, after the implementing the chain connecting the packaged primitive functions and callback functions to obtain the translated target code, the processor is further configured to implement:
and running the converted target code, and generating a corresponding running log based on the running state to perform feedback.
An embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, where the computer program includes a program instruction, and the processor executes the program instruction to implement the asynchronous conversion method for any callback function provided in the embodiment of the present application.
The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, for example, a hard disk or a memory of the computer device. The computer readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the computer device.
Further, the computer-readable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the blockchain node, and the like.
In addition, the block chain referred to in the application is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
While the invention has been described with reference to specific embodiments, the scope of the invention is not limited thereto, and those skilled in the art can easily conceive various equivalent modifications or substitutions within the technical scope of the invention. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method for asynchronous translation of callback functions, the method comprising:
receiving an asynchronous conversion instruction, and acquiring a target code based on the asynchronous conversion instruction;
cutting the target code according to the configuration file of the target code to obtain a plurality of primitive functions and a plurality of callback functions;
packaging the plurality of primitive functions and the plurality of callback functions according to a target conversion language;
and performing chain connection on the packaged original functions and the callback functions to obtain a converted target code.
2. The method of claim 1, wherein receiving an asynchronous translation instruction and retrieving target code based on the asynchronous translation instruction comprises:
receiving an asynchronous conversion instruction, and identifying a configuration file contained in the asynchronous conversion instruction;
and acquiring the target code for conversion according to the path information contained in the configuration file.
3. The method according to claim 2, wherein the cutting the object code according to the configuration file of the object code to obtain a plurality of primitive functions and a plurality of callback functions comprises:
cutting the target code according to the configuration file of the target code to obtain a first callback function and a first primitive function, wherein the first primitive function and the first callback function form the target code;
determining whether the first callback function contains a function separation mark, and cutting the first callback function when the first callback function contains the separation mark to obtain a second primitive function and a second callback function, wherein the second primitive function and the second callback function form the first callback function, and the second primitive function is a callback function;
and determining whether the second callback function contains a function separation mark, and determining that the cutting is finished when determining that the second callback function does not contain the separation mark, so as to obtain a first primitive function, a second primitive function and a second callback function.
4. The method according to claim 3, wherein the cutting the object code according to the configuration file of the object code to obtain the first callback function and the first primitive function comprises:
acquiring a callback function identifier corresponding to the target code in the configuration file, and determining a first cut-off character corresponding to the callback function in the target code;
and cutting the target code based on the first cutter to obtain a first callback function and a first primitive function corresponding to the target code.
5. The method of claim 1, wherein encapsulating the primitive functions and the callback functions according to a target translation language comprises:
and constructing a plurality of object examples according to a target conversion language, and encapsulating the plurality of primitive functions and the plurality of callback functions according to the plurality of object examples to obtain a plurality of encapsulated primitive functions and a plurality of callback functions.
6. The method of claim 1, further comprising:
labeling the callback functions based on the cutting independent sequence of the callback functions;
the chain connecting the packaged original functions and the callback functions to obtain the converted target code includes:
acquiring a chain connection function corresponding to a target conversion language;
and sequentially connecting the plurality of callback functions according to the sizes of the labels by taking the first primitive function as a starting point according to the chain connection function, and obtaining a converted target code when the connection is finished.
7. The method according to any one of claims 1 to 6, wherein after the chaining the packaged primitive functions and callback functions to obtain the translated target code, the method further comprises:
and running the converted target code, and generating a corresponding running log based on the running state to perform feedback.
8. An apparatus for asynchronous translation of callback functions, said apparatus comprising:
the information acquisition module is used for receiving an asynchronous conversion instruction and acquiring a target code based on the asynchronous conversion instruction;
the code cutting module is used for cutting the target code according to the configuration file of the target code to obtain a plurality of original functions and a plurality of callback functions;
the function packaging module is used for packaging the plurality of original functions and the plurality of callback functions according to a target conversion language;
and the code conversion module is used for performing chain connection on the packaged original functions and the callback functions to obtain converted target codes.
9. A computer device, comprising a memory and a processor:
the memory has stored therein computer readable instructions which, when executed by the processor, cause the processor to perform the steps of the asynchronous translation method of callback functions according to any of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, wherein the computer-readable instructions, when executed by the processors, cause one or more processors to perform the steps of the asynchronous translation method of callback functions as claimed in any of claims 1 to 7.
CN202011631348.2A 2020-12-30 2020-12-30 Asynchronous conversion method, device and equipment of callback function and readable storage medium Pending CN112685043A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011631348.2A CN112685043A (en) 2020-12-30 2020-12-30 Asynchronous conversion method, device and equipment of callback function and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011631348.2A CN112685043A (en) 2020-12-30 2020-12-30 Asynchronous conversion method, device and equipment of callback function and readable storage medium

Publications (1)

Publication Number Publication Date
CN112685043A true CN112685043A (en) 2021-04-20

Family

ID=75456001

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011631348.2A Pending CN112685043A (en) 2020-12-30 2020-12-30 Asynchronous conversion method, device and equipment of callback function and readable storage medium

Country Status (1)

Country Link
CN (1) CN112685043A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113326039A (en) * 2021-06-21 2021-08-31 深圳市网通兴技术发展有限公司 Asynchronous code generation method and system for medical code flow modeling

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113326039A (en) * 2021-06-21 2021-08-31 深圳市网通兴技术发展有限公司 Asynchronous code generation method and system for medical code flow modeling
CN113326039B (en) * 2021-06-21 2022-02-18 深圳市网通兴技术发展有限公司 Asynchronous code generation method and system for medical code flow modeling

Similar Documents

Publication Publication Date Title
US11667033B2 (en) Systems and methods for robotic process automation
US10579349B2 (en) Verification of a dataflow representation of a program through static type-checking
CN108965375B (en) Service call proxy control system, method, server and readable storage medium
CN112685043A (en) Asynchronous conversion method, device and equipment of callback function and readable storage medium
CN114895935A (en) Method and device for flashing vehicle ECU, electronic equipment and storage medium
CN111240772A (en) Data processing method and device based on block chain and storage medium
CN105335185B (en) Red cap source code assures the processing method and processing device of reason SRPM packet
CN109343856A (en) The generation method and device of custom algorithm component
US10338891B2 (en) Migration between model elements of different types in a modeling environment
CN116431127A (en) Low code development method, system, equipment and readable storage medium
CN111930387B (en) Integration method and device of integration package, electronic equipment and storage medium
JP2010049439A (en) System construction method using software model and modeling device
CN110414021A (en) Edge device event rules generation system, the device and method of industrial Internet of Things
CN111880803B (en) Software construction method and device applied to multiple platforms
CN114090074A (en) Method and device for configuring operating environment, storage medium and electronic device
CN112988225A (en) Annotation configuration method, device, equipment and storage medium
CN113296790A (en) Method, apparatus and computer readable medium for generating application data package
CN117648081B (en) Visual software integrated development method, system and storage medium
CN115964075B (en) Application export import method and device, computer equipment and storage medium
CN114237615A (en) Packing method based on decision tree model and related equipment
CN115202709A (en) Software project dependence analysis method and device, computer equipment and storage medium
CN116301815A (en) Workflow generating method and workflow template machine
CN115271503A (en) Automatic operation and maintenance method and device, electronic equipment and storage medium
CN117892665A (en) Modeling simulation method, device, medium and equipment based on circuit system level model
CN115269707A (en) Python Flink-based Pulsar connector implementation method and system

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