commit
f87e4f5880
13
pkg/diag/colors/windows.go
Normal file
13
pkg/diag/colors/windows.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
|
||||
|
||||
//+build windows
|
||||
|
||||
package colors
|
||||
|
||||
import (
|
||||
"github.com/reconquest/loreley"
|
||||
)
|
||||
|
||||
func init() {
|
||||
loreley.Colorize = loreley.ColorizeNever
|
||||
}
|
|
@ -201,7 +201,7 @@ func newResourceMonitor(reschan chan *evalSourceGoal) (*resmon, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
resmon.addr = fmt.Sprintf("0.0.0.0:%d", port)
|
||||
resmon.addr = fmt.Sprintf("127.0.0.1:%d", port)
|
||||
resmon.done = done
|
||||
|
||||
return resmon, nil
|
||||
|
|
|
@ -44,7 +44,7 @@ func newHostServer(host Host, ctx *Context) (*hostServer, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
engine.addr = fmt.Sprintf("0.0.0.0:%d", port)
|
||||
engine.addr = fmt.Sprintf("127.0.0.1:%d", port)
|
||||
engine.done = done
|
||||
|
||||
return engine, nil
|
||||
|
|
|
@ -30,7 +30,7 @@ func IsBenignCloseErr(err error) bool {
|
|||
// the server is finished, in the case of a successful launch of the RPC server.
|
||||
func Serve(port int, cancel chan bool, registers []func(*grpc.Server) error) (int, chan error, error) {
|
||||
// Listen on a TCP port, but let the kernel choose a free port for us.
|
||||
lis, err := net.Listen("tcp", ":"+strconv.Itoa(port))
|
||||
lis, err := net.Listen("tcp", "127.0.0.1:"+strconv.Itoa(port))
|
||||
if err != nil {
|
||||
return port, nil, errors.Errorf("failed to listen on TCP port ':%v': %v", port, err)
|
||||
}
|
||||
|
|
|
@ -5,8 +5,19 @@
|
|||
"sources": [
|
||||
"closure.cc"
|
||||
],
|
||||
"include_dirs": [
|
||||
"<!(node -e \"console.log(\`third_party/node/node-\${process.version}/deps/v8\`)\")"
|
||||
"conditions": [
|
||||
[ 'OS=="win"',
|
||||
{
|
||||
"include_dirs": [
|
||||
"<!(node -e \"console.log(`third_party/node/node-${process.version}/deps/v8`)\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"include_dirs": [
|
||||
"<!(node -e \"console.log(\`third_party/node/node-\${process.version}/deps/v8\`)\")"
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -77,6 +77,12 @@ Local<Value> Lookup(Isolate* isolate, v8::internal::Handle<v8::internal::Context
|
|||
return Local<Value>();
|
||||
}
|
||||
|
||||
// MSVC 2015 (which we build with on Windows) does not treat strlen of a literal as a constexpr,
|
||||
// so we can't use it to intialize our buffer size. So instead, we use sizeof() to compute the
|
||||
// length, so we need a literal string instead of just a const char*.
|
||||
#define BAD_PREFIX "[Function:"
|
||||
#define STRLEN_LITERAL_ONLY(S) (sizeof((S))/sizeof(char) - 1)
|
||||
|
||||
Local<String> SerializeFunctionCode(Isolate *isolate, Local<Function> func) {
|
||||
// Serialize the code simply by calling toString on the Function.
|
||||
Local<Function> toString = Local<Function>::Cast(
|
||||
|
@ -84,12 +90,11 @@ Local<String> SerializeFunctionCode(Isolate *isolate, Local<Function> func) {
|
|||
Local<String> code = Local<String>::Cast(toString->Call(func, 0, nullptr));
|
||||
|
||||
// Ensure that the code is a function expression (including arrows), and not a definition, etc.
|
||||
const char* badprefix = "[Function:";
|
||||
size_t badprefixLength = strlen(badprefix);
|
||||
constexpr size_t badprefixLength = STRLEN_LITERAL_ONLY(BAD_PREFIX);
|
||||
if (code->Length() >= (int)badprefixLength) {
|
||||
char buf[badprefixLength];
|
||||
code->WriteUtf8(buf, badprefixLength);
|
||||
if (!strncmp(badprefix, buf, badprefixLength)) {
|
||||
if (!strncmp(BAD_PREFIX, buf, badprefixLength)) {
|
||||
isolate->ThrowException(Exception::TypeError(
|
||||
String::NewFromUtf8(isolate,
|
||||
"Cannot serialize non-expression functions (such as definitions and generators)")));
|
||||
|
@ -101,6 +106,8 @@ Local<String> SerializeFunctionCode(Isolate *isolate, Local<Function> func) {
|
|||
String::Concat(String::NewFromUtf8(isolate, "("), code),
|
||||
String::NewFromUtf8(isolate, ")"));
|
||||
}
|
||||
#undef BAD_PREFIX
|
||||
#undef STRLEN_LITERAL_ONLY
|
||||
|
||||
// SerializeFunction serializes a JavaScript function expression and its associated closure environment.
|
||||
Local<Value> SerializeFunction(Isolate *isolate, Local<Function> func,
|
||||
|
|
Loading…
Reference in a new issue