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

Side by Side Diff: include/v8.h

Issue 7889046: Add an optional source length field to the Extension constructor. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 3 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 | src/api.cc » ('j') | src/api.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 /** 1161 /**
1162 * Get the ExternalStringResource for an external string. Returns 1162 * Get the ExternalStringResource for an external string. Returns
1163 * NULL if IsExternal() doesn't return true. 1163 * NULL if IsExternal() doesn't return true.
1164 */ 1164 */
1165 inline ExternalStringResource* GetExternalStringResource() const; 1165 inline ExternalStringResource* GetExternalStringResource() const;
1166 1166
1167 /** 1167 /**
1168 * Get the ExternalAsciiStringResource for an external ascii string. 1168 * Get the ExternalAsciiStringResource for an external ascii string.
1169 * Returns NULL if IsExternalAscii() doesn't return true. 1169 * Returns NULL if IsExternalAscii() doesn't return true.
1170 */ 1170 */
1171 V8EXPORT ExternalAsciiStringResource* GetExternalAsciiStringResource() const; 1171 V8EXPORT const ExternalAsciiStringResource*GetExternalAsciiStringResource()
Aaron Boodman 2011/09/14 20:33:18 Nit: Put the space back after the *.
miket_OOO 2011/09/14 20:47:16 Whoops! Thanks.
1172 const;
1172 1173
1173 static inline String* Cast(v8::Value* obj); 1174 static inline String* Cast(v8::Value* obj);
1174 1175
1175 /** 1176 /**
1176 * Allocates a new string from either utf-8 encoded or ascii data. 1177 * Allocates a new string from either utf-8 encoded or ascii data.
1177 * The second parameter 'length' gives the buffer length. 1178 * The second parameter 'length' gives the buffer length.
1178 * If the data is utf-8 encoded, the caller must 1179 * If the data is utf-8 encoded, the caller must
1179 * be careful to supply the length parameter. 1180 * be careful to supply the length parameter.
1180 * If it is not given, the function calls 1181 * If it is not given, the function calls
1181 * 'strlen' to determine the buffer length, it might be 1182 * 'strlen' to determine the buffer length, it might be
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2441 static Local<TypeSwitch> New(Handle<FunctionTemplate> type); 2442 static Local<TypeSwitch> New(Handle<FunctionTemplate> type);
2442 static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]); 2443 static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]);
2443 int match(Handle<Value> value); 2444 int match(Handle<Value> value);
2444 private: 2445 private:
2445 TypeSwitch(); 2446 TypeSwitch();
2446 }; 2447 };
2447 2448
2448 2449
2449 // --- Extensions --- 2450 // --- Extensions ---
2450 2451
2452 class ExternalAsciiStringResourceImpl
2453 : public String::ExternalAsciiStringResource {
2454 public:
2455 ExternalAsciiStringResourceImpl() : data_(0), length_(0) {};
fschneider 2011/09/19 07:58:57 No ; at the end?
miket_OOO 2011/09/19 17:39:21 Fixed (et seq.). Thanks. Still a bit rusty on C++
2456 ExternalAsciiStringResourceImpl(const char *data, size_t length)
Aaron Boodman 2011/09/14 20:33:18 In chrome, the * goes next to the type.
miket_OOO 2011/09/14 20:47:16 I'm trying to untrain myself. Fixed; thanks.
2457 : data_(data), length_(length) {};
fschneider 2011/09/19 07:58:57 ; at the end should not be necessary
2458 const char *data() const { return data_; }
2459 size_t length() const { return length_; }
2460 private:
fschneider 2011/09/19 07:58:57 Newline before private:
miket_OOO 2011/09/19 17:39:21 Fixed.
2461 const char *data_;
2462 size_t length_;
2463 };
2451 2464
2452 /** 2465 /**
2453 * Ignore 2466 * Ignore
2454 */ 2467 */
2455 class V8EXPORT Extension { // NOLINT 2468 class V8EXPORT Extension { // NOLINT
2456 public: 2469 public:
2470 // Note that the strings passed into this constructor must live as long
2471 // as the Extension itself.
2457 Extension(const char* name, 2472 Extension(const char* name,
2458 const char* source = 0, 2473 const char* source = 0,
2459 int dep_count = 0, 2474 int dep_count = 0,
2460 const char** deps = 0); 2475 const char** deps = 0,
2476 int source_length = -1);
fschneider 2011/09/19 07:58:57 I wish there was a way to reduce the number of opt
miket_OOO 2011/09/19 17:39:21 Agreed. I'd appreciate your opinion on altering vs
2461 virtual ~Extension() { } 2477 virtual ~Extension() { }
2462 virtual v8::Handle<v8::FunctionTemplate> 2478 virtual v8::Handle<v8::FunctionTemplate>
2463 GetNativeFunction(v8::Handle<v8::String> name) { 2479 GetNativeFunction(v8::Handle<v8::String> name) {
2464 return v8::Handle<v8::FunctionTemplate>(); 2480 return v8::Handle<v8::FunctionTemplate>();
2465 } 2481 }
2466 2482
2467 const char* name() { return name_; } 2483 const char* name() const { return name_; }
2468 const char* source() { return source_; } 2484 size_t source_length() const { return source_length_; }
2485 const String::ExternalAsciiStringResource* source() const {
2486 return &source_; }
2469 int dependency_count() { return dep_count_; } 2487 int dependency_count() { return dep_count_; }
2470 const char** dependencies() { return deps_; } 2488 const char** dependencies() { return deps_; }
2471 void set_auto_enable(bool value) { auto_enable_ = value; } 2489 void set_auto_enable(bool value) { auto_enable_ = value; }
2472 bool auto_enable() { return auto_enable_; } 2490 bool auto_enable() { return auto_enable_; }
2473 2491
2474 private: 2492 private:
2475 const char* name_; 2493 const char* name_;
2476 const char* source_; 2494 size_t source_length_; // expected to initialize before source_
2495 ExternalAsciiStringResourceImpl source_;
2477 int dep_count_; 2496 int dep_count_;
2478 const char** deps_; 2497 const char** deps_;
2479 bool auto_enable_; 2498 bool auto_enable_;
2480 2499
2481 // Disallow copying and assigning. 2500 // Disallow copying and assigning.
2482 Extension(const Extension&); 2501 Extension(const Extension&);
2483 void operator=(const Extension&); 2502 void operator=(const Extension&);
2484 }; 2503 };
2485 2504
2486 2505
(...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after
4198 4217
4199 4218
4200 } // namespace v8 4219 } // namespace v8
4201 4220
4202 4221
4203 #undef V8EXPORT 4222 #undef V8EXPORT
4204 #undef TYPE_CHECK 4223 #undef TYPE_CHECK
4205 4224
4206 4225
4207 #endif // V8_H_ 4226 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698