|
Lines 757-772
class MOZ_STACK_CLASS SourceBufferHolder
|
Link Here
|
---|
|
757 |
static const char16_t NullChar_ = 0; |
757 |
static const char16_t NullChar_ = 0; |
758 |
if (!get()) { |
758 |
if (!get()) { |
759 |
data_ = &NullChar_; |
759 |
data_ = &NullChar_; |
760 |
length_ = 0; |
760 |
length_ = 0; |
761 |
ownsChars_ = false; |
761 |
ownsChars_ = false; |
762 |
} |
762 |
} |
763 |
} |
763 |
} |
764 |
|
764 |
|
|
|
765 |
SourceBufferHolder(SourceBufferHolder&& other) |
766 |
: data_(other.data_), |
767 |
length_(other.length_), |
768 |
ownsChars_(other.ownsChars_) |
769 |
{ |
770 |
other.data_ = nullptr; |
771 |
other.length_ = 0; |
772 |
other.ownsChars_ = false; |
773 |
} |
774 |
|
765 |
~SourceBufferHolder() { |
775 |
~SourceBufferHolder() { |
766 |
if (ownsChars_) |
776 |
if (ownsChars_) |
767 |
js_free(const_cast<char16_t*>(data_)); |
777 |
js_free(const_cast<char16_t*>(data_)); |
768 |
} |
778 |
} |
769 |
|
779 |
|
770 |
// Access the underlying source buffer without affecting ownership. |
780 |
// Access the underlying source buffer without affecting ownership. |
771 |
const char16_t* get() const { return data_; } |
781 |
const char16_t* get() const { return data_; } |
772 |
|
782 |
|
Lines 4112-4127
CanCompileOffThread(JSContext* cx, const
|
Link Here
|
---|
|
4112 |
extern JS_PUBLIC_API(bool) |
4122 |
extern JS_PUBLIC_API(bool) |
4113 |
CompileOffThread(JSContext* cx, const ReadOnlyCompileOptions& options, |
4123 |
CompileOffThread(JSContext* cx, const ReadOnlyCompileOptions& options, |
4114 |
const char16_t* chars, size_t length, |
4124 |
const char16_t* chars, size_t length, |
4115 |
OffThreadCompileCallback callback, void* callbackData); |
4125 |
OffThreadCompileCallback callback, void* callbackData); |
4116 |
|
4126 |
|
4117 |
extern JS_PUBLIC_API(JSScript*) |
4127 |
extern JS_PUBLIC_API(JSScript*) |
4118 |
FinishOffThreadScript(JSContext* maybecx, JSRuntime* rt, void* token); |
4128 |
FinishOffThreadScript(JSContext* maybecx, JSRuntime* rt, void* token); |
4119 |
|
4129 |
|
|
|
4130 |
extern JS_PUBLIC_API(bool) |
4131 |
CompileOffThreadModule(JSContext* cx, const ReadOnlyCompileOptions& options, |
4132 |
const char16_t* chars, size_t length, |
4133 |
OffThreadCompileCallback callback, void* callbackData); |
4134 |
|
4135 |
extern JS_PUBLIC_API(JSObject*) |
4136 |
FinishOffThreadModule(JSContext* maybecx, JSRuntime* rt, void* token); |
4137 |
|
4120 |
/** |
4138 |
/** |
4121 |
* Compile a function with scopeChain plus the global as its scope chain. |
4139 |
* Compile a function with scopeChain plus the global as its scope chain. |
4122 |
* scopeChain must contain objects in the current compartment of cx. The actual |
4140 |
* scopeChain must contain objects in the current compartment of cx. The actual |
4123 |
* scope chain used for the function will consist of With wrappers for those |
4141 |
* scope chain used for the function will consist of With wrappers for those |
4124 |
* objects, followed by the current global of the compartment cx is in. This |
4142 |
* objects, followed by the current global of the compartment cx is in. This |
4125 |
* global must not be explicitly included in the scope chain. |
4143 |
* global must not be explicitly included in the scope chain. |
4126 |
*/ |
4144 |
*/ |
4127 |
extern JS_PUBLIC_API(bool) |
4145 |
extern JS_PUBLIC_API(bool) |
Lines 4255-4270
Evaluate(JSContext* cx, const ReadOnlyCo
|
Link Here
|
---|
|
4255 |
|
4273 |
|
4256 |
/** |
4274 |
/** |
4257 |
* Evaluate the given file in the scope of the current global of cx. |
4275 |
* Evaluate the given file in the scope of the current global of cx. |
4258 |
*/ |
4276 |
*/ |
4259 |
extern JS_PUBLIC_API(bool) |
4277 |
extern JS_PUBLIC_API(bool) |
4260 |
Evaluate(JSContext* cx, const ReadOnlyCompileOptions& options, |
4278 |
Evaluate(JSContext* cx, const ReadOnlyCompileOptions& options, |
4261 |
const char* filename, JS::MutableHandleValue rval); |
4279 |
const char* filename, JS::MutableHandleValue rval); |
4262 |
|
4280 |
|
|
|
4281 |
/** |
4282 |
* Get the HostResolveImportedModule hook for a global. |
4283 |
*/ |
4284 |
extern JS_PUBLIC_API(JSFunction*) |
4285 |
GetModuleResolveHook(JSContext* cx); |
4286 |
|
4287 |
/** |
4288 |
* Set the HostResolveImportedModule hook for a global to the given function. |
4289 |
*/ |
4290 |
extern JS_PUBLIC_API(void) |
4291 |
SetModuleResolveHook(JSContext* cx, JS::HandleFunction func); |
4292 |
|
4293 |
/** |
4294 |
* Parse the given source buffer as a module in the scope of the current global |
4295 |
* of cx and return a source text module record. |
4296 |
*/ |
4297 |
extern JS_PUBLIC_API(bool) |
4298 |
ParseModule(JSContext* cx, const ReadOnlyCompileOptions& options, |
4299 |
SourceBufferHolder& srcBuf, JS::MutableHandleObject moduleRecord); |
4300 |
|
4301 |
/** |
4302 |
* Set the [[HostDefined]] field of a source text module record to the given |
4303 |
* value. |
4304 |
*/ |
4305 |
extern JS_PUBLIC_API(void) |
4306 |
SetModuleHostDefinedField(JSObject* module, JS::Value value); |
4307 |
|
4308 |
/** |
4309 |
* Get the [[HostDefined]] field of a source text module record. |
4310 |
*/ |
4311 |
extern JS_PUBLIC_API(JS::Value) |
4312 |
GetModuleHostDefinedField(JSObject* module); |
4313 |
|
4314 |
/* |
4315 |
* Perform the ModuleDeclarationInstantiation operation on on the give source |
4316 |
* text module record. |
4317 |
* |
4318 |
* This transitively resolves all module dependencies (calling the |
4319 |
* HostResolveImportedModule hook) and initializes the environment record for |
4320 |
* the module. |
4321 |
*/ |
4322 |
extern JS_PUBLIC_API(bool) |
4323 |
ModuleDeclarationInstantiation(JSContext* cx, JS::HandleObject moduleRecord); |
4324 |
|
4325 |
/* |
4326 |
* Perform the ModuleEvaluation operation on on the give source text module |
4327 |
* record. |
4328 |
* |
4329 |
* This does nothing if this module has already been evaluated. Otherwise, it |
4330 |
* transitively evaluates all dependences of this module and then evaluates this |
4331 |
* module. |
4332 |
* |
4333 |
* ModuleDeclarationInstantiation must have completed prior to calling this. |
4334 |
*/ |
4335 |
extern JS_PUBLIC_API(bool) |
4336 |
ModuleEvaluation(JSContext* cx, JS::HandleObject moduleRecord); |
4337 |
|
4338 |
/* |
4339 |
* Get a list of the module specifiers used by a source text module |
4340 |
* record to request importation of modules. |
4341 |
* |
4342 |
* The result is a JavaScript array of string values. ForOfIterator can be used |
4343 |
* to extract the individual strings. |
4344 |
*/ |
4345 |
extern JS_PUBLIC_API(bool) |
4346 |
GetRequestedModules(JSContext* cx, JS::HandleObject moduleRecord, |
4347 |
JS::MutableHandleObject rval); |
4348 |
|
4349 |
/* |
4350 |
* Get a the script associated with a module. |
4351 |
*/ |
4352 |
extern JS_PUBLIC_API(JSScript*) |
4353 |
GetModuleScript(JSContext* cx, JS::HandleObject moduleRecord); |
4354 |
|
4263 |
} /* namespace JS */ |
4355 |
} /* namespace JS */ |
4264 |
|
4356 |
|
4265 |
extern JS_PUBLIC_API(bool) |
4357 |
extern JS_PUBLIC_API(bool) |
4266 |
JS_CheckForInterrupt(JSContext* cx); |
4358 |
JS_CheckForInterrupt(JSContext* cx); |
4267 |
|
4359 |
|
4268 |
/* |
4360 |
/* |
4269 |
* These functions allow setting an interrupt callback that will be called |
4361 |
* These functions allow setting an interrupt callback that will be called |
4270 |
* from the JS thread some time after any thread triggered the callback using |
4362 |
* from the JS thread some time after any thread triggered the callback using |