Friday, 6 September 2013

What's does it mean of" /* overloaded elements data types */ #define OE_IS_ARRAY (1

What's does it mean of" /* overloaded elements data types */ #define
OE_IS_ARRAY (1

Today,when I read php kernel codes, which in dir: php5.3/Zend/Zend.h,
there was a line code make me confused.
Code is follow:
/* overloaded elements data types */
#define OE_IS_ARRAY (1<<0)
#define OE_IS_OBJECT (1<<1)
#define OE_IS_METHOD (1<<2)
Is it means like this? And I use int type which has four bytes,it shows
left shift operations.
0000 0000 0000 0000 0000 0000 0000 0000 = 0
After 1 <<
0000 0000 0000 0000 0000 0000 0000 0000 = 0
___________________________________________
0000 0000 0000 0000 0000 0000 0000 0001 = 1
After 1<<
0000 0000 0000 0000 0000 0000 0000 0010 = 2
___________________________________________
0000 0000 0000 0000 0000 0000 0000 0010 = 1
After 1<<
0000 0000 0000 0000 0000 0000 0000 0100 = 4
But if she/he want do this why not just assign the const variables directly?
/* overloaded elements data types */
#define OE_IS_ARRAY (0)//turn the 1<<0 directly
#define OE_IS_OBJECT (2)//turn the 1<<1 directly
#define OE_IS_METHOD (4)//turn the 1<<2 directly
If you know please help me ,thanks a lot! :)

No comments:

Post a Comment