Duplicate processing method, device, apparatus and storage medium
By parsing the executable file of an Objective-C application, the problem of methods with the same name in multiple categories of the same class is identified, which solves the problems of low efficiency and performance impact in the existing technology, and ensures the stability and efficient processing of the application.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING 58 INFORMATION TTECH CO LTD
- Filing Date
- 2024-12-27
- Publication Date
- 2026-04-10
AI Technical Summary
In the Objective-C programming language, the existence of methods with the same name in multiple categories of the same class can easily lead to method overriding. Existing technologies that detect this by scanning the source code are inefficient and impact computer performance.
By obtaining the executable file of the target application, parsing the file header and classification information layer by layer, determining the method information of multiple categories, and identifying methods with the same name, the acquisition of source code and script writing are avoided, improving efficiency and reducing the impact on computer performance.
It enables efficient identification and handling of methods with the same name, ensuring the stable operation of the application and avoiding the inefficiency and performance impact of source code scanning and script execution.
Smart Images

Figure CN119883279B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and in particular, to a same name processing method, device and equipment and storage medium. BACKGROUND
[0002] When designing and developing an application program for an iOS operating system using an Objective-C programming language, if multiple categories are added to the same class, and the methods corresponding to the multiple categories have the same name, the method defined later will cover the method defined earlier, thereby affecting the stability of the application program. A class can be understood as a collection of objects with the same properties and methods, and each object in the object collection has the properties and methods defined by the class. A category is a new method added to an existing class. For ease of understanding, for example, a class can correspond to multiple categories, and each category contains multiple methods, for example, the first category of the target class contains two methods, rendering and live, and the second category of the target class contains two methods, rendering and sayhello. Therefore, it can be understood that the first category and the second category have the same method name, i.e. rendering. Moreover, if it is known that the method in the second category is defined later than the method in the first category, the rendering in the second category will cover the rendering in the first category.
[0003] Therefore, the prior art generally scans the source code of the application program by writing a script to collect the method names corresponding to all categories of the target class, so as to determine whether there are duplicate method names. However, this method needs to scan the entire source code of the application program, which is time-consuming and inefficient. Moreover, the running of the script will occupy certain CPU and memory resources, and if the script is frequently run (for example, this method is used for same name detection for each class), it will have a certain impact on the performance of the computer. SUMMARY
[0004] The embodiments of the present application provide a same name processing method, device, equipment and storage medium, which do not need to obtain the source code of the target application program or write a script, and thus are not only high in work efficiency, but also do not have an impact on the performance of the computer.
[0005] In a first aspect, the embodiments of the present application provide a same name processing method, comprising:
[0006] obtaining an executable file of a target application program, wherein the executable file is obtained by compiling a set programming language, the executable file contains a file header for storing file basic information, and executable code executed by the target application program when running on a set device;
[0007] determine, based on the file header, classification information of a plurality of classifications corresponding to the target class of the set programming language;
[0008] determine, according to the classification information, method information of a method corresponding to each of the plurality of classifications, wherein the method is used to perform a set operation when the target application program is running;
[0009] determine, according to the method information corresponding to each of the plurality of classifications, a method with the same name in the plurality of classifications.
[0010] In a second aspect, an embodiment of the present application provides a same-name processing apparatus, comprising:
[0011] an obtaining module configured to obtain an executable file of a target application program, wherein the executable file is obtained by compiling a set programming language, the executable file contains a file header used to store file basic information, and executable code executed when the target application program runs on a set device;
[0012] a determining module configured to determine, based on the file header, classification information of a plurality of classifications corresponding to the target class of the set programming language, and determine, according to the classification information, method information of a method corresponding to each of the plurality of classifications, and determine, according to the method information corresponding to each of the plurality of classifications, a method with the same name in the plurality of classifications, wherein the method is used to perform a set operation when the target application program is running.
[0013] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor performs the same-name processing method according to the first aspect.
[0014] In a fourth aspect, an embodiment of the present application provides a non-transitory machine-readable storage medium, wherein the non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor performs the same-name processing method according to the first aspect.
[0015] In a fifth aspect, an embodiment of the present application provides a computer program product, comprising a computer program, and when the computer program is executed by a processor of an electronic device, the processor performs the same-name processing method according to the first aspect.
[0016] The same name processing method provided by the embodiment of the application can obtain the method information of the methods corresponding to the plurality of classifications respectively by obtaining the executable file of the target application program and performing layer-by-layer analysis on the executable file (the specific layer-by-layer analysis process is as follows: first, based on the file header of the executable file, the classification information of the plurality of classifications corresponding to the target class of the set programming language is determined, and then according to the classification information, the method information of the methods corresponding to the plurality of classifications respectively is determined), and then the same name methods in the plurality of classifications are determined according to the method information, the whole process does not need to obtain the source code of the target application program, nor does it need to write scripts, which is not only high in work efficiency, but also does not affect the computer performance. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the application, the following will briefly introduce the drawings needed to be used in the embodiment description. Obviously, the drawings in the following description are some embodiments of the application, and other drawings can also be obtained by those skilled in the art without creative labor.
[0018] Figure 1 The flow chart of the same name processing method provided by the embodiment of the application;
[0019] Figure 2 The specific application flow chart of the same name processing method provided by the embodiment of the application;
[0020] Figure 3 Another specific application flow chart of the same name processing method provided by the embodiment of the application;
[0021] Figure 4 The application schematic diagram of the same name processing method provided by the embodiment of the application;
[0022] Figure 5 The structural schematic diagram of the same name processing device provided by the embodiment of the application;
[0023] Figure 6 The structural schematic diagram of the electronic device provided by the embodiment of the application. DETAILED DESCRIPTION
[0024] In order to make the objects, technical solutions and advantages of the embodiments of the application clearer, the following will combine the drawings in the embodiments of the application to clearly and completely describe the technical solutions in the embodiments of the application. Obviously, the described embodiments are some of the embodiments of the application, not all the embodiments. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative labor are within the protection scope of the application.
[0025] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the embodiments of the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal.
[0026] Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The following embodiments and features in the embodiments can be combined with each other without conflict between the embodiments. In addition, the step sequence in each method embodiment described below is only an example, not a strict limitation.
[0027] First, the terms or concepts involved in the embodiments of the present application are explained:
[0028] Mach Object (abbreviation: Mach-O): a file format for executable files, object code, dynamic libraries, kernel dumps.
[0029] Objective-C: an object-oriented programming language based on C language and extending its object-oriented functions. It is mainly used for the development of iOS and Mac OS X systems.
[0030] When designing and developing an application program for an iOS operating system using an Objective-C programming language, if multiple categories are added to the same class, and there are methods with the same name in the methods corresponding to the multiple categories respectively, the method defined later will cover the method defined earlier, which will affect the stability of the application program. Among them, a class can be understood as a collection of objects with the same properties and methods, and each object in the object collection has the properties and methods defined by the class. A category is a new method added on the basis of an existing class. For ease of understanding, for example, a class can correspond to multiple categories, and each category contains multiple methods, for example, in the first category of the target class, it contains two methods of rendering and live, and in the second category of the target class, it contains two methods of rendering and sayhello. Therefore, it can be understood that there are methods with the same name, i.e. "rendering", in the first category and the second category. And if it is known that the method in the second category is defined later than the method in the first category, the "rendering" in the second category will cover the "rendering" in the first category.
[0031] At present, generally, the source code of an application program is scanned by writing a script to collect the method names corresponding to all classifications of the target class, so as to determine whether there is a repeated method name. However, such a way needs to scan the complete application program source code, which is time-consuming and low in efficiency. Moreover, the running of the script occupies certain CPU and memory resources, and if the script is frequently run (for example, such a way is used for same name detection for each class), the computer performance will be affected to a certain extent.
[0032] In view of this, the embodiment of the present application provides a same name processing method, which solves the above problems by the following idea: obtaining an executable file of a target application program, and performing layer-by-layer analysis on the executable file. Specifically, first, based on the file header of the executable file, the classification information of a plurality of classifications corresponding to the target class of a set programming language is determined, and then according to the classification information, the method information (i.e. the method name) of the methods corresponding to the plurality of classifications respectively is determined. At this time, according to the method information, the methods with the same name in the plurality of classifications can be determined, so that the developer can perform subsequent processing on the methods with the same name. In this process, the source code of the target application program does not need to be obtained, and a script does not need to be written, which is not only high in work efficiency, but also does not affect the computer performance.
[0033] The same name processing method provided by the embodiment of the present application will be described below in combination with specific embodiments.
[0034] The same name processing method provided by the embodiment of the present application can be executed by an electronic device, which can be a terminal device such as a PC, a notebook computer, a smart phone, etc., or a server. The server can be a physical server containing a separate host, or can be a virtual server, or can be a cloud server or a server cluster.
[0035] Figure 1 The flowchart of the same name processing method provided by the embodiment of the present application is shown in Figure 1 The method comprises the following steps:
[0036] 101. Obtain an executable file of a target application program, wherein the executable file is obtained by compiling a set programming language, the executable file contains a file header for storing file basic information, and executable code executed by the target application program when running on a set device.
[0037] 102. Based on the file header, determine the classification information of a plurality of classifications corresponding to the target class of a set programming language.
[0038] 103. According to the classification information, determine the method information of the methods corresponding to the plurality of classifications respectively, wherein the method is used to execute a set operation when the target application program runs.
[0039] 104. Determine the method with the same name in the plurality of categories according to the method information corresponding to each of the plurality of categories.
[0040] It should be noted that the target application program can be an office application program, a game application program, a music application program, etc., which is not limited herein. The executable file of the target application program can be a Mach-O file, and the format of data in the Mach-O file is binary format. For ease of understanding, the executable file is taken as a Mach-O file for specific description below:
[0041] In actual application, the standard file I / O function of C language or Objective-C can be used to read the Mach-O file of the target application program. It can be understood that the Mach-O file includes a file header for storing basic information of the file, and executable code of the target application program executed when running on a set device. The file header at least includes a magic number (used to identify the file type, for example, 0xfeedface represents a 32-bit Mach-O file, and 0xfeedfacf represents a 64-bit Mach-O file), a CPU type (that is, to determine which CPU architecture the file is compiled for), a file type (used to indicate whether the file is an executable file, a dynamic library, a static library, or other types), a number of loading commands (the number of loading commands following the file header, which describe how to load each part of the file), etc., which are not listed one by one.
[0042] After obtaining the executable file, the classification information of the plurality of categories corresponding to the target class of the set programming language is determined based on the file header of the executable file, and the specific process is as follows: based on the file header information, the target architecture type of the set device is determined; based on the file header, the classification information of the plurality of categories corresponding to the target class of the set programming language is determined under the target architecture type.
[0043] In specific implementation, the file header can be parsed to obtain the cputype field in the file header, and the target architecture type of the set device is determined according to the value of the cputype field, for example, if the value of the cputype field is CPU_TYPE_ARM64, it is determined that the target architecture type is ARM64. Based on the advantages of the ARM64 architecture, such as greater memory addressing capability, higher performance, and better energy efficiency, the target architecture type in the embodiment of the application can preferably be the ARM64 architecture type, but is not limited thereto, and can also be the ARMv7 architecture type. The set device can be a terminal device such as a mobile phone or a tablet computer.
[0044] Further, after determining the target architecture type, the classification information of the multiple categories corresponding to the target class of the set programming language can be determined based on the file header under the ARM64 architecture, and the specific steps are as follows: in the target field in the file header, the target classification data segment is determined, the target field is used to store the data segment related to the class and category of the set programming language, and the target classification data segment contains the classification information of the multiple categories corresponding to the target class of the set programming language. By determining the target classification data segment in the target field in the file header, further analysis of the executable file is realized, which lays a foundation for subsequent acquisition of the method information of the methods corresponding to the multiple categories respectively.
[0045] It can be understood that, in addition to the above-mentioned examples, the file header can also contain a target field, which stores the data segment related to the class and category of the set programming language, and the specific form can be a_DATA field, which contains multiple data segments.
[0046] In specific implementation, the multiple data segments in the_DATA field can be traversed to find the target classification data segment, which contains the classification information of the multiple categories corresponding to the target class of the set programming language, and the specific form can be an_objc_catlist segment. At this time, the offset address and size of the objc_catlist segment are obtained. For ease of understanding, for example, it is assumed that there are 3000 bytes of data in the_DATA field, and the_objc_catlist segment occupies the 1700th-2000th byte. Therefore, the start address of the_objc_catlist segment is determined as the address of the 1700th byte, the offset address is the address of the 2000th byte, and the size is 300 bytes.
[0047] The target classification data segment contains multiple structure bodies for storing classification information, and the structure body corresponds to a category one by one.
[0048] For ease of understanding, the following will continue to take the_objc_catlist segment as an example to illustrate:
[0049] The_objc_catlist segment contains multiple category_t structure bodies corresponding to the multiple categories respectively, and the specific example of the category_t structure body is as follows:
[0050]
[0051] Assuming the target class is A, the corresponding classification can include A1, A2, A3...A100 (i.e. classification information), each classification corresponds to a category_t structure, through which the method names contained in each classification can be obtained, the specific process is as follows: in the structure corresponding to each of the multiple classifications, determine the method-related field; based on the index information in the method-related field, obtain the method names contained in each of the multiple classifications (i.e. method information), wherein the method is used to execute a set operation when the target application program is running, such as rendering, live streaming, sayhello, etc.
[0052] Take one of the multiple classifications (assume A1) as an example, the "category name" in the category_t structure corresponding to it is A1, and the "extended class" is A. The methods contained in the instance method list and / or class method list can include: method a, method b, method c. Wherein all or part of method a, method b, method c can be instance methods or class methods. Wherein "*" can be understood as index information, and its specific form can be a pointer.
[0053] In actual application, by parsing the category_t structure of each classification, the pointer of the instance method list and the pointer of the class method list corresponding to each classification (i.e. the method-related field) can be extracted. Since the instance method list and the class method list point to the method_list_t field (if the above example is followed, this field can also be called method64_list_t field) through the pointer, therefore, by parsing the method64_list_t field, the detailed information of the method64_t structure in it can be obtained, including: name field, types field and imp field. Wherein the name field is a pointer to the method name string, the types field contains the type signature information of the method (such as parameter type, return value type, etc.), and the imp field is a pointer to the method implementation code. By parsing the name field, the method name corresponding to each method in the classification can be obtained.
[0054] By determining the method-related field in the structure corresponding to each of the multiple classifications, and based on the index information in the method-related field, the method names contained in each of the multiple classifications are obtained, and the layer-by-layer analysis of the executable file is successfully completed, so that subsequent rapid judgment can be made on whether there are methods with the same name in the multiple classifications according to the method names contained in each of the multiple classifications.
[0055] For the specific process of the method for judging whether there are same-named methods in multiple classifications, for example, a dictionary (or a similar data structure) can be created, taking the method name as the key and taking an object (such as a method name, a type signature, an implementation address, a classification to which the method belongs, etc.) containing detailed information of the method as the value. The method information of the methods corresponding to the multiple classifications respectively collected is traversed to fill the dictionary. Then, the dictionary is traversed to check whether multiple values correspond to the same key (i.e., the method name). For the same-named methods in two classifications, the type signature and the implementation address are compared. If the type signature and the implementation address are the same, it is indicated that the two methods are the same method with the same name, and if the type signature and / or the implementation address are different, it is indicated that the two methods are different methods.
[0056] The same-name processing method provided by the embodiment of the application can obtain the method information of the methods corresponding to the multiple classifications by obtaining the executable file of the target application program and performing layer-by-layer parsing on the executable file (the specific layer-by-layer parsing process is as follows: first, the classification information of the multiple classifications corresponding to the target class of the set programming language is determined based on the file header of the executable file, and then the method information of the methods corresponding to the multiple classifications respectively is determined according to the classification information), and further, the same-named methods in the multiple classifications are determined according to the method information. The entire process does not need to obtain the source code of the target application program or write scripts, and thus is not only high in work efficiency but also does not affect the performance of the computer.
[0057] In addition, it can be understood that in the development of an IOS application program, the codes used by the developer are all natural languages, and finally, the natural languages need to be converted into a binary format that can be understood by the development device. The executable file in the binary format is used in the embodiment of the application, and thus the format conversion process can be effectively avoided, and the work efficiency is further improved.
[0058] Figure 2 A specific application flowchart of the same-name processing method provided by the embodiment of the application is shown in FIG. 1. Figure 2 The method includes the following steps.
[0059] 201. An executable file of a target application program is obtained, wherein the executable file is obtained by compiling a set programming language, the executable file includes a file header for storing basic information of the file, and executable code of the target application program executed when the target application program runs on a set device.
[0060] 202. Classification information of multiple classifications corresponding to a target class of a set programming language is determined based on the file header.
[0061] 203. Method information of methods corresponding to the multiple classifications respectively is determined according to the classification information, wherein the methods are used to perform a set operation when the target application program runs.
[0062] 204. Based on the method information corresponding to each of the multiple categories, determine the methods with the same name in the multiple categories.
[0063] 205. If it is determined that there is a first target method with the same name in the first category and the second category among multiple categories, then delete the first target method in the first category or the second category.
[0064] The specific execution process of steps 201-204 can be found in the above embodiments and will not be repeated here. For step 205, for ease of understanding, in specific implementation, for example, suppose that target class A has a first category A1 and a second category A2, where the first category A1 contains method a, method c and method d, and the second category A2 contains method a, method b and method e. The first category and the second category have a first target method with the same name (i.e., method a). In this case, you can choose to delete method a in the first category A1 or delete method a in the second category A2.
[0065] By deleting the first target method with the same name in either the first or second category when it is determined that there are multiple categories, the problem of method name duplication is effectively solved, ensuring the stable operation of the application.
[0066] Figure 3 Another specific application flowchart of a name-matching method provided in an embodiment of the present invention is shown below. Figure 3 As shown, the method includes the following steps:
[0067] 301. Obtain the executable file of the target application. The executable file is compiled using a specified programming language and contains a file header for storing basic file information, as well as executable code that is executed when the target application runs on the specified device.
[0068] 302. Based on the file header, determine the classification information of multiple categories corresponding to the target class of the programming language.
[0069] 303. Based on the classification information, determine the method information of the methods corresponding to each of the multiple categories, wherein the methods are used to perform the set operations when the target application is running.
[0070] 304. Based on the method information corresponding to each of the multiple categories, determine the methods with the same name in the multiple categories.
[0071] 305. If it is determined that there is a first target method with the same name in the first category and the second category among multiple categories, then modify the method name of the first target method in the first category or the second category so that the naming of the first target method in the first category and the second category is different.
[0072] The specific execution process of steps 301-304 can be referred to the above embodiment, and will not be described here. For step 305, for the convenience of understanding, in the implementation, for example, it is assumed that the target class A has a first classification A1 and a second classification A2, wherein the first classification A1 includes a method a, a method c and a method d, the second classification A2 includes a method a, a method b and a method e, and the first classification and the second classification have a same-named first target method (i.e. the method a). At this time, the name of the method a in the first classification A1 can be modified, for example, the name of the method a is modified to a method f, or the name of the method a in the second classification A2 can be modified, for example, the name of the method a is modified to a method j, as long as the name of the method a in the first classification and the second classification is no longer the same.
[0073] By modifying the method name of the first target method in the first classification or the second classification when it is determined that the first classification and the second classification in the plurality of classifications have a same-named first target method, the problem of method name duplication is effectively solved, and the stable operation of the application program is ensured.
[0074] In addition, it should be noted that in actual application, not only the classification can include a plurality of corresponding methods, but also the target class to which the plurality of classifications belong can include a plurality of methods. Therefore, if the same method name exists in the target class and the plurality of classifications corresponding to the target class (for example, the target class A includes a method a and a method b, and the classification A1 includes a method a and a method c, and it can be determined that the target class A and the classification A1 corresponding to the target class A have the same method name, i.e. the method a), the problem of method coverage will also occur.
[0075] Therefore, Figure 4 An application diagram of the same-name processing method provided by the embodiment of the present application is shown in Figure 4 The method comprises the following steps:
[0076] 401. In the target field of the file header, a target class data segment is determined, and the target class data segment includes methods corresponding to the target class of the set programming language.
[0077] 402. The methods corresponding to the target class are compared with the methods included in the classification corresponding to the target class, and a second target method with the same method name is determined.
[0078] In implementation, the target class data section can be determined from the target field of the file header (i.e., the above-mentioned_DATA field), which contains the methods corresponding to the target class of the set programming language, and the specific form can be_objc_classlist section. In the_objc_classlist section, the method information of the target class is generally stored in a cl ass_ro_t structure. By reading the method field of the cl ass_ro_t structure and comparing the method fields with the method fields (i.e., "instance_methods" and "class_methods") read from the objc_catlist section, the second target method with the same method name in the target class and the corresponding multiple categories can be determined.
[0079] By determining the second target method using the above method, the developer can be timely warned and reminded of the existence of the second target method with the same method name, so that the developer can perform corresponding processing on the second target method with the same method name, thereby effectively avoiding the occurrence of method coverage and ensuring the stable operation of the application program.
[0080] In summary, the same name processing method provided by the embodiments of the present application can obtain the method information of the methods corresponding to the multiple categories respectively by obtaining the executable file of the target application program and performing layer-by-layer parsing on the executable file (the specific layer-by-layer parsing process is as follows: first, based on the file header of the executable file, the category information of the multiple categories corresponding to the target class of the set programming language is determined, and then according to the category information, the method information of the methods corresponding to the multiple categories respectively is determined), and then the same name methods in the multiple categories are determined according to the method information. The entire process does not need to obtain the source code of the target application program, nor does it need to write scripts, which not only has high work efficiency, but also does not affect the performance of the computer. By using data sections such as_objc_catlist and method64_list_t, accurate positioning of the required data is achieved, meaningless data traversal and redundant processing are avoided, and the extraction and analysis of the category methods can be quickly completed.
[0081] The same name processing device of one or more embodiments of the present application will be described in detail below. Those skilled in the art can understand that these devices can be configured by using commercially available hardware components through the steps taught by the present solution.
[0082] Figure 5 A structural schematic diagram of a same name processing device provided by an embodiment of the present application is shown in Figure 5 The device includes an acquisition module 11 and a determination module 12.
[0083] The acquisition module 11 is configured to acquire an executable file of the target application program, wherein the executable file is obtained by compiling a programming language, the executable file comprises a file header for storing file basic information and executable code for executing the target application program on a specified device.
[0084] The determination module 12 is configured to determine, based on the file header, classification information of a plurality of classifications corresponding to a target class of the specified programming language, and determine, according to the classification information, method information of a plurality of methods corresponding to the plurality of classifications respectively, and determine a same-named method in the plurality of classifications according to the method information of the plurality of methods corresponding to the plurality of classifications respectively, wherein the method is used to perform a specified operation when the target application program is running.
[0085] Optionally, the apparatus further comprises a deletion module configured to delete a first target method in a first classification or a second classification if it is determined that the first target method is same-named in the first classification and the second classification.
[0086] Optionally, the apparatus further comprises a modification module configured to modify a method name of a first target method in a first classification or a second classification if it is determined that the first target method is same-named in the first classification and the second classification.
[0087] Optionally, the determination module 12 is specifically configured to determine a target architecture type of the specified device based on the file header information, and determine, based on the file header under the target architecture type, classification information of a plurality of classifications corresponding to a target class of the specified programming language, and determine a target classification data segment in a target field in the file header, the target field being used to store data segments related to classes and classifications of the specified programming language, and the target classification data segment comprising the classification information of the plurality of classifications corresponding to the target class of the specified programming language.
[0088] Optionally, the target classification data segment comprises a plurality of structure bodies for storing classification information, and the structure bodies correspond to the classifications one by one; and the determination module 12 is specifically further configured to determine a method-related field in a structure body corresponding to each of the plurality of classifications, and acquire a method name contained in each of the plurality of classifications based on index information in the method-related field.
[0089] Optionally, the determination module 12 is specifically further configured to determine a target class data segment in a target field of the file header, the target class data segment comprising a method corresponding to the target class of the specified programming language, and compare the method corresponding to the target class with a method contained in a classification corresponding to the target class to determine a second target method with a same method name.
[0090] wherein, optionally, the format of the data in the executable file is a binary format.
[0091] Figure 5 The apparatus shown can perform the steps provided in the foregoing embodiments, and refer to the detailed execution process and technical effects in the foregoing embodiments, which will not be repeated here.
[0092] In one possible design, the above Figure 5 The structure of the same-name processing apparatus shown can be implemented as an electronic device. For example, Figure 6 The electronic device shown can include a processor 21, a memory 22, and a communication interface 23. The memory 22 stores executable code, and when the executable code is executed by the processor 21, the processor 21 can at least implement the same-name processing method provided in the foregoing embodiments.
[0093] In addition, the embodiment of the present application provides a non-transitory machine readable storage medium, and the non-transitory machine readable storage medium stores executable code, and when the executable code is executed by the processor of the electronic device, the processor can at least implement the same-name processing method provided in the foregoing embodiments.
[0094] In addition, the embodiment of the present application provides a computer program product, and the computer program product includes a computer program, and when the computer program is executed by the processor of the electronic device, the processor can at least implement the same-name processing method provided in the foregoing embodiments.
[0095] The apparatus embodiments described above are only schematic, and the units described as separate components can or can not be physically separate. Some or all of the modules can be implemented to achieve the purposes of the embodiments. Those skilled in the art can understand and implement without creative labor.
[0096] From the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of a general hardware platform, and of course can also be implemented by means of hardware and application combination. Based on such understanding, the above technical solutions can be embodied in the form of computer program products, and the present application can be implemented in the form of computer program products on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program code.
[0097] It should be pointed out finally that the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit the same; and although the present application has been described in detail with reference to the foregoing embodiments, it should be appreciated by those skilled in the art that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features thereof can be replaced equivalently; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for handling duplicate names, characterized in that, The method is applied to the design and development of applications for the iOS operating system using the Objective-C programming language. The method includes: Obtain the executable file of the target application, wherein the executable file is compiled using the Objective-C programming language, and the executable file contains a file header for storing basic file information, as well as executable code that is executed by the target application when it runs on a specified device; Based on the file header, the target architecture type of the specified device is determined; Under the target architecture type, based on the file header, the classification information of multiple categories corresponding to the target class of the Objective-C programming language is determined. In the target field of the file header, a target classification data segment is determined. The target field is used to store data segments related to the class and category of the Objective-C programming language. The target classification data segment contains the classification information of multiple categories corresponding to the target class of the Objective-C programming language. The target classification data segment contains multiple structures for storing classification information, and the structures correspond one-to-one with the categories. In the structures corresponding to the multiple categories, method-related fields are determined, and based on the index information in the method-related fields, the method names contained in each of the multiple categories are obtained, wherein the method is used to perform a set operation when the target application is running; Based on the method names contained in each of the multiple categories, determine the methods with the same name in the multiple categories.
2. The method according to claim 1, characterized in that, Also includes: If it is determined that a first target method with the same name exists in the first category and the second category among the multiple categories, then the first target method in either the first category or the second category is deleted.
3. The method according to claim 1, characterized in that, Also includes: If it is determined that a first target method with the same name exists in the first category and the second category among the multiple categories, then the method name of the first target method in the first category or the second category is modified so that the naming of the first target method in the first category and the second category is different.
4. The method according to claim 1, characterized in that, Also includes: In the target field of the file header, a target class data segment is determined, which contains the methods corresponding to the target class of the Objective-C programming language; The methods corresponding to the target class are compared with the methods contained in the corresponding category of the target class to determine the second target method with the same method name.
5. The method according to any one of claims 1-4, characterized in that, The data in the executable file is in binary format.
6. A processing device with the same name, characterized in that, The device is used for designing and developing applications for the iOS operating system using the Objective-C programming language. The device includes: The acquisition module is used to acquire the executable file of the target application, wherein the executable file is compiled using the Objective-C programming language, and the executable file contains a file header for storing basic file information, as well as executable code that is executed by the target application when it runs on the specified device; The determination module is used to determine the target architecture type of the specified device based on the file header; under the target architecture type, in the target field of the file header, a target category data segment is determined, the target field is used to store data segments related to classes and categories of the Objective-C programming language, the target category data segment contains classification information of multiple categories corresponding to the target class of the Objective-C programming language, the target category data segment contains multiple structures for storing classification information, the structures correspond one-to-one with the categories; in the structures corresponding to each of the multiple categories, a method corresponding field is determined, based on the index information in the method corresponding field, the method name of the method contained in each of the multiple categories is obtained, and the method with the same name in the multiple categories is determined according to the method name contained in each of the multiple categories, wherein the method is used to perform a specified operation when the target application runs.
7. An electronic device, characterized in that, include: The system includes a memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor performs the processing method of the same name as described in any one of claims 1 to 5.
8. A non-transitory machine-readable storage medium, characterized in that, The non-transitory machine-readable storage medium stores executable code that, when executed by a processor of an electronic device, causes the processor to perform the processing method of the same name as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Test method and device based on test case identification, electronic equipment and medium
CN117215965A
Report generation method and device, equipment and medium
CN118821739A