CN103823663A - Method and device of calling member variables - Google Patents

Method and device of calling member variables Download PDF

Info

Publication number
CN103823663A
CN103823663A CN201210468095.0A CN201210468095A CN103823663A CN 103823663 A CN103823663 A CN 103823663A CN 201210468095 A CN201210468095 A CN 201210468095A CN 103823663 A CN103823663 A CN 103823663A
Authority
CN
China
Prior art keywords
member variable
dynamic link
link library
play amount
mark
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201210468095.0A
Other languages
Chinese (zh)
Other versions
CN103823663B (en
Inventor
牛东升
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201210468095.0A priority Critical patent/CN103823663B/en
Publication of CN103823663A publication Critical patent/CN103823663A/en
Application granted granted Critical
Publication of CN103823663B publication Critical patent/CN103823663B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a method and device of calling member variables, and belongs to the technical field of computers. The method includes analyzing the member variables contained by a dynamic link library, and acquiring offset of the member variables in class objects; storing identifiers of the member variables and the offset of the member variables in the class objects in the relation between the identifiers of the member variables and the offset; when calling the member variables to be called, calling the member variables to be called contained by the dynamic link library according to the relation between the identifiers of the member variables and the offset. The device comprises an acquiring module, a storing module and a calling module. According to the method and device, before the member variables contained by the dynamic link library is called, the correct offset of the member variables contained by the dynamic link library in the class objects is calculated, and accordingly calling errors can be avoided when the member variables are called.

Description

A kind of method and apparatus that calls member variable
Technical field
The present invention relates to field of computer technology, particularly a kind of method and apparatus that calls member variable.
Background technology
In computer system, dynamic link library comprises multiple class objects, and class object comprises multiple member variables, in the time needing to use certain member variable in application program operational process, first need to from this dynamic link library, call this member variable.
At present, the detailed process of calling member variable is: in the time of compiling of application, the side-play amount of the member variable that compiler can use application program in its place class object recorded into application program.In the time needing certain member variable in application program operational process, terminal is obtained the first address of this member variable place class object, and the side-play amount of recording during according to the first address of this member variable place class object and compiling is called this member variable from dynamic link library.
Realizing in process of the present invention, inventor finds that prior art at least exists following problem:
In the dynamic link library of different editions, the side-play amount of member variable may be different, and when compiling determined side-play amount only have portion, and dynamic link library may be revised in the time generating terminal by different terminals production firm, the position of the member variable in dynamic link library is changed, when the sequence of positions of definite member variable is called the member variable that dynamic link library comprises when so prior art is according to compiling, may occur calling the phenomenon of makeing mistakes.
Summary of the invention
Occur calling the phenomenon of makeing mistakes when calling the member variable that dynamic link library comprises, the embodiment of the present invention provides a kind of method and apparatus that calls member variable.Described technical scheme is as follows:
On the one hand, provide a kind of method of calling member variable, described method comprises:
The member variable that dynamic link library is comprised is analyzed, and obtains the side-play amount of described member variable in its place class object;
By the mark of described member variable and described member variable, the side-play amount in its place class object is stored in the mark of member variable and the corresponding relation of side-play amount;
When call wait call member variable time, according to the corresponding relation of the mark of described member variable and side-play amount, member variable to be called described in calling from described dynamic link library.
Wherein, the described member variable that dynamic link library is comprised is analyzed, and obtains the side-play amount of described member variable in its place class object, comprising:
The member variable comprising for dynamic link library arranges respectively a corresponding unique magic number, and the member variable that described dynamic link library is comprised replaces with the magic number of its correspondence;
The magic number that the mark of the member variable that described dynamic link library is comprised and described member variable are corresponding is stored in the mark of member variable and the corresponding relation of magic number;
According to the corresponding relation of the mark of described member variable and magic number, obtain member variable that described dynamic link library the comprises side-play amount in its place class object.
Wherein, the described member variable comprising for dynamic link library arranges respectively a corresponding unique magic number, and the member variable that described dynamic link library is comprised replaces with the magic number of its correspondence, comprising:
First member variable comprising from dynamic link library scans;
Unique magic number corresponding to member variable of described scanning is set;
Described member variable is replaced with to the magic number that described member variable is corresponding in described dynamic link library.
Further, described according to the corresponding relation of the mark of described member variable and magic number, obtain member variable that described dynamic link library the comprises side-play amount in its place class object, comprising:
From the mark of described member variable and the corresponding relation of magic number, obtain magic number corresponding to member variable that described dynamic link library comprises;
First magic number that member variable place class object comprises described in pointed is set, the initial value of pointer movement number of times is set;
The magic number magic number corresponding with described member variable of more described pointed, if both are identical, the side-play amount that described member variable is set is described pointer movement number of times, if both are different, the next magic number of pointed is set, increases described pointer movement number of times.
Wherein, described when call wait call member variable time, according to the corresponding relation of the mark of described member variable and side-play amount, member variable to be called described in calling from described dynamic link library, comprising:
When call wait call member variable time, according to the mark of member variable described to be called, member variable the to be called side-play amount in its place class object described in obtaining from the mark of described member variable and the corresponding relation of side-play amount;
The first address of member variable place class object to be called described in obtaining;
Side-play amount according to member variable described to be called in its place class object and described in the first address of member variable place class object to be called, member variable to be called described in calling from described dynamic link library.
On the other hand, provide a kind of device that calls member variable, described device comprises:
Acquisition module, analyzes for the member variable that dynamic link library is comprised, obtains the side-play amount of described member variable in its place class object;
Memory module, is stored in the mark of member variable and the corresponding relation of side-play amount in the side-play amount of its place class object for the described member variable that the mark of described member variable and described acquisition module are obtained;
Calling module, for when call wait call member variable time, according to the corresponding relation of the mark of the described member variable of described memory module storage and side-play amount, member variable to be called described in calling from described dynamic link library.
Wherein, described acquisition module comprises:
Replacement unit, is used to the member variable that dynamic link library comprises that a corresponding unique magic number is set respectively, and the member variable that described dynamic link library is comprised replaces with the magic number of its correspondence;
Storage unit, is stored in the mark of member variable and the corresponding relation of magic number for mark and the magic number corresponding to described member variable of member variable that described dynamic link library is comprised;
The first acquiring unit, for according to the corresponding relation of the mark of the described member variable of described cell stores and magic number, obtains member variable that described dynamic link library the comprises side-play amount in its place class object.
Wherein, described replacement unit comprises:
Scanning subelement, scans for first member variable comprising from dynamic link library;
First arranges subelement, for unique magic number corresponding to member variable of described scanning is set;
Replace subelement, for described member variable being replaced with to the magic number that described member variable is corresponding at described dynamic link library.
Further, described acquiring unit comprises:
Obtain subelement, for the corresponding relation of the mark from described member variable and magic number, obtain magic number corresponding to member variable that described dynamic link library comprises;
Second arranges subelement, for first magic number that member variable place class object comprises described in pointed is set, the initial value of pointer movement number of times is set;
The 3rd arranges subelement, for the magic number magic number corresponding with described member variable of more described pointed, if both are identical, the side-play amount that described member variable is set is described pointer movement number of times, if both are different, the next magic number of pointed is set, increases described pointer movement number of times.
Wherein, described calling module comprises:
Second acquisition unit, for when call wait call member variable time, according to the mark of member variable described to be called, member variable the to be called side-play amount in its place class object described in obtaining from the mark of described member variable and the corresponding relation of side-play amount;
The 3rd acquiring unit, for the first address of member variable place class object to be called described in obtaining;
Call unit, for member variable to be called described in basis the side-play amount of its place class object and described in the first address of member variable place class object to be called, member variable to be called described in calling from described dynamic link library.
In embodiments of the present invention, the member variable that dynamic link library is comprised is analyzed, and obtains the side-play amount of this member variable in its place class object; By the mark of this member variable and this member variable, the side-play amount in its place class object is stored in the mark of member variable and the corresponding relation of side-play amount; When call wait call member variable time, according to the corresponding relation of the mark of member variable and side-play amount, from this dynamic link library, call member variable to be called.Wherein, before calling member variable to be called, calculate member variable correct side-play amount in its place class object that dynamic link library comprises, when call wait call member variable time, according to the first address of member variable place class object to be called and member variable correct side-play amount in its place class object to be called, from this dynamic link library, call member variable to be called, so, can avoid calling the member variable that dynamic link library comprises time, occur calling the phenomenon of makeing mistakes.
Accompanying drawing explanation
Fig. 1 is a kind of method flow diagram that calls member variable that the embodiment of the present invention one provides;
Fig. 2 is a kind of method flow diagram that calls member variable that the embodiment of the present invention two provides;
Fig. 3 is the structural representation of the dynamic link library of a kind of encapsulation of providing of the embodiment of the present invention two;
Fig. 4 is a kind of apparatus structure schematic diagram that calls member variable that the embodiment of the present invention three provides.
Embodiment
For making the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing, embodiment of the present invention is described further in detail.
Embodiment mono-
The embodiment of the present invention provides a kind of method of calling member variable, and referring to Fig. 1, the method comprises:
Step 101: the member variable that dynamic link library is comprised is analyzed, obtains the side-play amount of this member variable in its place class object;
Step 102: the side-play amount in its place class object is stored in the mark of member variable and the corresponding relation of side-play amount by the mark of this member variable and this member variable;
Step 103: when call wait call member variable time, according to the corresponding relation of the mark of this member variable and side-play amount, from this dynamic link library, call member variable to be called.
In embodiments of the present invention, the member variable that dynamic link library is comprised is analyzed, and obtains the side-play amount of this member variable in its place class object; By the mark of this member variable and this member variable, the side-play amount in its place class object is stored in the mark of member variable and the corresponding relation of side-play amount; When call wait call member variable time, according to the corresponding relation of the mark of member variable and side-play amount, from this dynamic link library, call member variable to be called.Wherein, before calling member variable to be called, calculate member variable correct side-play amount in its place class object that dynamic link library comprises, when call wait call member variable time, according to the first address of member variable place class object to be called and member variable correct side-play amount in its place class object to be called, from this dynamic link library, call member variable to be called, so, can avoid calling the member variable that dynamic link library comprises time, occur calling the phenomenon of makeing mistakes.
Embodiment bis-
The embodiment of the present invention provides a kind of method of calling member variable.Wherein, in identical version dynamic link library, also likely there is member variable problem of misalignment, re-start calculating so needed to treat the side-play amount of the member variable calling in its place class object before calling member variable to be called.Referring to Fig. 2, the method comprises:
Step 201: terminal loads dynamic link library, this dynamic link library comprises public dynamic link library and difference dynamic link library;
Particularly, terminal is loaded into public dynamic link library in internal memory, obtain the version identifier of this dynamic link library by dynamic link library difference manager, according to this dynamic link library version identifier, difference dynamic link library corresponding this dynamic link library is loaded in internal memory.
Wherein, for any dynamic link library, the identical interface and the member variable that in advance the dynamic link library of different editions corresponding this dynamic link library are comprised are encapsulated in a public dynamic link library, remaining interface and member variable the interface comprising except public dynamic link library in each version dynamic link library and member variable are encapsulated in the difference dynamic link library that each dynamic link library is corresponding, so obtain a public dynamic link library and difference dynamic link library corresponding to each version that this dynamic link library comprises.
For example, the dynamic link library of encapsulation as shown in Figure 3 comprises public dynamic link library and difference dynamic link library, the version of dynamic link library comprises V1.0, V2.1 and V3.2, extract V1.0 dynamic link library, identical interface and member variables all in V2.1 dynamic link library and V3.2 dynamic link library, by the V1.0 dynamic link library extracting, in V2.1 dynamic link library and V3.2 dynamic link library, all identical interface and member variable is encapsulated in public dynamic link library, remaining interface and member variable the interface comprising except public dynamic link library in V1.0 dynamic link library and member variable are encapsulated in difference dynamic link library 1, remaining interface and member variable the interface comprising except public dynamic link library in V2.1 dynamic link library and member variable are encapsulated in difference dynamic link library 2, remaining interface and member variable the interface comprising except public dynamic link library in V3.2 dynamic link library and member variable are encapsulated in difference dynamic link library 3.
Step 202: the member variable comprising for this dynamic link library arranges respectively a corresponding unique magic number, and the member variable that this dynamic link library is comprised replaces with the magic number of its correspondence;
Particularly, first member variable comprising from this dynamic link library starts to scan, for the member variable of scanning arranges unique magic number of its correspondence, and the member variable of scanning is replaced with to the magic number that this member variable is corresponding in this dynamic link library, whether the member variable that judges scanning is last member variable that this dynamic link library comprises, if not, continues the next member variable that this dynamic link library of scanning comprises, if so, end operation.
For example, in the code of the class object SkBitmap of dynamic link library as follows, this class object SkBitmap comprises member variable iNum, member variable iCount, member variable printCount (void) and member variable incCount (void).
The code of the class object of dynamic link library:
Figure BDA00002428997800061
Scan the member variable iNum that this dynamic link library comprises, for the member variable iNum of scanning, that a unique evil spirit is set is several 11, in dynamic link library as follows, member variable iNum is replaced with to 11; Scanning member variable i Count, for the member variable iCount of scanning, that a unique evil spirit is set is several 12, in dynamic link library as follows, member variable iCount is replaced with to 12; Scanning member variable printCount (void), for the member variable printCount (void) of scanning, that a unique evil spirit is set is several 13, in dynamic link library as follows, the member variable printCount (void) of scanning is replaced with to 13; Scanning member variable i ncCount (void), for the member variable incCount (void) of scanning, that a unique evil spirit is set is several 14, in dynamic link library as follows, member variable incCount (void) is replaced with to 14.
The code of the class object of dynamic link library:
Figure BDA00002428997800071
Step 203: the magic number that the mark of the member variable that this dynamic link library is comprised and this member variable are corresponding is stored in the mark of member variable and the corresponding relation of magic number;
Wherein, in step 202, scan the member variable in the class object that this dynamic link library comprises, for after this member arranges a corresponding unique magic number, the mark of the member variable of scanning and magic number corresponding to this member variable are stored in the mark of member variable and the corresponding relation of magic number.
For example, member variable iNum is designated Name1, member variable iCount is designated Name2, member variable printCount (void) is designated Name3, member variable incCount (void) is designated Name4, scanning member variable i Num, and be after 11 for member variable 1 arranges a corresponding unique magic number, the mark Name1 of member variable iNum and a unique evil spirit several 11 corresponding to member variable iNum are stored in the mark of member variable as shown in table 1 and the corresponding relation of magic number, scanning member variable i Count, be after 12 for member variable iCount arranges a corresponding unique magic number, the mark Name2 of member variable iCount and a unique evil spirit several 12 corresponding to member variable iCount are stored in the mark of member variable as shown in table 1 and the corresponding relation of magic number, scanning member variable printCount (void), be after 13 for member variable printCount (void) arranges a corresponding unique magic number, the mark Name3 of member variable printCount (void) and a unique evil spirit several 13 corresponding to member variable printCount (void) are stored in the mark of member variable as shown in table 1 and the corresponding relation of magic number, scanning member variable i ncCount (void), for after member variable incCount (void) arranges a corresponding unique evil spirit several 14, the mark Name4 of member variable incCount (void) and a unique evil spirit several 14 corresponding to member variable incCount (void) are stored in the mark of member variable as shown in table 1 and the corresponding relation of magic number.
Table 1
The mark of member variable Evil spirit number
Name1 11
Name2 12
Name3 13
Name4 14
Step 204: according to the corresponding relation of the mark of member variable and magic number, obtain member variable that this dynamic link library the comprises side-play amount in its place class object;
Particularly, this step can be divided into the step of following (1)-(4):
(1), from the mark of member variable and the corresponding relation of magic number, obtain magic number corresponding to member variable that this dynamic link library comprises;
Particularly, the Article 1 record in the scanning mark of member variable and the corresponding relation of magic number obtains mark and the magic number corresponding to this member variable of the member variable that this dynamic link library comprises from the Article 1 record of scanning.
(2), find out the class object at this member variable place according to the mark of this member variable;
Particularly, find this member variable place class object according to the mark of this member variable, obtain the first address of the class object at this member variable place, according to the first address of this member variable place class object, in this dynamic link library, orient this class object.
(3), first magic number that this member variable place class object of pointed comprises is set, the initial value of pointer movement number of times is set;
Particularly, start to search first magic number that this class object comprises from the first address of this class object, first magic number that this member variable place class object of pointed comprises is set, the initial value of pointer movement number of times is set.
Wherein, the initial value of pointer movement number of times can be set to 0.
(4), the magic number of this pointed magic number corresponding with this member variable relatively, if both are identical, the side-play amount that this member variable is set is pointer movement number of times, return to step (1), if both are different, the next magic number of pointed is set, increases pointer movement number of times, continue to carry out this step.
Particularly, obtain the magic number of pointed, the magic number of pointed and magic number corresponding to this member variable are compared, if the magic number that the magic number of pointed is corresponding with this member variable is identical, the side-play amount that this member variable is set is pointer movement number of times, return to step (1) and obtain the magic number of next member variable, and determine the side-play amount of next member variable in its place class object; If the magic number that the magic number of pointed and this member variable are corresponding is not identical, moving hand makes the next magic number of pointed, and increases pointer movement number of times, continues to carry out this step.
Wherein, increasing pointer movement number of times can be: pointer movement number of times is added to 1.
Wherein, if the magic number of this pointed magic number corresponding with this member variable is identical, judge in this member variable place class object whether also have magic number corresponding to member variable, if had, return to step (1); Otherwise, end operation.
For example, Article 2 record in the scanning mark of member variable and the corresponding relation of magic number, from the Article 2 record of scanning, obtain mark Name2 and evil spirit several 12 corresponding to this member variable iCount of the member variable iCount that this dynamic link library comprises, find out this member variable iCount place class object SkBitmap according to the mark Name2 of this member variable, obtain the first address 0005H of this class object SkBitmap, orient this class object SkBitmap according to the first address 0005H of this member variable iCount place class object SkBitmap, start to search from the first address 0005H of this class object SkBitmap first magic number that this class object comprises, if first magic number that this class object comprises is 11, pointed evil spirit several 11 is set, and the initial value that pointer movement number of times is set is 0, judge the evil spirit several 11 of pointed and evil spirit several 12 corresponding to member variable iCount that scanning is obtained, the evil spirit several 12 obtaining due to evil spirit several 11 and the scanning of pointed is not identical, moving hand points to next magic number, pointer movement number of times is added to 1, if the magic number pointing to after pointer movement is 12, evil spirit that the magic number of known pointed and the member variable iCount that obtains of scanning are corresponding is several 12 identical, obtaining pointer movement number of times is 1, so it is 0001H that the side-play amount of member's variable i Count in class object SkBitmap is set.
Step 205: the side-play amount in its place class object is stored in the mark of member variable and the corresponding relation of side-play amount by the mark of this member variable and this member variable;
Wherein, if the magic number that the member variable of the magic number of pointed and scanning is corresponding is identical, the side-play amount of the member variable that scanning is set in its place class object is pointer movement number of times, and the side-play amount in its place class object is stored in the mark of member variable and the corresponding relation of side-play amount by the mark of the member variable of scanning and this member variable.
Wherein, when the version of dynamic link library identical, and different terminals production firm has changed this dynamic link library in the time generating terminal, the position of the member variable in dynamic link library is changed, the method providing according to the embodiment of the present invention is determined member variable correct side-play amount in its place class object, can avoid calling the phenomenon of makeing mistakes; And when occurring the dynamic link library of redaction, and when the sequence of positions of the member variable that this redaction dynamic link library comprises is different, the method that also can provide according to the embodiment of the present invention is determined the correct side-play amount of member variable, thereby avoid calling the phenomenon of makeing mistakes, realize the upward compatibility of member variable.
Wherein, after the mark of the member variable that this dynamic link library is comprised and the side-play amount of this member variable in its class object are stored in the mark of member variable and the corresponding relation of side-play amount, discharge the public dynamic link library of encapsulation and the internal memory that difference dynamic link library corresponding to this dynamic link library takies.
For example, the side-play amount of member variable iNum in class object SkBitmap is 0000H, and by the mark Name1 of member variable iNum and member variable iNum, the side-play amount in class object SkBitmap is that 0000H is stored in the mark of member variable as shown in table 2 below and the corresponding relation of side-play amount; The side-play amount of member variable iCount in class object SkBitmap is 0001H, and by the mark Name2 of member variable iCount and member variable iCount, the side-play amount in class object SkBitmap is that 0001H is stored in the mark of member variable as shown in table 2 below and the corresponding relation of side-play amount; The side-play amount of member variable printCount (void) in class object SkBitmap is 0002H, and by the mark Name3 of member variable printCount (void) and member variable printCount (void), the side-play amount in class object SkBitmap is that 0002H is stored in the mark of member variable as shown in table 2 below and the corresponding relation of side-play amount; The side-play amount of member variable incCount (void) in class object SkBitmap is 0003H, and by the mark Name4 of member variable incCount (void) and member variable incCount (void), the side-play amount in class object SkBitmap is that 0003H is stored in the mark of member variable as shown in table 2 below and the corresponding relation of side-play amount.
Table 2
The mark of member variable Side-play amount
Name1 0000H
Name2 0001H
Name3 0002H
Name4 0003H
Wherein, in the time needing to call this dynamic link library in the operational process of application program, load public dynamic link library and the difference dynamic link library corresponding to this dynamic link library of encapsulation.
Step 206: in the time of this dynamic link library of application call, load public dynamic link library and the difference dynamic link library corresponding to this dynamic link library of encapsulation;
Wherein, in the time of this dynamic link library of application call, terminal is loaded into public dynamic link library in internal memory, obtain the version identifier of this dynamic link library by dynamic link library difference manager, according to the version identifier of this dynamic link library, difference dynamic link library corresponding this dynamic link library version identifier is loaded in internal memory.
Wherein, in the time of certain member variable in this dynamic link library of application call, this member variable is member variable to be called.
Step 207: when call wait call member variable time, according to the corresponding relation of the mark of member variable and side-play amount, from this dynamic link library, call member variable to be called.
Particularly, when call wait call member variable time, according to the mark of member variable to be called, from the mark of member variable and the corresponding relation of side-play amount, obtain member variable the to be called side-play amount in its place class object, obtain the first address of member variable place class object to be called, the offset addition in its place class object by the first address of member variable place class object to be called and member variable to be called, obtain member variable the to be called address in internal memory, call by location member variable to be called according to member variable to be called in internal memory.
Wherein, in embodiments of the present invention, in the time that application program is moved for the first time in this terminal, the member variable that dynamic link library is comprised is analyzed, obtain member variable that this dynamic link library the comprises side-play amount in its place class object, the mark of the member variable that this dynamic link library is comprised and this member variable side-play amount in its place internal memory is stored in the mark of member variable and the corresponding relation of side-play amount, and the corresponding relation of the mark of member variable and side-play amount is stored in a configuration file, this configuration file is kept in terminal, in the time that this application program is moved again, directly from this configuration file of this terminal storage, obtain mark and the side-play amount of this member variable in its place class object of the member variable that this dynamic link library comprises.
Alternatively, the said method that the embodiment of the present invention provides can also be: in the time that application program is moved, the member variable that dynamic link library is comprised is analyzed, obtain member variable that this dynamic link library the comprises side-play amount in its place class object, the mark of the member variable that this dynamic link library is comprised and this member variable side-play amount in its place class object is stored in the mark of member variable and the corresponding relation of side-play amount, and this corresponding relation is stored in internal memory, will call the member variable that this dynamic link library comprises in application program operational process time, the mark of member variable of preserving from internal memory and the corresponding relation of side-play amount, obtain the side-play amount of this member variable in its place class object, and call this member variable according to the first address of the place class object of this member variable and the side-play amount of this member variable in its place class object, in the time that application program finishes to move, discharge the internal memory that the mark of member variable that this dynamic link library comprises and the corresponding relation of side-play amount take, in the time that this application program is moved again, then the member variable that this dynamic link library is comprised analyzes, and obtains member variable that this dynamic link library the comprises side-play amount in its place class object.
For example, member variable to be called is the member variable printCount (void) in class object SkBitmap, from the mark of member variable and the corresponding relation of side-play amount, obtain member variable printCount (void) the to be called side-play amount 0002H in class object SkBitmap according to the mark Name3 of member variable printCount (void) to be called, obtaining member variable printCount (void) to be called is 0010H at the first address of the class object SkBitmap at place, by the first address 0010H of member variable printCount (void) place class object SkBitmap to be called and member variable printCount (void) to be called, the side-play amount 0002H in class object SkBitmap is added, obtaining member variable printCount (void) the to be called address in internal memory is 0012H, call member variable printCount (void) to be called according to the memory address 0012H of member variable printCount (void) to be called.
In embodiments of the present invention, the member variable that dynamic link library is comprised is analyzed, and obtains the side-play amount of this member variable in its place class object; By the mark of this member variable and this member variable, the side-play amount in its place class object is stored in the mark of member variable and the corresponding relation of side-play amount; When call wait call member variable time, according to the corresponding relation of the mark of member variable and side-play amount, from this dynamic link library, call member variable to be called.Wherein, before calling member variable to be called, calculate member variable correct side-play amount in its place class object that dynamic link library comprises, when call wait call member variable time, according to the first address of member variable place class object to be called and member variable correct side-play amount in its place class object to be called, from this dynamic link library, call member variable to be called, so, can avoid calling the member variable that dynamic link library comprises time, occur calling the phenomenon of makeing mistakes.
Embodiment tri-
Referring to Fig. 4, the embodiment of the present invention provides a kind of device that calls member variable, and this device comprises:
Acquisition module 401, analyzes for the member variable that dynamic link library is comprised, obtains the side-play amount of this member variable in its place class object;
Memory module 402, is stored in the mark of member variable and the corresponding relation of side-play amount in the side-play amount of its place class object for this member variable that the mark of this member variable and acquisition module are obtained;
Calling module 403, for when call wait call member variable time, according to the corresponding relation of the mark of the member variable of memory module storage and side-play amount, from this dynamic link library, call member variable to be called.
Wherein, acquisition module 401 comprises:
Replacement unit, is used to the member variable that dynamic link library comprises that a corresponding unique magic number is set respectively, and the member variable that this dynamic link library is comprised replaces with the magic number of its correspondence;
Storage unit, is stored in the mark of member variable and the corresponding relation of magic number for mark and the magic number corresponding to this member variable of member variable that this dynamic link library is comprised;
The first acquiring unit, for according to the corresponding relation of the mark of the member variable of cell stores and magic number, obtains member variable that this dynamic link library the comprises side-play amount in its place class object.
Further, replacement unit comprises:
Scanning subelement, scans for first member variable comprising from dynamic link library;
First arranges subelement, for unique magic number corresponding to member variable of scanning is set;
Replace subelement, for the member variable of scanning being replaced with to the magic number that this member variable is corresponding at this dynamic link library.
Further, acquiring unit comprises:
Obtain subelement, for the corresponding relation of the mark from member variable and magic number, obtain magic number corresponding to member variable that this dynamic link library comprises;
Second arranges subelement, and first the magic number comprising for this member variable place class object of pointed is set arranges the initial value of pointer movement number of times;
The 3rd arranges subelement, for comparing the magic number magic number corresponding with this member variable of pointed, if both are identical, the side-play amount that this member variable is set is pointer movement number of times, if both are different, the next magic number of pointed is set, increase pointer movement number of times.
Wherein, calling module 403 comprises:
Second acquisition unit, for when call wait call member variable time, according to the mark of member variable to be called, from the mark of member variable and the corresponding relation of side-play amount, obtain member variable the to be called side-play amount in its place class object;
The 3rd acquiring unit, for obtaining the first address of member variable place class object to be called;
Call unit for the first address at the side-play amount of its place class object and member variable place class object to be called according to member variable to be called, calls member variable to be called from this dynamic link library.
In embodiments of the present invention, the member variable that dynamic link library is comprised is analyzed, and obtains the side-play amount of this member variable in its place class object; By the mark of this member variable and this member variable, the side-play amount in its place class object is stored in the mark of member variable and the corresponding relation of side-play amount; When call wait call member variable time, according to the corresponding relation of the mark of member variable and side-play amount, from this dynamic link library, call member variable to be called.Wherein, before calling member variable to be called, calculate member variable correct side-play amount in its place class object that dynamic link library comprises, when call wait call member variable time, according to the first address of member variable place class object to be called and member variable correct side-play amount in its place class object to be called, from this dynamic link library, call member variable to be called, so, can avoid calling the member variable that dynamic link library comprises time, occur calling the phenomenon of makeing mistakes.
One of ordinary skill in the art will appreciate that all or part of step that realizes above-described embodiment can complete by hardware, also can carry out the hardware that instruction is relevant by program completes, described program can be stored in a kind of computer-readable recording medium, the above-mentioned storage medium of mentioning can be ROM (read-only memory), disk or CD etc.
The foregoing is only preferred embodiment of the present invention, in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.

Claims (10)

1. a method of calling member variable, is characterized in that, described method comprises:
The member variable that dynamic link library is comprised is analyzed, and obtains the side-play amount of described member variable in its place class object;
By the mark of described member variable and described member variable, the side-play amount in its place class object is stored in the mark of member variable and the corresponding relation of side-play amount;
When call wait call member variable time, according to the corresponding relation of the mark of described member variable and side-play amount, member variable to be called described in calling from described dynamic link library.
2. method according to claim 1, is characterized in that, the described member variable that dynamic link library is comprised is analyzed, and obtains the side-play amount of described member variable in its place class object, comprising:
The member variable comprising for dynamic link library arranges respectively a corresponding unique magic number, and the member variable that described dynamic link library is comprised replaces with the magic number of its correspondence;
The magic number that the mark of the member variable that described dynamic link library is comprised and described member variable are corresponding is stored in the mark of member variable and the corresponding relation of magic number;
According to the corresponding relation of the mark of described member variable and magic number, obtain member variable that described dynamic link library the comprises side-play amount in its place class object.
3. method according to claim 2, is characterized in that, the described member variable comprising for dynamic link library arranges respectively a corresponding unique magic number, and the member variable that described dynamic link library is comprised replaces with the magic number of its correspondence, comprising:
First member variable comprising from dynamic link library scans;
Unique magic number corresponding to member variable of described scanning is set;
Described member variable is replaced with to the magic number that described member variable is corresponding in described dynamic link library.
4. method according to claim 2, is characterized in that, described according to the corresponding relation of the mark of described member variable and magic number, obtains member variable that described dynamic link library the comprises side-play amount in its place class object, comprising:
From the mark of described member variable and the corresponding relation of magic number, obtain magic number corresponding to member variable that described dynamic link library comprises;
First magic number that member variable place class object comprises described in pointed is set, the initial value of pointer movement number of times is set;
The magic number magic number corresponding with described member variable of more described pointed, if both are identical, the side-play amount that described member variable is set is described pointer movement number of times, if both are different, the next magic number of pointed is set, increases described pointer movement number of times.
5. method according to claim 1, is characterized in that, described when call wait call member variable time, according to the corresponding relation of the mark of described member variable and side-play amount, member variable to be called described in calling from described dynamic link library, comprising:
When call wait call member variable time, according to the mark of member variable described to be called, member variable the to be called side-play amount in its place class object described in obtaining from the mark of described member variable and the corresponding relation of side-play amount;
The first address of member variable place class object to be called described in obtaining;
Side-play amount according to member variable described to be called in its place class object and described in the first address of member variable place class object to be called, member variable to be called described in calling from described dynamic link library.
6. a device that calls member variable, is characterized in that, described device comprises:
Acquisition module, analyzes for the member variable that dynamic link library is comprised, obtains the side-play amount of described member variable in its place class object;
Memory module, is stored in the mark of member variable and the corresponding relation of side-play amount in the side-play amount of its place class object for the described member variable that the mark of described member variable and described acquisition module are obtained;
Calling module, for when call wait call member variable time, according to the corresponding relation of the mark of the described member variable of described memory module storage and side-play amount, member variable to be called described in calling from described dynamic link library.
7. device according to claim 6, is characterized in that, described acquisition module comprises:
Replacement unit, is used to the member variable that dynamic link library comprises that a corresponding unique magic number is set respectively, and the member variable that described dynamic link library is comprised replaces with the magic number of its correspondence;
Storage unit, is stored in the mark of member variable and the corresponding relation of magic number for mark and the magic number corresponding to described member variable of member variable that described dynamic link library is comprised;
The first acquiring unit, for according to the corresponding relation of the mark of the described member variable of described cell stores and magic number, obtains member variable that described dynamic link library the comprises side-play amount in its place class object.
8. device according to claim 7, is characterized in that, described replacement unit comprises:
Scanning subelement, scans for first member variable comprising from dynamic link library;
First arranges subelement, for unique magic number corresponding to member variable of described scanning is set;
Replace subelement, for described member variable being replaced with to the magic number that described member variable is corresponding at described dynamic link library.
9. device according to claim 7, is characterized in that, described acquiring unit comprises:
Obtain subelement, for the corresponding relation of the mark from described member variable and magic number, obtain magic number corresponding to member variable that described dynamic link library comprises;
Second arranges subelement, for first magic number that member variable place class object comprises described in pointed is set, the initial value of pointer movement number of times is set;
The 3rd arranges subelement, for the magic number magic number corresponding with described member variable of more described pointed, if both are identical, the side-play amount that described member variable is set is described pointer movement number of times, if both are different, the next magic number of pointed is set, increases described pointer movement number of times.
10. device according to claim 6, is characterized in that, described calling module comprises:
Second acquisition unit, for when call wait call member variable time, according to the mark of member variable described to be called, member variable the to be called side-play amount in its place class object described in obtaining from the mark of described member variable and the corresponding relation of side-play amount;
The 3rd acquiring unit, for the first address of member variable place class object to be called described in obtaining;
Call unit, for member variable to be called described in basis the side-play amount of its place class object and described in the first address of member variable place class object to be called, member variable to be called described in calling from described dynamic link library.
CN201210468095.0A 2012-11-19 2012-11-19 A kind of method and apparatus for calling member variable Active CN103823663B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210468095.0A CN103823663B (en) 2012-11-19 2012-11-19 A kind of method and apparatus for calling member variable

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210468095.0A CN103823663B (en) 2012-11-19 2012-11-19 A kind of method and apparatus for calling member variable

Publications (2)

Publication Number Publication Date
CN103823663A true CN103823663A (en) 2014-05-28
CN103823663B CN103823663B (en) 2017-12-01

Family

ID=50758751

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210468095.0A Active CN103823663B (en) 2012-11-19 2012-11-19 A kind of method and apparatus for calling member variable

Country Status (1)

Country Link
CN (1) CN103823663B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106502745A (en) * 2016-10-26 2017-03-15 腾讯科技(深圳)有限公司 A kind of function calling method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010032281A1 (en) * 1998-06-30 2001-10-18 Laurent Daynes Method and apparatus for filtering lock requests
US20020129177A1 (en) * 2000-12-15 2002-09-12 Mcguire Richard Kenneth System and method for class loader constraint checking
CN1632761A (en) * 2003-12-24 2005-06-29 华为技术有限公司 Method for traversing and accessing object in tested application program
CN102023843A (en) * 2010-11-24 2011-04-20 北京握奇数据系统有限公司 Function calling method and device as well as smart card
CN101714075B (en) * 2009-12-17 2012-12-19 深圳市万兴软件有限公司 Function calling method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010032281A1 (en) * 1998-06-30 2001-10-18 Laurent Daynes Method and apparatus for filtering lock requests
US20020129177A1 (en) * 2000-12-15 2002-09-12 Mcguire Richard Kenneth System and method for class loader constraint checking
CN1632761A (en) * 2003-12-24 2005-06-29 华为技术有限公司 Method for traversing and accessing object in tested application program
CN101714075B (en) * 2009-12-17 2012-12-19 深圳市万兴软件有限公司 Function calling method and device
CN102023843A (en) * 2010-11-24 2011-04-20 北京握奇数据系统有限公司 Function calling method and device as well as smart card

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106502745A (en) * 2016-10-26 2017-03-15 腾讯科技(深圳)有限公司 A kind of function calling method and device

Also Published As

Publication number Publication date
CN103823663B (en) 2017-12-01

Similar Documents

Publication Publication Date Title
US9430224B2 (en) Hot-update method and apparatus
US8566372B2 (en) Method and device for dynamically loading relocatable file
CN104008060B (en) Method for detecting compatibility of plug-in and host, and detection server
US9558096B2 (en) Method and apparatus for supporting performance analysis
US20040268370A1 (en) Exception handling
US20110138236A1 (en) Apparatus and method for providing visual interface for information of error generated in multithread testing
CN106354536A (en) Method and device of loading ELF file of Linux system in Windows system
CN104636203A (en) Method and apparatus to represent a processor context with fewer bits
CN102495790A (en) Version change difference identifier and version change identification method
CN105760292A (en) Assertion verification method and device for unit testing
CN100492286C (en) Performance optimization design method for graph library of embedded system development platform
CN103777978A (en) Automatic user-mode 3G-USB network interface card detecting method based on Linux kernel
CN107544811B (en) Method, storage medium, electronic device and system for hiding dylib file in IOS platform
JP2009026081A (en) Memory management method, information processor, and memory management program
CN111027054A (en) Method and system for judging running of application program in multi-open environment based on android system
CN101493775A (en) Dynamic loading system and loading method thereof for embedded system
CN103823663A (en) Method and device of calling member variables
US20050097258A1 (en) Systems and methods for accessing thread private data
CN105335432A (en) Oracle database access method
CN116628027A (en) Cross-database query method, apparatus, device, medium and computer program product
CN103019663A (en) Method and system for acquiring intermodule function interface in program
US9495278B2 (en) Dynamic discovery of data segments within instrumented code
CN110187884B (en) Memory access instruction instrumentation optimization method in multi-thread application scene
CN102724591A (en) Set top box page displaying method and set top box device
CN113590133A (en) Android system injection detection method, device, equipment and computer storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant