// NewSwitch node constructor
554549
func NewSwitch(Cond node.Node, CaseList *CaseList) *Switch {
	return &Switch{
		FreeFloating: nil,
		Cond:         Cond,
		CaseList:     CaseList,
	}
}
657737
func newSynth(client *Client, defName string, id int32) *Synth {
	return &Synth{
		DefName: defName,
		ID:      id,
		client:  client,
	}
}
519361
func (s *Server) newServer(proto, addr string) ([]*HTTPServer, error) {
	var (
		ls []net.Listener
	)
	switch proto {
	case "tcp":
		l, err := s.initTCPSocket(addr)
		if err != nil {
			return nil, err
		}
		ls = append(ls, l)

	default:
		return nil, errors.New("Invalid protocol format. Windows only supports tcp.")
	}

	var res []*HTTPServer
	for _, l := range ls {
		res = append(res, &HTTPServer{
			&http.Server{
				Addr: addr,
			},
			l,
		})
	}
	return res, nil

}
192173
func NewSyntaxHighlighter(p Parser) (SyntaxHighlighter, error) {
	if rn, err := p.Parse(); err != nil {
		return nil, err
	} else {
		return &nodeHighlighter{rootNode: rn}, nil
	}
}
792139
func NewSyncFromClient(client *raven.Client) *Handler {
	handler := NewFromClient(client)

	handler.sendSynchronously = true

	return handler
}
309589
func NewAltSwitch(Cond node.Node, CaseList *CaseList) *AltSwitch {
	return &AltSwitch{
		FreeFloating: nil,
		Cond:         Cond,
		CaseList:     CaseList,
	}
}
661464
func (fs *KBFSOpsStandard) PushConnectionStatusChange(
	service string, newStatus error) {
	fs.currentStatus.PushConnectionStatusChange(service, newStatus)

	if fs.config.KeybaseService() == nil {
		return
	}

	switch service {
	case KeybaseServiceName, GregorServiceName:
	default:
		return
	}

	fs.opsLock.Lock()
	defer fs.opsLock.Unlock()

	for _, fbo := range fs.ops {
		fbo.PushConnectionStatusChange(service, newStatus)
	}

	if newStatus == nil {
		fs.log.CDebugf(nil, "Asking for an edit re-init after reconnection")
		fs.editActivity.Add(1)
		go fs.initTlfsForEditHistories()
	}
}
984686
func (client *Client) CreateVSwitch(args *CreateVSwitchArgs) (vswitchId string, err error) {
	response := CreateVSwitchResponse{}
	err = client.Invoke("CreateVSwitch", args, &response)
	if err != nil {
		return "", err
	}
	return response.VSwitchId, err
}
1277571
func (res *Resource) NewStruct() interface{} {
	if res.Value == nil {
		return nil
	}
	return reflect.New(utils.Indirect(reflect.ValueOf(res.Value)).Type()).Interface()
}
969852
func (api *VPCRouterAPI) DisconnectFromSwitch(id int64, nicIndex int) (bool, error) {
	var (
		method = "DELETE"
		uri    = fmt.Sprintf("%s/%d/interface/%d/to/switch", api.getResourceURL(), id, nicIndex)
	)
	return api.modify(method, uri, nil)
}
26671
func NewSyncFromNotifier(notifier *gobrake.Notifier) *Handler {
	handler := NewFromNotifier(notifier)

	handler.sendSynchronously = true

	return handler
}
27114
func NewSystemConnection() (*Conn, error) {
	return NewConnection(func() (*dbus.Conn, error) {
		return dbusAuthHelloConnection(dbus.SystemBusPrivate)
	})
}
802529
func (gitter *Gitter) newStreamConnection(wait time.Duration, retries int) *streamConnection {
	return &streamConnection{
		closed:  true,
		wait:    wait,
		retries: retries,
	}
}
1270053
func NewShiftRight(Variable node.Node, Expression node.Node) *ShiftRight {
	return &ShiftRight{
		FreeFloating: nil,
		Left:         Variable,
		Right:        Expression,
	}
}
133020
func NewSwitch(info Info) *Switch {
	acc := Switch{}
	acc.Accessory = New(info, TypeSwitch)
	acc.Switch = service.NewSwitch()
	acc.AddService(acc.Switch.Service)

	return &acc
}
1204336
func NewServerConnection(conn net.Conn, newStreamHandler httpstream.NewStreamHandler) (httpstream.Connection, error) {
	spdyConn, err := spdystream.NewConnection(conn, true)
	if err != nil {
		defer conn.Close()
		return nil, err
	}

	return newConnection(spdyConn, newStreamHandler), nil
}
1049585
func (m *SwitchManager) CreateSwitch(conn of.OFPConn) error {
	m.init()

	// Read ofp_hello message to get protocol version
	r, err := conn.Receive()
	if err != nil {
		log.ErrorLog("switch_manager/CREATE_SWITCH",
			"Failed to read ofp_hello message from connection: ", err)
		return err
	}

	constructor := SwitchByVersion(r.Proto)
	if constructor == nil {
		log.ErrorLog("switch_manager/CREATE_SWITCH",
			"Unknown protocol version: ", r.Proto)

		return errors.New("SwitchManager: Unknown protocol version")
	}

	// Create a new switch instance
	sw := constructor.New()

	log.DebugLog("switch_manager/CREATE_SWITCH",
		"Booting switch...")

	// Wait for switch boot up
	if err = sw.Boot(conn); err != nil {
		log.ErrorLog("switch_manager/CREATE_SWITCH",
			"Failed to boot switch: ", err)
		return err
	}

	log.DebugLog("switch_manager/CREATE_SWITCH",
		"Switch successfully booted for ", r.Proto)

	linkManager := NewLinkMechanismManager()

	extensionManager := &ExtensionMechanismManager{
		BaseMechanismManager{sw.ID(), ExtensionMechanisms(), 0, 0},
	}

	// Create a new mechanism driver context
	context := &MechanismContext{
		Switch:    sw,
		Func:      rpc.New(),
		Mux:       of.NewServeMux(),
		Extension: extensionManager,
		Managers:  injector.New(),
	}

	linkManager.Enable(context)
	extensionManager.Enable(context)

	// Since switch already booted, activate drivers
	// TODO: make this configurable (or deactivate all by default)
	linkManager.Activate()
	extensionManager.Activate()

	if err = linkManager.CreateLink(); err != nil {
		log.ErrorLog("switch_manager/CREATE_SWITCH",
			"Failed to create link configuration: ", err)
	}

	log.DebugLog("switch_manager/CREATE_SWITCH",
		"Switch successfully created")

	m.lock.Lock()
	defer m.lock.Unlock()

	m.entries[context.Switch.ID()] = context

	// Serve can delete context from entries list,
	// so call it after adding context to entries list.
	go m.serve(context)

	return nil
}