| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2609,6 +2609,33 @@ void ClearFatalExceptionHandlers(Environment* env) { | |||
| 2609 | 2609 | Undefined(env->isolate())).FromJust(); | |
| 2610 | 2610 | } | |
| 2611 | 2611 | ||
| 2612 | + // Call process.emitWarning(str), fmt is a snprintf() format string | ||
| 2613 | + void ProcessEmitWarning(Environment* env, const char* fmt, ...) { | ||
| 2614 | + char warning[1024]; | ||
| 2615 | + va_list ap; | ||
| 2616 | + | ||
| 2617 | + va_start(ap, fmt); | ||
| 2618 | + vsnprintf(warning, sizeof(warning), fmt, ap); | ||
| 2619 | + va_end(ap); | ||
| 2620 | + | ||
| 2621 | + HandleScope handle_scope(env->isolate()); | ||
| 2622 | + Context::Scope context_scope(env->context()); | ||
| 2623 | + | ||
| 2624 | + Local<Object> process = env->process_object(); | ||
| 2625 | + MaybeLocal<Value> emit_warning = process->Get(env->context(), | ||
| 2626 | + FIXED_ONE_BYTE_STRING(env->isolate(), "emitWarning")); | ||
| 2627 | + Local<Value> arg = node::OneByteString(env->isolate(), warning); | ||
| 2628 | + | ||
| 2629 | + Local<Value> f; | ||
| 2630 | + | ||
| 2631 | + if (!emit_warning.ToLocal(&f)) return; | ||
| 2632 | + if (!f->IsFunction()) return; | ||
| 2633 | + | ||
| 2634 | + // MakeCallback() unneeded, because emitWarning is internal code, it calls | ||
| 2635 | + // process.emit('warning', ..), but does so on the nextTick. | ||
| 2636 | + f.As<v8::Function>()->Call(process, 1, &arg); | ||
| 2637 | + } | ||
| 2638 | + | ||
| 2612 | 2639 | ||
| 2613 | 2640 | static void Binding(const FunctionCallbackInfo<Value>& args) { | |
| 2614 | 2641 | Environment* env = Environment::GetCurrent(args); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -133,6 +133,8 @@ void AppendExceptionLine(Environment* env, | |||
| 133 | 133 | ||
| 134 | 134 | NO_RETURN void FatalError(const char* location, const char* message); | |
| 135 | 135 | ||
| 136 | + void ProcessEmitWarning(Environment* env, const char* fmt, ...); | ||
| 137 | + | ||
| 136 | 138 | v8::Local<v8::Value> BuildStatsObject(Environment* env, const uv_stat_t* s); | |
| 137 | 139 | ||
| 138 | 140 | enum Endianness { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments