Mercurial > yakumo_izuru > aya
comparison vendor/github.com/yosssi/gcss/mixin_invocation.go @ 66:787b5ee0289d draft
Use vendored modules
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>
author | yakumo.izuru |
---|---|
date | Sun, 23 Jul 2023 13:18:53 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
65:6d985efa0f7a | 66:787b5ee0289d |
---|---|
1 package gcss | |
2 | |
3 import "io" | |
4 | |
5 // mixinInvocation represents a mixin invocation. | |
6 type mixinInvocation struct { | |
7 elementBase | |
8 name string | |
9 paramValues []string | |
10 } | |
11 | |
12 // WriteTo writes the selector to the writer. | |
13 func (mi *mixinInvocation) WriteTo(w io.Writer) (int64, error) { | |
14 return 0, nil | |
15 } | |
16 | |
17 // decsParams returns the mixin's declarations and params. | |
18 func (mi *mixinInvocation) decsParams() ([]*declaration, map[string]string) { | |
19 md, ok := mi.Context().mixins[mi.name] | |
20 | |
21 if !ok { | |
22 return nil, nil | |
23 } | |
24 | |
25 params := make(map[string]string) | |
26 | |
27 l := len(mi.paramValues) | |
28 | |
29 for i, name := range md.paramNames { | |
30 if i < l { | |
31 params[name] = mi.paramValues[i] | |
32 } | |
33 } | |
34 | |
35 return md.decs, params | |
36 } | |
37 | |
38 // selsParams returns the mixin's selectors and params. | |
39 func (mi *mixinInvocation) selsParams() ([]*selector, map[string]string) { | |
40 md, ok := mi.Context().mixins[mi.name] | |
41 | |
42 if !ok { | |
43 return nil, nil | |
44 } | |
45 | |
46 params := make(map[string]string) | |
47 | |
48 l := len(mi.paramValues) | |
49 | |
50 for i, name := range md.paramNames { | |
51 if i < l { | |
52 params[name] = mi.paramValues[i] | |
53 } | |
54 } | |
55 | |
56 return md.sels, params | |
57 } | |
58 | |
59 // newMixinInvocation creates and returns a mixin invocation. | |
60 func newMixinInvocation(ln *line, parent element) (*mixinInvocation, error) { | |
61 name, paramValues, err := mixinNP(ln, false) | |
62 | |
63 if err != nil { | |
64 return nil, err | |
65 } | |
66 | |
67 return &mixinInvocation{ | |
68 elementBase: newElementBase(ln, parent), | |
69 name: name, | |
70 paramValues: paramValues, | |
71 }, nil | |
72 } |