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

Side by Side Diff: runtime/lib/date.cc

Issue 11468016: Rename GET_NATIVE_ARGUMENT macro to GET_NON_NULL_NATIVE_ARGUMENT. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 | « runtime/lib/byte_array.cc ('k') | runtime/lib/double.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <time.h> 5 #include <time.h>
6 6
7 #include "vm/bootstrap_natives.h" 7 #include "vm/bootstrap_natives.h"
8 8
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/native_entry.h" 10 #include "vm/native_entry.h"
11 #include "vm/object.h" 11 #include "vm/object.h"
12 #include "vm/os.h" 12 #include "vm/os.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 static int32_t kMaxAllowedSeconds = 2100000000; 16 static int32_t kMaxAllowedSeconds = 2100000000;
17 17
18 DEFINE_NATIVE_ENTRY(DateNatives_timeZoneName, 1) { 18 DEFINE_NATIVE_ENTRY(DateNatives_timeZoneName, 1) {
19 GET_NATIVE_ARGUMENT(Integer, dart_seconds, arguments->NativeArgAt(0)); 19 GET_NON_NULL_NATIVE_ARGUMENT(
20 Integer, dart_seconds, arguments->NativeArgAt(0));
20 int64_t seconds = dart_seconds.AsInt64Value(); 21 int64_t seconds = dart_seconds.AsInt64Value();
21 if (seconds < 0 || seconds > kMaxAllowedSeconds) { 22 if (seconds < 0 || seconds > kMaxAllowedSeconds) {
22 GrowableArray<const Object*> args; 23 GrowableArray<const Object*> args;
23 args.Add(&dart_seconds); 24 args.Add(&dart_seconds);
24 Exceptions::ThrowByType(Exceptions::kArgument, args); 25 Exceptions::ThrowByType(Exceptions::kArgument, args);
25 } 26 }
26 const char* name = OS::GetTimeZoneName(seconds); 27 const char* name = OS::GetTimeZoneName(seconds);
27 return String::New(name); 28 return String::New(name);
28 } 29 }
29 30
30 31
31 DEFINE_NATIVE_ENTRY(DateNatives_timeZoneOffsetInSeconds, 1) { 32 DEFINE_NATIVE_ENTRY(DateNatives_timeZoneOffsetInSeconds, 1) {
32 GET_NATIVE_ARGUMENT(Integer, dart_seconds, arguments->NativeArgAt(0)); 33 GET_NON_NULL_NATIVE_ARGUMENT(
34 Integer, dart_seconds, arguments->NativeArgAt(0));
33 int64_t seconds = dart_seconds.AsInt64Value(); 35 int64_t seconds = dart_seconds.AsInt64Value();
34 if (seconds < 0 || seconds > kMaxAllowedSeconds) { 36 if (seconds < 0 || seconds > kMaxAllowedSeconds) {
35 GrowableArray<const Object*> args; 37 GrowableArray<const Object*> args;
36 args.Add(&dart_seconds); 38 args.Add(&dart_seconds);
37 Exceptions::ThrowByType(Exceptions::kArgument, args); 39 Exceptions::ThrowByType(Exceptions::kArgument, args);
38 } 40 }
39 int offset = OS::GetTimeZoneOffsetInSeconds(seconds); 41 int offset = OS::GetTimeZoneOffsetInSeconds(seconds);
40 return Integer::New(offset); 42 return Integer::New(offset);
41 } 43 }
42 44
43 45
44 DEFINE_NATIVE_ENTRY(DateNatives_localTimeZoneAdjustmentInSeconds, 0) { 46 DEFINE_NATIVE_ENTRY(DateNatives_localTimeZoneAdjustmentInSeconds, 0) {
45 int adjustment = OS::GetLocalTimeZoneAdjustmentInSeconds(); 47 int adjustment = OS::GetLocalTimeZoneAdjustmentInSeconds();
46 return Integer::New(adjustment); 48 return Integer::New(adjustment);
47 } 49 }
48 50
49 51
50 DEFINE_NATIVE_ENTRY(DateNatives_currentTimeMillis, 0) { 52 DEFINE_NATIVE_ENTRY(DateNatives_currentTimeMillis, 0) {
51 return Integer::New(OS::GetCurrentTimeMillis()); 53 return Integer::New(OS::GetCurrentTimeMillis());
52 } 54 }
53 55
54 } // namespace dart 56 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/byte_array.cc ('k') | runtime/lib/double.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698