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

Side by Side Diff: include/v8.h

Issue 7978028: Landing for miket@chromium.org: 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') | no next file with comments »
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 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 /** 1164 /**
1165 * Get the ExternalStringResource for an external string. Returns 1165 * Get the ExternalStringResource for an external string. Returns
1166 * NULL if IsExternal() doesn't return true. 1166 * NULL if IsExternal() doesn't return true.
1167 */ 1167 */
1168 inline ExternalStringResource* GetExternalStringResource() const; 1168 inline ExternalStringResource* GetExternalStringResource() const;
1169 1169
1170 /** 1170 /**
1171 * Get the ExternalAsciiStringResource for an external ASCII string. 1171 * Get the ExternalAsciiStringResource for an external ASCII string.
1172 * Returns NULL if IsExternalAscii() doesn't return true. 1172 * Returns NULL if IsExternalAscii() doesn't return true.
1173 */ 1173 */
1174 V8EXPORT ExternalAsciiStringResource* GetExternalAsciiStringResource() const; 1174 V8EXPORT const ExternalAsciiStringResource* GetExternalAsciiStringResource()
1175 const;
1175 1176
1176 static inline String* Cast(v8::Value* obj); 1177 static inline String* Cast(v8::Value* obj);
1177 1178
1178 /** 1179 /**
1179 * Allocates a new string from either UTF-8 encoded or ASCII data. 1180 * Allocates a new string from either UTF-8 encoded or ASCII data.
1180 * The second parameter 'length' gives the buffer length. 1181 * The second parameter 'length' gives the buffer length.
1181 * If the data is UTF-8 encoded, the caller must 1182 * If the data is UTF-8 encoded, the caller must
1182 * be careful to supply the length parameter. 1183 * be careful to supply the length parameter.
1183 * If it is not given, the function calls 1184 * If it is not given, the function calls
1184 * 'strlen' to determine the buffer length, it might be 1185 * 'strlen' to determine the buffer length, it might be
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 static Local<TypeSwitch> New(Handle<FunctionTemplate> type); 2445 static Local<TypeSwitch> New(Handle<FunctionTemplate> type);
2445 static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]); 2446 static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]);
2446 int match(Handle<Value> value); 2447 int match(Handle<Value> value);
2447 private: 2448 private:
2448 TypeSwitch(); 2449 TypeSwitch();
2449 }; 2450 };
2450 2451
2451 2452
2452 // --- Extensions --- 2453 // --- Extensions ---
2453 2454
2455 class ExternalAsciiStringResourceImpl
2456 : public String::ExternalAsciiStringResource {
2457 public:
2458 ExternalAsciiStringResourceImpl() : data_(0), length_(0) {}
2459 ExternalAsciiStringResourceImpl(const char* data, size_t length)
2460 : data_(data), length_(length) {}
2461 const char* data() const { return data_; }
2462 size_t length() const { return length_; }
2463
2464 private:
2465 const char* data_;
2466 size_t length_;
2467 };
2454 2468
2455 /** 2469 /**
2456 * Ignore 2470 * Ignore
2457 */ 2471 */
2458 class V8EXPORT Extension { // NOLINT 2472 class V8EXPORT Extension { // NOLINT
2459 public: 2473 public:
2474 // Note that the strings passed into this constructor must live as long
2475 // as the Extension itself.
2460 Extension(const char* name, 2476 Extension(const char* name,
2461 const char* source = 0, 2477 const char* source = 0,
2462 int dep_count = 0, 2478 int dep_count = 0,
2463 const char** deps = 0); 2479 const char** deps = 0,
2480 int source_length = -1);
2464 virtual ~Extension() { } 2481 virtual ~Extension() { }
2465 virtual v8::Handle<v8::FunctionTemplate> 2482 virtual v8::Handle<v8::FunctionTemplate>
2466 GetNativeFunction(v8::Handle<v8::String> name) { 2483 GetNativeFunction(v8::Handle<v8::String> name) {
2467 return v8::Handle<v8::FunctionTemplate>(); 2484 return v8::Handle<v8::FunctionTemplate>();
2468 } 2485 }
2469 2486
2470 const char* name() { return name_; } 2487 const char* name() const { return name_; }
2471 const char* source() { return source_; } 2488 size_t source_length() const { return source_length_; }
2489 const String::ExternalAsciiStringResource* source() const {
2490 return &source_; }
2472 int dependency_count() { return dep_count_; } 2491 int dependency_count() { return dep_count_; }
2473 const char** dependencies() { return deps_; } 2492 const char** dependencies() { return deps_; }
2474 void set_auto_enable(bool value) { auto_enable_ = value; } 2493 void set_auto_enable(bool value) { auto_enable_ = value; }
2475 bool auto_enable() { return auto_enable_; } 2494 bool auto_enable() { return auto_enable_; }
2476 2495
2477 private: 2496 private:
2478 const char* name_; 2497 const char* name_;
2479 const char* source_; 2498 size_t source_length_; // expected to initialize before source_
2499 ExternalAsciiStringResourceImpl source_;
2480 int dep_count_; 2500 int dep_count_;
2481 const char** deps_; 2501 const char** deps_;
2482 bool auto_enable_; 2502 bool auto_enable_;
2483 2503
2484 // Disallow copying and assigning. 2504 // Disallow copying and assigning.
2485 Extension(const Extension&); 2505 Extension(const Extension&);
2486 void operator=(const Extension&); 2506 void operator=(const Extension&);
2487 }; 2507 };
2488 2508
2489 2509
(...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after
4201 4221
4202 4222
4203 } // namespace v8 4223 } // namespace v8
4204 4224
4205 4225
4206 #undef V8EXPORT 4226 #undef V8EXPORT
4207 #undef TYPE_CHECK 4227 #undef TYPE_CHECK
4208 4228
4209 4229
4210 #endif // V8_H_ 4230 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698