Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Side by Side Diff: src/macros.py

Issue 6232: Minor cleanups to macros.py. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2006-2008 the V8 project authors. All rights reserved. 1 # Copyright 2006-2008 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 10 matching lines...) Expand all
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 # Dictionary that is passed as defines for js2c.py. 28 # Dictionary that is passed as defines for js2c.py.
29 # Used for defines that must be defined for all native js files. 29 # Used for defines that must be defined for all native js files.
30 30
31 const NONE = 0; 31 const NONE = 0;
32 const READ_ONLY = 1; 32 const READ_ONLY = 1;
33 const DONT_ENUM = 2; 33 const DONT_ENUM = 2;
34 const DONT_DELETE = 4; 34 const DONT_DELETE = 4;
35 35
36 # Constants used for getter and setter operations. 36 # Constants used for getter and setter operations.
37 const GETTER = 0; 37 const GETTER = 0;
38 const SETTER = 1; 38 const SETTER = 1;
39 39
40 # These definitions must match the index of the properties in objects.h. 40 # These definitions must match the index of the properties in objects.h.
41 const kApiTagOffset = 0; 41 const kApiTagOffset = 0;
42 const kApiPropertyListOffset = 1; 42 const kApiPropertyListOffset = 1;
43 const kApiSerialNumberOffset = 2; 43 const kApiSerialNumberOffset = 2;
44 const kApiConstructorOffset = 2; 44 const kApiConstructorOffset = 2;
45 const kApiPrototypeTemplateOffset = 5; 45 const kApiPrototypeTemplateOffset = 5;
46 const kApiParentTemplateOffset = 6; 46 const kApiParentTemplateOffset = 6;
47 47
48 const NO_HINT = 0; 48 const NO_HINT = 0;
49 const NUMBER_HINT = 1; 49 const NUMBER_HINT = 1;
50 const STRING_HINT = 2; 50 const STRING_HINT = 2;
51 51
52 const kFunctionTag = 0; 52 const kFunctionTag = 0;
53 const kNewObjectTag = 1; 53 const kNewObjectTag = 1;
54 54
55 # For date.js 55 # For date.js.
56 const HoursPerDay = 24; 56 const HoursPerDay = 24;
57 const MinutesPerHour = 60; 57 const MinutesPerHour = 60;
58 const SecondsPerMinute = 60; 58 const SecondsPerMinute = 60;
59 const msPerSecond = 1000; 59 const msPerSecond = 1000;
60 const msPerMinute = 60000; 60 const msPerMinute = 60000;
61 const msPerHour = 3600000; 61 const msPerHour = 3600000;
62 const msPerDay = 86400000; 62 const msPerDay = 86400000;
63 63
64 # Note: kDayZeroInJulianDay = ToJulianDay(1970, 0, 1) 64 # Note: kDayZeroInJulianDay = ToJulianDay(1970, 0, 1).
65 const kInvalidDate = 'Invalid Date'; 65 const kInvalidDate = 'Invalid Date';
66 const kDayZeroInJulianDay = 2440588; 66 const kDayZeroInJulianDay = 2440588;
67 const kMonthMask = 0x1e0; 67 const kMonthMask = 0x1e0;
68 const kDayMask = 0x01f; 68 const kDayMask = 0x01f;
69 const kYearShift = 9; 69 const kYearShift = 9;
70 const kMonthShift = 5; 70 const kMonthShift = 5;
71 71
72 # Type query macros 72 # Type query macros.
73 macro IS_NULL(arg) = (arg === null); 73 macro IS_NULL(arg) = (arg === null);
74 macro IS_NULL_OR_UNDEFINED(arg) = (arg == null); 74 macro IS_NULL_OR_UNDEFINED(arg) = (arg == null);
75 macro IS_UNDEFINED(arg) = (typeof(arg) === 'undefined'); 75 macro IS_UNDEFINED(arg) = (typeof(arg) === 'undefined');
76 macro IS_FUNCTION(arg) = (typeof(arg) === 'function'); 76 macro IS_FUNCTION(arg) = (typeof(arg) === 'function');
77 macro IS_NUMBER(arg) = (typeof(arg) === 'number'); 77 macro IS_NUMBER(arg) = (typeof(arg) === 'number');
78 macro IS_STRING(arg) = (typeof(arg) === 'string'); 78 macro IS_STRING(arg) = (typeof(arg) === 'string');
79 macro IS_OBJECT(arg) = (typeof(arg) === 'object'); 79 macro IS_OBJECT(arg) = (typeof(arg) === 'object');
80 macro IS_BOOLEAN(arg) = (typeof(arg) === 'boolean'); 80 macro IS_BOOLEAN(arg) = (typeof(arg) === 'boolean');
81 macro IS_REGEXP(arg) = (%ClassOf(arg) === 'RegExp'); 81 macro IS_REGEXP(arg) = (%ClassOf(arg) === 'RegExp');
82 macro IS_ARRAY(arg) = (%ClassOf(arg) === 'Array'); 82 macro IS_ARRAY(arg) = (%ClassOf(arg) === 'Array');
83 macro IS_DATE(arg) = (%ClassOf(arg) === 'Date'); 83 macro IS_DATE(arg) = (%ClassOf(arg) === 'Date');
84 macro IS_ERROR(arg) = (%ClassOf(arg) === 'Error'); 84 macro IS_ERROR(arg) = (%ClassOf(arg) === 'Error');
85 macro IS_SCRIPT(arg) = (%ClassOf(arg) === 'Script'); 85 macro IS_SCRIPT(arg) = (%ClassOf(arg) === 'Script');
86 86
87 # 'Inline' macros 87 # Inline macros. Use %IS_VAR to make sure arg is evaluated only once.
88 # (Make sure arg is evaluated only once via %IS_VAR) 88 macro NUMBER_IS_NAN(arg) = (!%_IsSmi(%IS_VAR(arg)) && !(arg == arg));
89 macro NUMBER_IS_NAN(arg) = (!%_IsSmi(%IS_VAR(arg)) && !(arg == arg)); 89 macro TO_INTEGER(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : ToInteger(arg));
90 macro TO_INTEGER(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : ToInteger(arg)) ; 90 macro TO_INT32(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : ToInt32(arg));
91 macro TO_INT32(arg) = (%_IsSmi(%IS_VAR(arg)) ? arg : ToInt32(arg));
92 91
93 python macro CHAR_CODE(str) = ord(str[1]); 92 # Macros implemented in Python.
93 python macro CHAR_CODE(str) = ord(str[1]);
94 94
95 # Accessors for original global properties that ensure they have been loaded. 95 # Accessors for original global properties that ensure they have been loaded.
96 const ORIGINAL_REGEXP = (global.RegExp, $RegExp); 96 const ORIGINAL_REGEXP = (global.RegExp, $RegExp);
97 const ORIGINAL_DATE = (global.Date, $Date); 97 const ORIGINAL_DATE = (global.Date, $Date);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698