-
Notifications
You must be signed in to change notification settings - Fork 869
Expand file tree
/
Copy pathPragmaCollection.cs
More file actions
64 lines (53 loc) · 1.73 KB
/
PragmaCollection.cs
File metadata and controls
64 lines (53 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System.Collections;
using System.Collections.Generic;
namespace UnityEditor.ShaderGraph
{
[GenerationAPI]
internal class PragmaCollection : IEnumerable<PragmaCollection.Item>
{
public class Item : IConditional
{
public PragmaDescriptor descriptor { get; }
public FieldCondition[] fieldConditions { get; }
public string value => $"#pragma {descriptor.value}";
public Item(PragmaDescriptor descriptor, FieldCondition[] fieldConditions)
{
this.descriptor = descriptor;
this.fieldConditions = fieldConditions;
}
}
readonly List<Item> m_Items;
public PragmaCollection()
{
m_Items = new List<Item>();
}
public PragmaCollection Add(PragmaCollection pragmas)
{
m_Items.AddRange(pragmas);
return this;
}
public PragmaCollection Add(PragmaDescriptor descriptor)
{
m_Items.Add(new Item(descriptor, null));
return this;
}
public PragmaCollection Add(PragmaDescriptor descriptor, FieldCondition fieldCondition)
{
m_Items.Add(new Item(descriptor, new FieldCondition[] { fieldCondition }));
return this;
}
public PragmaCollection Add(PragmaDescriptor descriptor, FieldCondition[] fieldConditions)
{
m_Items.Add(new Item(descriptor, fieldConditions));
return this;
}
public IEnumerator<Item> GetEnumerator()
{
return m_Items.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}