Skip to content

Commit

Permalink
tag.Expr v0.8.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Drew O'Meara committed Nov 23, 2024
1 parent 53b78d5 commit de560df
Show file tree
Hide file tree
Showing 18 changed files with 531 additions and 181 deletions.
6 changes: 3 additions & 3 deletions amp.Unity/AmpCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static AmpCoreReflection() {
"ChJFcnJDb2RlX0ludmFsaWRUYWcQj8z+////////ARIhChRFcnJDb2RlX0F0",
"dHJOb3RGb3VuZBCOzP7///////8BEiQKF0VyckNvZGVfTm90aGluZ1RvQ29t",
"bWl0EI3M/v///////wESIQoURXJyQ29kZV9Db21taXRGYWlsZWQQjMz+////",
"////ARIiChVFcnJDb2RlX1NwYWNlTm90Rm91bmQQi8z+////////ARIjChZF",
"////ARIiChVFcnJDb2RlX1N0b3JlTm90Rm91bmQQi8z+////////ARIjChZF",
"cnJDb2RlX1N0b3JhZ2VGYWlsdXJlEIrM/v///////wESIAoTRXJyQ29kZV9B",
"cHBOb3RGb3VuZBCJzP7///////8BEiAKE0VyckNvZGVfTWFsZm9ybWVkVHgQ",
"iMz+////////ARIeChFFcnJDb2RlX0JhZFNjaGVtYRCAzP7///////8BEiAK",
Expand Down Expand Up @@ -346,7 +346,7 @@ public enum ErrCode {
[pbr::OriginalName("ErrCode_AttrNotFound")] AttrNotFound = -23026,
[pbr::OriginalName("ErrCode_NothingToCommit")] NothingToCommit = -23027,
[pbr::OriginalName("ErrCode_CommitFailed")] CommitFailed = -23028,
[pbr::OriginalName("ErrCode_SpaceNotFound")] SpaceNotFound = -23029,
[pbr::OriginalName("ErrCode_StoreNotFound")] StoreNotFound = -23029,
[pbr::OriginalName("ErrCode_StorageFailure")] StorageFailure = -23030,
[pbr::OriginalName("ErrCode_AppNotFound")] AppNotFound = -23031,
[pbr::OriginalName("ErrCode_MalformedTx")] MalformedTx = -23032,
Expand Down Expand Up @@ -2836,7 +2836,7 @@ public string UID {
public const int TextFieldNumber = 13;
private string text_ = "";
/// <summary>
/// tag.Spec, custom content, or expression
/// tag.Expr, custom content, or expression
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
Expand Down
30 changes: 15 additions & 15 deletions amp.Unity/AmpStdEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@ namespace Amp.Std {
public static partial class Spec {
public static readonly TagID MetaNodeID = new(0, 0, 2701);

public static readonly TagSpec TagRoot = new TagSpec().With("amp");
public static readonly TagSpec AttrSpec = TagRoot.With("attr");
public static readonly TagSpec AppSpec = TagRoot.With("app");
public static readonly TagSpec CellChildren = AttrSpec.With("children.TagID");
public static readonly TagSpec CellProperties = AttrSpec.With("cell-properties");
public static readonly TagExpr TagRoot = new TagExpr().With("amp");
public static readonly TagExpr AttrSpec = TagRoot.With("attr");
public static readonly TagExpr AppSpec = TagRoot.With("app");
public static readonly TagExpr CellChildren = AttrSpec.With("children.Tag.ID");
public static readonly TagExpr CellProperties = AttrSpec.With("cell-properties");

public static readonly TagSpec Property = new TagSpec().With("cell-property");
public static readonly TagExpr Property = new TagExpr().With("cell-property");

public static readonly TagSpec Glyphs = Property.With("Tags.glyphs");
public static readonly TagSpec Links = Property.With("Tags.links");
public static readonly TagExpr Glyphs = Property.With("Tags.glyphs");
public static readonly TagExpr Links = Property.With("Tags.links");

public static readonly TagID CellMediaID = Property.With("Tag.content.media").ID;
public static readonly TagID CellCover = Property.With("Tag.content.cover").ID;
public static readonly TagID CellVis = Property.With("Tag.content.vis").ID;

public static readonly TagSpec TextTag = Property.With("Tag.text");
public static readonly TagExpr TextTag = Property.With("Tag.text");
public static readonly TagID CellLabel = TextTag.With("label").ID;
public static readonly TagID CellCaption = TextTag.With("caption").ID;
public static readonly TagID CellCollection = TextTag.With("collection").ID;

// Meta attrs registered (allowed) to be pushed
public static readonly TagSpec Login = Registry.RegisterPrototype<Login>();
public static readonly TagSpec LoginChallenge = Registry.RegisterPrototype<LoginChallenge>();
public static readonly TagSpec LoginResponse = Registry.RegisterPrototype<LoginResponse>();
public static readonly TagSpec LoginCheckpoint = Registry.RegisterPrototype<LoginCheckpoint>();
public static readonly TagSpec PinRequest = Registry.RegisterPrototype<PinRequest>();
public static readonly TagSpec LaunchURL = Registry.RegisterPrototype<LaunchURL>();
public static readonly TagExpr Login = Registry.RegisterPrototype<Login>();
public static readonly TagExpr LoginChallenge = Registry.RegisterPrototype<LoginChallenge>();
public static readonly TagExpr LoginResponse = Registry.RegisterPrototype<LoginResponse>();
public static readonly TagExpr LoginCheckpoint = Registry.RegisterPrototype<LoginCheckpoint>();
public static readonly TagExpr PinRequest = Registry.RegisterPrototype<PinRequest>();
public static readonly TagExpr LaunchURL = Registry.RegisterPrototype<LaunchURL>();
public static readonly TagID Err = Registry.RegisterPrototype<Err>().ID;
public static readonly TagID Tag = Registry.RegisterPrototype<Tag>().ID;

Expand Down
66 changes: 33 additions & 33 deletions amp/amp.core.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions amp/amp.core.proto
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ message Tag {

string ContentType = 10; // e.g. "text/html", "image/png", "image/*", "amp.vis/content.*"
string UID = 12; // UID, SKU, or other literal
string Text = 13; // tag.Spec, custom content, or expression
string Text = 13; // tag.Expr, custom content, or expression
string URL = 15; // IEEE 1738 URL: schema://hostname.com/path/query

// Metric specifies the metric system used for the size metric values
Expand Down Expand Up @@ -373,7 +373,7 @@ enum ErrCode {
ErrCode_AttrNotFound = -23026;
ErrCode_NothingToCommit = -23027;
ErrCode_CommitFailed = -23028;
ErrCode_SpaceNotFound = -23029;
ErrCode_StoreNotFound = -23029;
ErrCode_StorageFailure = -23030;
ErrCode_AppNotFound = -23031;
ErrCode_MalformedTx = -23032;
Expand Down
26 changes: 13 additions & 13 deletions amp/amp.registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type registry struct {
attrDefs map[tag.ID]AttrDef
}

func (reg *registry) RegisterPrototype(context tag.Spec, prototype tag.Value, subTags string) tag.Spec {
func (reg *registry) RegisterPrototype(context tag.Expr, prototype tag.Value, subTags string) tag.Expr {
if subTags == "" {
typeOf := reflect.TypeOf(prototype)
if typeOf.Kind() == reflect.Ptr {
Expand All @@ -35,14 +35,14 @@ func (reg *registry) RegisterPrototype(context tag.Spec, prototype tag.Value, su
subTags = typeOf.Name()
}

attrSpec := context.With(subTags)
attrExpr := context.With(subTags)
reg.mu.Lock()
defer reg.mu.Unlock()
reg.attrDefs[attrSpec.ID] = AttrDef{
Spec: attrSpec,
reg.attrDefs[attrExpr.ID] = AttrDef{
Expr: attrExpr,
Prototype: prototype,
}
return attrSpec
return attrExpr
}

func (reg *registry) Import(other Registry) error {
Expand Down Expand Up @@ -141,9 +141,9 @@ func (reg *registry) MakeValue(attrSpec tag.ID) (tag.Value, error) {
/*
func (reg *registry) RegisterDefs(defs *RegisterDefs) error {
for _, tagSpec := range defs.TagSpecs {
for _, tagExpr := range defs.TagExprs {
def := AttrDef{
Spec: tag.FormSpec(tag.Spec{}, tagSpec),
Spec: tag.FormSpec(tag.Expr{}, tagExpr),
}
reg.attrDefs[def.Spec.ID] = def
}
Expand All @@ -158,20 +158,20 @@ func MakeSchemaForType(valTyp reflect.Type) (*AttrSchema, error) {
schema := &AttrSchema{
CellDataModel: valTyp.Name(),
SchemaName: "on-demand-reflect",
Attrs: make([]*tag.Spec, 0, numFields),
Attrs: make([]*tag.Expr, 0, numFields),
}
for i := 0; i < numFields; i++ {
// Importantly, TagSpecID is always set to the field index + 1, so we know what field to inspect when given an TagSpecID.
// Importantly, TagExprID is always set to the field index + 1, so we know what field to inspect when given an TagExprID.
field := valTyp.Field(i)
if !field.IsExported() {
continue
}
attr := &tag.Spec{
attr := &tag.Expr{
TypedName: field.Name,
TagSpecID: int32(i + 1),
TagExprID: int32(i + 1),
}
attrType := field.Type
Expand Down Expand Up @@ -233,7 +233,7 @@ func ReadCell(ctx AppContext, subKey string, schema *AttrSchema, dstStruct any)
for _, ai := range schema.Attrs {
if ai.TypedName == field.Name {
for _, msg := range msgs {
if msg.TagSpecID == ai.TagSpecID {
if msg.TagExprID == ai.TagExprID {
msg.LoadVal(dst.Field(fi).Addr().Interface())
goto nextField
}
Expand Down Expand Up @@ -271,7 +271,7 @@ func WriteCell(ctx AppContext, subKey string, schema *AttrSchema, srcStruct any)
for _, attr := range schema.Attrs {
msg := tx.AddMsg()
msg.Op = MsgOp_PushAttr
msg.TagSpecID = attr.TagSpecID
msg.TagExprID = attr.TagExprID
for i := 0; i < numFields; i++ {
if valType.Field(i).Name == attr.TypedName {
msg.setVal(src.Field(i).Interface())
Expand Down
24 changes: 12 additions & 12 deletions amp/amp.support.attrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var (
// CellID hard-wired to denote the root c
MetaNodeID = tag.ID{0, 0, 2701}

TagRoot = tag.Spec{}.With("amp")
TagRoot = tag.Expr{}.With("amp")
AttrSpec = TagRoot.With("attr")
AppSpec = TagRoot.With("app")
)
Expand Down Expand Up @@ -65,7 +65,7 @@ func (v *Tag) MarshalToStore(in []byte) (out []byte, err error) {
return MarshalPbToStore(v, in)
}

func (v *Tag) TagSpec() tag.Spec {
func (v *Tag) TagExpr() tag.Expr {
return AttrSpec.With("Tag")
}

Expand All @@ -84,7 +84,7 @@ func (v *Tags) MarshalToStore(in []byte) (out []byte, err error) {
return MarshalPbToStore(v, in)
}

func (v *Tags) TagSpec() tag.Spec {
func (v *Tags) TagExpr() tag.Expr {
return AttrSpec.With("Tags")
}

Expand All @@ -107,7 +107,7 @@ func (v *Tag) AsID() tag.ID {
if v.UID != "" {
v.SetID(tag.FromLiteral([]byte(v.UID)))
} else if v.Text != "" {
v.SetID(tag.FromString(v.Text))
v.SetID(tag.FromExpr(v.Text))
}
}
return [3]uint64{
Expand Down Expand Up @@ -139,7 +139,7 @@ func (v *Err) MarshalToStore(in []byte) (out []byte, err error) {
return MarshalPbToStore(v, in)
}

func (v *Err) TagSpec() tag.Spec {
func (v *Err) TagExpr() tag.Expr {
return AttrSpec.With("Err")
}

Expand Down Expand Up @@ -183,7 +183,7 @@ func (v *LaunchURL) MarshalToStore(in []byte) (out []byte, err error) {
return MarshalPbToStore(v, in)
}

func (v *LaunchURL) TagSpec() tag.Spec {
func (v *LaunchURL) TagExpr() tag.Expr {
return AttrSpec.With("LaunchURL")
}

Expand All @@ -195,7 +195,7 @@ func (v *Login) MarshalToStore(in []byte) (out []byte, err error) {
return MarshalPbToStore(v, in)
}

func (v *Login) TagSpec() tag.Spec {
func (v *Login) TagExpr() tag.Expr {
return AttrSpec.With("Login")
}

Expand All @@ -207,7 +207,7 @@ func (v *LoginChallenge) MarshalToStore(in []byte) (out []byte, err error) {
return MarshalPbToStore(v, in)
}

func (v *LoginChallenge) TagSpec() tag.Spec {
func (v *LoginChallenge) TagExpr() tag.Expr {
return AttrSpec.With("LoginChallenge")
}

Expand All @@ -219,7 +219,7 @@ func (v *LoginResponse) MarshalToStore(in []byte) (out []byte, err error) {
return MarshalPbToStore(v, in)
}

func (v *LoginResponse) TagSpec() tag.Spec {
func (v *LoginResponse) TagExpr() tag.Expr {
return AttrSpec.With("LoginResponse")
}

Expand All @@ -231,7 +231,7 @@ func (v *LoginCheckpoint) MarshalToStore(in []byte) (out []byte, err error) {
return MarshalPbToStore(v, in)
}

func (v *LoginCheckpoint) TagSpec() tag.Spec {
func (v *LoginCheckpoint) TagExpr() tag.Expr {
return AttrSpec.With("LoginCheckpoint")
}

Expand All @@ -243,7 +243,7 @@ func (v *PinRequest) MarshalToStore(in []byte) (out []byte, err error) {
return MarshalPbToStore(v, in)
}

func (v *PinRequest) TagSpec() tag.Spec {
func (v *PinRequest) TagExpr() tag.Expr {
return AttrSpec.With("PinRequest")
}

Expand All @@ -265,7 +265,7 @@ func (v *Request) AttrsToPin() map[tag.ID]struct{} {
for _, attr := range v.PinAttrs {
attrID := attr.AttrID()
if attrID.IsNil() && attr.URL != "" {
attrID = tag.FormSpec(tag.Spec{}, attr.URL).ID
attrID = tag.FormSpec(tag.Expr{}, attr.URL).ID
}
if !attrID.IsNil() {
pinAttrs[attrID] = struct{}{}
Expand Down
Loading

0 comments on commit de560df

Please sign in to comment.