id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c17600
ok { return t.root } return s }
c17601
src.Name, Line: src.Line, ScopeName: scope.GetName(), Reason: err, } } t, err = typeSpecReference{Name: iname}.Link(includedScope) if err != nil { return nil, referenceError{ Target: src.Name, Line: src.Line, ScopeName: scope.GetName(), Reason: err, } } return t,...
c17602
on unresolved TypeSpec reference %v."+ "Make sure you called Link().", r, )) }
c17603
return compileSetType(t) case ast.TypeReference: return typeSpecReference(t), nil default: panic(fmt.Sprintf("unknown type %v", typ)) } }
c17604
return Server{p: p, h: h} }
c17605
= tappExc(err, exception.ExceptionTypeInternalError) } if err != nil { return nil, err } } var buff bytes.Buffer if err := s.p.EncodeEnveloped(response, &buff); err != nil { return nil, err } return buff.Bytes(), nil }
c17606
Message: ptr.String(err.Error()), Type: &typ, }).ToWire() }
c17607
append(names, h.Name()) } return fmt.Sprintf("MultiHandle{%v}", strings.Join(names, ", ")) }
c17608
func(_ int, h Handle) error { return h.Close() }) }
c17609
len(mh)) for _, h := range mh { if sg := h.ServiceGenerator(); sg != nil { msg = append(msg, sg) } } return msg }
c17610
sg := range msg { mh[i] = sg.Handle() } return mh }
c17611
res.Files { if takenBy, taken := usedPaths[path]; taken { return fmt.Errorf("plugin conflict: cannot write file %q for plugin %q: "+ "plugin %q already wrote to that file", path, pluginName, takenBy) } usedPaths[path] = pluginName files[path] = contents } return nil }) return &api.Generat...
c17612
name, Reason: errAPIVersionMismatch{Want: api.APIVersion, Got: handshake.APIVersion}, } } features := make(map[api.Feature]struct{}, len(handshake.Features)) for _, feature := range handshake.Features { features[feature] = struct{}{} } return &transportHandle{ name: name, Transport: t, Client...
c17613
} buff := new(bytes.Buffer) if err := g.Write(buff, token.NewFileSet()); err != nil { return nil, fmt.Errorf("could not write %s.%s: %v", s.Name, functionName, err) } // TODO check for conflicts files[fileName] = buff } return files, nil }
c17614
of a %v.%v function call.\n\n"+ "The result of a %v execution is sent and received over the wire as this struct.", resultName, s.Name, f.Name, f.Name, ) if f.ResultSpec.ReturnType != nil { resultDoc += fmt.Sprintf("\n\nSuccess is set only if the function did not throw an exception.") } resultGen := fieldGr...
c17615
<typeReference .Type>, <- else> <$params.NewName .Name> <typeReferencePtr .Type>, <- end -> <end> `, f) }
c17616
<- else> <$params.NewName .Name> <typeReferencePtr .Type>, <- end -> <end> ) *<$prefix>Args { return &<$prefix>Args{ <range $f.ArgsSpec> <- if .Required -> <goCase .Name>: <$params.Rotate .Name>, <- else -> <goCase .Name>: <$params.Rotate .Name>, <- end> <end> } } `,...
c17617
:= writerPool.Get().(*Writer) writer.writer = w return writer }
c17618
return err } return bw.write(b) case wire.TStruct: return bw.writeStruct(v.GetStruct()) case wire.TMap: return bw.writeMap(v.GetMap()) case wire.TSet: return bw.writeSet(v.GetSet()) case wire.TList: return bw.writeList(v.GetList()) default: return fmt.Errorf("unknown ttype %v", v.Type()) } }
c17619
{ return DefinitionInfo{Name: c.Name, Line: c.Line} }
c17620
{ return DefinitionInfo{Name: t.Name, Line: t.Line} }
c17621
{ return DefinitionInfo{Name: e.Name, Line: e.Line} }
c17622
{ return DefinitionInfo{Name: s.Name, Line: s.Line} }
c17623
{ return DefinitionInfo{Name: s.Name, Line: s.Line} }
c17624
if typ.NumIn() > 0 && typ.In(0) == _typeOfGenerator { return curry.One(f, g) } return f }
c17625
namespace, importer: newImporter(namespace.Child()), mangler: newMangler(), thriftImporter: o.Importer, fset: token.NewFileSet(), noZap: o.NoZap, } }
c17626
ok := g.(*generator); ok { return gen.noZap } return false }
c17627
curryGenerator(g.e.Equals, g), "equalsPtr": curryGenerator(g.e.EqualsPtr, g), "zapEncodeBegin": curryGenerator(g.z.zapEncodeBegin, g), "zapEncodeEnd": g.z.zapEncodeEnd, "zapEncoder": curryGenerator(g.z.zapEncoder, g), "zapMarshaler": curryGenerator(g.z.zapMarshaler, g), "zapMarsh...
c17628
= append(g.decls, decl) }
c17629
return generateError{Name: m.ThriftPath, Reason: err} } return nil } // Note that we call generate directly on only those modules that we need // to generate code for. If the user used --no-recurse, we're not going to // generate code for included modules. if o.NoRecurse { if err := generate(m); err != ...
c17630
n Node) Visitor { f(w, n) return f }
c17631
return nil, multierr.Combine( fmt.Errorf("failed to open plugin %q: %v", f.Name, err), transport.Close(), ) } return handle, nil }
c17632
find executable %q: %v", value, exe, err) } cmd := exec.Command(path, tokens[1:]...) cmd.Stderr = os.Stderr // connect stderr so that plugins can log f.Command = cmd return nil }
c17633
err := f.Handle() if err != nil { return err } lock.Lock() defer lock.Unlock() multi = append(multi, h) return nil }) if err == nil { return multi, nil } return nil, multierr.Append(err, multi.Close()) }
c17634
*compile.I64Spec, *compile.DoubleSpec, *compile.StringSpec: return w.ToWire(g, spec, fmt.Sprintf("*(%s)", varName)) default: // Everything else is either a reference type or has a ToWire method // on it that does automatic dereferencing. return w.ToWire(g, spec, varName) } }
c17635
:= newVar "x" -> var <$x> <typeReference .Spec> <$x>, err = <fromWire .Spec .Value> <.LHS> = &<$x -> `, struct { Spec compile.TypeSpec LHS string Value string }{Spec: spec, LHS: lhs, Value: value}, ) }
c17636
return fmt.Sprintf("%s.TList", wire) case *compile.SetSpec: return fmt.Sprintf("%s.TSet", wire) case *compile.EnumSpec: return fmt.Sprintf("%s.TI32", wire) case *compile.StructSpec: return fmt.Sprintf("%s.TStruct", wire) default: panic(fmt.Sprintf("unknown type spec %v (type %T)", spec, spec)) } }
c17637
} } default: // do nothing } // A field is considered required only if it was marked required AND it // does not have a default value. return (src.Requiredness == ast.Required && src.Default == nil), nil }
c17638
Line: src.Line, Reason: err, } } return &FieldSpec{ // TODO(abg): perform bounds check on field ID ID: int16(src.ID), Name: src.Name, Type: typ, Doc: src.Doc, Required: required, Default: compileConstantValue(src.Default), Annotations: annotations, }, ...
c17639
f.Default, err = f.Default.Link(scope, f.Type) } return err }
c17640
return nil, compileError{ Target: astField.Name, Line: astField.Line, Reason: fieldIDConflictError{ ID: field.ID, Name: conflictingField, }, } } fields = append(fields, field) usedIDs[field.ID] = field.Name } return FieldGroup(fields), nil }
c17641
range fg { if field.Name == name { return field, nil } } return nil, fmt.Errorf("unknown field %v", name) }
c17642
err != nil { return err } } return nil }
c17643
if err := f(field.Type); err != nil { return err } } return nil }
c17644
return t, nil } return nil, lookupError{Name: name} }
c17645
return c, nil } return nil, lookupError{Name: name} }
c17646
return s, nil } return nil, lookupError{Name: name} }
c17647
s.Module, nil } return nil, lookupError{Name: name} }
c17648
toVisit = toVisit[1:] if _, ok := visited[m.ThriftPath]; ok { continue } visited[m.ThriftPath] = struct{}{} for _, inc := range m.Includes { toVisit = append(toVisit, inc.Module) } if err := f(m); err != nil { return err } } return nil }
c17649
return ConstantInt(src) case ast.ConstantString: return ConstantString(src) case ast.ConstantDouble: return ConstantDouble(src) default: panic(fmt.Sprintf("unknown constant value of type %T: %v", src, src)) } }
c17650
nil, constantValueCastError{Value: c, Type: t} } return c, nil }
c17651
return nil, constantValueCastError{ Value: c, Type: t, Reason: fmt.Errorf( "%v is not a valid value for enum %q", int32(c), spec.ThriftName()), } } return nil, constantValueCastError{Value: c, Type: t} // TODO: AST for constants will need to track positions for us to // include them in the erro...
c17652
!ok { return nil, constantValueCastError{Value: c, Type: t} } return c, nil }
c17653
nil, constantValueCastError{Value: c, Type: t} } return c, nil }
c17654
is not a string: all keys must be strings", pair.Key) } fields[string(s)] = pair.Value } return &ConstantStruct{Fields: fields}, nil }
c17655
err := f.Link(scope, field.Type) if err != nil { return nil, constantValueCastError{ Value: c, Type: t, Reason: constantStructFieldCastError{ FieldName: field.Name, Reason: err, }, } } c.Fields[field.Name] = f } return c, nil }
c17656
key, err := item.Key.Link(scope, m.KeySpec) if err != nil { return nil, err } value, err := item.Value.Link(scope, m.ValueSpec) if err != nil { return nil, err } // TODO(abg): Duplicate key check items[i] = ConstantValuePair{Key: key, Value: value} } return ConstantMap(items), nil }
c17657
:= make([]ConstantValue, len(c)) for i, v := range c { value, err := v.Link(scope, s.ValueSpec) if err != nil { return nil, err } values[i] = value } return ConstantSet(values), nil }
c17658
make([]ConstantValue, len(c)) for i, v := range c { value, err := v.Link(scope, l.ValueSpec) if err != nil { return nil, err } values[i] = value } return ConstantList(values), nil }
c17659
return c, nil } return c.Target.Value.Link(scope, t) }
c17660
return nil, constantValueCastError{Value: e, Type: t} } return e, nil }
c17661
EnumName: mname, ItemName: iname, }, } } includedScope, err := getIncludedScope(scope, mname) if err != nil { return nil, referenceError{ Target: src.Name, Line: src.Line, ScopeName: scope.GetName(), Reason: err, } } value, err := constantReference{Name: iname}.Link(included...
c17662
:= t.(*EnumSpec); ok { return enum, true } return nil, false }
c17663
return nil, fmt.Errorf("failed to create stdin pipe to %q: %v", cmd.Path, err) } if err := cmd.Start(); err != nil { return nil, fmt.Errorf("failed to start %q: %v", cmd.Path, err) } return &Client{ stdout: stdout, stdin: stdin, running: atomic.NewBool(true), client: frame.NewClient(stdin, stdout),...
c17664
{ panic(fmt.Sprintf("process.Client for %q has been closed", c.cmd.Path)) } return c.client.Send(data) }
c17665
errors = append(errors, fmt.Errorf("failed to detach stdin from %q: %v", c.cmd.Path, err)) } if err := c.cmd.Wait(); err != nil { errors = append(errors, fmt.Errorf("%q failed with: %v", c.cmd.Path, err)) } return multierr.Combine(errors...) }
c17666
if v == nil { return rhs == nil } else if rhs == nil { return false } return true }
c17667
{ if v == nil { return rhs == nil } else if rhs == nil { return false } return true }
c17668
return nl.lineNumber() } return 0 }
c17669
if length < _fastPathFrameSize { return r.readFastPath(length) } var buff bytes.Buffer _, err := io.CopyN(&buff, r.r, length) if err != nil { return nil, err } return buff.Bytes(), nil }
c17670
c, ok := r.r.(io.Closer); ok { return c.Close() } return nil }
c17671
Len: sh.Len, Cap: sh.Len, } return *(*[]byte)(unsafe.Pointer(&sliceHeader)) }
c17672
$lhsCast $rhsCast> } <if not (checkNoZap) -> </* We want the behavior of the underlying type for typedefs: in the case that they are objects or arrays, we need to cast to the underlying object or array; else, zapMarshaler in zap.go will take care of it. */> <if (eq (zapEncoder .Target) "Object") -> ...
c17673
Type: t, SeqID: r.SeqID, Value: v, }) binary.ReturnWriter(writer) return err }
c17674
for _, t := range f { if t == s { return true } } return false }
c17675
:= make(typeCycleFinder, 0, len(f)+1) newf = append(newf, f...) newf = append(newf, s) return newf }
c17676
ns, imports: make(map[string]*ast.ImportSpec), } }
c17677
i.ns.Reserve(name); err != nil { return err } i.imports[path] = spec return nil }
c17678
astImport := &ast.ImportSpec{ Name: ast.NewIdent(name), Path: stringLiteral(path), } i.imports[path] = astImport return name }
c17679
:= &ast.GenDecl{Tok: token.IMPORT, Specs: specs} if len(specs) > 1 { // Just need a non-zero value for Lparen to get the parens added. decl.Lparen = token.Pos(1) } return decl }
c17680
!= nil { return err } return p.EncodeEnveloped(wire.Envelope{ SeqID: seqID, Name: e.MethodName(), Type: e.EnvelopeType(), Value: body, }, w) }
c17681
// Decode the exception payload. ex := &exception.TApplicationException{} if err := ex.FromWire(envelope.Value); err != nil { return envelope.Value, envelope.SeqID, fmt.Errorf("failed to decode exception: %v", err) } return envelope.Value, envelope.SeqID, ex }
c17682
compileTypeReference(src.ValueType) if err != nil { return nil, err } return &MapSpec{ KeySpec: keySpec, ValueSpec: valueSpec, Annotations: annots, }, nil }
c17683
m.ValueSpec, err = m.ValueSpec.Link(scope) if err != nil { return m, err } return m, nil }
c17684
m.KeySpec.ThriftName(), m.ValueSpec.ThriftName(), ) }
c17685
nil { return err } return f(m.ValueSpec) }
c17686
{ return nil, err } return &ListSpec{ ValueSpec: valueSpec, Annotations: annots, }, nil }
c17687
var err error l.ValueSpec, err = l.ValueSpec.Link(scope) return l, err }
c17688
error { return f(l.ValueSpec) }
c17689
return nil, err } return &SetSpec{ ValueSpec: valueSpec, Annotations: annots, }, nil }
c17690
var err error s.ValueSpec, err = s.ValueSpec.Link(scope) return s, err }
c17691
error { return f(s.ValueSpec) }
c17692
err := compileAnnotations(src.Annotations) if err != nil { return nil, compileError{ Target: src.Name, Line: src.Line, Reason: err, } } return &StructSpec{ Name: src.Name, File: file, Type: src.Type, Fields: fields, Doc: src.Doc, Annotations: annotations...
c17693
nil } err := s.Fields.Link(scope) return s, err }
c17694
return s.Fields.ForEachTypeReference(f) }
c17695
err) } if strings.HasPrefix(path, "..") { return fmt.Errorf( "%q is not contained in the %q directory tree", m.ThriftPath, root) } return nil }) }
c17696
return nil } result = commonPrefix(result, parts) if len(result) == 1 && result[0] == "" { return fmt.Errorf( "%q does not share an ancestor with %q", thriftPath, lastString) } lastString = thriftPath return nil }) if err != nil { return "", err } return strings.Join(result, string(fi...
c17697
i++ { if l[i] != r[i] { break } } return l[:i] }
c17698
within the directory tree. if !strings.HasPrefix(packagePath, "..") { return packagePath, nil } } return "", fmt.Errorf("directory %q is not inside $GOPATH/src", dir) }
c17699
!= nil { return r, err } if r.Minor, err = parseUint(parts[2]); err != nil { return r, err } if r.Patch, err = parseUint(parts[3]); err != nil { return r, err } if parts[4] != "" { r.Pre = strings.Split(parts[4], ".") } r.Meta = parts[5] return r, nil }