Function calling method and device, code processing method and device, equipment and storage medium

By implementing the call to the target preset function in the source code file of the application installation package, determining and executing the implementation logic of the target function, the problem of increasing the volume of the application installation package caused by chain syntax calls is solved, and accurate chain calls are realized while controlling the volume of the package.

CN119597290APending Publication Date: 2025-03-11BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311161308.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-08
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

In the source code file that generates the application installation package, there are a large number of chain syntax calls, which leads to a significant increase in the application installation package volume and increases the volume pressure of the project package.

Method used

By providing a function call method, in response to the target object's call request to the target preset function, determine the objective function implementation logic corresponding to the target preset function, realize chain calls to at least two target original functions, and return the result to the target object. At the same time, look up the preset string in the initial source code file, replace it with the corresponding preset function, and generate the target source code file to reduce the number of chain calls.

Benefits of technology

Effectively control the volume of the package to ensure the accurate implementation of chain calls, and avoid the increase in the volume of the application installation package due to the existence of chain syntax calls.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119597290A_ABST
    Figure CN119597290A_ABST
Patent Text Reader

Abstract

The invention provides a function calling method and device, a code processing method and device, equipment and a storage medium, and relates to the technical field of computers. The function calling method comprises the steps that in response to a calling request of a target object for a target preset function, target function implementation logic corresponding to the target preset function is determined, the target function implementation logic comprises calling logic of at least two target original functions meeting the chained calling relation, and the target preset function is called by executing the target function implementation logic. Chained calling of the at least two target original functions is achieved, and a chained calling result is returned to the target object. By the adoption of the technical scheme, in the running process of the application program, chained calling of the corresponding original function is achieved by calling the preset function, and therefore accurate implementation of chained calling is guaranteed under the condition that the package size is effectively controlled.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the field of computer technology, and in particular to a function calling method, a code processing method, an apparatus, a device, and a storage medium. Background Art

[0002] In the process of code writing, chain syntax is a common syntax that exists in many programming languages. Using chain syntax to call a function can be called chain syntax call, or simply chain call. Chain call can reduce the amount of code, make the logic centralized and clear, and easy to view and modify.

[0003] However, when the source code file used to generate the application installation package contains a large number of chain syntax calls, the size of the application installation package will increase significantly, increasing the volume pressure of the project package. Summary of the invention

[0004] The embodiments of the present disclosure provide a function calling method, a code processing method, an apparatus, a device, and a storage medium, which can optimize the existing chain calling solution.

[0005] In a first aspect, an embodiment of the present disclosure provides a function calling method, comprising:

[0006] In response to a call request of a target object to a target preset function, determining a target function implementation logic corresponding to the target preset function, wherein the target function implementation logic includes the call logic of at least two target original functions that satisfy a chain call relationship;

[0007] Implementing a chain call of the at least two target primitive functions by executing the target function implementation logic;

[0008] The execution result of the target function implementation logic is returned to the target object.

[0009] In a second aspect, the present disclosure also provides a code processing method, including:

[0010] Searching for a preset string in the initial source code file, wherein the preset string contains at least two primitive functions, and each two primitive functions of the at least two primitive functions are connected by a preset call symbol in the preset string;

[0011] According to the preset correspondence, the preset string found is replaced with the corresponding preset function to obtain a target source code file, wherein the preset correspondence includes the correspondence between the preset string and the preset function, and the target source code file is used to generate an application installation package, and the application installation package includes the function implementation logic corresponding to the preset function, and the function implementation logic includes the calling logic of the at least two original functions.

[0012] In a third aspect, the embodiment of the present disclosure further provides a function calling device, including:

[0013] An implementation logic determination module, configured to determine, in response to a call request from a target object to a target preset function, a target function implementation logic corresponding to the target preset function, wherein the target function implementation logic includes the call logic of at least two target original functions that satisfy a chain call relationship;

[0014] Implementing a logic execution module, used to implement chain calls to the at least two target primitive functions by executing the target function implementation logic;

[0015] The call result return module is used to return the execution result of the target function implementation logic to the target object.

[0016] In a fourth aspect, the present disclosure also provides a code processing device, including:

[0017] A search module, used for searching a preset string in an initial source code file, wherein the preset string contains at least two primitive functions, and each two primitive functions of the at least two primitive functions are connected by a preset call symbol in the preset string;

[0018] A replacement module is used to replace the preset string found with the corresponding preset function according to a preset correspondence, so as to obtain a target source code file, wherein the preset correspondence includes the correspondence between the preset string and the preset function, and the target source code file is used to generate an application installation package, wherein the application installation package includes the function implementation logic corresponding to the preset function, and the function implementation logic includes the calling logic of the at least two original functions.

[0019] In a fifth aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:

[0020] one or more processors;

[0021] a storage device for storing one or more programs,

[0022] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided by the embodiment of the present disclosure.

[0023] In a sixth aspect, an embodiment of the present disclosure further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the method provided by an embodiment of the present disclosure.

[0024] The function calling scheme provided by the embodiment of the present disclosure responds to the calling request of the target object to the target preset function, determines the target function implementation logic corresponding to the target preset function, wherein the target function implementation logic includes the calling logic of at least two target original functions that satisfy the chain calling relationship, and realizes the chain calling of at least two target original functions by executing the target function implementation logic, and returns the chain calling result to the target object. By adopting the above technical scheme, the accurate implementation of the chain calling can be guaranteed while effectively controlling the package size.

[0025] The code processing scheme provided by the embodiment of the present disclosure searches for a preset string in an initial source code file, wherein the preset string contains at least two original functions, and each of the at least two original functions is connected by a preset call symbol in the preset string, and according to a preset correspondence, the preset string found is replaced with the corresponding preset function to obtain a target source code file, wherein the preset correspondence includes a correspondence between the preset string and the preset function, and the target source code file is used to generate an application installation package, and the application installation package includes the function implementation logic corresponding to the preset function, and the function implementation logic includes the call logic of at least two original functions. By adopting the above technical scheme, the increase in the size of the application installation package due to the existence of chained syntax calls can be avoided. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0027] Figure 1 A flowchart of a function calling method provided by an embodiment of the present disclosure;

[0028] Figure 2 A flowchart of another function calling method provided by an embodiment of the present disclosure;

[0029] Figure 3 A flowchart of a code processing method provided by an embodiment of the present disclosure;

[0030] Figure 4 A schematic diagram of the structure of a function calling device provided by an embodiment of the present disclosure;

[0031] Figure 5 A schematic diagram of the structure of a code processing device provided by an embodiment of the present disclosure;

[0032] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0033] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0034] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0035] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0036] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0037] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0038] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0039] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.

[0040] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.

[0041] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0042] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0043] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.

[0044] Figure 1 A flow chart of a function calling method provided in an embodiment of the present disclosure is applicable to the situation where a function is called during the running of an application. The method can be executed by a function calling device, which can be implemented in the form of software and / or hardware. Optionally, it can be implemented by an electronic device, which can be a mobile terminal such as a mobile phone, a smart watch, a tablet computer, and a personal digital assistant, or a device such as a personal computer (PC) or a server.

[0045] like Figure 1 As shown, the method includes:

[0046] Step 101, in response to a call request from a target object to a target preset function, determine a target function implementation logic corresponding to the target preset function, wherein the target function implementation logic includes the call logic of at least two target original functions that satisfy a chain call relationship.

[0047] Exemplarily, chain syntax calls may exist in a variety of computer programming languages, such as Python or Swift. The code written in the chain syntax call mode (recorded as a preset string in the disclosed embodiment) contains at least two functions (recorded as original functions in the disclosed embodiment), and each two original functions are connected in the preset string using a preset call symbol. The preset call symbol may be, for example, a dot, such as ".", or an underscore, such as "_", or other symbols, which are determined according to the specific programming language. Taking the preset call symbol as "." as an example, assuming that the original functions are A and B, the preset string may be AB, which means that function A is called first, the return value contains a call to function B, and then function B is called to implement the chain call of function A and function B. Taking Swift language as an example, there are many chain calls in the conventional layout writing in Swift, and the preset call symbol is ".". For example, a chain syntax call in SnapKit in Swift language used to express layout relationship can be written as snp.makeConstrains. SnapKit is an automatic layout component library in Swift project. Compared with the traditional frame layout method, SnapKit can better adapt to devices of various sizes, and is simple and easy to use, with good readability. It is widely used in the user interface (UI) layout of Swift project. For example, a chain syntax call in SnapKit used to express layout combination can be written as width.height.equalTo. The preset string contains 3 primitive functions.

[0048] Exemplarily, when the source code file used to generate the application installation package contains a large number of chain syntax calls, that is, when it contains a large number of preset strings described in the embodiments of the present disclosure, the volume of the application installation package will increase significantly, increasing the volume pressure of the project package. In the embodiments of the present disclosure, a new function (recorded as a preset function in the embodiments of the present disclosure) is used to encapsulate the chain syntax call, which can be understood as encapsulating the old interface with a new interface. The call to the preset function is directly included in the source code file, which can reduce the number of chain calls and reduce the package size. Optionally, the function name of the preset function can be determined based on the function names of at least two corresponding original functions, thereby reducing the cost of R&D. As shown in the above example, camel case writing can be used, starting from the second original function, and the first letter of the subsequent original functions is changed to uppercase. The function name of the preset function corresponding to snp.makeConstrains can be snpMakeConstrains; the function name of the preset function corresponding to width.height.equalTo can be widthHeightEqualTo.

[0049] For example, the call to the preset function in the source code file can be written directly based on the preset function, or the chain call can be replaced with the call to the preset function based on the already written initial code file, and the specific implementation method is not limited. After compiling the source code file containing the call to the preset function, the corresponding application installation package can be obtained, and the application installation package can be installed through the electronic device to achieve the installation of the application.

[0050] Exemplarily, this step is performed during the running of the application program, wherein the object is generally an instance of a class, the target object can be understood as the object that currently needs to call the target preset function, and the target preset function can be understood as the preset function that the target object currently needs to call.

[0051] In the disclosed embodiment, in order to ensure the accurate implementation of chain calls, the application program includes function implementation logic corresponding to each preset function, and the function implementation logic includes the call logic of at least two original functions that satisfy the chain call relationship corresponding to the preset function. For the target preset function, the corresponding function implementation logic is recorded as the target function implementation logic, and the target function implementation logic includes the call logic of at least two target original functions that satisfy the chain call relationship corresponding to the target preset function, which can be understood as the implementation method of the preset function is to call the original function in a chain call manner.

[0052] Step 102: Implement chain calling of the at least two target primitive functions by executing the target function implementation logic.

[0053] Exemplarily, after determining the target function implementation logic, the chain call of the at least two target primitive functions can be implemented by executing the target function implementation logic.

[0054] For example, as in the above example, the target preset function is snpMakeConstrains, and the process of executing the target function implementation logic may be to first call the function snp, and if the return value includes a call to the function makeConstrains, then call the function makeConstrains.

[0055] Step 103: Return the execution result of the objective function implementation logic to the target object.

[0056] Exemplarily, after the target function implementation logic is executed, the call result of the chain call is obtained, and the call result is returned to the target object as the execution result, thereby completing the chain call of the target object to the target original function. As in the above example, the call result of the function makeConstrains is returned to the target object.

[0057] The function calling method of the embodiment of the present disclosure determines the target function implementation logic corresponding to the target preset function in response to the target object's call request for the target preset function, wherein the target function implementation logic includes the call logic of at least two target original functions that satisfy the chain call relationship, and realizes the chain call of at least two target original functions by executing the target function implementation logic, and returns the chain call result to the target object. By adopting the above technical scheme, for the original function that satisfies the chain call relationship, it is not necessary to include the chain syntax call in the source code, which can avoid the increase in the size of the application installation package due to the existence of the chain syntax call. During the operation of the application, the chain call of the corresponding original function is realized by calling the preset function, thereby ensuring the accurate implementation of the chain call while effectively controlling the package size.

[0058] In some embodiments, the determining the target function implementation logic corresponding to the target preset function includes: determining the target function implementation logic corresponding to the target preset function by querying a preset extension file in a preset component library of a preset language, wherein the preset extension file includes the function implementation logic corresponding to the preset function, and the function implementation logic is written based on the preset language. Thus, the preset extension file containing the function implementation logic corresponding to the preset function is included in the preset component library, which can avoid the introduction of an additional software development kit (SDK) and reduce development costs.

[0059] Exemplarily, as in the above example, the preset language may be Swift, the preset component library may be SnapKit, and the preset extension file may be an extension protocol (extension) file added to the preset component library.

[0060] In some embodiments, the step of determining the target function implementation logic corresponding to the target preset function by querying the preset extension file in the preset component library of the preset language includes: determining the target class to which the target object belongs; and determining the target function implementation logic corresponding to the target preset function by querying the preset extension file of the target class in the preset component library of the preset language. Thus, for different classes, corresponding preset extension files are written respectively. When the target function implementation logic needs to be queried, the target class is first determined, and then the corresponding preset extension file is queried, which can improve the query efficiency of the target function implementation logic and thus improve the response speed of the call request.

[0061] For example, taking Swift language as an example, corresponding preset extension files can be added for classes such as ConstraintView and ConstraintMaker. Optionally, if an extension file already exists for a class, the function implementation logic corresponding to the preset function can be added to the existing extension file to obtain the corresponding preset extension file.

[0062] Figure 2 This is a flow chart of another function calling method provided by an embodiment of the present disclosure. The embodiment of the present disclosure is optimized based on the various optional solutions in the above embodiments. Specifically, the method includes the following steps:

[0063] Step 201: In response to a call request from a target object to a target preset function, determine the target class to which the target object belongs.

[0064] For example, taking Swift language as an example, it mainly involves two classes, ConstraintView and ConstraintMaker, and corresponding preset extension files can be written in advance for these two classes. After receiving a call request from a target object to a target preset function, it can be determined which of the two classes the target object inherits, and then the target class can be determined.

[0065] Step 202: Determine the target function implementation logic corresponding to the target preset function by querying the preset extension file of the target class in the preset component library of the preset language.

[0066] For example, taking Swift language as an example, extensions can be pre-added for the two classes of ConstraintView and ConstraintMaker, and the preset functions can be implemented in the preset extension files corresponding to the two classes respectively, for example, they can be recorded as ConstraintView+Extensions.swift file and ConstraintMaker+Extensions.swift file respectively.

[0067] For example, taking the ConstraintMaker+Extensions.swift file as an example, in this file, the function implementation logic corresponding to each preset function corresponding to the ConstraintMaker class can be pre-written. For example, the function implementation logic corresponding to the preset function snpMakeConstrains can be:

[0068] @inline(never)

[0069] public func snpMakeConstraints(_closure:(_make:ConstraintMaker)->

[0070] self.snp.makeConstraints(closure)

[0071] Among them, self can be understood as an object.

[0072] Exemplarily, the target function implementation logic is found in the corresponding preset extension file according to the function name of the target preset function.

[0073] Step 203: Implement chain calls to at least two target primitive functions by executing the target function implementation logic.

[0074] Exemplarily, as in the above example, the function snp is called first, and the return value includes calling the function makeConstraints, and then the function makeConstraints is called.

[0075] Step 204: Return the execution result of the target function implementation logic to the target object.

[0076] Exemplarily, the result of calling the makeConstrains function is returned to the target object.

[0077] The function calling method provided by the embodiment of the present disclosure, in response to the target object's call request for the target preset function, first determines the target class to which the target object belongs, then determines the target function implementation logic corresponding to the target preset function by querying the preset extension file of the target class in the preset component library of the preset language, and implements the chain call of at least two target original functions by executing the target function implementation logic, and finally returns the execution result of the target function implementation logic to the target object. By including the preset extension file containing the function implementation logic corresponding to the preset function in the preset component library, it is possible to avoid introducing an additional SDK and reduce development costs. After receiving the call request for the target preset function, the target class can be determined first, and then the corresponding preset extension file can be queried, which can improve the query efficiency of the target function implementation logic, thereby improving the response speed of the call request, and quickly and accurately implementing the chain call while effectively controlling the package size.

[0078] In some embodiments, when at least one of the at least two target primitive functions contains input parameters, the call request includes the target input parameter value corresponding to the at least one target primitive function; wherein, implementing the chain call of the at least two target primitive functions by executing the target function implementation logic includes: implementing the chain call of the at least two target primitive functions based on the target input parameter value by executing the target function implementation logic. Thus, the chain call of the target primitive function requiring input parameters can be implemented.

[0079] Exemplarily, if at least two target primitive functions contain input parameters, the call request includes target input parameter values ​​corresponding to at least two target primitive functions. In the process of executing the target function implementation logic, for each target primitive function, it is determined whether the target primitive function to be called currently has a corresponding target input parameter value. If so, the corresponding target input parameter value is input into the target primitive function to be called currently, so as to call the target primitive function to be called currently.

[0080] Exemplarily, assuming that function A, function B, and function C are in a chain call relationship, function B contains an input parameter b, function C contains an input parameter c, the preset string may be AB(b).C(c), and the corresponding preset function may be ABC(b, c), that is, when the preset function is called, the call request includes the parameter values ​​of b and c at the same time. Optionally, the parameter type corresponding to each input parameter may also be included in the preset function. For example, taking the Swift language as an example, regarding the writing of offset, the preset string may be, for example, left.equalTo(other).offset(offset), and the corresponding preset function may be leftEqualTo(_other: ConstraintRelatableTarget, offset: ConstraintOffsetTarget), where ConstraintRelatableTarget and ConstraintOffsetTarget represent parameter types.

[0081] Figure 3The present invention provides a flowchart of a code processing method provided by an embodiment of the present invention. The present invention is applicable to the case where the code involving chain calls in the source code file is processed. The method can be executed by a code processing device, which can be implemented in the form of software and / or hardware, and the specific form can be a script tool. Optionally, it can be implemented by an electronic device, which can be a mobile terminal such as a mobile phone, a smart watch, a tablet computer, and a personal digital assistant, or a personal computer (PC) or a server.

[0082] Step 301: Search for a preset string in an initial source code file, wherein the preset string contains at least two primitive functions, and each two primitive functions of the at least two primitive functions are connected by a preset call symbol in the preset string.

[0083] Exemplarily, the initial source code file can be understood as a source code file written by a developer, and the initial source code file contains code written in a chain syntax call mode, that is, a preset string. Every two primitive functions in the preset string are connected by a preset call symbol to indicate that the at least two primitive functions satisfy the chain call relationship. The preset call symbol can be, for example, a dot, such as ".", or an underscore, such as "_", or other symbols, which are determined according to the specific programming language. Exemplarily, the code in the initial source code file can be traversed by a script tool, and the preset string can be located by keyword search (with the preset string as the keyword).

[0084] Step 302: replace the preset string found with the corresponding preset function according to the preset correspondence relationship to obtain a target source code file, wherein the preset correspondence relationship includes the correspondence between the preset string and the preset function, and the target source code file is used to generate an application installation package, and the application installation package includes the function implementation logic corresponding to the preset function, and the function implementation logic includes the calling logic of the at least two original functions.

[0085] Exemplarily, the script tool may store a preset correspondence, or the script tool may read a file storing the preset correspondence to obtain the preset correspondence. The preset correspondence includes a correspondence between a preset string and a preset function, for example, the preset string snp.makeConstrains corresponds to the preset function snpMakeConstrains. After the preset string is found, the found preset string is replaced with the corresponding preset function, such as replacing all snp.makeConstrains found with snpMakeConstrains. After all the found preset strings are replaced with the corresponding preset functions, the target source code file is obtained.

[0086] Exemplarily, the target source code file is used to generate an application installation package, which includes function implementation logic corresponding to a preset function, and the function implementation logic includes calling logic of at least two original functions, so that after the application is installed using the application installation package, when the preset function needs to be called during the running of the application, the corresponding function implementation logic can be executed to implement a chain call to the corresponding at least two original functions.

[0087] The code processing method provided by the embodiment of the present disclosure searches for a preset string in an initial source code file, wherein the preset string contains at least two original functions, and each of the at least two original functions is connected by a preset call symbol in the preset string, and according to the preset correspondence, the preset string found is replaced with the corresponding preset function to obtain a target source code file, wherein the preset correspondence includes the correspondence between the preset string and the preset function, and the target source code file is used to generate an application installation package, and the application installation package includes the function implementation logic corresponding to the preset function, and the function implementation logic includes the call logic of at least two original functions. By adopting the above technical solution, the chain syntax call part in the written initial source code file containing the chain syntax call can be replaced with the call to the corresponding preset function to obtain the target source code file, and the application installation package is generated by using the target source code file and the function implementation logic corresponding to the preset function, which can avoid the increase in the size of the application installation package due to the existence of the chain syntax call, so that during the operation of the application, the chain call of the corresponding original function can be realized by calling the preset function, so that the accurate implementation of the chain call can be guaranteed under the condition of effectively controlling the package size.

[0088] In some embodiments, it further includes: obtaining a preset extension file, wherein the preset extension file includes the function implementation logic corresponding to the preset function; adding the preset extension file to a preset component library of a preset language, wherein the function implementation logic is written based on the preset language, and the preset component library is used to generate the application installation package with the target source code file. Thus, adding the preset extension file containing the function implementation logic corresponding to the preset function to the preset component library can avoid introducing an additional SDK and reduce development costs.

[0089] Exemplarily, after the preset extension file is added to the preset component library of the preset language, an application installation package is generated according to the target source code file and the preset component library.

[0090] Optionally, the preset extension files corresponding to each class are obtained, and the preset extension files corresponding to each class are added to the preset component library of the preset language. Thus, for different classes, corresponding preset extension files are written respectively. When the target function implementation logic needs to be queried, the target class is first determined, and then the corresponding preset extension file is queried. This can improve the query efficiency of the target function implementation logic, and thus improve the response speed of the call request.

[0091] In some embodiments, when at least one of the at least two primitive functions contains an input parameter, the corresponding preset function includes the input parameter, thereby ensuring normal implementation of chain calls of primitive functions that require input parameters.

[0092] Exemplarily, if at least two original functions include input parameters, the corresponding preset function includes the input parameters, and the order of the included input parameters in the preset function is consistent with the order in the preset character string.

[0093] For the Swift language, there are a large number of chain calls in the conventional layout writing method in Swift. By adopting the technical solution provided by the embodiment of the present disclosure, a layer of direct call function is outsourced in the original multi-layer chain syntax call, and the original chain call is replaced by a direct call, which can greatly reduce the number of chain calls, thereby reducing the package size. The naming method of the preset function (new interface) is similar to the preset string (old interface), which can reduce the cost of research and development. Based on the preset correspondence, the script tool can be used to quickly replace the preset string in the project, which can realize the rapid implementation of the optimization plan. By adding an extension, the place where the Snapkit layout code is used in the original project can be directly modified into the optimized preset function, and the preset function implementation location is also in Snapkit, so there is no need to introduce a new SDK, reducing development costs.

[0094] Figure 4A schematic diagram of a function calling device provided by an embodiment of the present disclosure is shown in FIG. Figure 4 As shown, the device comprises:

[0095] The implementation logic determination module 401 is used to determine the target function implementation logic corresponding to the target preset function in response to the target object's call request for the target preset function, wherein the target function implementation logic includes the call logic of at least two target original functions that satisfy the chain call relationship;

[0096] An implementation logic execution module 402, configured to implement a chain call of the at least two target primitive functions by executing the target function implementation logic;

[0097] The call result returning module 403 is used to return the execution result of the target function implementation logic to the target object.

[0098] The function calling device provided in the embodiment of the present disclosure does not need to include chain syntax calls in the source code for the original functions that satisfy the chain calling relationship, which can avoid the increase in the size of the application installation package due to the existence of chain syntax calls. During the running of the application, the chain calling of the corresponding original function is realized by calling the preset function, thereby ensuring the accurate implementation of the chain calling while effectively controlling the package size.

[0099] Optionally, determining the target function implementation logic corresponding to the target preset function includes: determining the target function implementation logic corresponding to the target preset function by querying a preset extension file in a preset component library of a preset language, wherein the preset extension file includes the function implementation logic corresponding to the preset function, and the function implementation logic is written based on the preset language.

[0100] Optionally, determining the target function implementation logic corresponding to the target preset function by querying the preset extension file in the preset component library of the preset language includes: determining the target class to which the target object belongs; determining the target function implementation logic corresponding to the target preset function by querying the preset extension file of the target class in the preset component library of the preset language.

[0101] Optionally, when at least one of the at least two target primitive functions contains an input parameter, the calling request includes a target input parameter value corresponding to the at least one target primitive function;

[0102] The implementation logic execution module is specifically used for:

[0103] By executing the target function implementation logic, a chain call of the at least two target primitive functions based on the target input parameter value is implemented.

[0104] Figure 5 A schematic diagram of the structure of a code processing device provided by an embodiment of the present disclosure is shown in FIG. Figure 5 As shown, the device comprises:

[0105] A search module 501 is used to search for a preset string in an initial source code file, wherein the preset string contains at least two primitive functions, and each two primitive functions of the at least two primitive functions are connected by a preset call symbol in the preset string;

[0106] The replacement module 502 is used to replace the preset string found with the corresponding preset function according to the preset correspondence relationship, and obtain the target source code file, wherein the preset correspondence relationship includes the correspondence between the preset string and the preset function, and the target source code file is used to generate an application installation package, and the application installation package includes the function implementation logic corresponding to the preset function, and the function implementation logic includes the calling logic of the at least two original functions.

[0107] The code processing device provided by the embodiment of the present disclosure can replace the chain syntax call part in the initial source code file that has been written and contains the chain syntax call with a call to the corresponding preset function to obtain the target source code file, and generate an application installation package by using the function implementation logic corresponding to the target source code file and the preset function. This can avoid the increase in the size of the application installation package due to the existence of the chain syntax call, so that during the operation of the application, the corresponding original function can be chained by calling the preset function, thereby ensuring the accurate implementation of the chain call while effectively controlling the package size.

[0108] Optionally, the device further comprises:

[0109] An extension file acquisition module, used to acquire a preset extension file, wherein the preset extension file includes a function implementation logic corresponding to a preset function;

[0110] An extension file adding module is used to add the preset extension file to a preset component library of a preset language, wherein the function implementation logic is written based on the preset language, and the preset component library is used to generate the application installation package with the target source code file.

[0111] The function calling device provided in the embodiment of the present disclosure can execute the function calling method provided in any embodiment of the present disclosure, and has the functional modules and beneficial effects corresponding to the execution method. The code processing device provided in the embodiment of the present disclosure can execute the code processing method provided in any embodiment of the present disclosure, and has the functional modules and beneficial effects corresponding to the execution method.

[0112] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.

[0113] Figure 6 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 6 , which shows an electronic device (eg, Figure 6 The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0114] like Figure 6 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An edit / output (I / O) interface 605 is also connected to the bus 604.

[0115] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0116] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0117] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0118] The electronic device provided by the embodiment of the present disclosure and the function calling and / or code processing method provided by the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0119] An embodiment of the present disclosure provides a computer storage medium on which a computer program is stored. When the program is executed by a processor, the function calling and / or code processing method provided by the above embodiment is implemented.

[0120] The embodiments of the present disclosure provide a computer program product, including a computer program, which, when executed by a processor, implements the function calling and / or code processing method provided by the above embodiments.

[0121] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0122] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0123] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0124] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: responds to the target object's call request for the target preset function, determines the target function implementation logic corresponding to the target preset function, wherein the target function implementation logic includes the call logic of at least two target primitive functions that satisfy the chain call relationship; realizes the chain call of the at least two target primitive functions by executing the target function implementation logic; and returns the execution result of the target function implementation logic to the target object.

[0125] Alternatively, the computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device: searches for a preset string in an initial source code file, wherein the preset string contains at least two original functions, and each two of the at least two original functions are connected in the preset string using a preset call symbol; replaces the found preset string with a corresponding preset function based on a preset correspondence, to obtain a target source code file, wherein the preset correspondence includes a correspondence between the preset string and the preset function, and the target source code file is used to generate an application installation package, the application installation package includes function implementation logic corresponding to the preset function, and the function implementation logic includes calling logic of the at least two original functions.

[0126] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0127] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0128] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a module does not, in some cases, constitute a limitation on the module itself. For example, a call result return module may also be described as "a module that returns the execution result of the target function implementation logic to the target object".

[0129] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0130] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0131] According to one or more embodiments of the present disclosure, a function calling method is provided, comprising:

[0132] In response to a call request of a target object to a target preset function, determining a target function implementation logic corresponding to the target preset function, wherein the target function implementation logic includes the call logic of at least two target original functions that satisfy a chain call relationship;

[0133] Implementing a chain call of the at least two target primitive functions by executing the target function implementation logic;

[0134] The execution result of the target function implementation logic is returned to the target object.

[0135] According to one or more embodiments of the present disclosure, the step of determining the target function implementation logic corresponding to the target preset function includes:

[0136] The target function implementation logic corresponding to the target preset function is determined by querying the preset extension file in the preset component library of the preset language, wherein the preset extension file includes the function implementation logic corresponding to the preset function, and the function implementation logic is written based on the preset language.

[0137] According to one or more embodiments of the present disclosure, the step of determining the target function implementation logic corresponding to the target preset function by querying the preset extension file in the preset component library of the preset language includes:

[0138] Determine the target class to which the target object belongs;

[0139] The target function implementation logic corresponding to the target preset function is determined by querying the preset extension file of the target class in the preset component library of the preset language.

[0140] According to one or more embodiments of the present disclosure, when at least one of the at least two target primitive functions contains an input parameter, the call request includes a target input parameter value corresponding to the at least one target primitive function;

[0141] The step of implementing the chain call of the at least two target primitive functions by executing the target function implementation logic includes:

[0142] By executing the target function implementation logic, a chain call of the at least two target primitive functions based on the target input parameter value is implemented.

[0143] According to one or more embodiments of the present disclosure, a code processing method is provided, including:

[0144] Searching for a preset string in the initial source code file, wherein the preset string contains at least two primitive functions, and each two primitive functions of the at least two primitive functions are connected by a preset call symbol in the preset string;

[0145] According to the preset correspondence, the preset string found is replaced with the corresponding preset function to obtain a target source code file, wherein the preset correspondence includes the correspondence between the preset string and the preset function, and the target source code file is used to generate an application installation package, and the application installation package includes the function implementation logic corresponding to the preset function, and the function implementation logic includes the calling logic of the at least two original functions.

[0146] According to one or more embodiments of the present disclosure, the present invention further includes:

[0147] Obtaining a preset extension file, wherein the preset extension file includes function implementation logic corresponding to the preset function;

[0148] The preset extension file is added to a preset component library of a preset language, wherein the function implementation logic is written based on the preset language, and the preset component library is used to generate the application installation package with the target source code file.

[0149] According to one or more embodiments of the present disclosure, a function calling device is provided, comprising:

[0150] An implementation logic determination module, configured to determine, in response to a call request from a target object to a target preset function, a target function implementation logic corresponding to the target preset function, wherein the target function implementation logic includes the call logic of at least two target original functions that satisfy a chain call relationship;

[0151] Implementing a logic execution module, used to implement chain calls to the at least two target primitive functions by executing the target function implementation logic;

[0152] The call result return module is used to return the execution result of the target function implementation logic to the target object.

[0153] According to one or more embodiments of the present disclosure, a code processing device is provided, including:

[0154] A search module, used for searching a preset string in an initial source code file, wherein the preset string contains at least two primitive functions, and each two primitive functions of the at least two primitive functions are connected by a preset call symbol in the preset string;

[0155] A replacement module is used to replace the preset string found with the corresponding preset function according to a preset correspondence, so as to obtain a target source code file, wherein the preset correspondence includes the correspondence between the preset string and the preset function, and the target source code file is used to generate an application installation package, wherein the application installation package includes the function implementation logic corresponding to the preset function, and the function implementation logic includes the calling logic of the at least two original functions.

[0156] According to one or more embodiments of the present disclosure, an electronic device is provided, the electronic device comprising:

[0157] one or more processors;

[0158] a storage device for storing one or more programs,

[0159] When the one or more programs are executed by the one or more processors, the one or more processors implement the function calling and / or code processing method provided by the embodiments of the present disclosure.

[0160] According to one or more embodiments of the present disclosure, a storage medium containing computer executable instructions is provided. When the computer executable instructions are executed by a computer processor, they are used to execute the function call and / or code processing method provided by the embodiments of the present disclosure.

[0161] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0162] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0163] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A function calling method, characterized in that: include: In response to a call request of a target object to a target preset function, determining a target function implementation logic corresponding to the target preset function, wherein the target function implementation logic includes the call logic of at least two target original functions that satisfy a chain call relationship; Implementing a chain call of the at least two target primitive functions by executing the target function implementation logic; The execution result of the target function implementation logic is returned to the target object.

2. The method according to claim 1, characterized in that: The determining of the target function implementation logic corresponding to the target preset function includes: The target function implementation logic corresponding to the target preset function is determined by querying the preset extension file in the preset component library of the preset language, wherein the preset extension file includes the function implementation logic corresponding to the preset function, and the function implementation logic is written based on the preset language.

3. The method according to claim 2, characterized in that The step of determining the target function implementation logic corresponding to the target preset function by querying the preset extension file in the preset component library of the preset language includes: Determine the target class to which the target object belongs; The target function implementation logic corresponding to the target preset function is determined by querying the preset extension file of the target class in the preset component library of the preset language.

4. The method according to claim 1, characterized in that: In the case where at least one of the at least two target primitive functions includes an input parameter, the call request includes a target input parameter value corresponding to the at least one target primitive function; The step of implementing the chain call of the at least two target primitive functions by executing the target function implementation logic includes: By executing the target function implementation logic, a chain call of the at least two target primitive functions based on the target input parameter value is implemented.

5. A code processing method, characterized in that: include: Searching for a preset string in the initial source code file, wherein the preset string contains at least two primitive functions, and each two primitive functions of the at least two primitive functions are connected by a preset call symbol in the preset string; According to the preset correspondence, the preset string found is replaced with the corresponding preset function to obtain a target source code file, wherein the preset correspondence includes the correspondence between the preset string and the preset function, and the target source code file is used to generate an application installation package, and the application installation package includes the function implementation logic corresponding to the preset function, and the function implementation logic includes the calling logic of the at least two original functions.

6. The method according to claim 5, characterized in that Also includes: Obtaining a preset extension file, wherein the preset extension file includes function implementation logic corresponding to the preset function; The preset extension file is added to a preset component library of a preset language, wherein the function implementation logic is written based on the preset language, and the preset component library is used to generate the application installation package with the target source code file.

7. A function calling device, characterized in that: include: An implementation logic determination module, configured to determine, in response to a call request from a target object to a target preset function, a target function implementation logic corresponding to the target preset function, wherein the target function implementation logic includes the call logic of at least two target original functions that satisfy a chain call relationship; Implementing a logic execution module, used to implement chain calls to the at least two target primitive functions by executing the target function implementation logic; The call result returning module is used to return the execution result of the target function implementation logic to the target object.

8. A code processing device, characterized in that: include: A search module, used for searching a preset string in an initial source code file, wherein the preset string contains at least two primitive functions, and each two primitive functions of the at least two primitive functions are connected by a preset call symbol in the preset string; A replacement module is used to replace the preset string found with the corresponding preset function according to a preset correspondence, so as to obtain a target source code file, wherein the preset correspondence includes the correspondence between the preset string and the preset function, and the target source code file is used to generate an application installation package, wherein the application installation package includes the function implementation logic corresponding to the preset function, and the function implementation logic includes the calling logic of the at least two original functions.

9. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

10. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions are used to perform the method according to any one of claims 1 to 6 when executed by a computer processor.