/[aya]/vendor/github.com/yosssi/gcss/mixin_invocation.go
ViewVC logotype

Contents of /vendor/github.com/yosssi/gcss/mixin_invocation.go

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations)
Mon Sep 30 00:42:06 2024 UTC (6 weeks, 4 days ago) by yakumo_izuru
Branch: MAIN
CVS Tags: HEAD
Mirrored from https://git.chaotic.ninja/git/yakumo_izuru/aya

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 }

nishi@chaotic.ninja
ViewVC Help
Powered by ViewVC 1.3.0-dev