OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1013 int read = static_cast<int>(fread(&chars[i], 1, size - i, file)); | 1013 int read = static_cast<int>(fread(&chars[i], 1, size - i, file)); |
1014 i += read; | 1014 i += read; |
1015 } | 1015 } |
1016 fclose(file); | 1016 fclose(file); |
1017 *size_out = size; | 1017 *size_out = size; |
1018 return chars; | 1018 return chars; |
1019 } | 1019 } |
1020 | 1020 |
1021 | 1021 |
1022 Handle<Value> Shell::ReadBuffer(const Arguments& args) { | 1022 Handle<Value> Shell::ReadBuffer(const Arguments& args) { |
1023 STATIC_ASSERT(sizeof(char) == sizeof(uint8_t)); // NOLINT | 1023 ASSERT(sizeof(char) == sizeof(uint8_t)); // NOLINT |
Sven Panne
2012/06/01 12:26:20
sizeof(char) = 1 by definition, so I am not sure i
| |
1024 String::Utf8Value filename(args[0]); | 1024 String::Utf8Value filename(args[0]); |
1025 int length; | 1025 int length; |
1026 if (*filename == NULL) { | 1026 if (*filename == NULL) { |
1027 return ThrowException(String::New("Error loading file")); | 1027 return ThrowException(String::New("Error loading file")); |
1028 } | 1028 } |
1029 | 1029 |
1030 uint8_t* data = reinterpret_cast<uint8_t*>(ReadChars(*filename, &length)); | 1030 uint8_t* data = reinterpret_cast<uint8_t*>(ReadChars(*filename, &length)); |
1031 if (data == NULL) { | 1031 if (data == NULL) { |
1032 return ThrowException(String::New("Error reading file")); | 1032 return ThrowException(String::New("Error reading file")); |
1033 } | 1033 } |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1542 } | 1542 } |
1543 | 1543 |
1544 } // namespace v8 | 1544 } // namespace v8 |
1545 | 1545 |
1546 | 1546 |
1547 #ifndef GOOGLE3 | 1547 #ifndef GOOGLE3 |
1548 int main(int argc, char* argv[]) { | 1548 int main(int argc, char* argv[]) { |
1549 return v8::Shell::Main(argc, argv); | 1549 return v8::Shell::Main(argc, argv); |
1550 } | 1550 } |
1551 #endif | 1551 #endif |
OLD | NEW |