From a97f4a6a63793a084dbb507db1aa31a19a4e3381 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Mon, 12 Feb 2024 14:54:49 +0000 Subject: [PATCH 01/32] Initial Matlab codegen. Basic types working --- tooling/internal/cmd/generatecommand.go | 11 + tooling/internal/cmd/initcontent/package.tpl | 3 + tooling/internal/matlab/binary/binary.go | 319 +++++++++++++++++ tooling/internal/matlab/common/common.go | 236 +++++++++++++ tooling/internal/matlab/matlab.go | 90 +++++ .../internal/matlab/protocols/protocols.go | 327 ++++++++++++++++++ .../+yardl/+binary/BinaryProtocolReader.m | 51 +++ .../+yardl/+binary/BinaryProtocolWriter.m | 46 +++ .../+yardl/+binary/BoolSerializer.m | 14 + .../+binary/CURRENT_BINARY_FORMAT_VERSION.m | 3 + .../+yardl/+binary/CodedInputStream.m | 51 +++ .../+yardl/+binary/CodedOutputStream.m | 61 ++++ .../+yardl/+binary/Complexfloat32Serializer.m | 22 ++ .../+yardl/+binary/Complexfloat64Serializer.m | 17 + .../+yardl/+binary/DateSerializer.m | 18 + .../+yardl/+binary/DatetimeSerializer.m | 20 ++ .../+yardl/+binary/EnumSerializer.m | 22 ++ .../static_files/+yardl/+binary/Error.m | 12 + .../+yardl/+binary/FixedVectorSerializer.m | 29 ++ .../+yardl/+binary/Float32Serializer.m | 17 + .../+yardl/+binary/Float64Serializer.m | 14 + .../+yardl/+binary/Int16Serializer.m | 14 + .../+yardl/+binary/Int32Serializer.m | 14 + .../+yardl/+binary/Int64Serializer.m | 14 + .../+yardl/+binary/Int8Serializer.m | 14 + .../static_files/+yardl/+binary/MAGIC_BYTES.m | 3 + .../+yardl/+binary/MapSerializer.m | 38 ++ .../+yardl/+binary/OptionalSerializer.m | 42 +++ .../+yardl/+binary/RecordSerializer.m | 32 ++ .../+yardl/+binary/SizeSerializer.m | 2 + .../+yardl/+binary/StreamSerializer.m | 32 ++ .../+yardl/+binary/StringSerializer.m | 18 + .../+yardl/+binary/TimeSerializer.m | 20 ++ .../+yardl/+binary/TypeSerializer.m | 6 + .../+yardl/+binary/Uint16Serializer.m | 14 + .../+yardl/+binary/Uint32Serializer.m | 14 + .../+yardl/+binary/Uint64Serializer.m | 14 + .../+yardl/+binary/Uint8Serializer.m | 14 + .../+yardl/+binary/VectorSerializer.m | 25 ++ .../matlab/static_files/+yardl/DateTime.m | 42 +++ .../matlab/static_files/+yardl/Exception.m | 11 + .../matlab/static_files/+yardl/None.m | 11 + .../static_files/+yardl/ProtocolError.m | 3 + .../matlab/static_files/+yardl/Time.m | 42 +++ .../matlab/static_files/+yardl/TypeError.m | 3 + .../matlab/static_files/+yardl/ValueError.m | 3 + tooling/internal/matlab/types/types.go | 169 +++++++++ tooling/pkg/packaging/packageinfo.go | 18 +- 48 files changed, 2014 insertions(+), 1 deletion(-) create mode 100644 tooling/internal/matlab/binary/binary.go create mode 100644 tooling/internal/matlab/common/common.go create mode 100644 tooling/internal/matlab/matlab.go create mode 100644 tooling/internal/matlab/protocols/protocols.go create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolReader.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolWriter.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/BoolSerializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/CURRENT_BINARY_FORMAT_VERSION.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/CodedInputStream.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/CodedOutputStream.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/Complexfloat32Serializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/Complexfloat64Serializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/DateSerializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/DatetimeSerializer.m create mode 100644 tooling/internal/matlab/static_files/+yardl/+binary/EnumSerializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/Error.m create mode 100644 tooling/internal/matlab/static_files/+yardl/+binary/FixedVectorSerializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/Float32Serializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/Float64Serializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/Int16Serializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/Int32Serializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/Int64Serializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/Int8Serializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/MAGIC_BYTES.m create mode 100644 tooling/internal/matlab/static_files/+yardl/+binary/MapSerializer.m create mode 100644 tooling/internal/matlab/static_files/+yardl/+binary/OptionalSerializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/RecordSerializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/SizeSerializer.m create mode 100644 tooling/internal/matlab/static_files/+yardl/+binary/StreamSerializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/StringSerializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/TimeSerializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/TypeSerializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/Uint16Serializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/Uint32Serializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/Uint64Serializer.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/Uint8Serializer.m create mode 100644 tooling/internal/matlab/static_files/+yardl/+binary/VectorSerializer.m create mode 100644 tooling/internal/matlab/static_files/+yardl/DateTime.m create mode 100755 tooling/internal/matlab/static_files/+yardl/Exception.m create mode 100644 tooling/internal/matlab/static_files/+yardl/None.m create mode 100644 tooling/internal/matlab/static_files/+yardl/ProtocolError.m create mode 100644 tooling/internal/matlab/static_files/+yardl/Time.m create mode 100644 tooling/internal/matlab/static_files/+yardl/TypeError.m create mode 100644 tooling/internal/matlab/static_files/+yardl/ValueError.m create mode 100644 tooling/internal/matlab/types/types.go diff --git a/tooling/internal/cmd/generatecommand.go b/tooling/internal/cmd/generatecommand.go index 228a30cb..c53f9a87 100644 --- a/tooling/internal/cmd/generatecommand.go +++ b/tooling/internal/cmd/generatecommand.go @@ -18,6 +18,7 @@ import ( "github.com/inancgumus/screen" "github.com/microsoft/yardl/tooling/internal/cpp" "github.com/microsoft/yardl/tooling/internal/iocommon" + "github.com/microsoft/yardl/tooling/internal/matlab" "github.com/microsoft/yardl/tooling/internal/python" "github.com/microsoft/yardl/tooling/pkg/dsl" "github.com/microsoft/yardl/tooling/pkg/packaging" @@ -153,6 +154,9 @@ func WriteSuccessfulSummary(packageInfo *packaging.PackageInfo) { if packageInfo.Json != nil { fmt.Printf("✅ Wrote JSON to %s.\n", packageInfo.Json.OutputDir) } + if packageInfo.Matlab != nil { + fmt.Printf("✅ Wrote Matlab to %s.\n", packageInfo.Matlab.OutputDir) + } } func generateImpl() (*packaging.PackageInfo, []string, error) { @@ -192,6 +196,13 @@ func generateImpl() (*packaging.PackageInfo, []string, error) { } } + if packageInfo.Matlab != nil { + err = matlab.Generate(env, *packageInfo.Matlab) + if err != nil { + return packageInfo, warnings, err + } + } + return packageInfo, warnings, err } diff --git a/tooling/internal/cmd/initcontent/package.tpl b/tooling/internal/cmd/initcontent/package.tpl index 34e87ebf..af477322 100644 --- a/tooling/internal/cmd/initcontent/package.tpl +++ b/tooling/internal/cmd/initcontent/package.tpl @@ -5,3 +5,6 @@ cpp: python: outputDir: ../python + +matlab: + outputDir: ../matlab diff --git a/tooling/internal/matlab/binary/binary.go b/tooling/internal/matlab/binary/binary.go new file mode 100644 index 00000000..c1eb353a --- /dev/null +++ b/tooling/internal/matlab/binary/binary.go @@ -0,0 +1,319 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package binary + +import ( + "bytes" + "fmt" + "path" + "strconv" + "strings" + + "github.com/microsoft/yardl/tooling/internal/formatting" + "github.com/microsoft/yardl/tooling/internal/iocommon" + "github.com/microsoft/yardl/tooling/internal/matlab/common" + "github.com/microsoft/yardl/tooling/pkg/dsl" +) + +func WriteBinary(ns *dsl.Namespace, packageDir string) error { + + if ns.IsTopLevel { + if err := writeProtocols(ns, packageDir); err != nil { + return err + } + } + + return writeRecordSerializers(ns, packageDir) +} + +func writeProtocols(ns *dsl.Namespace, packageDir string) error { + for _, p := range ns.Protocols { + + if err := writeProtocolWriter(p, ns, packageDir); err != nil { + return err + } + + if err := writeProtocolReader(p, ns, packageDir); err != nil { + return err + } + } + return nil +} + +func writeProtocolWriter(p *dsl.ProtocolDefinition, ns *dsl.Namespace, packageDir string) error { + b := bytes.Buffer{} + w := formatting.NewIndentedWriter(&b, " ") + common.WriteGeneratedFileHeader(w) + + common.WriteComment(w, fmt.Sprintf("Binary writer for the %s protocol", p.Name)) + common.WriteComment(w, p.Comment) + fmt.Fprintf(w, "classdef %s < yardl.binary.BinaryProtocolWriter & %s\n", BinaryWriterName(p), common.AbstractWriterName(p)) + common.WriteBlockBody(w, func() { + + w.WriteStringln("methods") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "function obj = %s(filename)\n", BinaryWriterName(p)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "obj@%s();\n", common.AbstractWriterName(p)) + fmt.Fprintf(w, "obj@yardl.binary.BinaryProtocolWriter(filename, %s.schema);\n", common.AbstractWriterName(p)) + }) + }) + w.WriteStringln("") + + w.WriteStringln("methods (Access=protected)") + common.WriteBlockBody(w, func() { + for i, step := range p.Sequence { + fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "w = %s;\n", typeSerializer(step.Type, ns.Name, nil)) + w.WriteStringln("w.write(obj.stream_, value);") + }) + if i < len(p.Sequence)-1 { + w.WriteStringln("") + } + } + }) + }) + + binaryPath := path.Join(packageDir, fmt.Sprintf("%s.m", BinaryWriterName(p))) + return iocommon.WriteFileIfNeeded(binaryPath, b.Bytes(), 0644) +} + +func writeProtocolReader(p *dsl.ProtocolDefinition, ns *dsl.Namespace, packageDir string) error { + b := bytes.Buffer{} + w := formatting.NewIndentedWriter(&b, " ") + common.WriteGeneratedFileHeader(w) + + common.WriteComment(w, fmt.Sprintf("Binary reader for the %s protocol", p.Name)) + common.WriteComment(w, p.Comment) + fmt.Fprintf(w, "classdef %s < yardl.binary.BinaryProtocolReader & %s\n", BinaryReaderName(p), common.AbstractReaderName(p)) + common.WriteBlockBody(w, func() { + + w.WriteStringln("methods") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "function obj = %s(filename)\n", BinaryReaderName(p)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "obj@%s();\n", common.AbstractReaderName(p)) + fmt.Fprintf(w, "obj@yardl.binary.BinaryProtocolReader(filename, %s.schema);\n", common.AbstractReaderName(p)) + }) + }) + w.WriteStringln("") + + w.WriteStringln("methods (Access=protected)") + common.WriteBlockBody(w, func() { + for i, step := range p.Sequence { + fmt.Fprintf(w, "function value = %s(obj, value)\n", common.ProtocolReadImplMethodName(step)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "r = %s;\n", typeSerializer(step.Type, ns.Name, nil)) + w.WriteStringln("value = r.read(obj.stream_);") + }) + + if i < len(p.Sequence)-1 { + w.WriteStringln("") + } + } + }) + }) + + binaryPath := path.Join(packageDir, fmt.Sprintf("%s.m", BinaryReaderName(p))) + return iocommon.WriteFileIfNeeded(binaryPath, b.Bytes(), 0644) +} + +func writeRecordSerializers(ns *dsl.Namespace, packageDir string) error { + for _, td := range ns.TypeDefinitions { + switch td := td.(type) { + case *dsl.RecordDefinition: + if err := writeRecordSerializer(td, ns, packageDir); err != nil { + return err + } + } + } + return nil +} + +func writeRecordSerializer(rec *dsl.RecordDefinition, ns *dsl.Namespace, packageDir string) error { + b := bytes.Buffer{} + w := formatting.NewIndentedWriter(&b, " ") + common.WriteGeneratedFileHeader(w) + + typeSyntax := common.TypeSyntax(rec, ns.Name) + fmt.Fprintf(w, "classdef %s < yardl.binary.RecordSerializer\n", recordSerializerClassName(rec, ns.Name)) + common.WriteBlockBody(w, func() { + + w.WriteStringln("methods") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "function obj = %s()\n", recordSerializerClassName(rec, ns.Name)) + common.WriteBlockBody(w, func() { + for i, field := range rec.Fields { + fmt.Fprintf(w, "field_serializers{%d} = %s;\n", i+1, typeSerializer(field.Type, ns.Name, nil)) + } + fmt.Fprintf(w, "obj@yardl.binary.RecordSerializer(field_serializers);\n") + }) + w.WriteStringln("") + + fmt.Fprintf(w, "function write(obj, outstream, value)\n") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "assert(isa(value, '%s'));\n", typeSyntax) + + fieldAccesses := make([]string, len(rec.Fields)) + for i, field := range rec.Fields { + fieldAccesses[i] = fmt.Sprintf("value.%s", common.FieldIdentifierName(field.Name)) + } + fmt.Fprintf(w, "obj.write_(outstream, %s)\n", strings.Join(fieldAccesses, ", ")) + }) + w.WriteStringln("") + + fmt.Fprintf(w, "function value = read(obj, instream)\n") + common.WriteBlockBody(w, func() { + w.WriteStringln("field_values = obj.read_(instream);") + fmt.Fprintf(w, "value = %s(field_values{:});\n", typeSyntax) + }) + }) + }) + + binaryPath := path.Join(packageDir, fmt.Sprintf("%s.m", recordSerializerClassName(rec, ns.Name))) + return iocommon.WriteFileIfNeeded(binaryPath, b.Bytes(), 0644) +} + +func recordSerializerClassName(record *dsl.RecordDefinition, contextNamespace string) string { + className := fmt.Sprintf("%sSerializer", formatting.ToPascalCase(record.Name)) + if record.Namespace != contextNamespace { + className = fmt.Sprintf("%s.binary.%s", common.NamespaceIdentifierName(record.Namespace), className) + } + return className +} + +func typeDefinitionSerializer(t dsl.TypeDefinition, contextNamespace string) string { + switch t := t.(type) { + case dsl.PrimitiveDefinition: + return fmt.Sprintf("yardl.binary.%sSerializer", formatting.ToPascalCase(string(t))) + case *dsl.EnumDefinition: + var baseType dsl.Type + if t.BaseType != nil { + baseType = t.BaseType + } else { + baseType = dsl.Int32Type + } + + elementSerializer := typeSerializer(baseType, contextNamespace, nil) + return fmt.Sprintf("yardl.binary.EnumSerializer(%s, @%s)", elementSerializer, common.TypeSyntax(t, contextNamespace)) + case *dsl.RecordDefinition: + serializerName := recordSerializerClassName(t, contextNamespace) + if len(t.TypeParameters) == 0 { + return fmt.Sprintf("%s()", serializerName) + } + if len(t.TypeArguments) == 0 { + panic("Expected type arguments") + } + + typeArguments := make([]string, 0, len(t.TypeArguments)) + for _, arg := range t.TypeArguments { + typeArguments = append(typeArguments, typeSerializer(arg, contextNamespace, nil)) + } + + if len(typeArguments) == 0 { + return fmt.Sprintf("%s()", serializerName) + } + + return fmt.Sprintf("%s(%s)", serializerName, strings.Join(typeArguments, ", ")) + case *dsl.GenericTypeParameter: + return fmt.Sprintf("%s_serializer", formatting.ToSnakeCase(t.Name)) + case *dsl.NamedType: + return typeSerializer(t.Type, contextNamespace, t) + default: + panic(fmt.Sprintf("Not implemented %T", t)) + } +} + +func typeSerializer(t dsl.Type, contextNamespace string, namedType *dsl.NamedType) string { + switch t := t.(type) { + case nil: + return "yardl.binary.none_serializer" + case *dsl.SimpleType: + return typeDefinitionSerializer(t.ResolvedDefinition, contextNamespace) + case *dsl.GeneralizedType: + getScalarSerializer := func() string { + if t.Cases.IsSingle() { + return typeSerializer(t.Cases[0].Type, contextNamespace, namedType) + } + if t.Cases.IsOptional() { + return fmt.Sprintf("yardl.binary.OptionalSerializer(%s)", typeSerializer(t.Cases[1].Type, contextNamespace, namedType)) + } + + // TODO:! + return fmt.Sprintf("NOT YET IMPLEMENTED") + + // unionClassName, typeParameters := common.UnionClassName(t) + // if namedType != nil { + // unionClassName = namedType.Name + // if namedType.Namespace != contextNamespace { + // unionClassName = fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(namedType.Namespace), unionClassName) + // } + // } + + // var classSyntax string + // if len(typeParameters) == 0 { + // classSyntax = unionClassName + // } else { + // classSyntax = fmt.Sprintf("%s[%s]", unionClassName, typeParameters) + // } + // options := make([]string, len(t.Cases)) + // for i, c := range t.Cases { + // if c.Type == nil { + // options[i] = "None" + // } else { + // options[i] = fmt.Sprintf("(%s.%s, %s)", classSyntax, formatting.ToPascalCase(c.Tag), typeSerializer(c.Type, contextNamespace, namedType)) + // } + // } + + // return fmt.Sprintf("yardl.binary.UnionSerializer(%s, [%s])", unionClassName, strings.Join(options, ", ")) + + } + switch td := t.Dimensionality.(type) { + case nil: + return getScalarSerializer() + case *dsl.Stream: + return fmt.Sprintf("yardl.binary.StreamSerializer(%s)", getScalarSerializer()) + case *dsl.Vector: + if td.Length != nil { + return fmt.Sprintf("yardl.binary.FixedVectorSerializer(%s, %d)", getScalarSerializer(), *td.Length) + } + + return fmt.Sprintf("yardl.binary.VectorSerializer(%s)", getScalarSerializer()) + case *dsl.Array: + if td.IsFixed() { + dims := make([]string, len(*td.Dimensions)) + for i, d := range *td.Dimensions { + dims[i] = strconv.FormatUint(*d.Length, 10) + } + + return fmt.Sprintf("yardl.binary.FixedNDArraySerializer(%s, (%s,))", getScalarSerializer(), strings.Join(dims, ", ")) + } + + if td.HasKnownNumberOfDimensions() { + return fmt.Sprintf("yardl.binary.NDArraySerializer(%s, %d)", getScalarSerializer(), len(*td.Dimensions)) + } + + return fmt.Sprintf("yardl.binary.DynamicNDArraySerializer(%s)", getScalarSerializer()) + + case *dsl.Map: + keySerializer := typeSerializer(td.KeyType, contextNamespace, namedType) + valueSerializer := typeSerializer(t.ToScalar(), contextNamespace, namedType) + + return fmt.Sprintf("yardl.binary.MapSerializer(%s, %s)", keySerializer, valueSerializer) + default: + panic(fmt.Sprintf("Not implemented %T", t.Dimensionality)) + } + default: + panic(fmt.Sprintf("Not implemented %T", t)) + } +} + +func BinaryWriterName(p *dsl.ProtocolDefinition) string { + return fmt.Sprintf("Binary%sWriter", formatting.ToPascalCase(p.Name)) +} + +func BinaryReaderName(p *dsl.ProtocolDefinition) string { + return fmt.Sprintf("Binary%sReader", formatting.ToPascalCase(p.Name)) +} diff --git a/tooling/internal/matlab/common/common.go b/tooling/internal/matlab/common/common.go new file mode 100644 index 00000000..2c724434 --- /dev/null +++ b/tooling/internal/matlab/common/common.go @@ -0,0 +1,236 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package common + +import ( + "fmt" + "strings" + + "github.com/microsoft/yardl/tooling/internal/formatting" + "github.com/microsoft/yardl/tooling/pkg/dsl" +) + +// TODO: Populate all Matlab reserved names +var isReservedName = map[string]bool{} + +var TypeSyntaxWriter dsl.TypeSyntaxWriter[string] = func(self dsl.TypeSyntaxWriter[string], t dsl.Node, contextNamespace string) string { + switch t := t.(type) { + case dsl.PrimitiveDefinition: + switch t { + case dsl.Bool: + return "bool" + case dsl.Int8: + return "int8" + case dsl.Uint8: + return "uint8" + case dsl.Int16: + return "int16" + case dsl.Uint16: + return "uint16" + case dsl.Int32: + return "int32" + case dsl.Uint32: + return "uint32" + case dsl.Int64: + return "int64" + case dsl.Uint64: + return "uint64" + case dsl.Size: + return "uint64" + case dsl.Float32: + return "float32" + case dsl.Float64: + return "float64" + case dsl.ComplexFloat32: + return "complex" + case dsl.ComplexFloat64: + return "complex" + case dsl.String: + return "str" + case dsl.Date: + return "datetime" + case dsl.Time: + return "datetime" + case dsl.DateTime: + return "datetime" + default: + panic(fmt.Sprintf("primitive '%v' not recognized", t)) + } + case *dsl.GenericTypeParameter: + return TypeIdentifierName(t.Name) + case dsl.TypeDefinition: + meta := t.GetDefinitionMeta() + typeName := TypeIdentifierName(meta.Name) + if t.GetDefinitionMeta().Namespace != contextNamespace { + typeName = fmt.Sprintf("%s.%s", formatting.ToSnakeCase(meta.Namespace), typeName) + } + + typeSyntax := typeName + + // TODO: Generic TypeDefinitions and TypeParameters + if len(meta.TypeParameters) > 0 { + // typeArguments := make([]string, 0, len(meta.TypeParameters)) + // if len(meta.TypeArguments) > 0 { + // for i, typeArg := range meta.TypeArguments { + // typeParameter := meta.TypeParameters[i] + // use := typeParameter.Annotations[TypeParameterUseAnnotationKey].(TypeParameterUse) + // if use&TypeParameterUseScalar != 0 { + // typeArguments = append(typeArguments, self.ToSyntax(typeArg, contextNamespace)) + // } + // if use&TypeParameterUseArray != 0 { + // typeArguments = append(typeArguments, TypeArrayTypeArgument(typeArg)) + // } + // } + // } else { + // for i, typeParam := range meta.TypeParameters { + // typeParameter := meta.TypeParameters[i] + // use := typeParameter.Annotations[TypeParameterUseAnnotationKey].(TypeParameterUse) + // if use&TypeParameterUseScalar != 0 { + // typeArguments = append(typeArguments, self.ToSyntax(typeParam, contextNamespace)) + // } + // if use&TypeParameterUseArray != 0 { + // typeArguments = append(typeArguments, NumpyTypeParameterSyntax(typeParam)) + // } + // } + // } + + // typeSyntax = fmt.Sprintf("%s[%s]", typeName, strings.Join(typeArguments, ", ")) + } + + if nt, ok := t.(*dsl.NamedType); ok { + if gt, ok := nt.Type.(*dsl.GeneralizedType); ok && gt.Cases.HasNullOption() && !gt.Cases.IsOptional() { + typeSyntax = fmt.Sprintf("typing.Optional[%s]", typeSyntax) + } + } + + return typeSyntax + + case nil: + return "None" + case *dsl.SimpleType: + return self.ToSyntax(t.ResolvedDefinition, contextNamespace) + case *dsl.GeneralizedType: + scalarString := func() string { + if t.Cases.IsSingle() { + return self.ToSyntax(t.Cases[0].Type, contextNamespace) + } + if t.Cases.IsOptional() { + return fmt.Sprintf("typing.Optional[%s]", self.ToSyntax(t.Cases[1].Type, contextNamespace)) + } + + // TODO: Union syntax? + // return UnionSyntax(t) + panic("Unions not yet supported") + }() + + switch d := t.Dimensionality.(type) { + case nil, *dsl.Stream: + return scalarString + case *dsl.Vector: + return fmt.Sprintf("list[%s]", scalarString) + case *dsl.Array: + // TODO: Array type arg + // return fmt.Sprintf("npt.NDArray[%s]", TypeArrayTypeArgument(t.ToScalar())) + panic("Arrays not yet supported") + case *dsl.Map: + return fmt.Sprintf("dict[%s, %s]", self.ToSyntax(d.KeyType, contextNamespace), scalarString) + default: + panic(fmt.Sprintf("unexpected type %T", d)) + } + default: + panic(fmt.Sprintf("unexpected type %T", t)) + } + +} + +func TypeSyntax(typeOrTypeDefinition dsl.Node, contextNamespace string) string { + return TypeSyntaxWriter.ToSyntax(typeOrTypeDefinition, contextNamespace) +} + +func ComputedFieldIdentifierName(name string) string { + cased := formatting.ToSnakeCase(name) + if !isReservedName[name] { + return cased + } + + return cased + "_" +} + +func TypeIdentifierName(name string) string { + if !isReservedName[name] { + return name + } + + return name + "_" +} + +func PackageDir(name string) string { + return fmt.Sprintf("+%s", formatting.ToSnakeCase(name)) +} + +func NamespaceIdentifierName(namespace string) string { + return formatting.ToSnakeCase(namespace) +} + +func FieldIdentifierName(name string) string { + snakeCased := formatting.ToSnakeCase(name) + if !isReservedName[snakeCased] { + return snakeCased + } + + return snakeCased + "_" +} + +func EnumValueIdentifierName(name string) string { + cased := formatting.ToUpperSnakeCase(name) + if !isReservedName[cased] { + return cased + } + + return cased + "_" +} + +func WriteBlockBody(w *formatting.IndentedWriter, f func()) { + defer func() { + w.WriteStringln("end") + }() + w.Indented(f) +} + +func WriteComment(w *formatting.IndentedWriter, comment string) { + comment = strings.TrimSpace(comment) + if comment != "" { + w = formatting.NewIndentedWriter(w, "% ").Indent() + w.WriteStringln(comment) + } +} + +func AbstractWriterName(p *dsl.ProtocolDefinition) string { + return fmt.Sprintf("%sWriterBase", formatting.ToPascalCase(p.Name)) +} + +func AbstractReaderName(p *dsl.ProtocolDefinition) string { + return fmt.Sprintf("%sReaderBase", formatting.ToPascalCase(p.Name)) +} + +func ProtocolWriteMethodName(s *dsl.ProtocolStep) string { + return fmt.Sprintf("write_%s", formatting.ToSnakeCase(s.Name)) +} + +func ProtocolWriteImplMethodName(s *dsl.ProtocolStep) string { + return fmt.Sprintf("write_%s_", formatting.ToSnakeCase(s.Name)) +} + +func ProtocolReadMethodName(s *dsl.ProtocolStep) string { + return fmt.Sprintf("read_%s", formatting.ToSnakeCase(s.Name)) +} + +func ProtocolReadImplMethodName(s *dsl.ProtocolStep) string { + return fmt.Sprintf("read_%s_", formatting.ToSnakeCase(s.Name)) +} + +func WriteGeneratedFileHeader(w *formatting.IndentedWriter) { + WriteComment(w, "This file was generated by the \"yardl\" tool. DO NOT EDIT.") + w.WriteStringln("") +} diff --git a/tooling/internal/matlab/matlab.go b/tooling/internal/matlab/matlab.go new file mode 100644 index 00000000..3d26e856 --- /dev/null +++ b/tooling/internal/matlab/matlab.go @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package matlab + +import ( + "bytes" + "embed" + "os" + "path" + + "github.com/microsoft/yardl/tooling/internal/formatting" + "github.com/microsoft/yardl/tooling/internal/iocommon" + "github.com/microsoft/yardl/tooling/internal/matlab/binary" + "github.com/microsoft/yardl/tooling/internal/matlab/common" + "github.com/microsoft/yardl/tooling/internal/matlab/protocols" + "github.com/microsoft/yardl/tooling/internal/matlab/types" + "github.com/microsoft/yardl/tooling/pkg/dsl" + "github.com/microsoft/yardl/tooling/pkg/packaging" +) + +//go:embed static_files/* +var staticFiles embed.FS + +func Generate(env *dsl.Environment, options packaging.MatlabCodegenOptions) error { + // common.AnnotateGenerics(env) + + err := os.MkdirAll(options.OutputDir, 0775) + if err != nil { + return err + } + + topNamespace := env.GetTopLevelNamespace() + // topPackageDir := path.Join(options.OutputDir, common.PackageDir(topNamespace.Name)) + topPackageDir := path.Join(options.OutputDir, formatting.ToSnakeCase(topNamespace.Name)) + if err := iocommon.CopyEmbeddedStaticFiles(topPackageDir, options.InternalSymlinkStaticFiles, staticFiles); err != nil { + return err + } + + for _, ns := range env.Namespaces { + packageDir := topPackageDir + if !ns.IsTopLevel { + packageDir = path.Join(packageDir, common.PackageDir(ns.Name)) + } + err = writeNamespace(ns, env.SymbolTable, packageDir) + if err != nil { + return err + } + } + + return nil +} + +func writeNamespace(ns *dsl.Namespace, st dsl.SymbolTable, packageDir string) error { + if err := os.MkdirAll(packageDir, 0775); err != nil { + return err + } + + if err := writePackageInitFile(ns, packageDir); err != nil { + return err + } + + if err := types.WriteTypes(ns, st, packageDir); err != nil { + return err + } + + if ns.IsTopLevel { + if err := protocols.WriteProtocols(ns, st, packageDir); err != nil { + return err + } + } + + if err := binary.WriteBinary(ns, packageDir); err != nil { + return err + } + + // if err := ndjson.WriteNDJson(ns, packageDir); err != nil { + // return err + // } + + return nil +} + +func writePackageInitFile(ns *dsl.Namespace, packageDir string) error { + b := bytes.Buffer{} + w := formatting.NewIndentedWriter(&b, " ") + common.WriteGeneratedFileHeader(w) + + return iocommon.WriteFileIfNeeded(path.Join(packageDir, "init.m"), b.Bytes(), 0644) +} diff --git a/tooling/internal/matlab/protocols/protocols.go b/tooling/internal/matlab/protocols/protocols.go new file mode 100644 index 00000000..73428ef7 --- /dev/null +++ b/tooling/internal/matlab/protocols/protocols.go @@ -0,0 +1,327 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package protocols + +import ( + "bytes" + "fmt" + "path" + + "github.com/microsoft/yardl/tooling/internal/formatting" + "github.com/microsoft/yardl/tooling/internal/iocommon" + "github.com/microsoft/yardl/tooling/internal/matlab/common" + "github.com/microsoft/yardl/tooling/pkg/dsl" +) + +func WriteProtocols(ns *dsl.Namespace, st dsl.SymbolTable, packageDir string) error { + + for _, p := range ns.Protocols { + if err := writeAbstractWriter(p, ns, st, packageDir); err != nil { + return err + } + if err := writeAbstractReader(p, ns, packageDir); err != nil { + return err + } + } + + return nil +} + +func writeAbstractWriter(p *dsl.ProtocolDefinition, ns *dsl.Namespace, st dsl.SymbolTable, packageDir string) error { + b := bytes.Buffer{} + w := formatting.NewIndentedWriter(&b, " ") + common.WriteGeneratedFileHeader(w) + + common.WriteComment(w, fmt.Sprintf("Abstract writer for protocol %s", p.Name)) + common.WriteComment(w, p.Comment) + fmt.Fprintf(w, "classdef (Abstract) %s < handle\n", common.AbstractWriterName(p)) + + common.WriteBlockBody(w, func() { + + w.WriteStringln("properties (Access=protected)") + common.WriteBlockBody(w, func() { w.WriteStringln("state_") }) + w.WriteStringln("") + + w.WriteStringln("methods") + common.WriteBlockBody(w, func() { + // Constructor + fmt.Fprintf(w, "function obj = %s()\n", common.AbstractWriterName(p)) + common.WriteBlockBody(w, func() { w.WriteStringln("obj.state_ = 0;") }) + w.WriteStringln("") + + // Destructor + // w.WriteStringln("function delete(obj)") + // common.WriteBlockBody(w, func() { + // }) + // w.WriteStringln("") + + // Close method + w.WriteStringln("function close(obj)") + common.WriteBlockBody(w, func() { + if len(p.Sequence) > 0 && p.Sequence[len(p.Sequence)-1].IsStream() { + fmt.Fprintf(w, "if obj.state_ == %d\n", len(p.Sequence)*2-1) + common.WriteBlockBody(w, func() { + w.WriteStringln("obj.end_stream_();") + w.WriteStringln("obj.close_();") + w.WriteStringln("return") + }) + } + w.WriteStringln("obj.close_();") + fmt.Fprintf(w, "if obj.state_ ~= %d\n", len(p.Sequence)*2) + common.WriteBlockBody(w, func() { + w.WriteStringln("expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8')));") + w.WriteStringln(`throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method));`) + }) + }) + w.WriteStringln("") + + // Public write methods + for i, step := range p.Sequence { + common.WriteComment(w, fmt.Sprintf("Ordinal %d", i)) + common.WriteComment(w, step.Comment) + fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteMethodName(step)) + common.WriteBlockBody(w, func() { + prevIsStream := i > 0 && p.Sequence[i-1].IsStream() + if prevIsStream { + fmt.Fprintf(w, "if obj.state_ == %d\n", i*2-1) + w.Indented(func() { + w.WriteStringln("obj.end_stream_();") + fmt.Fprintf(w, "obj.state_ = %d;\n", i*2) + }) + w.WriteString("else") + } + + if step.IsStream() { + fmt.Fprintf(w, "if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= %d\n", i*2) + } else { + fmt.Fprintf(w, "if obj.state_ ~= %d\n", i*2) + } + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i*2) + }) + w.WriteStringln("") + fmt.Fprintf(w, "obj.%s(value);\n", common.ProtocolWriteImplMethodName(step)) + if step.IsStream() { + fmt.Fprintf(w, "obj.state_ = %d;\n", i*2+1) + } else { + fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) + } + }) + + if i < len(p.Sequence)-1 { + w.WriteStringln("") + } + } + }) + w.WriteStringln("") + + w.WriteStringln("methods (Static)") + common.WriteBlockBody(w, func() { + w.WriteStringln("function res = schema()") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "res = string('%s');\n", dsl.GetProtocolSchemaString(p, st)) + }) + }) + w.WriteStringln("") + + // Protected abstract write methods + w.WriteStringln("methods (Abstract, Access=protected)") + common.WriteBlockBody(w, func() { + for _, step := range p.Sequence { + fmt.Fprintf(w, "%s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) + } + w.WriteStringln("") + + // end_stream method + w.WriteStringln("end_stream_(obj)") + // underlying close method + w.WriteStringln("close_(obj)") + }) + w.WriteStringln("") + + // Private methods + w.WriteStringln("methods (Access=private)") + common.WriteBlockBody(w, func() { + // _raise_unexpected_state method + w.WriteStringln("function raise_unexpected_state_(obj, actual)") + common.WriteBlockBody(w, func() { + w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") + w.WriteStringln("actual_method = obj.state_to_method_name_(actual);") + w.WriteStringln(`throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method));`) + }) + w.WriteStringln("") + + w.WriteStringln("function name = state_to_method_name_(obj, state)") + common.WriteBlockBody(w, func() { + for i, step := range p.Sequence { + fmt.Fprintf(w, "if state == %d\n", i*2) + w.Indented(func() { + fmt.Fprintf(w, "name = '%s';\n", common.ProtocolWriteMethodName(step)) + }) + w.WriteString("else") + } + w.WriteStringln("") + common.WriteBlockBody(w, func() { + w.WriteStringln("name = '';") + }) + }) + }) + + }) + + definitionsPath := path.Join(packageDir, fmt.Sprintf("%s.m", common.AbstractWriterName(p))) + return iocommon.WriteFileIfNeeded(definitionsPath, b.Bytes(), 0644) +} + +func writeAbstractReader(p *dsl.ProtocolDefinition, ns *dsl.Namespace, packageDir string) error { + b := bytes.Buffer{} + w := formatting.NewIndentedWriter(&b, " ") + common.WriteGeneratedFileHeader(w) + + common.WriteComment(w, p.Comment) + fmt.Fprintf(w, "classdef %s < handle\n", common.AbstractReaderName(p)) + + common.WriteBlockBody(w, func() { + + w.WriteStringln("properties (Access=protected)") + common.WriteBlockBody(w, func() { + w.WriteStringln("state_") + }) + w.WriteStringln("") + + w.WriteStringln("methods") + common.WriteBlockBody(w, func() { + // Constructor + fmt.Fprintf(w, "function obj = %s()\n", common.AbstractReaderName(p)) + common.WriteBlockBody(w, func() { + w.WriteStringln("obj.state_ = 0;") + }) + w.WriteStringln("") + + // Destructor + // w.WriteStringln("function delete(obj)") + // common.WriteBlockBody(w, func() { + // }) + // w.WriteStringln("") + + // Close method + w.WriteStringln("function close(obj)") + common.WriteBlockBody(w, func() { + w.WriteStringln("obj.close_();") + fmt.Fprintf(w, "if obj.state_ ~= %d\n", len(p.Sequence)*2) + common.WriteBlockBody(w, func() { + w.WriteStringln("if mod(obj.state_, 2) == 1") + w.Indented(func() { + w.WriteStringln("previous_method = obj.state_to_method_name_(obj.state_ - 1);") + w.WriteStringln(`throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method));`) + }) + w.WriteStringln("else") + common.WriteBlockBody(w, func() { + w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") + w.WriteStringln(`throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method));`) + }) + }) + }) + w.WriteStringln("") + + // Public read methods + for i, step := range p.Sequence { + common.WriteComment(w, fmt.Sprintf("Ordinal %d", i)) + common.WriteComment(w, step.Comment) + fmt.Fprintf(w, "function value = %s(obj)\n", common.ProtocolReadMethodName(step)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "if obj.state_ ~= %d\n", i*2) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i*2) + }) + w.WriteStringln("") + + fmt.Fprintf(w, "value = obj.%s();\n", common.ProtocolReadImplMethodName(step)) + if step.IsStream() { + // fmt.Fprintf(w, "obj.state_ = %d;\n", i*2+1) + // fmt.Fprintf(w, "value = obj.wrap_iterable_(value, %d);\n", (i+1)*2) + fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) + } else { + fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) + } + }) + w.WriteStringln("") + } + + // copy_to method + fmt.Fprintf(w, "function copy_to(obj, writer)\n") + common.WriteBlockBody(w, func() { + for _, step := range p.Sequence { + fmt.Fprintf(w, "writer.%s(obj.%s());\n", common.ProtocolWriteMethodName(step), common.ProtocolReadMethodName(step)) + } + }) + }) + w.WriteStringln("") + + w.WriteStringln("methods (Static)") + common.WriteBlockBody(w, func() { + w.WriteStringln("function res = schema()") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "res = %s.schema;\n", common.AbstractWriterName(p)) + }) + }) + w.WriteStringln("") + + // Protected abstract methods + w.WriteStringln("methods (Abstract, Access=protected)") + common.WriteBlockBody(w, func() { + for _, step := range p.Sequence { + fmt.Fprintf(w, "%s(obj, value)\n", common.ProtocolReadImplMethodName(step)) + } + + w.WriteStringln("") + w.WriteStringln("close_(obj)") + }) + w.WriteStringln("") + + w.WriteStringln("methods (Access=private)") + common.WriteBlockBody(w, func() { + // wrap_iterable method + w.WriteStringln("function value = wrap_iterable_(obj, iterable, final_state)") + common.WriteBlockBody(w, func() { + w.WriteStringln("% This is a no-op... In python, it's yield from iterable") + w.WriteStringln("value = iterable;") + w.WriteStringln("obj.state_ = final_state;") + }) + w.WriteStringln("") + + // raise_unexpected_state method + w.WriteStringln("function raise_unexpected_state_(obj, actual)") + common.WriteBlockBody(w, func() { + w.WriteStringln("actual_method = obj.state_to_method_name_(actual);") + w.WriteStringln("if mod(obj.state_, 2) == 1") + w.Indented(func() { + w.WriteStringln("previous_method = obj.state_to_method_name_(obj.state_ - 1);") + w.WriteStringln(`throw(yardl.ProtocolError("Received call to '%s' but the iterable returned by '%s' was not fully consumed.", actual_method, previous_method));`) + }) + w.WriteStringln("else") + common.WriteBlockBody(w, func() { + w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") + w.WriteStringln(`throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method));`) + }) + }) + w.WriteStringln("") + + // state_to_method_name method + w.WriteStringln("function name = state_to_method_name_(obj, state)") + common.WriteBlockBody(w, func() { + for i, step := range p.Sequence { + fmt.Fprintf(w, "if state == %d\n", i*2) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "name = '%s';\n", common.ProtocolReadMethodName(step)) + }) + } + w.WriteStringln("name = '';") + }) + }) + }) + + definitionsPath := path.Join(packageDir, fmt.Sprintf("%s.m", common.AbstractReaderName(p))) + return iocommon.WriteFileIfNeeded(definitionsPath, b.Bytes(), 0644) +} diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolReader.m b/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolReader.m new file mode 100755 index 00000000..bcf25f7e --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolReader.m @@ -0,0 +1,51 @@ +classdef BinaryProtocolReader < handle + + properties (Access=protected) + fid_ + stream_ + end + + methods + function obj = BinaryProtocolReader(filename, expected_schema) + [fileId, errMsg] = fopen(filename, "r"); + if fileId < 0 + throw(yardl.binary.Exception(errMsg)); + end + + obj.fid_ = fileId; + obj.stream_ = yardl.binary.CodedInputStream(fileId); + + magic_bytes = obj.stream_.read(length(yardl.binary.MAGIC_BYTES)); + if magic_bytes ~= yardl.binary.MAGIC_BYTES + throw(yardl.binary.Exception("Invalid magic bytes")); + end + + version = read_fixed_int32(obj.stream_); + if version ~= yardl.binary.CURRENT_BINARY_FORMAT_VERSION + throw(yardl.binary.Exception("Invalid binary format version")); + end + + s = yardl.binary.StringSerializer(); + schema = s.read(obj.stream_); + if ~isempty(expected_schema) & schema ~= expected_schema + fprintf("Expected schema: %s\n", expected_schema); + fprintf("Actual schema: %s\n", schema); + throw(yardl.binary.Exception("Invalid schema")); + end + end + end + + methods (Access=protected) + function close_(obj) + if obj.fid_ > 2 + obj.stream_.close(); + fclose(obj.fid_); + obj.fid_ = -1; + end + end + end +end + +function res = read_fixed_int32(stream) + res = typecast(stream.read(4), "int32"); +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolWriter.m b/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolWriter.m new file mode 100755 index 00000000..2374fd90 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolWriter.m @@ -0,0 +1,46 @@ +classdef BinaryProtocolWriter < handle + + properties (Access=protected) + fid_ + stream_ + end + + methods + function obj = BinaryProtocolWriter(filename, schema) + % TODO: What if user wants to append? Should take fid as arg + [fileId, errMsg] = fopen(filename, "w"); + if fileId < 0 + throw(yardl.Exception(errMsg)); + end + + obj.fid_ = fileId; + obj.stream_ = yardl.binary.CodedOutputStream(fileId); + + obj.stream_.write_bytes(yardl.binary.MAGIC_BYTES); + write_fixed_int32(obj.stream_, yardl.binary.CURRENT_BINARY_FORMAT_VERSION); + s = yardl.binary.StringSerializer(); + s.write(obj.stream_, schema); + end + end + + methods (Access=protected) + function end_stream_(obj) + obj.stream_.write_byte_no_check(0); + end + + function close_(obj) + if obj.fid_ > 2 + obj.stream_.close(); + fclose(obj.fid_); + obj.fid_ = -1; + end + end + end +end + +function write_fixed_int32(stream, value) + assert(value >= intmin("int32")); + assert(value <= intmax("int32")); + value = int32(value); + stream.write(typecast(value, "uint8")); +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/BoolSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/BoolSerializer.m new file mode 100755 index 00000000..3983a778 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/BoolSerializer.m @@ -0,0 +1,14 @@ +classdef BoolSerializer < yardl.binary.TypeSerializer + methods (Static) + function write( outstream, value) + assert(islogical(value)); + byte = cast(value, "uint8"); + outstream.write_bytes(byte); + end + + function res = read(instream) + byte = instream.read_byte(); + res = cast(byte, "logical"); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/CURRENT_BINARY_FORMAT_VERSION.m b/tooling/internal/matlab/static_files/+yardl/+binary/CURRENT_BINARY_FORMAT_VERSION.m new file mode 100755 index 00000000..b0285967 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/CURRENT_BINARY_FORMAT_VERSION.m @@ -0,0 +1,3 @@ +function res = CURRENT_BINARY_FORMAT_VERSION + res = int32(1); +end \ No newline at end of file diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/CodedInputStream.m b/tooling/internal/matlab/static_files/+yardl/+binary/CodedInputStream.m new file mode 100755 index 00000000..0152dc70 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/CodedInputStream.m @@ -0,0 +1,51 @@ +classdef CodedInputStream < handle + + properties + fileId + end + + methods + function obj = CodedInputStream(fileId) + obj.fileId = fileId; + end + + function close(obj) + % flush... + obj.fileId = -1; + end + + % In Python, this uses struct packing for any object... + function res = read(obj, count) + res = fread(obj.fileId, count, "*uint8"); + end + + function res = read_byte(obj) + res = fread(obj.fileId, 1, "*uint8"); + end + + function res = read_unsigned_varint(obj) + res = uint64(0); + shift = uint8(0); + + while true + byte = obj.read_byte(); + res = bitor(res, bitshift(uint64(bitand(byte, 0x7F)), shift)); + if byte < 0x80 + return + end + shift = shift + 7; + end + end + + function res = zigzag_decode(~, value) + value = uint64(value); + % res = int64(bitxor(bitshift(value, -1), -bitand(value, 1))); + res = bitxor(int64(bitshift(value, -1)), -int64(bitand(value, 1))); + end + + function res = read_signed_varint(obj) + res = obj.zigzag_decode(obj.read_unsigned_varint()); + end + + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/CodedOutputStream.m b/tooling/internal/matlab/static_files/+yardl/+binary/CodedOutputStream.m new file mode 100755 index 00000000..432a21e1 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/CodedOutputStream.m @@ -0,0 +1,61 @@ +classdef CodedOutputStream < handle + + properties + fid + end + + methods + function obj = CodedOutputStream(fileId) + obj.fid = fileId; + end + + function close(obj) + % flush... + obj.fid = -1; + end + + function write(obj, value) + assert(isa(value, "uint8")); + fwrite(obj.fid, value, "uint8"); + end + + function write_bytes(obj, bytes) + fwrite(obj.fid, bytes, "uint8"); + end + + function write_byte_no_check(obj, value) + assert(isscalar(value)); + assert(all(value >= 0)); + assert(all(value <= intmax("uint8"))); + + fwrite(obj.fid, value, "uint8"); + end + + function write_unsigned_varint(obj, value) + assert(isscalar(value)); + + int_val = uint64(value); + while true + if int_val < 0x80 + obj.write_byte_no_check(int_val); + return + end + + obj.write_byte_no_check(bitor(bitand(int_val, uint64(0x7F)), uint64(0x80))); + int_val = bitshift(int_val, -7); + end + end + + function res = zigzag_encode(~, value) + int_val = int64(value); + res = bitxor(bitshift(int_val, 1), bitshift(int_val, -63)); + end + + function write_signed_varint(obj, value) + assert(isscalar(value)); + + obj.write_unsigned_varint(obj.zigzag_encode(value)); + end + + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Complexfloat32Serializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/Complexfloat32Serializer.m new file mode 100755 index 00000000..1b924429 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Complexfloat32Serializer.m @@ -0,0 +1,22 @@ +classdef Complexfloat32Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + % assert(class(value) == "single"); + assert(real(value) <= realmax('single')); + assert(imag(value) <= realmax('single')); + assert(real(value) >= -realmax('single')); + assert(imag(value) >= -realmax('single')); + + real_bytes = typecast(single(real(value)), "uint8"); + imag_bytes = typecast(single(imag(value)), "uint8"); + outstream.write_bytes(real_bytes); + outstream.write_bytes(imag_bytes); + end + + function res = read(instream) + real_bytes = instream.read(4); + imag_bytes = instream.read(4); + res = complex(typecast(real_bytes, "single"), typecast(imag_bytes, "single")); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Complexfloat64Serializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/Complexfloat64Serializer.m new file mode 100755 index 00000000..1d79ed6e --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Complexfloat64Serializer.m @@ -0,0 +1,17 @@ +classdef Complexfloat64Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(class(value) == "double"); + real_bytes = typecast(double(real(value)), "uint8"); + imag_bytes = typecast(double(imag(value)), "uint8"); + outstream.write_bytes(real_bytes); + outstream.write_bytes(imag_bytes); + end + + function res = read(instream) + real_bytes = instream.read(8); + imag_bytes = instream.read(8); + res = complex(typecast(real_bytes, "double"), typecast(imag_bytes, "double")); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/DateSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/DateSerializer.m new file mode 100755 index 00000000..96eff3d4 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/DateSerializer.m @@ -0,0 +1,18 @@ +classdef DateSerializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(isdatetime(value)); + dur = int32(days(value - EPOCH_ORDINAL_DAYS)); + outstream.write_signed_varint(dur); + end + + function res = read(instream) + days_since_epoch = instream.read_signed_varint(); + res = EPOCH_ORDINAL_DAYS + days(days_since_epoch); + end + end +end + +function res = EPOCH_ORDINAL_DAYS + res = datetime(1970, 1, 1); +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/DatetimeSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/DatetimeSerializer.m new file mode 100755 index 00000000..51d50c0a --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/DatetimeSerializer.m @@ -0,0 +1,20 @@ +classdef DatetimeSerializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + if isa(value, 'datetime') + value = yardl.DateTime.from_datetime(value).value; + elseif isa(value, 'yardl.DateTime') + value = value.value; + else + throw(yardl.TypeError("Expected datetime or yardl.DateTime, got %s", class(value))); + end + + outstream.write_signed_varint(value); + end + + function res = read(instream) + value = instream.read_signed_varint(); + res = yardl.DateTime(value); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/EnumSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/EnumSerializer.m new file mode 100644 index 00000000..e623ee7d --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/EnumSerializer.m @@ -0,0 +1,22 @@ +classdef EnumSerializer < yardl.binary.TypeSerializer + properties + integer_serializer_; + enum_class_; + end + + methods + function obj = EnumSerializer(integer_serializer, enum_class) + obj.integer_serializer_ = integer_serializer; + obj.enum_class_ = enum_class; + end + + function write(obj, outstream, value) + obj.integer_serializer_.write(outstream, value); + end + + function res = read(obj, instream) + int_value = obj.integer_serializer_.read(instream); + res = obj.enum_class_(int_value); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Error.m b/tooling/internal/matlab/static_files/+yardl/+binary/Error.m new file mode 100755 index 00000000..ba166127 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Error.m @@ -0,0 +1,12 @@ +% function err = Exception(msg, A) +% identifier = "yardl:binary:error"; +% if nargin < 2 +% err = MException(identifier, msg); +% else +% err = MException(identifier, msg, A); +% end +% end + +function err = Error(varargin) + err = yardl.Exception("yardl:binary:Error", varargin{:}); +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/FixedVectorSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/FixedVectorSerializer.m new file mode 100644 index 00000000..daf8efc5 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/FixedVectorSerializer.m @@ -0,0 +1,29 @@ +classdef FixedVectorSerializer < yardl.binary.TypeSerializer + properties + element_serializer_; + length_; + end + + methods + function obj = FixedVectorSerializer(element_serializer, length) + obj.element_serializer_ = element_serializer; + obj.length_ = length; + end + + function write(obj, outstream, value) + if length(value) ~= obj.length_ + throw(yardl.ValueError("Expected an array of length %d, got %d", obj.length_, length(value))); + end + + for i = 1:obj.length_ + obj.element_serializer_.write(outstream, value(i)); + end + end + + function res = read(obj, instream) + for i = 1:obj.length_ + res(i) = obj.element_serializer_.read(instream); + end + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Float32Serializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/Float32Serializer.m new file mode 100755 index 00000000..1ae751fb --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Float32Serializer.m @@ -0,0 +1,17 @@ +classdef Float32Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + % assert(class(value) == "single"); + assert(value <= realmax('single')); + assert(value >= -realmax('single')); + + bytes = typecast(single(value), "uint8"); + outstream.write_bytes(bytes); + end + + function res = read(instream) + bytes = instream.read(4); + res = typecast(bytes, "single"); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Float64Serializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/Float64Serializer.m new file mode 100755 index 00000000..99d7766c --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Float64Serializer.m @@ -0,0 +1,14 @@ +classdef Float64Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(class(value) == "double"); + bytes = typecast(double(value), "uint8"); + outstream.write_bytes(bytes); + end + + function res = read(instream) + bytes = instream.read(8); + res = typecast(bytes, "double"); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Int16Serializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/Int16Serializer.m new file mode 100755 index 00000000..155972c4 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Int16Serializer.m @@ -0,0 +1,14 @@ +classdef Int16Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("int16")); + assert(value >= intmin("int16")); + value = int16(value); + outstream.write_signed_varint(value); + end + + function res = read(instream) + res = int16(instream.read_signed_varint()); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Int32Serializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/Int32Serializer.m new file mode 100755 index 00000000..17eac542 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Int32Serializer.m @@ -0,0 +1,14 @@ +classdef Int32Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("int32")); + assert(value >= intmin("int32")); + value = int32(value); + outstream.write_signed_varint(value); + end + + function res = read(instream) + res = int32(instream.read_signed_varint()); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Int64Serializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/Int64Serializer.m new file mode 100755 index 00000000..45cf2c2d --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Int64Serializer.m @@ -0,0 +1,14 @@ +classdef Int64Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("int64")); + assert(value >= intmin("int64")); + value = int64(value); + outstream.write_signed_varint(value); + end + + function res = read(instream) + res = int64(instream.read_signed_varint()); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Int8Serializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/Int8Serializer.m new file mode 100755 index 00000000..1cc6a052 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Int8Serializer.m @@ -0,0 +1,14 @@ +classdef Int8Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("int8")); + assert(value >= intmin("int8")); + bytes = typecast(int8(value), "uint8"); + outstream.write_bytes(bytes); + end + + function res = read(instream) + res = typecast(instream.read_byte(), "int8"); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/MAGIC_BYTES.m b/tooling/internal/matlab/static_files/+yardl/+binary/MAGIC_BYTES.m new file mode 100755 index 00000000..cd086b1c --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/MAGIC_BYTES.m @@ -0,0 +1,3 @@ +function res = MAGIC_BYTES + res = unicode2native('yardl'); +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/MapSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/MapSerializer.m new file mode 100644 index 00000000..302b373c --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/MapSerializer.m @@ -0,0 +1,38 @@ +classdef MapSerializer < yardl.binary.TypeSerializer + properties + key_serializer_; + value_serializer_; + end + + methods + function obj = MapSerializer(key_serializer, value_serializer) + obj.key_serializer_ = key_serializer; + obj.value_serializer_ = value_serializer; + end + + function write(obj, outstream, value) + % assert(isa(value, 'containers.Map')) + % OR, starting in R2022, Mathworks recommends using `dictionary` + % assert(isa(value, 'dictionary')) + + outstream.write_unsigned_varint(length(value)); + ks = keys(value); + vs = values(value); + for i = 1:length(value) + obj.key_serializer_.write(outstream, ks{i}); + obj.value_serializer_.write(outstream, vs{i}); + end + end + + function res = read(obj, instream) + count = instream.read_unsigned_varint(); + % TODO: If we can require R2022, should use `dictionary` + res = containers.Map; + for i = 1:count + k = obj.key_serializer_.read(instream); + v = obj.value_serializer_.read(instream); + res(k) = v; + end + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/OptionalSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/OptionalSerializer.m new file mode 100644 index 00000000..c6daa124 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/OptionalSerializer.m @@ -0,0 +1,42 @@ +classdef OptionalSerializer < yardl.binary.TypeSerializer + properties + element_serializer_; + end + + methods + function obj = OptionalSerializer(element_serializer) + obj.element_serializer_ = element_serializer; + end + + function write(obj, outstream, value) + if isa(value, 'yardl.None') + outstream.write_byte_no_check(0); + return + end + outstream.write_byte_no_check(1); + obj.element_serializer_.write(outstream, value); + + % if isa(value, 'yardl.Optional') + % if value.has_value() + % outstream.write_byte_no_check(1); + % obj.element_serializer_.write(outstream, value.get_value()); + % else + % outstream.write_byte_no_check(0); + % return + % end + % else + % outstream.write_byte_no_check(1); + % obj.element_serializer_.write(outstream, value); + % end + end + + function res = read(obj, instream) + has_value = instream.read_byte(); + if has_value == 0 + res = yardl.None; + else + res = obj.element_serializer_.read(instream); + end + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/RecordSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/RecordSerializer.m new file mode 100755 index 00000000..0e41f040 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/RecordSerializer.m @@ -0,0 +1,32 @@ +classdef RecordSerializer < handle + + properties + field_serializers + end + + methods + + function obj = RecordSerializer(field_serializers) + obj.field_serializers = field_serializers; + end + + end + + methods (Access=protected) + function write_(obj, outstream, varargin) + for i = 1:nargin-2 + fs = obj.field_serializers{i}; + field_value = varargin{i}; + fs.write(outstream, field_value); + end + end + + function res = read_(obj, instream) + res = cell(size(obj.field_serializers)); + for i = 1:length(obj.field_serializers) + fs = obj.field_serializers{i}; + res{i} = fs.read(instream); + end + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/SizeSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/SizeSerializer.m new file mode 100755 index 00000000..fcc7fe74 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/SizeSerializer.m @@ -0,0 +1,2 @@ +classdef SizeSerializer < yardl.binary.Uint64Serializer +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/StreamSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/StreamSerializer.m new file mode 100644 index 00000000..d3fbf6fc --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/StreamSerializer.m @@ -0,0 +1,32 @@ +classdef StreamSerializer < yardl.binary.TypeSerializer + properties + element_serializer_; + end + + methods + function obj = StreamSerializer(element_serializer) + obj.element_serializer_ = element_serializer; + end + + function write(obj, outstream, value) + outstream.write_unsigned_varint(length(value)); + % TODO: Optimize this? + for i = 1:length(value) + obj.element_serializer_.write(outstream, value(i)); + end + end + + function res = read(obj, instream) + count = instream.read_unsigned_varint(); + idx = 1; + while count > 0 + for c = 1:count + % TODO: Optimize this "append" approach + res(idx) = obj.element_serializer_.read(instream); + idx = idx + 1; + end + count = instream.read_unsigned_varint(); + end + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/StringSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/StringSerializer.m new file mode 100755 index 00000000..faa09fad --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/StringSerializer.m @@ -0,0 +1,18 @@ +classdef StringSerializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + % if ischar(value) + % value = convertCharsToStrings(value); + % end + bytes = unicode2native(value, "utf-8"); + outstream.write_unsigned_varint(length(bytes)); + outstream.write_bytes(bytes); + end + + function res = read(instream) + len = instream.read_unsigned_varint(); + bytes = instream.read(len); + res = convertCharsToStrings(native2unicode(bytes, "utf-8")); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/TimeSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/TimeSerializer.m new file mode 100755 index 00000000..488c81b6 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/TimeSerializer.m @@ -0,0 +1,20 @@ +classdef TimeSerializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + if isa(value, 'datetime') + value = yardl.Time.from_datetime(value).value; + elseif isa(value, 'yardl.Time') + value = value.value; + else + throw(yardl.TypeError("Expected datetime or yardl.Time, got %s", class(value))); + end + + outstream.write_signed_varint(value); + end + + function res = read(instream) + value = instream.read_signed_varint(); + res = yardl.Time(value); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/TypeSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/TypeSerializer.m new file mode 100755 index 00000000..da8cd343 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/TypeSerializer.m @@ -0,0 +1,6 @@ +classdef TypeSerializer < handle + methods (Static, Abstract) + write(obj, stream, value) + res = read(obj, stream) + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Uint16Serializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/Uint16Serializer.m new file mode 100755 index 00000000..ef5a9b80 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Uint16Serializer.m @@ -0,0 +1,14 @@ +classdef Uint16Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("uint16")); + assert(value >= intmin("uint16")); + value = uint16(value); + outstream.write_unsigned_varint(value); + end + + function res = read(instream) + res = instream.read_unsigned_varint(); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Uint32Serializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/Uint32Serializer.m new file mode 100755 index 00000000..0e0d9e40 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Uint32Serializer.m @@ -0,0 +1,14 @@ +classdef Uint32Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("uint32")); + assert(value >= intmin("uint32")); + value = uint32(value); + outstream.write_unsigned_varint(value); + end + + function res = read(instream) + res = instream.read_unsigned_varint(); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Uint64Serializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/Uint64Serializer.m new file mode 100755 index 00000000..81626462 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Uint64Serializer.m @@ -0,0 +1,14 @@ +classdef Uint64Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("uint64")); + assert(value >= intmin("uint64")); + value = uint64(value); + outstream.write_unsigned_varint(value); + end + + function res = read(instream) + res = instream.read_unsigned_varint(); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Uint8Serializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/Uint8Serializer.m new file mode 100755 index 00000000..936ad113 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Uint8Serializer.m @@ -0,0 +1,14 @@ +classdef Uint8Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("uint8")); + assert(value >= intmin("uint8")); + % bytes = typecast(uint8(value), "uint8"); + outstream.write_bytes(uint8(value)); + end + + function res = read(instream) + res = instream.read_byte(); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/VectorSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/VectorSerializer.m new file mode 100644 index 00000000..ce20d1cc --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/VectorSerializer.m @@ -0,0 +1,25 @@ +classdef VectorSerializer < yardl.binary.TypeSerializer + properties + element_serializer_; + end + + methods + function obj = VectorSerializer(element_serializer) + obj.element_serializer_ = element_serializer; + end + + function write(obj, outstream, value) + outstream.write_unsigned_varint(length(value)); + for i = 1:length(value) + obj.element_serializer_.write(outstream, value(i)); + end + end + + function res = read(obj, instream) + count = instream.read_unsigned_varint(); + for i = 1:count + res(i) = obj.element_serializer_.read(instream); + end + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/DateTime.m b/tooling/internal/matlab/static_files/+yardl/DateTime.m new file mode 100644 index 00000000..3258d23e --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/DateTime.m @@ -0,0 +1,42 @@ +% A basic datetime with nanosecond precision, always in UTC. +classdef DateTime < handle + + properties (Access=private) + nanoseconds_since_epoch_ + end + + methods + function obj = DateTime(nanoseconds_since_epoch) + obj.nanoseconds_since_epoch_ = nanoseconds_since_epoch; + end + + function value = value(obj) + value = obj.nanoseconds_since_epoch_; + end + + function dt = to_datetime(obj) + dt = datetime(obj.nanoseconds_since_epoch_, 'ConvertFrom', 'epochtime', 'TicksPerSecond', 1e9); + end + + function eq = eq(obj, other) + if isa(other, 'datetime') + other = yardl.DateTime.from_datetime(other); + end + + if isa(other, 'yardl.DateTime') + eq = all([obj.value] == [other.value]); + else + eq = false; + end + end + end + + methods (Static) + function dt = from_datetime(value) + value.TimeZone = 'UTC'; + nanoseconds_since_epoch = convertTo(value, 'epochtime', 'TicksPerSecond', 1e9); + dt = yardl.DateTime(nanoseconds_since_epoch); + end + end + +end diff --git a/tooling/internal/matlab/static_files/+yardl/Exception.m b/tooling/internal/matlab/static_files/+yardl/Exception.m new file mode 100755 index 00000000..c2dddb57 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/Exception.m @@ -0,0 +1,11 @@ +% function err = Exception(id, msg, A) +% if nargin < 3 +% err = MException(id, msg); +% else +% err = MException(id, msg, A); +% end +% end + +function err = Exception(id, varargin) + err = MException(id, varargin{:}); +end diff --git a/tooling/internal/matlab/static_files/+yardl/None.m b/tooling/internal/matlab/static_files/+yardl/None.m new file mode 100644 index 00000000..51d151b5 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/None.m @@ -0,0 +1,11 @@ +classdef None + methods + function eq = eq(~, ~) + eq = true; + end + + function neq = neq(~, ~) + neq = false; + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/ProtocolError.m b/tooling/internal/matlab/static_files/+yardl/ProtocolError.m new file mode 100644 index 00000000..36b0a6ba --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/ProtocolError.m @@ -0,0 +1,3 @@ +function err = ProtocolError(varargin) + err = yardl.Exception("yardl:ProtocolError", varargin{:}); +end diff --git a/tooling/internal/matlab/static_files/+yardl/Time.m b/tooling/internal/matlab/static_files/+yardl/Time.m new file mode 100644 index 00000000..10ee9143 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/Time.m @@ -0,0 +1,42 @@ +% A basic time of day with nanosecond precision. It is not timezone-aware and is +% meant to represent a wall clock time. +classdef Time < handle + + properties (Access=private) + nanoseconds_since_midnight_ + end + + methods + function obj = Time(nanoseconds_since_midnight) + obj.nanoseconds_since_midnight_ = nanoseconds_since_midnight; + end + + function value = value(obj) + value = obj.nanoseconds_since_midnight_; + end + + function dt = to_datetime(obj) + dt = datetime(obj.nanoseconds_since_midnight_, 'ConvertFrom', 'epochtime', 'Epoch', datetime('today'), 'TicksPerSecond', 1e9); + end + + function eq = eq(obj, other) + if isa(other, 'datetime') + other = yardl.Time.from_datetime(other); + end + + if isa(other, 'yardl.Time') + eq = all([obj.value] == [other.value]); + else + eq = false; + end + end + end + + methods (Static) + function t = from_datetime(value) + nanoseconds_since_midnight = convertTo(value, 'epochtime', 'Epoch', datetime('today', 'TimeZone', value.TimeZone), 'TicksPerSecond', 1e9); + t = yardl.Time(nanoseconds_since_midnight); + end + end + +end diff --git a/tooling/internal/matlab/static_files/+yardl/TypeError.m b/tooling/internal/matlab/static_files/+yardl/TypeError.m new file mode 100644 index 00000000..c4cf18f6 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/TypeError.m @@ -0,0 +1,3 @@ +function err = TypeError(varargin) + err = yardl.Exception("yardl:TypeError", varargin{:}); +end diff --git a/tooling/internal/matlab/static_files/+yardl/ValueError.m b/tooling/internal/matlab/static_files/+yardl/ValueError.m new file mode 100644 index 00000000..59f15c71 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/ValueError.m @@ -0,0 +1,3 @@ +function err = ValueError(varargin) + err = yardl.Exception("yardl:ValueError", varargin{:}); +end diff --git a/tooling/internal/matlab/types/types.go b/tooling/internal/matlab/types/types.go new file mode 100644 index 00000000..bb90a779 --- /dev/null +++ b/tooling/internal/matlab/types/types.go @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package types + +import ( + "bytes" + "fmt" + "path" + "strings" + + "github.com/microsoft/yardl/tooling/internal/formatting" + "github.com/microsoft/yardl/tooling/internal/iocommon" + "github.com/microsoft/yardl/tooling/internal/matlab/common" + "github.com/microsoft/yardl/tooling/pkg/dsl" +) + +func WriteTypes(ns *dsl.Namespace, st dsl.SymbolTable, packageDir string) error { + for _, td := range ns.TypeDefinitions { + b := bytes.Buffer{} + w := formatting.NewIndentedWriter(&b, " ") + common.WriteGeneratedFileHeader(w) + + switch td := td.(type) { + case *dsl.NamedType: + writeNamedType(w, td) + case *dsl.EnumDefinition: + writeEnum(w, td) + case *dsl.RecordDefinition: + writeRecord(w, td, st) + default: + panic(fmt.Sprintf("unsupported type definition: %T", td)) + } + + fname := fmt.Sprintf("%s.m", common.TypeSyntax(td, ns.Name)) + + definitionsPath := path.Join(packageDir, fname) + if err := iocommon.WriteFileIfNeeded(definitionsPath, b.Bytes(), 0644); err != nil { + return err + } + } + return nil +} + +func writeNamedType(w *formatting.IndentedWriter, td *dsl.NamedType) { + common.WriteComment(w, td.Comment) + fmt.Fprintf(w, "classdef %s < %s\n", common.TypeSyntax(td, td.Namespace), common.TypeSyntax(td.Type, td.Namespace)) + w.WriteStringln("end") +} + +func writeEnum(w *formatting.IndentedWriter, enum *dsl.EnumDefinition) { + var base string + if enum.BaseType == nil { + base = "uint64" + } else { + base = common.TypeSyntax(enum.BaseType, enum.Namespace) + } + + common.WriteComment(w, enum.Comment) + enumTypeSyntax := common.TypeSyntax(enum, enum.Namespace) + fmt.Fprintf(w, "classdef %s < %s\n", enumTypeSyntax, base) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "enumeration\n") + common.WriteBlockBody(w, func() { + for _, value := range enum.Values { + common.WriteComment(w, value.Comment) + fmt.Fprintf(w, "%s (%d)\n", common.EnumValueIdentifierName(value.Symbol), &value.IntegerValue) + } + }) + }) +} + +func writeRecord(w *formatting.IndentedWriter, rec *dsl.RecordDefinition, st dsl.SymbolTable) { + common.WriteComment(w, rec.Comment) + + fmt.Fprintf(w, "classdef %s < handle\n", common.TypeSyntax(rec, rec.Namespace)) + common.WriteBlockBody(w, func() { + + w.WriteStringln("properties") + var fieldNames []string + common.WriteBlockBody(w, func() { + for i, field := range rec.Fields { + common.WriteComment(w, field.Comment) + fieldNames = append(fieldNames, common.FieldIdentifierName(field.Name)) + fmt.Fprintf(w, "%s\n", common.FieldIdentifierName(field.Name)) + if i < len(rec.Fields)-1 { + w.WriteStringln("") + } + } + }) + w.WriteStringln("") + + w.WriteStringln("methods") + common.WriteBlockBody(w, func() { + + // Record Constructor + fmt.Fprintf(w, "function obj = %s(%s)\n", rec.Name, strings.Join(fieldNames, ", ")) + common.WriteBlockBody(w, func() { + for _, field := range rec.Fields { + fmt.Fprintf(w, "obj.%s = %s;\n", common.FieldIdentifierName(field.Name), common.FieldIdentifierName(field.Name)) + } + }) + w.WriteStringln("") + + // Computed Fields + for _, computedField := range rec.ComputedFields { + fieldName := common.ComputedFieldIdentifierName(computedField.Name) + + common.WriteComment(w, computedField.Comment) + fmt.Fprintf(w, "function res = %s(obj)\n", fieldName) + common.WriteBlockBody(w, func() { + writeComputedFieldExpression(w, computedField.Expression, rec.Namespace) + w.WriteStringln("") + }) + } + w.WriteStringln("") + + // eq method + w.WriteStringln("function res = eq(obj, other)") + common.WriteBlockBody(w, func() { + w.WriteStringln("res = ...") + w.Indented(func() { + fmt.Fprintf(w, "isa(other, '%s')", common.TypeSyntax(rec, rec.Namespace)) + for _, field := range rec.Fields { + w.WriteStringln(" && ...") + fieldIdentifier := common.FieldIdentifierName(field.Name) + w.WriteString(typeEqualityExpression(field.Type, "obj."+fieldIdentifier, "other."+fieldIdentifier)) + } + w.WriteStringln(";") + }) + }) + + // neq method + }) + + }) +} + +func typeEqualityExpression(t dsl.Type, a, b string) string { + // TODO: Figure out equality because in Matlab both 'a' and 'b' can be scalar or non-scalar... + if hasSimpleEquality(t) { + // return fmt.Sprintf("%s == %s", a, b) + return fmt.Sprintf("all(%s == %s)", a, b) + // return fmt.Sprintf("all([%s] == [%s])", a, b) + } + + // TODO: Other forms + panic(fmt.Sprintf("How about type equality expression for %s", dsl.TypeToShortSyntax(t, false))) +} + +func hasSimpleEquality(t dsl.Node) bool { + res := true + dsl.Visit(t, func(self dsl.Visitor, node dsl.Node) { + switch t := node.(type) { + case *dsl.SimpleType: + self.Visit(t.ResolvedDefinition) + case *dsl.Array, *dsl.GenericTypeParameter: + res = false + return + } + + self.VisitChildren(node) + }) + return res +} + +func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.Expression, contextNamespace string) { + // TODO +} diff --git a/tooling/pkg/packaging/packageinfo.go b/tooling/pkg/packaging/packageinfo.go index 44c5cf0a..982006e6 100644 --- a/tooling/pkg/packaging/packageinfo.go +++ b/tooling/pkg/packaging/packageinfo.go @@ -33,6 +33,7 @@ type PackageInfo struct { Json *JsonCodegenOptions `yaml:"json,omitempty"` Cpp *CppCodegenOptions `yaml:"cpp,omitempty"` Python *PythonCodegenOptions `yaml:"python,omitempty"` + Matlab *MatlabCodegenOptions `yaml:"matlab,omitempty"` } func (p *PackageInfo) PackageDir() string { @@ -112,6 +113,15 @@ func (p *PackageInfo) validate() error { } } + if p.Matlab != nil { + p.Matlab.PackageInfo = p + if p.Matlab.OutputDir == "" { + errorSink.Add(validation.NewValidationError(errors.New("the 'matlab.outputDir' field must not be empty"), p.FilePath)) + } else { + p.Matlab.OutputDir = filepath.Join(p.PackageDir(), p.Matlab.OutputDir) + } + } + return errorSink.AsError() } @@ -206,7 +216,13 @@ type PythonCodegenOptions struct { InternalSymlinkStaticFiles bool `yaml:"internalSymlinkStaticFiles"` } -// Parses PackageInfo in dir then loads all package Imports and Versions +type MatlabCodegenOptions struct { + PackageInfo *PackageInfo `yaml:"-"` + OutputDir string `yaml:"outputDir"` + InternalSymlinkStaticFiles bool `yaml:"internalSymlinkStaticFiles"` +} + +// Parses PackageInfo in dir then loads all package Imports and Predecessors func LoadPackage(dir string) (*PackageInfo, error) { packageInfo, err := loadPackageVersion(dir) if err != nil { From 03b49af0df2f7b885aa1fdcc543504d4bdf0c15c Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Tue, 5 Mar 2024 14:20:13 +0000 Subject: [PATCH 02/32] Add Matlab computed fields and NDArray serializers --- tooling/internal/matlab/binary/binary.go | 4 +- tooling/internal/matlab/common/common.go | 3 +- .../+yardl/+binary/DynamicNDArraySerializer.m | 27 ++ .../+yardl/+binary/FixedNDArraySerializer.m | 26 ++ .../+yardl/+binary/NDArraySerializer.m | 35 ++ .../+yardl/+binary/NDArraySerializerBase.m | 35 ++ .../+yardl/+binary/NoneSerializer.m | 10 + .../matlab/static_files/+yardl/KeyError.m | 3 + tooling/internal/matlab/types/types.go | 402 +++++++++++++++++- 9 files changed, 537 insertions(+), 8 deletions(-) create mode 100644 tooling/internal/matlab/static_files/+yardl/+binary/DynamicNDArraySerializer.m create mode 100644 tooling/internal/matlab/static_files/+yardl/+binary/FixedNDArraySerializer.m create mode 100644 tooling/internal/matlab/static_files/+yardl/+binary/NDArraySerializer.m create mode 100644 tooling/internal/matlab/static_files/+yardl/+binary/NDArraySerializerBase.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/NoneSerializer.m create mode 100644 tooling/internal/matlab/static_files/+yardl/KeyError.m diff --git a/tooling/internal/matlab/binary/binary.go b/tooling/internal/matlab/binary/binary.go index c1eb353a..613e9977 100644 --- a/tooling/internal/matlab/binary/binary.go +++ b/tooling/internal/matlab/binary/binary.go @@ -285,10 +285,10 @@ func typeSerializer(t dsl.Type, contextNamespace string, namedType *dsl.NamedTyp if td.IsFixed() { dims := make([]string, len(*td.Dimensions)) for i, d := range *td.Dimensions { - dims[i] = strconv.FormatUint(*d.Length, 10) + dims[len(*td.Dimensions)-i-1] = strconv.FormatUint(*d.Length, 10) } - return fmt.Sprintf("yardl.binary.FixedNDArraySerializer(%s, (%s,))", getScalarSerializer(), strings.Join(dims, ", ")) + return fmt.Sprintf("yardl.binary.FixedNDArraySerializer(%s, [%s])", getScalarSerializer(), strings.Join(dims, ", ")) } if td.HasKnownNumberOfDimensions() { diff --git a/tooling/internal/matlab/common/common.go b/tooling/internal/matlab/common/common.go index 2c724434..81ac5cd2 100644 --- a/tooling/internal/matlab/common/common.go +++ b/tooling/internal/matlab/common/common.go @@ -130,9 +130,8 @@ var TypeSyntaxWriter dsl.TypeSyntaxWriter[string] = func(self dsl.TypeSyntaxWrit case *dsl.Vector: return fmt.Sprintf("list[%s]", scalarString) case *dsl.Array: - // TODO: Array type arg + return scalarString // return fmt.Sprintf("npt.NDArray[%s]", TypeArrayTypeArgument(t.ToScalar())) - panic("Arrays not yet supported") case *dsl.Map: return fmt.Sprintf("dict[%s, %s]", self.ToSyntax(d.KeyType, contextNamespace), scalarString) default: diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/DynamicNDArraySerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/DynamicNDArraySerializer.m new file mode 100644 index 00000000..4042deb9 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/DynamicNDArraySerializer.m @@ -0,0 +1,27 @@ +classdef DynamicNDArraySerializer < yardl.binary.NDArraySerializerBase + + methods + function self = DynamicNDArraySerializer(element_serializer) + self@yardl.binary.NDArraySerializerBase(element_serializer); + end + + function write(self, outstream, value) + outstream.write_unsigned_varint(ndims(value)); + for dim = ndims(value): -1: 1 + len = size(value, dim); + outstream.write_unsigned_varint(len); + end + + self.write_data_(outstream, value); + end + + function value = read(self, instream) + ndims = instream.read_unsigned_varint(); + shape = zeros(1, ndims); + for dim = 1:ndims + shape(dim) = instream.read_unsigned_varint(); + end + value = self.read_data_(instream, flip(shape)); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/FixedNDArraySerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/FixedNDArraySerializer.m new file mode 100644 index 00000000..ff7c3433 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/FixedNDArraySerializer.m @@ -0,0 +1,26 @@ +classdef FixedNDArraySerializer < yardl.binary.NDArraySerializerBase + + properties + shape_ + end + + + methods + function self = FixedNDArraySerializer(element_serializer, shape) + self@yardl.binary.NDArraySerializerBase(element_serializer); + self.shape_ = shape; + end + + function write(self, outstream, value) + if size(value) ~= self.shape_ + throw(yardl.ValueError("Expected shape %s, got %s", self.shape_, size(value))); + end + + self.write_data_(outstream, value); + end + + function value = read(self, instream) + value = self.read_data_(instream, self.shape_); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/NDArraySerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/NDArraySerializer.m new file mode 100644 index 00000000..46fffc79 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/NDArraySerializer.m @@ -0,0 +1,35 @@ +classdef NDArraySerializer < yardl.binary.NDArraySerializerBase + + properties + ndims_ + end + + + methods + function self = NDArraySerializer(element_serializer, ndims) + self@yardl.binary.NDArraySerializerBase(element_serializer); + self.ndims_ = ndims; + end + + function write(self, outstream, value) + if ndims(value) ~= self.ndims_ + throw(yardl.ValueError("Expected %s dimensions, got %s", self.ndims_, ndims(value))); + end + + for dim = self.ndims_: -1: 1 + len = size(value, dim); + outstream.write_unsigned_varint(len); + end + + self.write_data_(outstream, value); + end + + function value = read(self, instream) + shape = zeros(1, self.ndims_); + for dim = 1:self.ndims_ + shape(dim) = instream.read_unsigned_varint(); + end + value = self.read_data_(instream, flip(shape)); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/NDArraySerializerBase.m b/tooling/internal/matlab/static_files/+yardl/+binary/NDArraySerializerBase.m new file mode 100644 index 00000000..77d4b494 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/NDArraySerializerBase.m @@ -0,0 +1,35 @@ +classdef NDArraySerializerBase < handle + + properties + element_serializer_ + end + + methods (Abstract) + write(self, outstream, value) + read(self, instream) + end + + methods (Access=protected) + function self = NDArraySerializerBase(element_serializer) + self.element_serializer_ = element_serializer; + end + + function write_data_(self, outstream, value) + flat_value = value(:); + for i = 1:length(flat_value) + self.element_serializer_.write(outstream, flat_value(i)); + end + end + + function value = read_data_(self, instream, shape) + flat_length = prod(shape); + % if self.element_serializer_.is_trivially_serializable()... + + for i = 1:flat_length + value(i) = self.element_serializer_.read(instream); + end + + value = reshape(value, shape); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/NoneSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/NoneSerializer.m new file mode 100755 index 00000000..29032438 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/NoneSerializer.m @@ -0,0 +1,10 @@ +classdef NoneSerializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + end + + function res = read(instream) + res = yardl.None; + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/KeyError.m b/tooling/internal/matlab/static_files/+yardl/KeyError.m new file mode 100644 index 00000000..70aa0034 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/KeyError.m @@ -0,0 +1,3 @@ +function err = KeyError(varargin) + err = yardl.Exception("yardl:KeyError", varargin{:}); +end diff --git a/tooling/internal/matlab/types/types.go b/tooling/internal/matlab/types/types.go index bb90a779..f1c8411e 100644 --- a/tooling/internal/matlab/types/types.go +++ b/tooling/internal/matlab/types/types.go @@ -107,11 +107,11 @@ func writeRecord(w *formatting.IndentedWriter, rec *dsl.RecordDefinition, st dsl fieldName := common.ComputedFieldIdentifierName(computedField.Name) common.WriteComment(w, computedField.Comment) - fmt.Fprintf(w, "function res = %s(obj)\n", fieldName) + fmt.Fprintf(w, "function res = %s(self)\n", fieldName) common.WriteBlockBody(w, func() { writeComputedFieldExpression(w, computedField.Expression, rec.Namespace) - w.WriteStringln("") }) + w.WriteStringln("") } w.WriteStringln("") @@ -145,7 +145,8 @@ func typeEqualityExpression(t dsl.Type, a, b string) string { } // TODO: Other forms - panic(fmt.Sprintf("How about type equality expression for %s", dsl.TypeToShortSyntax(t, false))) + // panic(fmt.Sprintf("How about type equality expression for %s", dsl.TypeToShortSyntax(t, false))) + return fmt.Sprintf("all(%s == %s)", a, b) } func hasSimpleEquality(t dsl.Node) bool { @@ -164,6 +165,399 @@ func hasSimpleEquality(t dsl.Node) bool { return res } +type tailHandler func(next func()) + +type tailWrapper struct { + outer *tailWrapper + handler tailHandler +} + +func (t tailWrapper) Append(handler tailHandler) tailWrapper { + return tailWrapper{ + outer: &t, + handler: handler, + } +} + +func (t tailWrapper) Run(body func()) { + t.composeFunc(body)() +} + +func (t tailWrapper) composeFunc(next func()) func() { + if t.handler == nil { + return next + } + this := func() { t.handler(next) } + if t.outer == nil { + return this + } + + return t.outer.composeFunc(this) +} + func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.Expression, contextNamespace string) { - // TODO + helperFunctionLookup := make(map[any]string) + dsl.Visit(expression, func(self dsl.Visitor, node dsl.Node) { + switch t := node.(type) { + case *dsl.FunctionCallExpression: + if t.FunctionName == dsl.FunctionDimensionIndex { + arrType := (t.Arguments[0].GetResolvedType()) + if _, ok := helperFunctionLookup[arrType]; !ok { + funcName := fmt.Sprintf("helper_%d_", len(helperFunctionLookup)) + helperFunctionLookup[arrType] = funcName + fmt.Fprintf(w, "function dim = %s(dim_name)\n", funcName) + common.WriteBlockBody(w, func() { + dims := dsl.ToGeneralizedType(arrType).Dimensionality.(*dsl.Array).Dimensions + for i, d := range *dims { + fmt.Fprintf(w, "if dim_name == \"%s\"\n", *d.Name) + w.Indented(func() { + fmt.Fprintf(w, "dim = %d;\n", i) + }) + w.WriteString("else") + } + w.WriteStringln("") + common.WriteBlockBody(w, func() { + w.WriteStringln(`throw(yardl.KeyError("Unknown dimension name: '%s'", dim_name));`) + }) + w.WriteStringln("") + }) + } + } + } + self.VisitChildren(node) + }) + + varCounter := 0 + newVarName := func() string { + varCounter++ + return fmt.Sprintf("var%d", varCounter) + } + + tail := tailWrapper{}.Append(func(next func()) { + w.WriteString("res = ") + next() + w.WriteStringln(";") + w.WriteStringln("return") + }) + + dsl.VisitWithContext(expression, tail, func(self dsl.VisitorWithContext[tailWrapper], node dsl.Node, tail tailWrapper) { + switch t := node.(type) { + case *dsl.UnaryExpression: + tail.Run(func() { + if t.Operator != dsl.UnaryOpNegate { + panic(fmt.Sprintf("unexpected unary operator %d", t.Operator)) + } + w.WriteString("-(") + self.Visit(t.Expression, tailWrapper{}) + w.WriteString(")") + }) + + case *dsl.BinaryExpression: + tail.Run(func() { + requiresParentheses := false + if l, ok := t.Left.(*dsl.BinaryExpression); ok && l.Operator.Precedence() < t.Operator.Precedence() { + requiresParentheses = true + } + + if requiresParentheses { + w.WriteString("(") + } + self.Visit(t.Left, tailWrapper{}) + if requiresParentheses { + w.WriteString(")") + } + + w.WriteString(" ") + + switch t.Operator { + case dsl.BinaryOpAdd: + w.WriteString("+") + case dsl.BinaryOpSub: + w.WriteString("-") + case dsl.BinaryOpMul: + w.WriteString(".*") + case dsl.BinaryOpDiv: + w.WriteString("./") + case dsl.BinaryOpPow: + w.WriteString("^") + default: + panic(fmt.Sprintf("unexpected binary operator %d", t.Operator)) + } + + w.WriteString(" ") + + requiresParentheses = false + if r, ok := t.Right.(*dsl.BinaryExpression); ok && r.Operator.Precedence() < t.Operator.Precedence() { + requiresParentheses = true + } + + if requiresParentheses { + w.WriteString("(") + } + self.Visit(t.Right, tailWrapper{}) + if requiresParentheses { + w.WriteString(")") + } + }) + + case *dsl.IntegerLiteralExpression: + tail.Run(func() { + fmt.Fprintf(w, "%d", &t.Value) + }) + case *dsl.FloatingPointLiteralExpression: + tail.Run(func() { + w.WriteString(t.Value) + }) + case *dsl.StringLiteralExpression: + tail.Run(func() { + fmt.Fprintf(w, "%q", t.Value) + }) + case *dsl.MemberAccessExpression: + tail.Run(func() { + if t.Target == nil { + if t.Kind == dsl.MemberAccessVariable { + w.WriteString(common.FieldIdentifierName(t.Member)) + return + } + + w.WriteString("self") + } else { + self.Visit(t.Target, tailWrapper{}) + } + w.WriteString(".") + if t.Kind == dsl.MemberAccessComputedField { + fmt.Fprintf(w, "%s()", common.ComputedFieldIdentifierName(t.Member)) + } else { + w.WriteString(common.FieldIdentifierName(t.Member)) + } + }) + + case *dsl.SubscriptExpression: + // Collapse adjacent subscript expressions (you can't do `array[x][y]` in Matlab, only `array(x,y)`) + target := t.Target + arguments := t.Arguments + dsl.Visit(t.Target, func(self dsl.Visitor, node dsl.Node) { + if t, ok := node.(*dsl.SubscriptExpression); ok { + target = t.Target + arguments = append(t.Arguments, arguments...) + self.VisitChildren(t.Target) + } + }) + + tail.Run(func() { + self.Visit(target, tailWrapper{}) + w.WriteString("(") + formatting.Delimited(w, ", ", arguments, func(w *formatting.IndentedWriter, i int, a *dsl.SubscriptArgument) { + self.Visit(a.Value, tailWrapper{}) + }) + w.WriteString(")") + }) + + case *dsl.FunctionCallExpression: + tail.Run(func() { + switch t.FunctionName { + case dsl.FunctionSize: + switch dsl.ToGeneralizedType(dsl.GetUnderlyingType(t.Arguments[0].GetResolvedType())).Dimensionality.(type) { + case *dsl.Vector, *dsl.Map: + fmt.Fprintf(w, "length(") + self.Visit(t.Arguments[0], tailWrapper{}) + fmt.Fprintf(w, ")") + case *dsl.Array: + w.WriteString("size(") + self.Visit(t.Arguments[0], tailWrapper{}) + + if len(t.Arguments) > 1 { + w.WriteString("(") + remainingArgs := t.Arguments[1:] + formatting.Delimited(w, ", ", remainingArgs, func(w *formatting.IndentedWriter, i int, arg dsl.Expression) { + self.Visit(arg, tailWrapper{}) + }) + fmt.Fprintf(w, ")") + } + w.WriteString(")") + } + + case dsl.FunctionDimensionIndex: + helperFuncName := helperFunctionLookup[t.Arguments[0].GetResolvedType()] + fmt.Fprintf(w, "%s(", helperFuncName) + self.Visit(t.Arguments[1], tailWrapper{}) + w.WriteString(")") + + case dsl.FunctionDimensionCount: + w.WriteString("ndims(") + self.Visit(t.Arguments[0], tailWrapper{}) + w.WriteString(")") + + default: + panic(fmt.Sprintf("Unknown function '%s'", t.FunctionName)) + } + }) + + case *dsl.SwitchExpression: + targetType := dsl.ToGeneralizedType(dsl.GetUnderlyingType(t.Target.GetResolvedType())) + + unionVariableName := newVarName() + fmt.Fprintf(w, "%s = ", unionVariableName) + self.Visit(t.Target, tailWrapper{}) + w.WriteStringln("") + + if targetType.Cases.IsOptional() { + for i, switchCase := range t.Cases { + writeSwitchCaseOverOptional(w, switchCase, unionVariableName, i == len(targetType.Cases)-1, self, tail) + } + return + } + + if targetType.Cases.IsUnion() { + // Special handling for SwitchExpression over a Union from an imported namespace + // targetTypeNamespace := "" + // dsl.Visit(t.Target, func(self dsl.Visitor, node dsl.Node) { + // switch node := node.(type) { + // case *dsl.SimpleType: + // self.Visit(node.ResolvedDefinition) + // case *dsl.RecordDefinition: + // for _, field := range node.Fields { + // u := dsl.GetUnderlyingType(field.Type) + // if u == t.Target.GetResolvedType() { + // if targetTypeNamespace == "" { + // meta := node.GetDefinitionMeta() + // targetTypeNamespace = meta.Namespace + // } + // return + // } + // } + // case dsl.Expression: + // t := node.GetResolvedType() + // if t != nil { + // self.Visit(t) + // } + // } + // self.VisitChildren(node) + // }) + + // unionClassName, _ := common.UnionClassName(targetType) + // if targetTypeNamespace != "" && targetTypeNamespace != contextNamespace { + // unionClassName = fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(targetTypeNamespace), unionClassName) + // } + + // for _, switchCase := range t.Cases { + // writeSwitchCaseOverUnion(w, targetType, unionClassName, switchCase, unionVariableName, self, tail) + // } + + // fmt.Fprintf(w, "raise RuntimeError(\"Unexpected union case\")\n") + return + } + + // this is over a single type + if len(t.Cases) != 1 { + panic("switch expression over a single type expected to have exactly one case") + } + switchCase := t.Cases[0] + switch pattern := switchCase.Pattern.(type) { + case *dsl.DeclarationPattern: + fmt.Fprintf(w, "%s = %s;\n", common.FieldIdentifierName(pattern.Identifier), unionVariableName) + self.Visit(switchCase.Expression, tail) + case *dsl.TypePattern, *dsl.DiscardPattern: + self.Visit(switchCase.Expression, tail) + default: + panic(fmt.Sprintf("Unexpected pattern type %T", t.Cases[0].Pattern)) + } + + case *dsl.TypeConversionExpression: + tail = tail.Append(func(next func()) { + writeTypeConversion(w, t.Type, next) + }) + + self.Visit(t.Expression, tail) + + default: + panic(fmt.Sprintf("Unknown expression type '%T'", t)) + } + }) +} + +func writeSwitchCaseOverOptional(w *formatting.IndentedWriter, switchCase *dsl.SwitchCase, variableName string, isLastCase bool, visitor dsl.VisitorWithContext[tailWrapper], tail tailWrapper) { + writeCore := func(declarationIdentifier string) { + if declarationIdentifier != "" { + fmt.Fprintf(w, "%s = %s;\n", declarationIdentifier, variableName) + } + visitor.Visit(switchCase.Expression, tail) + } + + writeTypeCase := func(typePattern *dsl.TypePattern, declarationIdentifier string) { + if isLastCase { + writeCore(declarationIdentifier) + return + } + + if typePattern.Type == nil { + fmt.Fprintf(w, "if isa(%s, yardl.None)\n", variableName) + } else { + fmt.Fprintf(w, "if ~isa(%s, yardl.None)\n", variableName) + } + + common.WriteBlockBody(w, func() { + writeCore(declarationIdentifier) + }) + } + + switch t := switchCase.Pattern.(type) { + case *dsl.TypePattern: + writeTypeCase(t, "") + case *dsl.DeclarationPattern: + writeTypeCase(&t.TypePattern, common.FieldIdentifierName(t.Identifier)) + case *dsl.DiscardPattern: + writeCore("") + default: + panic(fmt.Sprintf("Unknown pattern type '%T'", switchCase.Pattern)) + } +} + +func writeTypeConversion(w *formatting.IndentedWriter, t dsl.Type, next func()) { + getWrapper := func(t dsl.Type) (string, string) { + switch t := t.(type) { + case *dsl.SimpleType: + switch t := t.ResolvedDefinition.(type) { + case dsl.PrimitiveDefinition: + switch t { + case dsl.Bool: + return "logical(", ")" + case dsl.Int8: + return "int8(", ")" + case dsl.Uint8: + return "uint8(", ")" + case dsl.Int16: + return "int32(", ")" + case dsl.Uint16: + return "uint16(", ")" + case dsl.Int32: + return "int32(", ")" + case dsl.Uint32: + return "uint32(", ")" + case dsl.Int64: + return "int64(", ")" + case dsl.Uint64, dsl.Size: + return "uint64(", ")" + case dsl.Float32: + return "single(", ")" + case dsl.Float64: + return "double(", ")" + case dsl.ComplexFloat32: + return "complex(single(", "))" + case dsl.ComplexFloat64: + return "complex(double(", "))" + case dsl.String: + return "string(", ")" + case dsl.Date, dsl.Time, dsl.DateTime: + return "datetime(", ")" + } + } + } + panic(fmt.Sprintf("Unsupported type '%s'", t)) + } + + open, close := getWrapper(t) + w.WriteString(open) + next() + w.WriteString(close) } From 44c0a7582aa4ef399ff6c8836a4f793735268c88 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Tue, 5 Mar 2024 14:25:02 +0000 Subject: [PATCH 03/32] Add docker-compose for Matlab sidecar container --- .devcontainer/devcontainer.json | 9 ++++----- .devcontainer/docker-compose.yml | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 .devcontainer/docker-compose.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4842ec73..292ded09 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,11 +2,10 @@ // https://github.com/microsoft/vscode-dev-containerdevcotns/tree/v0.238.0/containers/go { "name": "yardl", - "build": { - "dockerfile": "Dockerfile", - "context": ".." - }, - "runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"], + "dockerComposeFile": "docker-compose.yml", + "service": "devcontainer", + "workspaceFolder": "/workspaces/yardl", + "overrideCommand": false, "mounts": [ // Bind mount docker socket under an alias to support docker-from-docker diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 00000000..a2a5b769 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3' +services: + devcontainer: + build: + context: .. + dockerfile: .devcontainer/Dockerfile + volumes: + - ../..:/workspaces:cached + cap_add: + - SYS_PTRACE + security_opt: + - seccomp:unconfined + + matlab: + image: mathworks/matlab:r2023b + volumes: + - ../..:/workspaces:cached + environment: + - MLM_LICENSE_FILE={{ matlab_license_server }} + entrypoint: /bin/bash + network_mode: service:devcontainer + init: true + tty: true From 729519dfd9d60ac661f4672e942d6a933c731f64 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Tue, 5 Mar 2024 15:56:57 +0000 Subject: [PATCH 04/32] Move Matlab installation into the devcontainer --- .devcontainer/Dockerfile | 54 +++++++++++++++++++ .devcontainer/devcontainer.json | 10 ++-- .devcontainer/docker-compose.yml | 23 -------- ...atlab-r2023b.ubuntu-22.04.dependencies.txt | 44 +++++++++++++++ 4 files changed, 104 insertions(+), 27 deletions(-) delete mode 100644 .devcontainer/docker-compose.yml create mode 100644 .devcontainer/matlab-r2023b.ubuntu-22.04.dependencies.txt diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 0f388e8f..6d8dc8ae 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -13,6 +13,7 @@ FROM ${DEVCONTAINER_BASE} as file-normalizer COPY environment.yml \ .devcontainer/devcontainer.bashrc \ + .devcontainer/matlab-r2023b.ubuntu-22.04.dependencies.txt \ /data/ RUN chmod -R 555 /data/ @@ -116,3 +117,56 @@ RUN . /opt/conda/etc/profile.d/conda.sh \ && mkdir -p /home/vscode/.local/share/CMakeTools \ && echo "[{\"name\":\"Conda\",\"compilers\":{\"C\":\"$GCC\",\"CXX\":\"$GXX\"}}]" > /home/vscode/.local/share/CMakeTools/cmake-tools-kits.json \ && chown vscode:conda /home/vscode/.local/share/CMakeTools/cmake-tools-kits.json + + +######################################################### +# Install Matlab +# Based on mathworks/{matlab-deps:r2023b,matlab:r2023b} +######################################################### + +ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" + +COPY --from=file-normalizer /data/matlab-r2023b.ubuntu-22.04.dependencies.txt /tmp/matlab-dependencies.txt + +RUN export DEBIAN_FRONTEND=noninteractive \ + && apt-get update \ + && apt-get install --no-install-recommends --yes \ + `cat /tmp/matlab-dependencies.txt` \ + wget \ + unzip \ + ca-certificates \ + && apt-get clean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* + +RUN [ -d /usr/share/X11/xkb ] || mkdir -p /usr/share/X11/xkb + +ARG MATLAB_RELEASE=r2023b +ARG MATLAB_PRODUCT_LIST="MATLAB" +ARG MATLAB_INSTALL_LOCATION="/opt/matlab/${MATLAB_RELEASE}" +ARG LICENSE_SERVER= + +RUN adduser --shell /bin/bash --disabled-password --gecos "" matlab \ + && echo "matlab ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/matlab \ + && chmod 0440 /etc/sudoers.d/matlab + +USER matlab +WORKDIR /home/matlab + +RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm \ + && chmod +x mpm \ + && sudo HOME=${HOME} ./mpm install \ + --release=${MATLAB_RELEASE} \ + --destination=${MATLAB_INSTALL_LOCATION} \ + --products ${MATLAB_PRODUCT_LIST} \ + || (echo "MPM Installation Failure. See below for more information:" && cat /tmp/mathworks_root.log && false) \ + && sudo rm -f mpm /tmp/mathworks_root.log \ + && sudo ln -s ${MATLAB_INSTALL_LOCATION}/bin/matlab /usr/local/bin/matlab + +# Configure the Matlab License Servier +# Option 1: Specify the host and port of the machine that serves the network licenses +# e.g. ENV MLM_LICENSE_FILE=27000@flexlm-server-name +ENV MLM_LICENSE_FILE=$LICENSE_SERVER + +# Option 2: Alternatively, copy your network license file into the container. +# COPY Network.lic ${MATLAB_INSTALL_LOCATION}/licenses/ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 292ded09..9cb0f896 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,10 +2,11 @@ // https://github.com/microsoft/vscode-dev-containerdevcotns/tree/v0.238.0/containers/go { "name": "yardl", - "dockerComposeFile": "docker-compose.yml", - "service": "devcontainer", - "workspaceFolder": "/workspaces/yardl", - + "build": { + "dockerfile": "Dockerfile", + "context": ".." + }, + "runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"], "overrideCommand": false, "mounts": [ // Bind mount docker socket under an alias to support docker-from-docker @@ -101,6 +102,7 @@ "JacquesLucke.gcov-viewer", "jinliming2.vscode-go-template", "matepek.vscode-catch2-test-adapter", + "mathworks.language-matlab", "mhutchie.git-graph", "ms-python.black-formatter", "ms-python.python", diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml deleted file mode 100644 index a2a5b769..00000000 --- a/.devcontainer/docker-compose.yml +++ /dev/null @@ -1,23 +0,0 @@ -version: '3' -services: - devcontainer: - build: - context: .. - dockerfile: .devcontainer/Dockerfile - volumes: - - ../..:/workspaces:cached - cap_add: - - SYS_PTRACE - security_opt: - - seccomp:unconfined - - matlab: - image: mathworks/matlab:r2023b - volumes: - - ../..:/workspaces:cached - environment: - - MLM_LICENSE_FILE={{ matlab_license_server }} - entrypoint: /bin/bash - network_mode: service:devcontainer - init: true - tty: true diff --git a/.devcontainer/matlab-r2023b.ubuntu-22.04.dependencies.txt b/.devcontainer/matlab-r2023b.ubuntu-22.04.dependencies.txt new file mode 100644 index 00000000..230ba3f5 --- /dev/null +++ b/.devcontainer/matlab-r2023b.ubuntu-22.04.dependencies.txt @@ -0,0 +1,44 @@ +ca-certificates +libasound2 +libc6 +libcairo-gobject2 +libcairo2 +libcap2 +libcups2 +libdrm2 +libgbm1 +libgdk-pixbuf-2.0-0 +libgl1 +libglib2.0-0 +libgstreamer-plugins-base1.0-0 +libgstreamer1.0-0 +libgtk-3-0 +libice6 +libltdl7 +libnspr4 +libnss3 +libpam0g +libpango-1.0-0 +libpangocairo-1.0-0 +libpangoft2-1.0-0 +libsndfile1 +libuuid1 +libwayland-client0 +libxcomposite1 +libxcursor1 +libxdamage1 +libxfixes3 +libxft2 +libxinerama1 +libxrandr2 +libxt6 +libxtst6 +libxxf86vm1 +locales +locales-all +make +net-tools +procps +sudo +unzip +zlib1g \ No newline at end of file From 63eccf84d2cdd8dacf9b7e268eae74c0abff08ff Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Wed, 6 Mar 2024 19:53:04 +0000 Subject: [PATCH 05/32] Add Matlab support for Unions, generic records --- matlab/tests/CodedStreamTest.m | 89 ++++ matlab/tests/run.m | 3 + models/test/_package.yml | 3 + tooling/internal/matlab/binary/binary.go | 251 +++++----- tooling/internal/matlab/common/common.go | 108 +++-- tooling/internal/matlab/matlab.go | 33 +- .../internal/matlab/protocols/protocols.go | 450 +++++++++--------- .../+yardl/+binary/BinaryProtocolReader.m | 20 +- .../+yardl/+binary/BinaryProtocolWriter.m | 19 +- .../+yardl/+binary/CodedInputStream.m | 45 +- .../+yardl/+binary/CodedOutputStream.m | 49 +- .../+yardl/+binary/Uint16Serializer.m | 2 +- .../+yardl/+binary/Uint32Serializer.m | 2 +- .../+yardl/+binary/Uint64Serializer.m | 2 +- .../+yardl/+binary/UnionSerializer.m | 60 +++ .../matlab/static_files/+yardl/Optional.m | 28 ++ .../matlab/static_files/+yardl/Union.m | 30 ++ tooling/internal/matlab/types/types.go | 333 ++++++++----- 18 files changed, 910 insertions(+), 617 deletions(-) create mode 100644 matlab/tests/CodedStreamTest.m create mode 100644 matlab/tests/run.m create mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/UnionSerializer.m create mode 100644 tooling/internal/matlab/static_files/+yardl/Optional.m create mode 100644 tooling/internal/matlab/static_files/+yardl/Union.m diff --git a/matlab/tests/CodedStreamTest.m b/matlab/tests/CodedStreamTest.m new file mode 100644 index 00000000..d9dffa22 --- /dev/null +++ b/matlab/tests/CodedStreamTest.m @@ -0,0 +1,89 @@ +classdef CodedStreamTest < matlab.unittest.TestCase + + methods (Test) + + function testScalarByte(testCase) + % w = yardl.binary.CodedOutputStream(tempname) + % for i = 0:15 + % w. + % end + end + + + function testVarShort(testCase) + entries = int16([0, 1, 5, 33, 0x7E, 0x7F, 0x80, 0x81, 255, 256, 257, 838, 0x3FFF, 0x4000, 0x4001, 0x7FFF]); + + filename = tempname; + w = yardl.binary.CodedOutputStream(filename); + for i = 1:length(entries) + yardl.binary.Int16Serializer.write(w, entries(i)); + yardl.binary.Int16Serializer.write(w, -entries(i)); + end + w.close(); + + r = yardl.binary.CodedInputStream(filename); + for i = 1:length(entries) + testCase.verifyEqual(yardl.binary.Int16Serializer.read(r), entries(i)); + testCase.verifyEqual(yardl.binary.Int16Serializer.read(r), -entries(i)); + end + r.close(); + end + + function testVarUShort(testCase) + entries = uint16([0, 1, 5, 33, 0x7E, 0x7F, 0x80, 0x81, 255, 256, 257, 838, 0x3FFF, 0x4000, 0x4001, 0x7FFF, 0x8000, 0x8001, 0xFFFF]); + + filename = tempname; + w = yardl.binary.CodedOutputStream(filename); + for i = 1:length(entries) + yardl.binary.Uint16Serializer.write(w, entries(i)); + end + w.close(); + + r = yardl.binary.CodedInputStream(filename); + for i = 1:length(entries) + testCase.verifyEqual(yardl.binary.Uint16Serializer.read(r), entries(i)); + end + r.close(); + end + + function testVarIntegers(testCase) + entries = uint32([ 0, 1, 5, 33, 0x7E, 0x7F, 0x80, 0x81, 255, 256, 257, 838, 283928, 2847772, 3443, 0x7FFFFFFF, 0xFFFFFFFF]); + + filename = tempname; + w = yardl.binary.CodedOutputStream(filename); + for i = 1:length(entries) + yardl.binary.Uint32Serializer.write(w, entries(i)); + + yardl.binary.Int32Serializer.write(w, int32(entries(i))); + yardl.binary.Int32Serializer.write(w, -int32(entries(i))); + + yardl.binary.Uint64Serializer.write(w, uint64(entries(i))); + yardl.binary.Uint64Serializer.write(w, bitor(uint64(entries(i)), uint64(0x800000000))); + + yardl.binary.Int64Serializer.write(w, int64(entries(i))); + yardl.binary.Int64Serializer.write(w, -int64(entries(i))); + yardl.binary.Int64Serializer.write(w, bitor(int64(entries(i)), int64(0x400000000))); + yardl.binary.Int64Serializer.write(w, -bitor(int64(entries(i)), int64(0x400000000))); + end + w.close(); + + r = yardl.binary.CodedInputStream(filename); + for i = 1:length(entries) + testCase.verifyEqual(yardl.binary.Uint32Serializer.read(r), entries(i)); + + testCase.verifyEqual(yardl.binary.Int32Serializer.read(r), int32(entries(i))); + testCase.verifyEqual(yardl.binary.Int32Serializer.read(r), -int32(entries(i))); + + testCase.verifyEqual(yardl.binary.Uint64Serializer.read(r), uint64(entries(i))); + testCase.verifyEqual(yardl.binary.Uint64Serializer.read(r), bitor(uint64(entries(i)), uint64(0x800000000))); + + testCase.verifyEqual(yardl.binary.Int64Serializer.read(r), int64(entries(i))); + testCase.verifyEqual(yardl.binary.Int64Serializer.read(r), -int64(entries(i))); + testCase.verifyEqual(yardl.binary.Int64Serializer.read(r), bitor(int64(entries(i)), int64(0x400000000))); + testCase.verifyEqual(yardl.binary.Int64Serializer.read(r), -bitor(int64(entries(i)), int64(0x400000000))); + end + r.close(); + end + + end +end diff --git a/matlab/tests/run.m b/matlab/tests/run.m new file mode 100644 index 00000000..01ea66f4 --- /dev/null +++ b/matlab/tests/run.m @@ -0,0 +1,3 @@ +addpath("../generated/test_model/") + +run(CodedStreamTest) diff --git a/models/test/_package.yml b/models/test/_package.yml index e051f7b0..fc8d2e54 100644 --- a/models/test/_package.yml +++ b/models/test/_package.yml @@ -17,5 +17,8 @@ python: outputDir: ../../python/ internalSymlinkStaticFiles: true +matlab: + outputDir: ../../matlab/generated + json: outputDir: ../../cpp/test/generated diff --git a/tooling/internal/matlab/binary/binary.go b/tooling/internal/matlab/binary/binary.go index 613e9977..71a9d9be 100644 --- a/tooling/internal/matlab/binary/binary.go +++ b/tooling/internal/matlab/binary/binary.go @@ -4,127 +4,113 @@ package binary import ( - "bytes" "fmt" - "path" "strconv" "strings" "github.com/microsoft/yardl/tooling/internal/formatting" - "github.com/microsoft/yardl/tooling/internal/iocommon" "github.com/microsoft/yardl/tooling/internal/matlab/common" "github.com/microsoft/yardl/tooling/pkg/dsl" ) -func WriteBinary(ns *dsl.Namespace, packageDir string) error { +func WriteBinary(fw *common.MatlabFileWriter, ns *dsl.Namespace) error { if ns.IsTopLevel { - if err := writeProtocols(ns, packageDir); err != nil { + if err := writeProtocols(fw, ns); err != nil { return err } } - return writeRecordSerializers(ns, packageDir) + return writeRecordSerializers(fw, ns) } -func writeProtocols(ns *dsl.Namespace, packageDir string) error { +func writeProtocols(fw *common.MatlabFileWriter, ns *dsl.Namespace) error { for _, p := range ns.Protocols { - - if err := writeProtocolWriter(p, ns, packageDir); err != nil { + if err := writeProtocolWriter(fw, p, ns); err != nil { return err } - if err := writeProtocolReader(p, ns, packageDir); err != nil { + if err := writeProtocolReader(fw, p, ns); err != nil { return err } } return nil } -func writeProtocolWriter(p *dsl.ProtocolDefinition, ns *dsl.Namespace, packageDir string) error { - b := bytes.Buffer{} - w := formatting.NewIndentedWriter(&b, " ") - common.WriteGeneratedFileHeader(w) - - common.WriteComment(w, fmt.Sprintf("Binary writer for the %s protocol", p.Name)) - common.WriteComment(w, p.Comment) - fmt.Fprintf(w, "classdef %s < yardl.binary.BinaryProtocolWriter & %s\n", BinaryWriterName(p), common.AbstractWriterName(p)) - common.WriteBlockBody(w, func() { - - w.WriteStringln("methods") +func writeProtocolWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, ns *dsl.Namespace) error { + return fw.WriteFile(BinaryWriterName(p), func(w *formatting.IndentedWriter) { + common.WriteComment(w, fmt.Sprintf("Binary writer for the %s protocol", p.Name)) + common.WriteComment(w, p.Comment) + fmt.Fprintf(w, "classdef %s < yardl.binary.BinaryProtocolWriter & %s\n", BinaryWriterName(p), common.AbstractWriterName(p)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "function obj = %s(filename)\n", BinaryWriterName(p)) - common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj@%s();\n", common.AbstractWriterName(p)) - fmt.Fprintf(w, "obj@yardl.binary.BinaryProtocolWriter(filename, %s.schema);\n", common.AbstractWriterName(p)) - }) - }) - w.WriteStringln("") - w.WriteStringln("methods (Access=protected)") - common.WriteBlockBody(w, func() { - for i, step := range p.Sequence { - fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) + w.WriteStringln("methods") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "function obj = %s(filename)\n", BinaryWriterName(p)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "w = %s;\n", typeSerializer(step.Type, ns.Name, nil)) - w.WriteStringln("w.write(obj.stream_, value);") + fmt.Fprintf(w, "obj@%s();\n", common.AbstractWriterName(p)) + fmt.Fprintf(w, "obj@yardl.binary.BinaryProtocolWriter(filename, %s.schema);\n", common.AbstractWriterName(p)) }) - if i < len(p.Sequence)-1 { - w.WriteStringln("") + }) + w.WriteStringln("") + + w.WriteStringln("methods (Access=protected)") + common.WriteBlockBody(w, func() { + for i, step := range p.Sequence { + fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "w = %s;\n", typeSerializer(step.Type, ns.Name, nil)) + w.WriteStringln("w.write(obj.stream_, value);") + }) + if i < len(p.Sequence)-1 { + w.WriteStringln("") + } } - } + }) }) }) - - binaryPath := path.Join(packageDir, fmt.Sprintf("%s.m", BinaryWriterName(p))) - return iocommon.WriteFileIfNeeded(binaryPath, b.Bytes(), 0644) } -func writeProtocolReader(p *dsl.ProtocolDefinition, ns *dsl.Namespace, packageDir string) error { - b := bytes.Buffer{} - w := formatting.NewIndentedWriter(&b, " ") - common.WriteGeneratedFileHeader(w) - - common.WriteComment(w, fmt.Sprintf("Binary reader for the %s protocol", p.Name)) - common.WriteComment(w, p.Comment) - fmt.Fprintf(w, "classdef %s < yardl.binary.BinaryProtocolReader & %s\n", BinaryReaderName(p), common.AbstractReaderName(p)) - common.WriteBlockBody(w, func() { - - w.WriteStringln("methods") +func writeProtocolReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, ns *dsl.Namespace) error { + return fw.WriteFile(BinaryReaderName(p), func(w *formatting.IndentedWriter) { + common.WriteComment(w, fmt.Sprintf("Binary reader for the %s protocol", p.Name)) + common.WriteComment(w, p.Comment) + fmt.Fprintf(w, "classdef %s < yardl.binary.BinaryProtocolReader & %s\n", BinaryReaderName(p), common.AbstractReaderName(p)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "function obj = %s(filename)\n", BinaryReaderName(p)) - common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj@%s();\n", common.AbstractReaderName(p)) - fmt.Fprintf(w, "obj@yardl.binary.BinaryProtocolReader(filename, %s.schema);\n", common.AbstractReaderName(p)) - }) - }) - w.WriteStringln("") - w.WriteStringln("methods (Access=protected)") - common.WriteBlockBody(w, func() { - for i, step := range p.Sequence { - fmt.Fprintf(w, "function value = %s(obj, value)\n", common.ProtocolReadImplMethodName(step)) + w.WriteStringln("methods") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "function obj = %s(filename)\n", BinaryReaderName(p)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "r = %s;\n", typeSerializer(step.Type, ns.Name, nil)) - w.WriteStringln("value = r.read(obj.stream_);") + fmt.Fprintf(w, "obj@%s();\n", common.AbstractReaderName(p)) + fmt.Fprintf(w, "obj@yardl.binary.BinaryProtocolReader(filename, %s.schema);\n", common.AbstractReaderName(p)) }) + }) + w.WriteStringln("") - if i < len(p.Sequence)-1 { - w.WriteStringln("") + w.WriteStringln("methods (Access=protected)") + common.WriteBlockBody(w, func() { + for i, step := range p.Sequence { + fmt.Fprintf(w, "function value = %s(obj, value)\n", common.ProtocolReadImplMethodName(step)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "r = %s;\n", typeSerializer(step.Type, ns.Name, nil)) + w.WriteStringln("value = r.read(obj.stream_);") + }) + + if i < len(p.Sequence)-1 { + w.WriteStringln("") + } } - } + }) }) }) - - binaryPath := path.Join(packageDir, fmt.Sprintf("%s.m", BinaryReaderName(p))) - return iocommon.WriteFileIfNeeded(binaryPath, b.Bytes(), 0644) } -func writeRecordSerializers(ns *dsl.Namespace, packageDir string) error { +func writeRecordSerializers(fw *common.MatlabFileWriter, ns *dsl.Namespace) error { for _, td := range ns.TypeDefinitions { switch td := td.(type) { case *dsl.RecordDefinition: - if err := writeRecordSerializer(td, ns, packageDir); err != nil { + if err := writeRecordSerializer(fw, td, ns); err != nil { return err } } @@ -132,48 +118,56 @@ func writeRecordSerializers(ns *dsl.Namespace, packageDir string) error { return nil } -func writeRecordSerializer(rec *dsl.RecordDefinition, ns *dsl.Namespace, packageDir string) error { - b := bytes.Buffer{} - w := formatting.NewIndentedWriter(&b, " ") - common.WriteGeneratedFileHeader(w) - - typeSyntax := common.TypeSyntax(rec, ns.Name) - fmt.Fprintf(w, "classdef %s < yardl.binary.RecordSerializer\n", recordSerializerClassName(rec, ns.Name)) - common.WriteBlockBody(w, func() { +func writeRecordSerializer(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, ns *dsl.Namespace) error { + return fw.WriteFile(recordSerializerClassName(rec, ns.Name), func(w *formatting.IndentedWriter) { - w.WriteStringln("methods") + typeSyntax := common.TypeSyntax(rec, ns.Name) + fmt.Fprintf(w, "classdef %s < yardl.binary.RecordSerializer\n", recordSerializerClassName(rec, ns.Name)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "function obj = %s()\n", recordSerializerClassName(rec, ns.Name)) + + w.WriteStringln("methods") common.WriteBlockBody(w, func() { - for i, field := range rec.Fields { - fmt.Fprintf(w, "field_serializers{%d} = %s;\n", i+1, typeSerializer(field.Type, ns.Name, nil)) + if len(rec.TypeParameters) > 0 { + typeParamSerializers := make([]string, 0, len(rec.TypeParameters)) + for _, tp := range rec.TypeParameters { + typeParamSerializers = append( + typeParamSerializers, + typeDefinitionSerializer(tp, ns.Name)) + } + + fmt.Fprintf(w, "function obj = %s(%s)\n", recordSerializerClassName(rec, ns.Name), strings.Join(typeParamSerializers, ", ")) + } else { + fmt.Fprintf(w, "function obj = %s()\n", recordSerializerClassName(rec, ns.Name)) } - fmt.Fprintf(w, "obj@yardl.binary.RecordSerializer(field_serializers);\n") - }) - w.WriteStringln("") - fmt.Fprintf(w, "function write(obj, outstream, value)\n") - common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "assert(isa(value, '%s'));\n", typeSyntax) + common.WriteBlockBody(w, func() { + for i, field := range rec.Fields { + fmt.Fprintf(w, "field_serializers{%d} = %s;\n", i+1, typeSerializer(field.Type, ns.Name, nil)) + } + fmt.Fprintf(w, "obj@yardl.binary.RecordSerializer(field_serializers);\n") + }) + w.WriteStringln("") - fieldAccesses := make([]string, len(rec.Fields)) - for i, field := range rec.Fields { - fieldAccesses[i] = fmt.Sprintf("value.%s", common.FieldIdentifierName(field.Name)) - } - fmt.Fprintf(w, "obj.write_(outstream, %s)\n", strings.Join(fieldAccesses, ", ")) - }) - w.WriteStringln("") + fmt.Fprintf(w, "function write(obj, outstream, value)\n") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "assert(isa(value, '%s'));\n", typeSyntax) - fmt.Fprintf(w, "function value = read(obj, instream)\n") - common.WriteBlockBody(w, func() { - w.WriteStringln("field_values = obj.read_(instream);") - fmt.Fprintf(w, "value = %s(field_values{:});\n", typeSyntax) + fieldAccesses := make([]string, len(rec.Fields)) + for i, field := range rec.Fields { + fieldAccesses[i] = fmt.Sprintf("value.%s", common.FieldIdentifierName(field.Name)) + } + fmt.Fprintf(w, "obj.write_(outstream, %s)\n", strings.Join(fieldAccesses, ", ")) + }) + w.WriteStringln("") + + fmt.Fprintf(w, "function value = read(obj, instream)\n") + common.WriteBlockBody(w, func() { + w.WriteStringln("field_values = obj.read_(instream);") + fmt.Fprintf(w, "value = %s(field_values{:});\n", typeSyntax) + }) }) }) }) - - binaryPath := path.Join(packageDir, fmt.Sprintf("%s.m", recordSerializerClassName(rec, ns.Name))) - return iocommon.WriteFileIfNeeded(binaryPath, b.Bytes(), 0644) } func recordSerializerClassName(record *dsl.RecordDefinition, contextNamespace string) string { @@ -229,7 +223,7 @@ func typeDefinitionSerializer(t dsl.TypeDefinition, contextNamespace string) str func typeSerializer(t dsl.Type, contextNamespace string, namedType *dsl.NamedType) string { switch t := t.(type) { case nil: - return "yardl.binary.none_serializer" + return "yardl.binary.NoneSerializer" case *dsl.SimpleType: return typeDefinitionSerializer(t.ResolvedDefinition, contextNamespace) case *dsl.GeneralizedType: @@ -241,34 +235,27 @@ func typeSerializer(t dsl.Type, contextNamespace string, namedType *dsl.NamedTyp return fmt.Sprintf("yardl.binary.OptionalSerializer(%s)", typeSerializer(t.Cases[1].Type, contextNamespace, namedType)) } - // TODO:! - return fmt.Sprintf("NOT YET IMPLEMENTED") - - // unionClassName, typeParameters := common.UnionClassName(t) - // if namedType != nil { - // unionClassName = namedType.Name - // if namedType.Namespace != contextNamespace { - // unionClassName = fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(namedType.Namespace), unionClassName) - // } - // } - - // var classSyntax string - // if len(typeParameters) == 0 { - // classSyntax = unionClassName - // } else { - // classSyntax = fmt.Sprintf("%s[%s]", unionClassName, typeParameters) - // } - // options := make([]string, len(t.Cases)) - // for i, c := range t.Cases { - // if c.Type == nil { - // options[i] = "None" - // } else { - // options[i] = fmt.Sprintf("(%s.%s, %s)", classSyntax, formatting.ToPascalCase(c.Tag), typeSerializer(c.Type, contextNamespace, namedType)) - // } - // } - - // return fmt.Sprintf("yardl.binary.UnionSerializer(%s, [%s])", unionClassName, strings.Join(options, ", ")) + unionClassName, _ := common.UnionClassName(t) + if namedType != nil { + unionClassName = namedType.Name + if namedType.Namespace != contextNamespace { + unionClassName = fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(namedType.Namespace), unionClassName) + } + } + + serializers := make([]string, len(t.Cases)) + factories := make([]string, len(t.Cases)) + for i, c := range t.Cases { + if c.Type == nil { + serializers[i] = "yardl.None" + factories[i] = "yardl.None" + } else { + serializers[i] = typeSerializer(c.Type, contextNamespace, namedType) + factories[i] = fmt.Sprintf("@%s.%s", unionClassName, formatting.ToPascalCase(c.Tag)) + } + } + return fmt.Sprintf("yardl.binary.UnionSerializer('%s', {%s}, {%s})", unionClassName, strings.Join(serializers, ", "), strings.Join(factories, ", ")) } switch td := t.Dimensionality.(type) { case nil: diff --git a/tooling/internal/matlab/common/common.go b/tooling/internal/matlab/common/common.go index 81ac5cd2..f0364125 100644 --- a/tooling/internal/matlab/common/common.go +++ b/tooling/internal/matlab/common/common.go @@ -4,10 +4,13 @@ package common import ( + "bytes" "fmt" + "path" "strings" "github.com/microsoft/yardl/tooling/internal/formatting" + "github.com/microsoft/yardl/tooling/internal/iocommon" "github.com/microsoft/yardl/tooling/pkg/dsl" ) @@ -68,42 +71,6 @@ var TypeSyntaxWriter dsl.TypeSyntaxWriter[string] = func(self dsl.TypeSyntaxWrit typeSyntax := typeName - // TODO: Generic TypeDefinitions and TypeParameters - if len(meta.TypeParameters) > 0 { - // typeArguments := make([]string, 0, len(meta.TypeParameters)) - // if len(meta.TypeArguments) > 0 { - // for i, typeArg := range meta.TypeArguments { - // typeParameter := meta.TypeParameters[i] - // use := typeParameter.Annotations[TypeParameterUseAnnotationKey].(TypeParameterUse) - // if use&TypeParameterUseScalar != 0 { - // typeArguments = append(typeArguments, self.ToSyntax(typeArg, contextNamespace)) - // } - // if use&TypeParameterUseArray != 0 { - // typeArguments = append(typeArguments, TypeArrayTypeArgument(typeArg)) - // } - // } - // } else { - // for i, typeParam := range meta.TypeParameters { - // typeParameter := meta.TypeParameters[i] - // use := typeParameter.Annotations[TypeParameterUseAnnotationKey].(TypeParameterUse) - // if use&TypeParameterUseScalar != 0 { - // typeArguments = append(typeArguments, self.ToSyntax(typeParam, contextNamespace)) - // } - // if use&TypeParameterUseArray != 0 { - // typeArguments = append(typeArguments, NumpyTypeParameterSyntax(typeParam)) - // } - // } - // } - - // typeSyntax = fmt.Sprintf("%s[%s]", typeName, strings.Join(typeArguments, ", ")) - } - - if nt, ok := t.(*dsl.NamedType); ok { - if gt, ok := nt.Type.(*dsl.GeneralizedType); ok && gt.Cases.HasNullOption() && !gt.Cases.IsOptional() { - typeSyntax = fmt.Sprintf("typing.Optional[%s]", typeSyntax) - } - } - return typeSyntax case nil: @@ -116,24 +83,18 @@ var TypeSyntaxWriter dsl.TypeSyntaxWriter[string] = func(self dsl.TypeSyntaxWrit return self.ToSyntax(t.Cases[0].Type, contextNamespace) } if t.Cases.IsOptional() { - return fmt.Sprintf("typing.Optional[%s]", self.ToSyntax(t.Cases[1].Type, contextNamespace)) + return "yardl.Optional" } - // TODO: Union syntax? - // return UnionSyntax(t) - panic("Unions not yet supported") + return UnionSyntax(t) }() switch d := t.Dimensionality.(type) { - case nil, *dsl.Stream: - return scalarString - case *dsl.Vector: - return fmt.Sprintf("list[%s]", scalarString) - case *dsl.Array: + case nil, *dsl.Stream, *dsl.Vector, *dsl.Array: return scalarString - // return fmt.Sprintf("npt.NDArray[%s]", TypeArrayTypeArgument(t.ToScalar())) case *dsl.Map: - return fmt.Sprintf("dict[%s, %s]", self.ToSyntax(d.KeyType, contextNamespace), scalarString) + // TODO: Update to Matlab `dictionary` class when we require Matlab version >= r2023b + return "containers.Map" default: panic(fmt.Sprintf("unexpected type %T", d)) } @@ -190,6 +151,40 @@ func EnumValueIdentifierName(name string) string { return cased + "_" } +func UnionClassName(gt *dsl.GeneralizedType) (className string, typeParameters string) { + if !gt.Cases.IsUnion() { + panic("Not a union") + } + + cases := make([]string, 0, len(gt.Cases)) + for _, typeCase := range gt.Cases { + if typeCase.Type == nil { + continue + } + cases = append(cases, formatting.ToPascalCase(typeCase.Tag)) + } + + return strings.Join(cases, "Or"), "" +} + +func UnionSyntax(gt *dsl.GeneralizedType) string { + className, typeParameters := UnionClassName(gt) + var syntax string + if len(typeParameters) > 0 { + // TODO: Remove + syntax = fmt.Sprintf("%s[%s]", className, typeParameters) + } else { + syntax = className + } + + // TODO: Not needed in Matlab + // if gt.Cases.HasNullOption() { + // return fmt.Sprintf("typing.Optional[%s]", syntax) + // } + + return syntax +} + func WriteBlockBody(w *formatting.IndentedWriter, f func()) { defer func() { w.WriteStringln("end") @@ -233,3 +228,22 @@ func WriteGeneratedFileHeader(w *formatting.IndentedWriter) { WriteComment(w, "This file was generated by the \"yardl\" tool. DO NOT EDIT.") w.WriteStringln("") } + +type MatlabFileWriter struct { + PackageDir string +} + +func (fw *MatlabFileWriter) WriteFile(name string, writeContents func(w *formatting.IndentedWriter)) error { + b := bytes.Buffer{} + w := formatting.NewIndentedWriter(&b, " ") + WriteGeneratedFileHeader(w) + + writeContents(w) + + fname := fmt.Sprintf("%s.m", name) + definitionsPath := path.Join(fw.PackageDir, fname) + if err := iocommon.WriteFileIfNeeded(definitionsPath, b.Bytes(), 0644); err != nil { + return err + } + return nil +} diff --git a/tooling/internal/matlab/matlab.go b/tooling/internal/matlab/matlab.go index 3d26e856..46eedd2b 100644 --- a/tooling/internal/matlab/matlab.go +++ b/tooling/internal/matlab/matlab.go @@ -4,7 +4,6 @@ package matlab import ( - "bytes" "embed" "os" "path" @@ -42,7 +41,13 @@ func Generate(env *dsl.Environment, options packaging.MatlabCodegenOptions) erro if !ns.IsTopLevel { packageDir = path.Join(packageDir, common.PackageDir(ns.Name)) } - err = writeNamespace(ns, env.SymbolTable, packageDir) + + if err := os.MkdirAll(packageDir, 0775); err != nil { + return err + } + + fw := &common.MatlabFileWriter{PackageDir: packageDir} + err = writeNamespace(fw, ns, env.SymbolTable) if err != nil { return err } @@ -51,26 +56,18 @@ func Generate(env *dsl.Environment, options packaging.MatlabCodegenOptions) erro return nil } -func writeNamespace(ns *dsl.Namespace, st dsl.SymbolTable, packageDir string) error { - if err := os.MkdirAll(packageDir, 0775); err != nil { - return err - } - - if err := writePackageInitFile(ns, packageDir); err != nil { - return err - } - - if err := types.WriteTypes(ns, st, packageDir); err != nil { +func writeNamespace(fw *common.MatlabFileWriter, ns *dsl.Namespace, st dsl.SymbolTable) error { + if err := types.WriteTypes(fw, ns, st); err != nil { return err } if ns.IsTopLevel { - if err := protocols.WriteProtocols(ns, st, packageDir); err != nil { + if err := protocols.WriteProtocols(fw, ns, st); err != nil { return err } } - if err := binary.WriteBinary(ns, packageDir); err != nil { + if err := binary.WriteBinary(fw, ns); err != nil { return err } @@ -80,11 +77,3 @@ func writeNamespace(ns *dsl.Namespace, st dsl.SymbolTable, packageDir string) er return nil } - -func writePackageInitFile(ns *dsl.Namespace, packageDir string) error { - b := bytes.Buffer{} - w := formatting.NewIndentedWriter(&b, " ") - common.WriteGeneratedFileHeader(w) - - return iocommon.WriteFileIfNeeded(path.Join(packageDir, "init.m"), b.Bytes(), 0644) -} diff --git a/tooling/internal/matlab/protocols/protocols.go b/tooling/internal/matlab/protocols/protocols.go index 73428ef7..89ae9bea 100644 --- a/tooling/internal/matlab/protocols/protocols.go +++ b/tooling/internal/matlab/protocols/protocols.go @@ -4,23 +4,19 @@ package protocols import ( - "bytes" "fmt" - "path" "github.com/microsoft/yardl/tooling/internal/formatting" - "github.com/microsoft/yardl/tooling/internal/iocommon" "github.com/microsoft/yardl/tooling/internal/matlab/common" "github.com/microsoft/yardl/tooling/pkg/dsl" ) -func WriteProtocols(ns *dsl.Namespace, st dsl.SymbolTable, packageDir string) error { - +func WriteProtocols(fw *common.MatlabFileWriter, ns *dsl.Namespace, st dsl.SymbolTable) error { for _, p := range ns.Protocols { - if err := writeAbstractWriter(p, ns, st, packageDir); err != nil { + if err := writeAbstractWriter(fw, p, ns, st); err != nil { return err } - if err := writeAbstractReader(p, ns, packageDir); err != nil { + if err := writeAbstractReader(fw, p, ns); err != nil { return err } } @@ -28,300 +24,290 @@ func WriteProtocols(ns *dsl.Namespace, st dsl.SymbolTable, packageDir string) er return nil } -func writeAbstractWriter(p *dsl.ProtocolDefinition, ns *dsl.Namespace, st dsl.SymbolTable, packageDir string) error { - b := bytes.Buffer{} - w := formatting.NewIndentedWriter(&b, " ") - common.WriteGeneratedFileHeader(w) - - common.WriteComment(w, fmt.Sprintf("Abstract writer for protocol %s", p.Name)) - common.WriteComment(w, p.Comment) - fmt.Fprintf(w, "classdef (Abstract) %s < handle\n", common.AbstractWriterName(p)) - - common.WriteBlockBody(w, func() { +func writeAbstractWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, ns *dsl.Namespace, st dsl.SymbolTable) error { + return fw.WriteFile(common.AbstractWriterName(p), func(w *formatting.IndentedWriter) { + common.WriteComment(w, fmt.Sprintf("Abstract writer for protocol %s", p.Name)) + common.WriteComment(w, p.Comment) + fmt.Fprintf(w, "classdef (Abstract) %s < handle\n", common.AbstractWriterName(p)) - w.WriteStringln("properties (Access=protected)") - common.WriteBlockBody(w, func() { w.WriteStringln("state_") }) - w.WriteStringln("") - - w.WriteStringln("methods") common.WriteBlockBody(w, func() { - // Constructor - fmt.Fprintf(w, "function obj = %s()\n", common.AbstractWriterName(p)) - common.WriteBlockBody(w, func() { w.WriteStringln("obj.state_ = 0;") }) - w.WriteStringln("") - // Destructor - // w.WriteStringln("function delete(obj)") - // common.WriteBlockBody(w, func() { - // }) - // w.WriteStringln("") + w.WriteStringln("properties (Access=protected)") + common.WriteBlockBody(w, func() { w.WriteStringln("state_") }) + w.WriteStringln("") - // Close method - w.WriteStringln("function close(obj)") + w.WriteStringln("methods") common.WriteBlockBody(w, func() { - if len(p.Sequence) > 0 && p.Sequence[len(p.Sequence)-1].IsStream() { - fmt.Fprintf(w, "if obj.state_ == %d\n", len(p.Sequence)*2-1) - common.WriteBlockBody(w, func() { - w.WriteStringln("obj.end_stream_();") - w.WriteStringln("obj.close_();") - w.WriteStringln("return") - }) - } - w.WriteStringln("obj.close_();") - fmt.Fprintf(w, "if obj.state_ ~= %d\n", len(p.Sequence)*2) - common.WriteBlockBody(w, func() { - w.WriteStringln("expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8')));") - w.WriteStringln(`throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method));`) - }) - }) - w.WriteStringln("") + // Constructor + fmt.Fprintf(w, "function obj = %s()\n", common.AbstractWriterName(p)) + common.WriteBlockBody(w, func() { w.WriteStringln("obj.state_ = 0;") }) + w.WriteStringln("") - // Public write methods - for i, step := range p.Sequence { - common.WriteComment(w, fmt.Sprintf("Ordinal %d", i)) - common.WriteComment(w, step.Comment) - fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteMethodName(step)) + // Destructor + // w.WriteStringln("function delete(obj)") + // common.WriteBlockBody(w, func() { + // }) + // w.WriteStringln("") + + // Close method + w.WriteStringln("function close(obj)") common.WriteBlockBody(w, func() { - prevIsStream := i > 0 && p.Sequence[i-1].IsStream() - if prevIsStream { - fmt.Fprintf(w, "if obj.state_ == %d\n", i*2-1) - w.Indented(func() { + if len(p.Sequence) > 0 && p.Sequence[len(p.Sequence)-1].IsStream() { + fmt.Fprintf(w, "if obj.state_ == %d\n", len(p.Sequence)*2-1) + common.WriteBlockBody(w, func() { w.WriteStringln("obj.end_stream_();") - fmt.Fprintf(w, "obj.state_ = %d;\n", i*2) + w.WriteStringln("obj.close_();") + w.WriteStringln("return") }) - w.WriteString("else") - } - - if step.IsStream() { - fmt.Fprintf(w, "if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= %d\n", i*2) - } else { - fmt.Fprintf(w, "if obj.state_ ~= %d\n", i*2) } + w.WriteStringln("obj.close_();") + fmt.Fprintf(w, "if obj.state_ ~= %d\n", len(p.Sequence)*2) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i*2) + w.WriteStringln("expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8')));") + w.WriteStringln(`throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method));`) }) - w.WriteStringln("") - fmt.Fprintf(w, "obj.%s(value);\n", common.ProtocolWriteImplMethodName(step)) - if step.IsStream() { - fmt.Fprintf(w, "obj.state_ = %d;\n", i*2+1) - } else { - fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) - } }) + w.WriteStringln("") - if i < len(p.Sequence)-1 { - w.WriteStringln("") + // Public write methods + for i, step := range p.Sequence { + common.WriteComment(w, fmt.Sprintf("Ordinal %d", i)) + common.WriteComment(w, step.Comment) + fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteMethodName(step)) + common.WriteBlockBody(w, func() { + prevIsStream := i > 0 && p.Sequence[i-1].IsStream() + if prevIsStream { + fmt.Fprintf(w, "if obj.state_ == %d\n", i*2-1) + w.Indented(func() { + w.WriteStringln("obj.end_stream_();") + fmt.Fprintf(w, "obj.state_ = %d;\n", i*2) + }) + w.WriteString("else") + } + + if step.IsStream() { + fmt.Fprintf(w, "if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= %d\n", i*2) + } else { + fmt.Fprintf(w, "if obj.state_ ~= %d\n", i*2) + } + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i*2) + }) + w.WriteStringln("") + fmt.Fprintf(w, "obj.%s(value);\n", common.ProtocolWriteImplMethodName(step)) + if step.IsStream() { + fmt.Fprintf(w, "obj.state_ = %d;\n", i*2+1) + } else { + fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) + } + }) + + if i < len(p.Sequence)-1 { + w.WriteStringln("") + } } - } - }) - w.WriteStringln("") + }) + w.WriteStringln("") - w.WriteStringln("methods (Static)") - common.WriteBlockBody(w, func() { - w.WriteStringln("function res = schema()") + w.WriteStringln("methods (Static)") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "res = string('%s');\n", dsl.GetProtocolSchemaString(p, st)) + w.WriteStringln("function res = schema()") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "res = string('%s');\n", dsl.GetProtocolSchemaString(p, st)) + }) }) - }) - w.WriteStringln("") - - // Protected abstract write methods - w.WriteStringln("methods (Abstract, Access=protected)") - common.WriteBlockBody(w, func() { - for _, step := range p.Sequence { - fmt.Fprintf(w, "%s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) - } w.WriteStringln("") - // end_stream method - w.WriteStringln("end_stream_(obj)") - // underlying close method - w.WriteStringln("close_(obj)") - }) - w.WriteStringln("") - - // Private methods - w.WriteStringln("methods (Access=private)") - common.WriteBlockBody(w, func() { - // _raise_unexpected_state method - w.WriteStringln("function raise_unexpected_state_(obj, actual)") + // Protected abstract write methods + w.WriteStringln("methods (Abstract, Access=protected)") common.WriteBlockBody(w, func() { - w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") - w.WriteStringln("actual_method = obj.state_to_method_name_(actual);") - w.WriteStringln(`throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method));`) + for _, step := range p.Sequence { + fmt.Fprintf(w, "%s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) + } + w.WriteStringln("") + + // end_stream method + w.WriteStringln("end_stream_(obj)") + // underlying close method + w.WriteStringln("close_(obj)") }) w.WriteStringln("") - w.WriteStringln("function name = state_to_method_name_(obj, state)") + // Private methods + w.WriteStringln("methods (Access=private)") common.WriteBlockBody(w, func() { - for i, step := range p.Sequence { - fmt.Fprintf(w, "if state == %d\n", i*2) - w.Indented(func() { - fmt.Fprintf(w, "name = '%s';\n", common.ProtocolWriteMethodName(step)) - }) - w.WriteString("else") - } + // _raise_unexpected_state method + w.WriteStringln("function raise_unexpected_state_(obj, actual)") + common.WriteBlockBody(w, func() { + w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") + w.WriteStringln("actual_method = obj.state_to_method_name_(actual);") + w.WriteStringln(`throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method));`) + }) w.WriteStringln("") + + w.WriteStringln("function name = state_to_method_name_(obj, state)") common.WriteBlockBody(w, func() { - w.WriteStringln("name = '';") + for i, step := range p.Sequence { + fmt.Fprintf(w, "if state == %d\n", i*2) + w.Indented(func() { + fmt.Fprintf(w, "name = '%s';\n", common.ProtocolWriteMethodName(step)) + }) + w.WriteString("else") + } + w.WriteStringln("") + common.WriteBlockBody(w, func() { + w.WriteStringln("name = '';") + }) }) }) - }) + }) }) - - definitionsPath := path.Join(packageDir, fmt.Sprintf("%s.m", common.AbstractWriterName(p))) - return iocommon.WriteFileIfNeeded(definitionsPath, b.Bytes(), 0644) } -func writeAbstractReader(p *dsl.ProtocolDefinition, ns *dsl.Namespace, packageDir string) error { - b := bytes.Buffer{} - w := formatting.NewIndentedWriter(&b, " ") - common.WriteGeneratedFileHeader(w) +func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, ns *dsl.Namespace) error { + return fw.WriteFile(common.AbstractReaderName(p), func(w *formatting.IndentedWriter) { + common.WriteComment(w, p.Comment) + fmt.Fprintf(w, "classdef %s < handle\n", common.AbstractReaderName(p)) - common.WriteComment(w, p.Comment) - fmt.Fprintf(w, "classdef %s < handle\n", common.AbstractReaderName(p)) - - common.WriteBlockBody(w, func() { - - w.WriteStringln("properties (Access=protected)") common.WriteBlockBody(w, func() { - w.WriteStringln("state_") - }) - w.WriteStringln("") - w.WriteStringln("methods") - common.WriteBlockBody(w, func() { - // Constructor - fmt.Fprintf(w, "function obj = %s()\n", common.AbstractReaderName(p)) + w.WriteStringln("properties (Access=protected)") common.WriteBlockBody(w, func() { - w.WriteStringln("obj.state_ = 0;") + w.WriteStringln("state_") }) w.WriteStringln("") - // Destructor - // w.WriteStringln("function delete(obj)") - // common.WriteBlockBody(w, func() { - // }) - // w.WriteStringln("") - - // Close method - w.WriteStringln("function close(obj)") + w.WriteStringln("methods") common.WriteBlockBody(w, func() { - w.WriteStringln("obj.close_();") - fmt.Fprintf(w, "if obj.state_ ~= %d\n", len(p.Sequence)*2) + // Constructor + fmt.Fprintf(w, "function obj = %s()\n", common.AbstractReaderName(p)) common.WriteBlockBody(w, func() { - w.WriteStringln("if mod(obj.state_, 2) == 1") - w.Indented(func() { - w.WriteStringln("previous_method = obj.state_to_method_name_(obj.state_ - 1);") - w.WriteStringln(`throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method));`) - }) - w.WriteStringln("else") + w.WriteStringln("obj.state_ = 0;") + }) + w.WriteStringln("") + + // Destructor + // w.WriteStringln("function delete(obj)") + // common.WriteBlockBody(w, func() { + // }) + // w.WriteStringln("") + + // Close method + w.WriteStringln("function close(obj)") + common.WriteBlockBody(w, func() { + w.WriteStringln("obj.close_();") + fmt.Fprintf(w, "if obj.state_ ~= %d\n", len(p.Sequence)*2) common.WriteBlockBody(w, func() { - w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") - w.WriteStringln(`throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method));`) + w.WriteStringln("if mod(obj.state_, 2) == 1") + w.Indented(func() { + w.WriteStringln("previous_method = obj.state_to_method_name_(obj.state_ - 1);") + w.WriteStringln(`throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method));`) + }) + w.WriteStringln("else") + common.WriteBlockBody(w, func() { + w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") + w.WriteStringln(`throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method));`) + }) }) }) - }) - w.WriteStringln("") + w.WriteStringln("") - // Public read methods - for i, step := range p.Sequence { - common.WriteComment(w, fmt.Sprintf("Ordinal %d", i)) - common.WriteComment(w, step.Comment) - fmt.Fprintf(w, "function value = %s(obj)\n", common.ProtocolReadMethodName(step)) - common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "if obj.state_ ~= %d\n", i*2) + // Public read methods + for i, step := range p.Sequence { + common.WriteComment(w, fmt.Sprintf("Ordinal %d", i)) + common.WriteComment(w, step.Comment) + fmt.Fprintf(w, "function value = %s(obj)\n", common.ProtocolReadMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i*2) + fmt.Fprintf(w, "if obj.state_ ~= %d\n", i*2) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i*2) + }) + w.WriteStringln("") + + fmt.Fprintf(w, "value = obj.%s();\n", common.ProtocolReadImplMethodName(step)) + if step.IsStream() { + // fmt.Fprintf(w, "obj.state_ = %d;\n", i*2+1) + // fmt.Fprintf(w, "value = obj.wrap_iterable_(value, %d);\n", (i+1)*2) + fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) + } else { + fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) + } }) w.WriteStringln("") + } - fmt.Fprintf(w, "value = obj.%s();\n", common.ProtocolReadImplMethodName(step)) - if step.IsStream() { - // fmt.Fprintf(w, "obj.state_ = %d;\n", i*2+1) - // fmt.Fprintf(w, "value = obj.wrap_iterable_(value, %d);\n", (i+1)*2) - fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) - } else { - fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) + // copy_to method + fmt.Fprintf(w, "function copy_to(obj, writer)\n") + common.WriteBlockBody(w, func() { + for _, step := range p.Sequence { + fmt.Fprintf(w, "writer.%s(obj.%s());\n", common.ProtocolWriteMethodName(step), common.ProtocolReadMethodName(step)) } }) - w.WriteStringln("") - } - - // copy_to method - fmt.Fprintf(w, "function copy_to(obj, writer)\n") - common.WriteBlockBody(w, func() { - for _, step := range p.Sequence { - fmt.Fprintf(w, "writer.%s(obj.%s());\n", common.ProtocolWriteMethodName(step), common.ProtocolReadMethodName(step)) - } }) - }) - w.WriteStringln("") + w.WriteStringln("") - w.WriteStringln("methods (Static)") - common.WriteBlockBody(w, func() { - w.WriteStringln("function res = schema()") + w.WriteStringln("methods (Static)") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "res = %s.schema;\n", common.AbstractWriterName(p)) + w.WriteStringln("function res = schema()") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "res = %s.schema;\n", common.AbstractWriterName(p)) + }) }) - }) - w.WriteStringln("") - - // Protected abstract methods - w.WriteStringln("methods (Abstract, Access=protected)") - common.WriteBlockBody(w, func() { - for _, step := range p.Sequence { - fmt.Fprintf(w, "%s(obj, value)\n", common.ProtocolReadImplMethodName(step)) - } - w.WriteStringln("") - w.WriteStringln("close_(obj)") - }) - w.WriteStringln("") - w.WriteStringln("methods (Access=private)") - common.WriteBlockBody(w, func() { - // wrap_iterable method - w.WriteStringln("function value = wrap_iterable_(obj, iterable, final_state)") + // Protected abstract methods + w.WriteStringln("methods (Abstract, Access=protected)") common.WriteBlockBody(w, func() { - w.WriteStringln("% This is a no-op... In python, it's yield from iterable") - w.WriteStringln("value = iterable;") - w.WriteStringln("obj.state_ = final_state;") + for _, step := range p.Sequence { + fmt.Fprintf(w, "%s(obj, value)\n", common.ProtocolReadImplMethodName(step)) + } + + w.WriteStringln("") + w.WriteStringln("close_(obj)") }) w.WriteStringln("") - // raise_unexpected_state method - w.WriteStringln("function raise_unexpected_state_(obj, actual)") + w.WriteStringln("methods (Access=private)") common.WriteBlockBody(w, func() { - w.WriteStringln("actual_method = obj.state_to_method_name_(actual);") - w.WriteStringln("if mod(obj.state_, 2) == 1") - w.Indented(func() { - w.WriteStringln("previous_method = obj.state_to_method_name_(obj.state_ - 1);") - w.WriteStringln(`throw(yardl.ProtocolError("Received call to '%s' but the iterable returned by '%s' was not fully consumed.", actual_method, previous_method));`) - }) - w.WriteStringln("else") + // wrap_iterable method + w.WriteStringln("function value = wrap_iterable_(obj, iterable, final_state)") common.WriteBlockBody(w, func() { - w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") - w.WriteStringln(`throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method));`) + w.WriteStringln("% This is a no-op... In python, it's yield from iterable") + w.WriteStringln("value = iterable;") + w.WriteStringln("obj.state_ = final_state;") }) - }) - w.WriteStringln("") + w.WriteStringln("") - // state_to_method_name method - w.WriteStringln("function name = state_to_method_name_(obj, state)") - common.WriteBlockBody(w, func() { - for i, step := range p.Sequence { - fmt.Fprintf(w, "if state == %d\n", i*2) + // raise_unexpected_state method + w.WriteStringln("function raise_unexpected_state_(obj, actual)") + common.WriteBlockBody(w, func() { + w.WriteStringln("actual_method = obj.state_to_method_name_(actual);") + w.WriteStringln("if mod(obj.state_, 2) == 1") + w.Indented(func() { + w.WriteStringln("previous_method = obj.state_to_method_name_(obj.state_ - 1);") + w.WriteStringln(`throw(yardl.ProtocolError("Received call to '%s' but the iterable returned by '%s' was not fully consumed.", actual_method, previous_method));`) + }) + w.WriteStringln("else") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "name = '%s';\n", common.ProtocolReadMethodName(step)) + w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") + w.WriteStringln(`throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method));`) }) - } - w.WriteStringln("name = '';") + }) + w.WriteStringln("") + + // state_to_method_name method + w.WriteStringln("function name = state_to_method_name_(obj, state)") + common.WriteBlockBody(w, func() { + for i, step := range p.Sequence { + fmt.Fprintf(w, "if state == %d\n", i*2) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "name = '%s';\n", common.ProtocolReadMethodName(step)) + }) + } + w.WriteStringln("name = '';") + }) }) }) }) - - definitionsPath := path.Join(packageDir, fmt.Sprintf("%s.m", common.AbstractReaderName(p))) - return iocommon.WriteFileIfNeeded(definitionsPath, b.Bytes(), 0644) } diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolReader.m b/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolReader.m index bcf25f7e..13739711 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolReader.m +++ b/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolReader.m @@ -1,20 +1,12 @@ classdef BinaryProtocolReader < handle properties (Access=protected) - fid_ stream_ end methods - function obj = BinaryProtocolReader(filename, expected_schema) - [fileId, errMsg] = fopen(filename, "r"); - if fileId < 0 - throw(yardl.binary.Exception(errMsg)); - end - - obj.fid_ = fileId; - obj.stream_ = yardl.binary.CodedInputStream(fileId); - + function obj = BinaryProtocolReader(input, expected_schema) + obj.stream_ = yardl.binary.CodedInputStream(input); magic_bytes = obj.stream_.read(length(yardl.binary.MAGIC_BYTES)); if magic_bytes ~= yardl.binary.MAGIC_BYTES throw(yardl.binary.Exception("Invalid magic bytes")); @@ -28,8 +20,6 @@ s = yardl.binary.StringSerializer(); schema = s.read(obj.stream_); if ~isempty(expected_schema) & schema ~= expected_schema - fprintf("Expected schema: %s\n", expected_schema); - fprintf("Actual schema: %s\n", schema); throw(yardl.binary.Exception("Invalid schema")); end end @@ -37,11 +27,7 @@ methods (Access=protected) function close_(obj) - if obj.fid_ > 2 - obj.stream_.close(); - fclose(obj.fid_); - obj.fid_ = -1; - end + obj.stream_.close(); end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolWriter.m b/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolWriter.m index 2374fd90..c833de3c 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolWriter.m +++ b/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolWriter.m @@ -1,21 +1,12 @@ classdef BinaryProtocolWriter < handle properties (Access=protected) - fid_ stream_ end methods - function obj = BinaryProtocolWriter(filename, schema) - % TODO: What if user wants to append? Should take fid as arg - [fileId, errMsg] = fopen(filename, "w"); - if fileId < 0 - throw(yardl.Exception(errMsg)); - end - - obj.fid_ = fileId; - obj.stream_ = yardl.binary.CodedOutputStream(fileId); - + function obj = BinaryProtocolWriter(output, schema) + obj.stream_ = yardl.binary.CodedOutputStream(output); obj.stream_.write_bytes(yardl.binary.MAGIC_BYTES); write_fixed_int32(obj.stream_, yardl.binary.CURRENT_BINARY_FORMAT_VERSION); s = yardl.binary.StringSerializer(); @@ -29,11 +20,7 @@ function end_stream_(obj) end function close_(obj) - if obj.fid_ > 2 - obj.stream_.close(); - fclose(obj.fid_); - obj.fid_ = -1; - end + obj.stream_.close(); end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/CodedInputStream.m b/tooling/internal/matlab/static_files/+yardl/+binary/CodedInputStream.m index 0152dc70..e82e9b2e 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/CodedInputStream.m +++ b/tooling/internal/matlab/static_files/+yardl/+binary/CodedInputStream.m @@ -1,34 +1,47 @@ classdef CodedInputStream < handle - properties - fileId + properties (Access=private) + fid_ + owns_stream_ end methods - function obj = CodedInputStream(fileId) - obj.fileId = fileId; + function self = CodedInputStream(input) + if isa(input, "string") || isa(input, "char") + [fileId, errMsg] = fopen(input, "r"); + if fileId < 0 + throw(yardl.binary.Exception(errMsg)); + end + self.fid_ = fileId; + self.owns_stream_ = true; + else + self.fid_ = input; + self.owns_stream_ = false; + end end - function close(obj) - % flush... - obj.fileId = -1; + function close(self) + if self.owns_stream_ && self.fid_ > 2 + fclose(self.fid_); + self.fid_ = -1; + end end - % In Python, this uses struct packing for any object... - function res = read(obj, count) - res = fread(obj.fileId, count, "*uint8"); + % In Python, this uses struct packing for any selfect... + function res = read(self, count) + res = fread(self.fid_, count, "*uint8"); end - function res = read_byte(obj) - res = fread(obj.fileId, 1, "*uint8"); + function res = read_byte(self) + res = fread(self.fid_, 1, "*uint8"); end - function res = read_unsigned_varint(obj) + function res = read_unsigned_varint(self) res = uint64(0); shift = uint8(0); while true - byte = obj.read_byte(); + byte = self.read_byte(); res = bitor(res, bitshift(uint64(bitand(byte, 0x7F)), shift)); if byte < 0x80 return @@ -43,8 +56,8 @@ function close(obj) res = bitxor(int64(bitshift(value, -1)), -int64(bitand(value, 1))); end - function res = read_signed_varint(obj) - res = obj.zigzag_decode(obj.read_unsigned_varint()); + function res = read_signed_varint(self) + res = self.zigzag_decode(self.read_unsigned_varint()); end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/CodedOutputStream.m b/tooling/internal/matlab/static_files/+yardl/+binary/CodedOutputStream.m index 432a21e1..9eb4625c 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/CodedOutputStream.m +++ b/tooling/internal/matlab/static_files/+yardl/+binary/CodedOutputStream.m @@ -1,47 +1,60 @@ classdef CodedOutputStream < handle - properties - fid + properties (Access=private) + fid_ + owns_stream_ end methods - function obj = CodedOutputStream(fileId) - obj.fid = fileId; + function self = CodedOutputStream(output) + if isa(output, "string") || isa(output, "char") + [fileId, errMsg] = fopen(output, "w"); + if fileId < 0 + throw(yardl.binary.Exception(errMsg)); + end + self.fid_ = fileId; + self.owns_stream_ = true; + else + self.fid_ = input; + self.owns_stream_ = false; + end end - function close(obj) - % flush... - obj.fid = -1; + function close(self) + if self.owns_stream_ && self.fid_ > 2 + fclose(self.fid_); + self.fid_ = -1; + end end - function write(obj, value) + function write(self, value) assert(isa(value, "uint8")); - fwrite(obj.fid, value, "uint8"); + fwrite(self.fid_, value, "uint8"); end - function write_bytes(obj, bytes) - fwrite(obj.fid, bytes, "uint8"); + function write_bytes(self, bytes) + fwrite(self.fid_, bytes, "uint8"); end - function write_byte_no_check(obj, value) + function write_byte_no_check(self, value) assert(isscalar(value)); assert(all(value >= 0)); assert(all(value <= intmax("uint8"))); - fwrite(obj.fid, value, "uint8"); + fwrite(self.fid_, value, "uint8"); end - function write_unsigned_varint(obj, value) + function write_unsigned_varint(self, value) assert(isscalar(value)); int_val = uint64(value); while true if int_val < 0x80 - obj.write_byte_no_check(int_val); + self.write_byte_no_check(int_val); return end - obj.write_byte_no_check(bitor(bitand(int_val, uint64(0x7F)), uint64(0x80))); + self.write_byte_no_check(bitor(bitand(int_val, uint64(0x7F)), uint64(0x80))); int_val = bitshift(int_val, -7); end end @@ -51,10 +64,10 @@ function write_unsigned_varint(obj, value) res = bitxor(bitshift(int_val, 1), bitshift(int_val, -63)); end - function write_signed_varint(obj, value) + function write_signed_varint(self, value) assert(isscalar(value)); - obj.write_unsigned_varint(obj.zigzag_encode(value)); + self.write_unsigned_varint(self.zigzag_encode(value)); end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Uint16Serializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/Uint16Serializer.m index ef5a9b80..7a91c28f 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/Uint16Serializer.m +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Uint16Serializer.m @@ -8,7 +8,7 @@ function write(outstream, value) end function res = read(instream) - res = instream.read_unsigned_varint(); + res = uint16(instream.read_unsigned_varint()); end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Uint32Serializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/Uint32Serializer.m index 0e0d9e40..4f425dda 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/Uint32Serializer.m +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Uint32Serializer.m @@ -8,7 +8,7 @@ function write(outstream, value) end function res = read(instream) - res = instream.read_unsigned_varint(); + res = uint32(instream.read_unsigned_varint()); end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Uint64Serializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/Uint64Serializer.m index 81626462..94046c73 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/Uint64Serializer.m +++ b/tooling/internal/matlab/static_files/+yardl/+binary/Uint64Serializer.m @@ -8,7 +8,7 @@ function write(outstream, value) end function res = read(instream) - res = instream.read_unsigned_varint(); + res = uint64(instream.read_unsigned_varint()); end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/UnionSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/UnionSerializer.m new file mode 100755 index 00000000..955ed22d --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/+binary/UnionSerializer.m @@ -0,0 +1,60 @@ +classdef UnionSerializer < handle + + properties (Access=protected) + union_class_ + case_serializers_ + case_factories_ + offset_ + end + + methods + + function obj = UnionSerializer(union_class, case_serializers, case_factories) + obj.union_class_ = union_class; + obj.case_serializers_ = case_serializers; + obj.case_factories_ = case_factories; + + if isa(case_serializers{1}, 'yardl.None') + obj.offset_ = 1; + else + obj.offset_ = 0; + end + end + + function write(obj, outstream, value) + if isa(value, 'yardl.None') + if isa(obj.case_serializers_{1}, 'yardl.None') + outstream.write_byte_no_check(0); + return; + else + throw(yardl.TypeError("None is not valid for this union type")) + end + end + + if ~isa(value, obj.union_class_) + throw(yardl.TypeError("Expected union value of type %s, got %s", obj.union_class_, class(value))) + end + + tag_index = uint8(value.index + obj.offset_); + outstream.write_byte_no_check(tag_index-1); + + serializer = obj.case_serializers_{tag_index}; + serializer.write(outstream, value.value); + end + + function res = read(obj, instream) + case_index = instream.read_byte() + 1; + + if case_index == 1 && obj.offset_ == 1 + res = yardl.None; + return + end + + serializer = obj.case_serializers_{case_index}; + value = serializer.read(instream); + + factory = obj.case_factories_{case_index}; + res = factory(value); + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/Optional.m b/tooling/internal/matlab/static_files/+yardl/Optional.m new file mode 100644 index 00000000..d6853742 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/Optional.m @@ -0,0 +1,28 @@ +classdef Optional < handle + properties (Access=protected) + has_value_ + value_ + end + + methods + function obj = Optional(varargin) + if nargin > 0 + obj.value_ = varargin{1}; + obj.has_value_ = true; + else + obj.has_value_ = false; + end + end + + function has_value = has_value(obj) + has_value = obj.has_value_; + end + + function value = value(obj) + if ~obj.has_value() + throw(yardl.TypeError("Optional type does not have a value")); + end + value = obj.value_; + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/Union.m b/tooling/internal/matlab/static_files/+yardl/Union.m new file mode 100644 index 00000000..680ff948 --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/Union.m @@ -0,0 +1,30 @@ +classdef Union < handle + properties (Access=protected) + index_ + value_ + end + + methods + + function obj = Union(index, value) + obj.index_ = index; + obj.value_ = value; + end + + function i = index(obj) + i = obj.index_; + end + + function v = value(obj) + v = obj.value_; + end + + function eq = eq(~, ~) + eq = true; + end + + function neq = neq(~, ~) + neq = false; + end + end +end diff --git a/tooling/internal/matlab/types/types.go b/tooling/internal/matlab/types/types.go index f1c8411e..b387154a 100644 --- a/tooling/internal/matlab/types/types.go +++ b/tooling/internal/matlab/types/types.go @@ -4,135 +4,197 @@ package types import ( - "bytes" "fmt" - "path" "strings" "github.com/microsoft/yardl/tooling/internal/formatting" - "github.com/microsoft/yardl/tooling/internal/iocommon" "github.com/microsoft/yardl/tooling/internal/matlab/common" "github.com/microsoft/yardl/tooling/pkg/dsl" ) -func WriteTypes(ns *dsl.Namespace, st dsl.SymbolTable, packageDir string) error { +func WriteTypes(fw *common.MatlabFileWriter, ns *dsl.Namespace, st dsl.SymbolTable) error { + unionGenerated := make(map[string]bool) + for _, td := range ns.TypeDefinitions { - b := bytes.Buffer{} - w := formatting.NewIndentedWriter(&b, " ") - common.WriteGeneratedFileHeader(w) + if err := writeUnionClasses(fw, td, unionGenerated); err != nil { + return err + } + } + for _, td := range ns.TypeDefinitions { + var err error switch td := td.(type) { case *dsl.NamedType: - writeNamedType(w, td) + if !unionGenerated[td.Name] { + err = writeNamedType(fw, td) + } case *dsl.EnumDefinition: - writeEnum(w, td) + err = writeEnum(fw, td) case *dsl.RecordDefinition: - writeRecord(w, td, st) + err = writeRecord(fw, td, st) default: panic(fmt.Sprintf("unsupported type definition: %T", td)) } + if err != nil { + return err + } + } - fname := fmt.Sprintf("%s.m", common.TypeSyntax(td, ns.Name)) - - definitionsPath := path.Join(packageDir, fname) - if err := iocommon.WriteFileIfNeeded(definitionsPath, b.Bytes(), 0644); err != nil { + for _, p := range ns.Protocols { + if err := writeUnionClasses(fw, p, unionGenerated); err != nil { return err } } + return nil } -func writeNamedType(w *formatting.IndentedWriter, td *dsl.NamedType) { - common.WriteComment(w, td.Comment) - fmt.Fprintf(w, "classdef %s < %s\n", common.TypeSyntax(td, td.Namespace), common.TypeSyntax(td.Type, td.Namespace)) - w.WriteStringln("end") -} +func writeUnionClasses(fw *common.MatlabFileWriter, td dsl.TypeDefinition, unionGenerated map[string]bool) error { + var writeError error + dsl.Visit(td, func(self dsl.Visitor, node dsl.Node) { + switch node := node.(type) { + case *dsl.GeneralizedType: + if node.Cases.IsUnion() { + unionClassName, typeParameters := common.UnionClassName(node) + if !unionGenerated[unionClassName] { + if _, isNamedType := td.(*dsl.NamedType); isNamedType { + // This is a named type defining a union, so we will use the named type's name instead + unionClassName = td.GetDefinitionMeta().Name + } + writeError = fw.WriteFile(unionClassName, func(w *formatting.IndentedWriter) { + writeUnionClass(w, unionClassName, typeParameters, node, td.GetDefinitionMeta().Namespace) + }) + if writeError != nil { + return + } + unionGenerated[unionClassName] = true + } + } + } + self.VisitChildren(node) + }) -func writeEnum(w *formatting.IndentedWriter, enum *dsl.EnumDefinition) { - var base string - if enum.BaseType == nil { - base = "uint64" - } else { - base = common.TypeSyntax(enum.BaseType, enum.Namespace) - } + return writeError +} - common.WriteComment(w, enum.Comment) - enumTypeSyntax := common.TypeSyntax(enum, enum.Namespace) - fmt.Fprintf(w, "classdef %s < %s\n", enumTypeSyntax, base) +func writeUnionClass(w *formatting.IndentedWriter, className string, typeParameters string, generalizedType *dsl.GeneralizedType, contextNamespace string) error { + fmt.Fprintf(w, "classdef %s < yardl.Union\n", className) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "enumeration\n") + w.WriteStringln("methods (Static)") common.WriteBlockBody(w, func() { - for _, value := range enum.Values { - common.WriteComment(w, value.Comment) - fmt.Fprintf(w, "%s (%d)\n", common.EnumValueIdentifierName(value.Symbol), &value.IntegerValue) + for i, tc := range generalizedType.Cases { + if tc.Type == nil { + continue + } + + fmt.Fprintf(w, "function res = %s(value)\n", formatting.ToPascalCase(tc.Tag)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "res = %s(%d, value);\n", className, i+1) + }) } }) }) + + return nil } -func writeRecord(w *formatting.IndentedWriter, rec *dsl.RecordDefinition, st dsl.SymbolTable) { - common.WriteComment(w, rec.Comment) +func writeNamedType(fw *common.MatlabFileWriter, td *dsl.NamedType) error { + return fw.WriteFile(common.TypeSyntax(td, td.Namespace), func(w *formatting.IndentedWriter) { + common.WriteComment(w, td.Comment) + fmt.Fprintf(w, "classdef %s < %s\n", common.TypeSyntax(td, td.Namespace), common.TypeSyntax(td.Type, td.Namespace)) + w.WriteStringln("end") + }) +} - fmt.Fprintf(w, "classdef %s < handle\n", common.TypeSyntax(rec, rec.Namespace)) - common.WriteBlockBody(w, func() { +func writeEnum(fw *common.MatlabFileWriter, enum *dsl.EnumDefinition) error { + return fw.WriteFile(common.TypeSyntax(enum, enum.Namespace), func(w *formatting.IndentedWriter) { + var base string + if enum.BaseType == nil { + base = "uint64" + } else { + base = common.TypeSyntax(enum.BaseType, enum.Namespace) + } - w.WriteStringln("properties") - var fieldNames []string + common.WriteComment(w, enum.Comment) + enumTypeSyntax := common.TypeSyntax(enum, enum.Namespace) + fmt.Fprintf(w, "classdef %s < %s\n", enumTypeSyntax, base) common.WriteBlockBody(w, func() { - for i, field := range rec.Fields { - common.WriteComment(w, field.Comment) - fieldNames = append(fieldNames, common.FieldIdentifierName(field.Name)) - fmt.Fprintf(w, "%s\n", common.FieldIdentifierName(field.Name)) - if i < len(rec.Fields)-1 { - w.WriteStringln("") + fmt.Fprintf(w, "enumeration\n") + common.WriteBlockBody(w, func() { + for _, value := range enum.Values { + common.WriteComment(w, value.Comment) + fmt.Fprintf(w, "%s (%d)\n", common.EnumValueIdentifierName(value.Symbol), &value.IntegerValue) } - } + }) }) - w.WriteStringln("") + }) +} - w.WriteStringln("methods") +func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl.SymbolTable) error { + return fw.WriteFile(common.TypeSyntax(rec, rec.Namespace), func(w *formatting.IndentedWriter) { + common.WriteComment(w, rec.Comment) + + fmt.Fprintf(w, "classdef %s < handle\n", common.TypeSyntax(rec, rec.Namespace)) common.WriteBlockBody(w, func() { - // Record Constructor - fmt.Fprintf(w, "function obj = %s(%s)\n", rec.Name, strings.Join(fieldNames, ", ")) + w.WriteStringln("properties") + var fieldNames []string common.WriteBlockBody(w, func() { - for _, field := range rec.Fields { - fmt.Fprintf(w, "obj.%s = %s;\n", common.FieldIdentifierName(field.Name), common.FieldIdentifierName(field.Name)) + for i, field := range rec.Fields { + common.WriteComment(w, field.Comment) + fieldNames = append(fieldNames, common.FieldIdentifierName(field.Name)) + fmt.Fprintf(w, "%s\n", common.FieldIdentifierName(field.Name)) + if i < len(rec.Fields)-1 { + w.WriteStringln("") + } } }) w.WriteStringln("") - // Computed Fields - for _, computedField := range rec.ComputedFields { - fieldName := common.ComputedFieldIdentifierName(computedField.Name) + w.WriteStringln("methods") + common.WriteBlockBody(w, func() { - common.WriteComment(w, computedField.Comment) - fmt.Fprintf(w, "function res = %s(self)\n", fieldName) + // Record Constructor + fmt.Fprintf(w, "function obj = %s(%s)\n", rec.Name, strings.Join(fieldNames, ", ")) common.WriteBlockBody(w, func() { - writeComputedFieldExpression(w, computedField.Expression, rec.Namespace) + for _, field := range rec.Fields { + fmt.Fprintf(w, "obj.%s = %s;\n", common.FieldIdentifierName(field.Name), common.FieldIdentifierName(field.Name)) + } }) w.WriteStringln("") - } - w.WriteStringln("") - // eq method - w.WriteStringln("function res = eq(obj, other)") - common.WriteBlockBody(w, func() { - w.WriteStringln("res = ...") - w.Indented(func() { - fmt.Fprintf(w, "isa(other, '%s')", common.TypeSyntax(rec, rec.Namespace)) - for _, field := range rec.Fields { - w.WriteStringln(" && ...") - fieldIdentifier := common.FieldIdentifierName(field.Name) - w.WriteString(typeEqualityExpression(field.Type, "obj."+fieldIdentifier, "other."+fieldIdentifier)) - } - w.WriteStringln(";") + // Computed Fields + for _, computedField := range rec.ComputedFields { + fieldName := common.ComputedFieldIdentifierName(computedField.Name) + + common.WriteComment(w, computedField.Comment) + fmt.Fprintf(w, "function res = %s(self)\n", fieldName) + common.WriteBlockBody(w, func() { + writeComputedFieldExpression(w, computedField.Expression, rec.Namespace) + }) + w.WriteStringln("") + } + w.WriteStringln("") + + // eq method + w.WriteStringln("function res = eq(obj, other)") + common.WriteBlockBody(w, func() { + w.WriteStringln("res = ...") + w.Indented(func() { + fmt.Fprintf(w, "isa(other, '%s')", common.TypeSyntax(rec, rec.Namespace)) + for _, field := range rec.Fields { + w.WriteStringln(" && ...") + fieldIdentifier := common.FieldIdentifierName(field.Name) + w.WriteString(typeEqualityExpression(field.Type, "obj."+fieldIdentifier, "other."+fieldIdentifier)) + } + w.WriteStringln(";") + }) }) + + // neq method }) - // neq method }) - }) } @@ -145,7 +207,6 @@ func typeEqualityExpression(t dsl.Type, a, b string) string { } // TODO: Other forms - // panic(fmt.Sprintf("How about type equality expression for %s", dsl.TypeToShortSyntax(t, false))) return fmt.Sprintf("all(%s == %s)", a, b) } @@ -211,7 +272,7 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E for i, d := range *dims { fmt.Fprintf(w, "if dim_name == \"%s\"\n", *d.Name) w.Indented(func() { - fmt.Fprintf(w, "dim = %d;\n", i) + fmt.Fprintf(w, "dim = %d;\n", len(*dims)-i) }) w.WriteString("else") } @@ -367,12 +428,19 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E self.Visit(t.Arguments[0], tailWrapper{}) if len(t.Arguments) > 1 { - w.WriteString("(") + w.WriteString(", [") remainingArgs := t.Arguments[1:] formatting.Delimited(w, ", ", remainingArgs, func(w *formatting.IndentedWriter, i int, arg dsl.Expression) { + if _, ok := arg.(*dsl.IntegerLiteralExpression); ok { + // Need to adjust integer literals for 1-based indexing in Matlab + // fmt.Fprintf(w, "%d", big.NewInt(0).Add(&intArg.Value, big.NewInt(1))) + w.WriteString("ndims(") + self.Visit(t.Arguments[0], tailWrapper{}) + w.WriteString(")-") + } self.Visit(arg, tailWrapper{}) }) - fmt.Fprintf(w, ")") + fmt.Fprintf(w, "]") } w.WriteString(")") } @@ -399,7 +467,7 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E unionVariableName := newVarName() fmt.Fprintf(w, "%s = ", unionVariableName) self.Visit(t.Target, tailWrapper{}) - w.WriteStringln("") + w.WriteStringln(";") if targetType.Cases.IsOptional() { for i, switchCase := range t.Cases { @@ -410,41 +478,41 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E if targetType.Cases.IsUnion() { // Special handling for SwitchExpression over a Union from an imported namespace - // targetTypeNamespace := "" - // dsl.Visit(t.Target, func(self dsl.Visitor, node dsl.Node) { - // switch node := node.(type) { - // case *dsl.SimpleType: - // self.Visit(node.ResolvedDefinition) - // case *dsl.RecordDefinition: - // for _, field := range node.Fields { - // u := dsl.GetUnderlyingType(field.Type) - // if u == t.Target.GetResolvedType() { - // if targetTypeNamespace == "" { - // meta := node.GetDefinitionMeta() - // targetTypeNamespace = meta.Namespace - // } - // return - // } - // } - // case dsl.Expression: - // t := node.GetResolvedType() - // if t != nil { - // self.Visit(t) - // } - // } - // self.VisitChildren(node) - // }) - - // unionClassName, _ := common.UnionClassName(targetType) - // if targetTypeNamespace != "" && targetTypeNamespace != contextNamespace { - // unionClassName = fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(targetTypeNamespace), unionClassName) - // } - - // for _, switchCase := range t.Cases { - // writeSwitchCaseOverUnion(w, targetType, unionClassName, switchCase, unionVariableName, self, tail) - // } - - // fmt.Fprintf(w, "raise RuntimeError(\"Unexpected union case\")\n") + targetTypeNamespace := "" + dsl.Visit(t.Target, func(self dsl.Visitor, node dsl.Node) { + switch node := node.(type) { + case *dsl.SimpleType: + self.Visit(node.ResolvedDefinition) + case *dsl.RecordDefinition: + for _, field := range node.Fields { + u := dsl.GetUnderlyingType(field.Type) + if u == t.Target.GetResolvedType() { + if targetTypeNamespace == "" { + meta := node.GetDefinitionMeta() + targetTypeNamespace = meta.Namespace + } + return + } + } + case dsl.Expression: + t := node.GetResolvedType() + if t != nil { + self.Visit(t) + } + } + self.VisitChildren(node) + }) + + unionClassName, _ := common.UnionClassName(targetType) + if targetTypeNamespace != "" && targetTypeNamespace != contextNamespace { + unionClassName = fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(targetTypeNamespace), unionClassName) + } + + for _, switchCase := range t.Cases { + writeSwitchCaseOverUnion(w, targetType, unionClassName, switchCase, unionVariableName, self, tail) + } + + w.WriteStringln(`throw(yardl.Error("Unexpected union case"))`) return } @@ -513,6 +581,43 @@ func writeSwitchCaseOverOptional(w *formatting.IndentedWriter, switchCase *dsl.S } } +func writeSwitchCaseOverUnion(w *formatting.IndentedWriter, unionType *dsl.GeneralizedType, unionClassName string, switchCase *dsl.SwitchCase, variableName string, visitor dsl.VisitorWithContext[tailWrapper], tail tailWrapper) { + writeTypeCase := func(typePattern *dsl.TypePattern, declarationIdentifier string) { + for i, typeCase := range unionType.Cases { + if dsl.TypesEqual(typePattern.Type, typeCase.Type) { + if typePattern.Type == nil { + fmt.Fprintf(w, "if isa(%s, 'yardl.None')\n", variableName) + common.WriteBlockBody(w, func() { + visitor.Visit(switchCase.Expression, tail) + }) + } else { + // fmt.Fprintf(w, "if isa(%s, %s.%s):\n", variableName, unionClassName, formatting.ToPascalCase(typeCase.Tag)) + fmt.Fprintf(w, "if %s.index == %d\n", variableName, i+1) + common.WriteBlockBody(w, func() { + if declarationIdentifier != "" { + fmt.Fprintf(w, "%s = %s.value\n", declarationIdentifier, variableName) + } + visitor.Visit(switchCase.Expression, tail) + }) + } + return + } + } + panic(fmt.Sprintf("Did not find pattern type '%s'", dsl.TypeToShortSyntax(typePattern.Type, false))) + } + + switch t := switchCase.Pattern.(type) { + case *dsl.TypePattern: + writeTypeCase(t, "") + case *dsl.DeclarationPattern: + writeTypeCase(&t.TypePattern, common.FieldIdentifierName(t.Identifier)) + case *dsl.DiscardPattern: + visitor.Visit(switchCase.Expression, tail) + default: + panic(fmt.Sprintf("Unknown pattern type '%T'", switchCase.Pattern)) + } +} + func writeTypeConversion(w *formatting.IndentedWriter, t dsl.Type, next func()) { getWrapper := func(t dsl.Type) (string, string) { switch t := t.(type) { From 764fbfc46452f8d9c68a9a18393a2db217b557f8 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Mon, 11 Mar 2024 16:54:21 +0000 Subject: [PATCH 06/32] Add Matlab tests --- matlab/tests/EqualityTest.m | 181 ++++++++++++ matlab/tests/GeneratedTypesTest.m | 134 +++++++++ matlab/tests/ProtocolStateTest.m | 63 ++++ matlab/tests/ProtocolStateTestReader.m | 21 ++ matlab/tests/ProtocolStateTestWriter.m | 21 ++ matlab/tests/YardlTypesTest.m | 75 +++++ matlab/tests/run.m | 8 +- tooling/internal/matlab/common/common.go | 38 ++- .../internal/matlab/protocols/protocols.go | 23 +- .../matlab/static_files/+yardl/Date.m | 45 +++ .../matlab/static_files/+yardl/DateTime.m | 22 +- .../matlab/static_files/+yardl/Time.m | 37 ++- tooling/internal/matlab/types/types.go | 272 ++++++++++++++++-- 13 files changed, 876 insertions(+), 64 deletions(-) create mode 100644 matlab/tests/EqualityTest.m create mode 100644 matlab/tests/GeneratedTypesTest.m create mode 100644 matlab/tests/ProtocolStateTest.m create mode 100644 matlab/tests/ProtocolStateTestReader.m create mode 100644 matlab/tests/ProtocolStateTestWriter.m create mode 100644 matlab/tests/YardlTypesTest.m create mode 100644 tooling/internal/matlab/static_files/+yardl/Date.m diff --git a/matlab/tests/EqualityTest.m b/matlab/tests/EqualityTest.m new file mode 100644 index 00000000..c138445c --- /dev/null +++ b/matlab/tests/EqualityTest.m @@ -0,0 +1,181 @@ +classdef EqualityTest < matlab.unittest.TestCase + methods (Test) + + function testSimpleEquality(testCase) + a = SimpleRecord(1, 2, 3); + b = SimpleRecord(1, 2, 3); + testCase.verifyEqual(a, b); + + c = SimpleRecord(1, 2, 4); + testCase.verifyNotEqual(a, c); + end + + function testFlagsEquality(testCase) + a = bitor(DaysOfWeek.MONDAY, DaysOfWeek.TUESDAY); + b = bitor(DaysOfWeek.TUESDAY, DaysOfWeek.MONDAY); + testCase.verifyEqual(a, b); + + c = DaysOfWeek(0); + d = DaysOfWeek(0); + testCase.verifyEqual(c, d); + testCase.verifyNotEqual(a, c); + + e = DaysOfWeek(0xFFFF); + f = DaysOfWeek(0xFFFF); + testCase.verifyEqual(e, f); + end + + function testEnumEquality(testCase) + a = Fruits.APPLE; + b = Fruits.APPLE; + testCase.verifyEqual(a, b); + + c = Fruits(10000); + d = Fruits(10000); + testCase.verifyEqual(c, d); + end + + function testRecordWithEnumEquality(testCase) + a = RecordWithEnums(Fruits.APPLE, bitor(DaysOfWeek.SATURDAY, DaysOfWeek.SUNDAY), 0); + b = RecordWithEnums(Fruits.APPLE, bitor(DaysOfWeek.SATURDAY, DaysOfWeek.SUNDAY), 0); + testCase.verifyEqual(a, b); + + c = RecordWithEnums(Fruits.APPLE, DaysOfWeek.SATURDAY, 0); + testCase.verifyNotEqual(a, c); + end + + function testDateEquality(testCase) + a = RecordWithPrimitives(); + a.date_field = yardl.Date.from_components(2020, 1, 1); + b = RecordWithPrimitives(); + b.date_field = yardl.Date.from_components(2020, 1, 1); + + testCase.verifyEqual(a, b); + + c = RecordWithPrimitives(); + c.date_field = yardl.Date.from_components(2020, 1, 2); + testCase.verifyNotEqual(a, c); + end + + function testTimeEquality(testCase) + a = RecordWithPrimitives(); + a.time_field = yardl.Time.from_components(12, 22, 44, 0); + b = RecordWithPrimitives(); + b.time_field = yardl.Time.from_components(12, 22, 44, 0); + + testCase.verifyEqual(a, b); + + c = RecordWithPrimitives(); + c.time_field = yardl.Time.from_components(12, 22, 45, 0); + testCase.verifyNotEqual(a, c); + end + + function testDateTimeEquality(testCase) + a = RecordWithPrimitives(); + a.datetime_field = yardl.DateTime.from_components(2020, 1, 1, 12, 22, 44, 0); + b = RecordWithPrimitives(); + b.datetime_field = yardl.DateTime.from_components(2020, 1, 1, 12, 22, 44, 0); + + testCase.verifyEqual(a, b); + + c = RecordWithPrimitives(); + c.datetime_field = yardl.DateTime.from_components(2020, 1, 1, 12, 22, 45, 0); + testCase.verifyNotEqual(a, c); + end + + function testStringEquality(testCase) + a = RecordWithStrings("a", "b"); + b = RecordWithStrings("a", "b"); + testCase.verifyEqual(a, b); + + c = RecordWithStrings("a", "c"); + testCase.verifyNotEqual(a, c); + end + + + function testRecordWithPrimitiveVectorsEquality(testCase) + a = RecordWithVectors( ... + [1, 2], ... + [1, 2, 3], ... + [[1, 2], [3, 4]] ... + ); + + b = RecordWithVectors( ... + [1, 2], ... + [1, 2, 3], ... + [[1, 2], [3, 4]] ... + ); + + testCase.verifyEqual(a, b); + end + + function testOptionalIntEquality(testCase) + a = RecordWithOptionalFields(); + a.optional_time = yardl.Time.from_components(1, 1, 1, 1); + b = RecordWithOptionalFields(); + b.optional_time = yardl.Time.from_components(1, 1, 1, 1); + testCase.verifyEqual(a, b); + + c = RecordWithOptionalFields(); + c.optional_time = yardl.Time.from_components(1, 1, 1, 2); + testCase.verifyNotEqual(a, c); + testCase.verifyNotEqual(b, c); + + d = RecordWithOptionalFields(); + e = RecordWithOptionalFields(); + testCase.verifyEqual(d, e); + testCase.verifyNotEqual(a, d); + end + + function testTimeVectorEquality(testCase) + a = RecordWithVectorOfTimes(... + [yardl.Time.from_components(1, 1, 1, 1), yardl.Time.from_components(1, 1, 1, 1)] ... + ); + b = RecordWithVectorOfTimes(... + [yardl.Time.from_components(1, 1, 1, 1), yardl.Time.from_components(1, 1, 1, 1)] ... + ); + testCase.verifyEqual(a, b); + + c = RecordWithVectorOfTimes(... + [yardl.Time.from_components(1, 1, 1, 1), yardl.Time.from_components(1, 1, 1, 2)] ... + ); + testCase.verifyNotEqual(a, c); + end + + function testSimpleArrayEquality(testCase) + a = RecordWithArrays(); + a.default_array = int32([1, 2, 3]); + b = RecordWithArrays(); + b.default_array = int32([1, 2, 3]); + testCase.verifyEqual(a, b); + + c = RecordWithArrays(); + c.default_array = int32([1, 2, 4]); + testCase.verifyNotEqual(a, c); + end + + % function testSimpleUnionEquality(testCase) + % a = basic_types.RecordWithUnions(); + % a.null_or_int_or_string = yardl.None; + % b = basic_types.RecordWithUnions(); + % b.null_or_int_or_string = yardl.None; + % testCase.verifyEqual(a, b); + + % c = basic_types.RecordWithUnions(); + % c.null_or_int_or_string = basic_types.Int32OrString.Int32(1); + % d = basic_types.RecordWithUnions(); + % d.null_or_int_or_string = basic_types.Int32OrString.Int32(1); + % testCase.verifyEqual(c, d); + % testCase.verifyNotEqual(a, c); + + % e = basic_types.RecordWithUnions(); + % e.null_or_int_or_string = basic_types.Int32OrString.String("hello"); + % d = basic_types.RecordWithUnions(); + % d.null_or_int_or_string = basic_types.Int32OrString.String("hello"); + % testCase.verifyEqual(e, d); + % testCase.verifyNotEqual(a, e); + % testCase.verifyNotEqual(c, e); + % end + + end +end diff --git a/matlab/tests/GeneratedTypesTest.m b/matlab/tests/GeneratedTypesTest.m new file mode 100644 index 00000000..10a38cab --- /dev/null +++ b/matlab/tests/GeneratedTypesTest.m @@ -0,0 +1,134 @@ +classdef GeneratedTypesTest < matlab.unittest.TestCase + methods (Test) + + function testDefaultRecordWithPrimitives(testCase) + r = RecordWithPrimitives(); + + assert(r.bool_field == false); + assert(r.int32_field == int32(0)); + assert(r.date_field == datetime(1970, 1, 1)); + assert(r.time_field == yardl.Time(0)); + assert(r.datetime_field == yardl.DateTime(0)); + end + + function testDefaultRecordWithVectors(testCase) + r = RecordWithVectors(); + + assert(isequal(r.default_vector, int32([]))); + assert(isequal(r.default_vector_fixed_length, int32([0, 0, 0]))); + assert(isequal(r.default_vector, int32([]))); + end + + function testDefaultRecordWithArrays(testCase) + r = RecordWithArrays(); + + assert(isequal(r.default_array, int32([]))); + assert(isempty(r.default_array_with_empty_dimension)); + assert(isempty(r.rank_1_array)); + assert(isempty(r.rank_2_array)); + assert(isequal(size(r.rank_2_array), [0, 0])); + assert(isempty(r.rank_2_array_with_named_dimensions)); + assert(isequal(size(r.rank_2_array_with_named_dimensions), [0, 0])); + + assert(isequal(r.rank_2_fixed_array, zeros(4, 3, 'int32'))); + assert(isequal(r.rank_2_fixed_array_with_named_dimensions, zeros(4, 3, 'int32'))); + + assert(isempty(r.dynamic_array)); + assert(isa(r.dynamic_array, 'int32')); + + assert(isa(r.array_of_vectors, 'int32')); + assert(isequal(size(r.array_of_vectors), [5, 4])); + end + + function testDefaultRecordWithOptionalFields(testCase) + r = RecordWithOptionalFields(); + + assert(r.optional_int == yardl.None); + end + + function testDefaultRecordWithUnionsOfContainers(testCase) + r = RecordWithUnionsOfContainers(); + + assert(r.map_or_scalar == MapOrScalar.Map(containers.Map)); + assert(r.vector_or_scalar == VectorOrScalar.Vector(int32([]))); + assert(r.array_or_scalar == ArrayOrScalar.Array(int32([]))); + end + + function testDefaultRecordWithAliasedGenerics(testCase) + r = RecordWithAliasedGenerics(); + + assert(r.my_strings.v1 == ""); + assert(r.my_strings.v2 == ""); + assert(r.aliased_strings.v1 == ""); + assert(r.aliased_strings.v2 == ""); + end + + function testDefaultRecordGenericEmpty(testCase) + g1 = RecordWithOptionalGenericField(); + testCase.verifyEqual(g1.v, yardl.None); + + g1a = RecordWithAliasedOptionalGenericField(); + testCase.verifyEqual(g1a.v, g1.v); + + g2 = RecordWithOptionalGenericUnionField(); + testCase.verifyEqual(g2.v, yardl.None); + + g2a = RecordWithAliasedOptionalGenericUnionField(); + testCase.verifyEqual(g2a.v, g2.v) + + testCase.verifyError(@() MyTuple(), 'MATLAB:minrhs'); + rm = RecordWithGenericMaps(); + testCase.verifyEqual(rm.m, containers.Map()); + testCase.verifyEqual(rm.am, rm.m); + end + + function testDefaultRecordWithGenericRequiredArguments(testCase) + testCase.verifyError(@() RecordWithGenericArrays(), 'MATLAB:minrhs'); + testCase.verifyError(@() RecordWithGenericVectors(), 'MATLAB:minrhs'); + testCase.verifyError(@() RecordWithGenericFixedVectors(), 'MATLAB:minrhs'); + end + + function testDefaultRecordContainingNestedGenericRecords(testCase) + r = RecordContainingNestedGenericRecords(); + + g1 = RecordWithOptionalGenericField(); + g1a = RecordWithAliasedOptionalGenericField(); + g2 = RecordWithOptionalGenericUnionField(); + g2a = RecordWithAliasedOptionalGenericUnionField(); + g7 = RecordWithGenericMaps(); + + testCase.verifyEqual(r.f1, g1); + testCase.verifyEqual(r.f1a, g1a); + testCase.verifyEqual(r.f2, g2); + testCase.verifyEqual(r.f2a, g2a); + + testCase.verifyEqual(r.nested.g1, g1); + testCase.verifyEqual(r.nested.g1a, g1a); + testCase.verifyEqual(r.nested.g2, g2); + testCase.verifyEqual(r.nested.g2a, g2a); + + testCase.verifyEqual(r.nested.g3.v1, ""); + testCase.verifyEqual(r.nested.g3.v2, int32(0)); + testCase.verifyEqual(r.nested.g3a.v1, r.nested.g3.v1); + testCase.verifyEqual(r.nested.g3a.v2, r.nested.g3.v2); + + testCase.verifyEqual(r.nested.g4.v, int32([])); + testCase.verifyEqual(r.nested.g4.av, r.nested.g4.v); + + testCase.verifyEqual(r.nested.g5.fv, int32([0, 0, 0])); + testCase.verifyEqual(r.nested.g5.afv, r.nested.g5.fv); + + testCase.verifyEqual(r.nested.g6.nd, int32([])); + testCase.verifyEqual(r.nested.g6.aliased_nd, r.nested.g6.nd); + + testCase.verifyEqual(r.nested.g6.fixed_nd, zeros(8, 16, 'int32')); + testCase.verifyEqual(r.nested.g6.aliased_fixed_nd, r.nested.g6.fixed_nd); + + testCase.verifyEqual(r.nested.g6.dynamic_nd, int32([])); + testCase.verifyEqual(r.nested.g6.aliased_dynamic_nd, r.nested.g6.dynamic_nd); + + testCase.verifyEqual(r.nested.g7, g7); + end + + end +end diff --git a/matlab/tests/ProtocolStateTest.m b/matlab/tests/ProtocolStateTest.m new file mode 100644 index 00000000..2778fde8 --- /dev/null +++ b/matlab/tests/ProtocolStateTest.m @@ -0,0 +1,63 @@ +classdef ProtocolStateTest < matlab.unittest.TestCase + methods (Test) + + function testProperSequenceWrite(testCase) + w = ProtocolStateTestWriter(); + w.write_an_int(1); + w.write_a_stream([1, 2, 3]); + w.write_another_int(3); + w.close(); + end + + function testProperSequenceWriteEmptyStream(testCase) + w = ProtocolStateTestWriter(); + w.write_an_int(1); + w.write_a_stream([]); + w.write_another_int(3); + w.close(); + end + + function testProperSequenceWriteMultipleStreams(testCase) + w = ProtocolStateTestWriter(); + w.write_an_int(1); + w.write_a_stream([1, 2, 3]); + w.write_a_stream([4, 5, 6]); + w.write_another_int(3); + w.close(); + end + + function testSequenceWriteMissingFirstStep(testCase) + w = ProtocolStateTestWriter(); + testCase.verifyError(@() w.write_a_stream([1, 2, 3]), 'yardl:ProtocolError'); + end + + function testSequenceWritePrematureClose(testCase) + w = ProtocolStateTestWriter(); + w.write_an_int(1); + w.write_a_stream([1, 2, 3]); + testCase.verifyError(@() w.close(), 'yardl:ProtocolError'); + end + + + function testProperSequenceRead(testCase) + r = ProtocolStateTestReader(); + r.read_an_int(); + r.read_a_stream(); + r.read_another_int(); + r.close(); + end + + function testReadSkipFirstStep(testCase) + r = ProtocolStateTestReader(); + testCase.verifyError(@() r.read_a_stream(), 'yardl:ProtocolError'); + end + + function testReadCloseEarly(testCase) + r = ProtocolStateTestReader(); + r.read_an_int(); + r.read_a_stream(); + testCase.verifyError(@() r.close(), 'yardl:ProtocolError'); + end + + end +end diff --git a/matlab/tests/ProtocolStateTestReader.m b/matlab/tests/ProtocolStateTestReader.m new file mode 100644 index 00000000..c544e0e4 --- /dev/null +++ b/matlab/tests/ProtocolStateTestReader.m @@ -0,0 +1,21 @@ +classdef ProtocolStateTestReader < StateTestReaderBase + + methods (Access=protected) + + function res = read_an_int_(self) + res = -2; + end + + function res =read_a_stream_(self) + res = [-1, -2, -3]; + end + + function res =read_another_int_(self) + res = -4; + end + + function close_(self) + end + + end +end diff --git a/matlab/tests/ProtocolStateTestWriter.m b/matlab/tests/ProtocolStateTestWriter.m new file mode 100644 index 00000000..dab837f2 --- /dev/null +++ b/matlab/tests/ProtocolStateTestWriter.m @@ -0,0 +1,21 @@ +classdef ProtocolStateTestWriter < StateTestWriterBase + + methods (Access=protected) + + function write_an_int_(self, value) + end + + function write_a_stream_(self, value) + end + + function write_another_int_(self, value) + end + + function end_stream_(self) + end + + function close_(self) + end + + end +end diff --git a/matlab/tests/YardlTypesTest.m b/matlab/tests/YardlTypesTest.m new file mode 100644 index 00000000..0f56ecbe --- /dev/null +++ b/matlab/tests/YardlTypesTest.m @@ -0,0 +1,75 @@ +classdef YardlTypesTest < matlab.unittest.TestCase + + methods (Test) + + function testDateTimeFromValidDatetime(testCase) + dt = yardl.DateTime.from_datetime(datetime(2020, 2, 29, 12, 22, 44, .111222)); + testCase.verifyEqual(dt.value(), int64(1582978964000111222)); + end + + function testDateTimeFromValidComponents(testCase) + dt = yardl.DateTime.from_components(2020, 2, 29, 12, 22, 44, 111222); + testCase.verifyEqual(dt.value(), int64(1582978964000111222)); + end + + function testDateTimeFromInvalidComponents(testCase) + % nanosecond out of range + testCase.verifyError(@() yardl.DateTime.from_components(2021, 2, 15, 12, 22, 44, 9999999999999999), 'yardl:ValueError'); + end + + function testDateTimeFromInt(testCase) + dt = yardl.DateTime(1577967764111222333); + mdt = dt.to_datetime(); + testCase.verifyEqual(mdt.Year, 2020); + testCase.verifyEqual(mdt.Month, 1); + testCase.verifyEqual(mdt.Day, 2); + testCase.verifyEqual(mdt.Hour, 12); + testCase.verifyEqual(mdt.Minute, 22); + testCase.verifyEqual(mdt.Second * 1e9, 44111222333, 'RelTol', 1e-8); + end + + function testDateFromValidDatetime(testCase) + d = yardl.Date.from_datetime(datetime(2020, 2, 29)); + testCase.verifyEqual(d.value(), 18321); + end + + function testDateFromValidComponents(testCase) + d = yardl.Date.from_components(2020, 2, 29); + md = d.to_datetime(); + testCase.verifyEqual(md.Year, 2020); + testCase.verifyEqual(md.Month, 2); + testCase.verifyEqual(md.Day, 29); + end + + function testTimeFromValidDatetime(testCase) + t = yardl.Time.from_datetime(datetime(2024, 3, 11, 12, 22, 44, 111.222)); + mdt = t.to_datetime(); + testCase.verifyEqual(mdt.Hour, 12); + testCase.verifyEqual(mdt.Minute, 22); + testCase.verifyEqual(mdt.Second * 1e9, 44111222000, 'RelTol', 1e-8); + end + + function testTimeFromValidComponents(testCase) + t = yardl.Time.from_components(12, 22, 44, 111222333); + mdt = t.to_datetime(); + testCase.verifyEqual(mdt.Hour, 12); + testCase.verifyEqual(mdt.Minute, 22); + testCase.verifyEqual(mdt.Second * 1e9, 44111222333, 'RelTol', 1e-8); + end + + function testTimeFromInvalidComponents(testCase) + % hour out of range + testCase.verifyError(@() yardl.Time.from_components(24, 0, 0, 0), 'yardl:ValueError'); + + % minute out of range + testCase.verifyError(@() yardl.Time.from_components(12, -3, 0, 0), 'yardl:ValueError'); + + % second out of range + testCase.verifyError(@() yardl.Time.from_components(12, 22, 74, 0), 'yardl:ValueError'); + + % nanosecond out of range + testCase.verifyError(@() yardl.Time.from_components(12, 22, 44, 9999999999999999), 'yardl:ValueError'); + end + + end +end diff --git a/matlab/tests/run.m b/matlab/tests/run.m index 01ea66f4..f04cccad 100644 --- a/matlab/tests/run.m +++ b/matlab/tests/run.m @@ -1,3 +1,7 @@ -addpath("../generated/test_model/") +addpath("../generated/test_model/"); -run(CodedStreamTest) +run(YardlTypesTest); +run(CodedStreamTest); +run(ProtocolStateTest); +run(GeneratedTypesTest); +run(EqualityTest); diff --git a/tooling/internal/matlab/common/common.go b/tooling/internal/matlab/common/common.go index f0364125..39b97594 100644 --- a/tooling/internal/matlab/common/common.go +++ b/tooling/internal/matlab/common/common.go @@ -37,26 +37,24 @@ var TypeSyntaxWriter dsl.TypeSyntaxWriter[string] = func(self dsl.TypeSyntaxWrit return "uint32" case dsl.Int64: return "int64" - case dsl.Uint64: - return "uint64" - case dsl.Size: + case dsl.Uint64, dsl.Size: return "uint64" case dsl.Float32: - return "float32" + return "single" case dsl.Float64: - return "float64" + return "double" case dsl.ComplexFloat32: return "complex" case dsl.ComplexFloat64: return "complex" case dsl.String: - return "str" + return "string" case dsl.Date: - return "datetime" + return "yardl.Date" case dsl.Time: - return "datetime" + return "yardl.Time" case dsl.DateTime: - return "datetime" + return "yardl.DateTime" default: panic(fmt.Sprintf("primitive '%v' not recognized", t)) } @@ -108,6 +106,28 @@ func TypeSyntax(typeOrTypeDefinition dsl.Node, contextNamespace string) string { return TypeSyntaxWriter.ToSyntax(typeOrTypeDefinition, contextNamespace) } +var typeSyntaxWithoutTypeParametersWriter dsl.TypeSyntaxWriter[string] = func(self dsl.TypeSyntaxWriter[string], t dsl.Node, contextNamespace string) string { + switch t := t.(type) { + case dsl.TypeDefinition: + meta := t.GetDefinitionMeta() + if len(meta.TypeParameters) > 0 { + meta := t.GetDefinitionMeta() + typeName := TypeIdentifierName(meta.Name) + if t.GetDefinitionMeta().Namespace != contextNamespace { + typeName = fmt.Sprintf("%s.%s", formatting.ToSnakeCase(meta.Namespace), typeName) + } + + return typeName + } + } + + return TypeSyntaxWriter(self, t, contextNamespace) +} + +func TypeSyntaxWithoutTypeParameters(typeOrTypeDefinition dsl.Node, contextNamespace string) string { + return typeSyntaxWithoutTypeParametersWriter.ToSyntax(typeOrTypeDefinition, contextNamespace) +} + func ComputedFieldIdentifierName(name string) string { cased := formatting.ToSnakeCase(name) if !isReservedName[name] { diff --git a/tooling/internal/matlab/protocols/protocols.go b/tooling/internal/matlab/protocols/protocols.go index 89ae9bea..f5bba51b 100644 --- a/tooling/internal/matlab/protocols/protocols.go +++ b/tooling/internal/matlab/protocols/protocols.go @@ -227,8 +227,6 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, fmt.Fprintf(w, "value = obj.%s();\n", common.ProtocolReadImplMethodName(step)) if step.IsStream() { - // fmt.Fprintf(w, "obj.state_ = %d;\n", i*2+1) - // fmt.Fprintf(w, "value = obj.wrap_iterable_(value, %d);\n", (i+1)*2) fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) } else { fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) @@ -270,29 +268,12 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, w.WriteStringln("methods (Access=private)") common.WriteBlockBody(w, func() { - // wrap_iterable method - w.WriteStringln("function value = wrap_iterable_(obj, iterable, final_state)") - common.WriteBlockBody(w, func() { - w.WriteStringln("% This is a no-op... In python, it's yield from iterable") - w.WriteStringln("value = iterable;") - w.WriteStringln("obj.state_ = final_state;") - }) - w.WriteStringln("") - // raise_unexpected_state method w.WriteStringln("function raise_unexpected_state_(obj, actual)") common.WriteBlockBody(w, func() { w.WriteStringln("actual_method = obj.state_to_method_name_(actual);") - w.WriteStringln("if mod(obj.state_, 2) == 1") - w.Indented(func() { - w.WriteStringln("previous_method = obj.state_to_method_name_(obj.state_ - 1);") - w.WriteStringln(`throw(yardl.ProtocolError("Received call to '%s' but the iterable returned by '%s' was not fully consumed.", actual_method, previous_method));`) - }) - w.WriteStringln("else") - common.WriteBlockBody(w, func() { - w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") - w.WriteStringln(`throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method));`) - }) + w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") + w.WriteStringln(`throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method));`) }) w.WriteStringln("") diff --git a/tooling/internal/matlab/static_files/+yardl/Date.m b/tooling/internal/matlab/static_files/+yardl/Date.m new file mode 100644 index 00000000..9a692c4e --- /dev/null +++ b/tooling/internal/matlab/static_files/+yardl/Date.m @@ -0,0 +1,45 @@ +classdef Date < handle + + properties (Access=private) + days_since_epoch_ + end + + methods + function obj = Date(days_since_epoch) + if nargin > 0 + obj.days_since_epoch_ = days_since_epoch; + else + obj.days_since_epoch_ = 0; + end + end + + function value = value(obj) + value = obj.days_since_epoch_; + end + + function dt = to_datetime(obj) + dt = datetime(0, 'ConvertFrom', 'epochtime') + days(obj.days_since_epoch_); + end + + function eq = eq(obj, other) + if isa(other, 'datetime') + other = yardl.Date.from_datetime(other); + end + + eq = isa(other, 'yardl.Date') && ... + all([obj.value] == [other.value]); + end + end + + methods (Static) + function d = from_datetime(value) + dur = value - datetime(0, 'ConvertFrom', 'epochtime'); + d = yardl.Date(days(dur)); + end + + function d = from_components(y, m, d) + d = yardl.Date.from_datetime(datetime(y, m, d)); + end + end + +end diff --git a/tooling/internal/matlab/static_files/+yardl/DateTime.m b/tooling/internal/matlab/static_files/+yardl/DateTime.m index 3258d23e..fb94d3aa 100644 --- a/tooling/internal/matlab/static_files/+yardl/DateTime.m +++ b/tooling/internal/matlab/static_files/+yardl/DateTime.m @@ -7,7 +7,11 @@ methods function obj = DateTime(nanoseconds_since_epoch) - obj.nanoseconds_since_epoch_ = nanoseconds_since_epoch; + if nargin > 0 + obj.nanoseconds_since_epoch_ = nanoseconds_since_epoch; + else + obj.nanoseconds_since_epoch_ = 0; + end end function value = value(obj) @@ -23,11 +27,8 @@ other = yardl.DateTime.from_datetime(other); end - if isa(other, 'yardl.DateTime') - eq = all([obj.value] == [other.value]); - else - eq = false; - end + eq = isa(other, 'yardl.DateTime') && ... + all([obj.value] == [other.value]); end end @@ -37,6 +38,15 @@ nanoseconds_since_epoch = convertTo(value, 'epochtime', 'TicksPerSecond', 1e9); dt = yardl.DateTime(nanoseconds_since_epoch); end + + function dt = from_components(year, month, day, hour, minute, second, nanosecond) + if ~(nanosecond >= 0 && nanosecond < 999999999) + throw(yardl.ValueError("nanosecond must be in 0..1e9")); + end + mdt = datetime(year, month, day, hour, minute, second, 'TimeZone', 'UTC'); + seconds_since_epoch = convertTo(mdt, 'epochtime'); + dt = yardl.DateTime(seconds_since_epoch * 1e9 + nanosecond); + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/Time.m b/tooling/internal/matlab/static_files/+yardl/Time.m index 10ee9143..ca647ed5 100644 --- a/tooling/internal/matlab/static_files/+yardl/Time.m +++ b/tooling/internal/matlab/static_files/+yardl/Time.m @@ -8,7 +8,14 @@ methods function obj = Time(nanoseconds_since_midnight) - obj.nanoseconds_since_midnight_ = nanoseconds_since_midnight; + if nargin > 0 + if nanoseconds_since_midnight < 0 || nanoseconds_since_midnight >= 24*60*60*1e9 + throw(yardl.ValuError("Time must be between 00:00:00 and 23:59:59.999999999")); + end + obj.nanoseconds_since_midnight_ = nanoseconds_since_midnight; + else + obj.nanoseconds_since_midnight_ = 0; + end end function value = value(obj) @@ -24,19 +31,35 @@ other = yardl.Time.from_datetime(other); end - if isa(other, 'yardl.Time') - eq = all([obj.value] == [other.value]); - else - eq = false; - end + eq = isa(other, 'yardl.Time') && ... + all([obj.value] == [other.value]); end end methods (Static) function t = from_datetime(value) - nanoseconds_since_midnight = convertTo(value, 'epochtime', 'Epoch', datetime('today', 'TimeZone', value.TimeZone), 'TicksPerSecond', 1e9); + nanoseconds_since_midnight = convertTo(value, 'epochtime', ... + 'Epoch', datetime(value.Year, value.Month, value.Day, 'TimeZone', value.TimeZone), ... + 'TicksPerSecond', 1e9); t = yardl.Time(nanoseconds_since_midnight); end + + function t = from_components(hour, minute, second, nanosecond) + if ~(hour >= 0 && hour <= 23) + throw(yardl.ValueError("hour must be between 0 and 23")); + end + if ~(minute >= 0 && minute <= 59) + throw(yardl.ValueError("minute must be between 0 and 59")); + end + if ~(second >= 0 && second <= 59) + throw(yardl.ValueError("second must be between 0 and 59")); + end + if ~(nanosecond >= 0 && nanosecond <= 999999999) + throw(yardl.ValueError("nanosecond must be between 0 and 999999999")); + end + + t = yardl.Time(hour * 60*60*1e9 + minute * 60*1e9 + second * 1e9 + nanosecond); + end end end diff --git a/tooling/internal/matlab/types/types.go b/tooling/internal/matlab/types/types.go index b387154a..2b43b03a 100644 --- a/tooling/internal/matlab/types/types.go +++ b/tooling/internal/matlab/types/types.go @@ -5,11 +5,13 @@ package types import ( "fmt" + "strconv" "strings" "github.com/microsoft/yardl/tooling/internal/formatting" "github.com/microsoft/yardl/tooling/internal/matlab/common" "github.com/microsoft/yardl/tooling/pkg/dsl" + "github.com/rs/zerolog/log" ) func WriteTypes(fw *common.MatlabFileWriter, ns *dsl.Namespace, st dsl.SymbolTable) error { @@ -119,11 +121,13 @@ func writeEnum(fw *common.MatlabFileWriter, enum *dsl.EnumDefinition) error { enumTypeSyntax := common.TypeSyntax(enum, enum.Namespace) fmt.Fprintf(w, "classdef %s < %s\n", enumTypeSyntax, base) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "enumeration\n") + // NOTE: We don't use Matlab enumeration class because you can't inherit from it + // and we use inheritance to define NamedTypes + w.WriteStringln("properties (Constant)") common.WriteBlockBody(w, func() { for _, value := range enum.Values { common.WriteComment(w, value.Comment) - fmt.Fprintf(w, "%s (%d)\n", common.EnumValueIdentifierName(value.Symbol), &value.IntegerValue) + fmt.Fprintf(w, "%s = %d\n", common.EnumValueIdentifierName(value.Symbol), &value.IntegerValue) } }) }) @@ -139,13 +143,18 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. w.WriteStringln("properties") var fieldNames []string + requireConstructorArgs := false common.WriteBlockBody(w, func() { - for i, field := range rec.Fields { + for _, field := range rec.Fields { common.WriteComment(w, field.Comment) - fieldNames = append(fieldNames, common.FieldIdentifierName(field.Name)) - fmt.Fprintf(w, "%s\n", common.FieldIdentifierName(field.Name)) - if i < len(rec.Fields)-1 { - w.WriteStringln("") + fieldName := common.FieldIdentifierName(field.Name) + fieldNames = append(fieldNames, fieldName) + w.WriteStringln(fieldName) + + _, defaultExpressionKind := typeDefault(field.Type, rec.Namespace, "", st) + switch defaultExpressionKind { + case defaultValueKindNone: + requireConstructorArgs = true } } }) @@ -157,24 +166,50 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. // Record Constructor fmt.Fprintf(w, "function obj = %s(%s)\n", rec.Name, strings.Join(fieldNames, ", ")) common.WriteBlockBody(w, func() { - for _, field := range rec.Fields { - fmt.Fprintf(w, "obj.%s = %s;\n", common.FieldIdentifierName(field.Name), common.FieldIdentifierName(field.Name)) + if requireConstructorArgs { + log.Warn().Msgf("Record %s requires constructor arguments", rec.Name) + for _, field := range rec.Fields { + fmt.Fprintf(w, "obj.%s = %s;\n", common.FieldIdentifierName(field.Name), common.FieldIdentifierName(field.Name)) + } + } else { + w.WriteStringln("if nargin > 0") + w.Indented(func() { + for _, field := range rec.Fields { + fmt.Fprintf(w, "obj.%s = %s;\n", common.FieldIdentifierName(field.Name), common.FieldIdentifierName(field.Name)) + } + }) + w.WriteStringln("else") + common.WriteBlockBody(w, func() { + for _, field := range rec.Fields { + fieldName := common.FieldIdentifierName(field.Name) + defaultExpression, defaultExpressionKind := typeDefault(field.Type, rec.Namespace, "", st) + switch defaultExpressionKind { + case defaultValueKindNone: + w.WriteStringln(fieldName) + case defaultValueKindImmutable, defaultValueKindMutable: + fmt.Fprintf(w, "obj.%s = %s;\n", fieldName, defaultExpression) + } + } + }) } + }) w.WriteStringln("") // Computed Fields - for _, computedField := range rec.ComputedFields { - fieldName := common.ComputedFieldIdentifierName(computedField.Name) + if len(rec.ComputedFields) > 0 { + for _, computedField := range rec.ComputedFields { + fieldName := common.ComputedFieldIdentifierName(computedField.Name) - common.WriteComment(w, computedField.Comment) - fmt.Fprintf(w, "function res = %s(self)\n", fieldName) - common.WriteBlockBody(w, func() { - writeComputedFieldExpression(w, computedField.Expression, rec.Namespace) - }) + common.WriteComment(w, computedField.Comment) + fmt.Fprintf(w, "function res = %s(self)\n", fieldName) + common.WriteBlockBody(w, func() { + writeComputedFieldExpression(w, computedField.Expression, rec.Namespace) + }) + w.WriteStringln("") + } w.WriteStringln("") } - w.WriteStringln("") // eq method w.WriteStringln("function res = eq(obj, other)") @@ -653,8 +688,12 @@ func writeTypeConversion(w *formatting.IndentedWriter, t dsl.Type, next func()) return "complex(double(", "))" case dsl.String: return "string(", ")" - case dsl.Date, dsl.Time, dsl.DateTime: - return "datetime(", ")" + case dsl.Date: + return "yardl.Date(", ")" + case dsl.Time: + return "yardl.Time(", ")" + case dsl.DateTime: + return "yardl.DateTime(", ")" } } } @@ -666,3 +705,198 @@ func writeTypeConversion(w *formatting.IndentedWriter, t dsl.Type, next func()) next() w.WriteString(close) } + +type defaultValueKind int + +const ( + defaultValueKindNone defaultValueKind = iota + defaultValueKindImmutable + defaultValueKindMutable +) + +func typeDefault(t dsl.Type, contextNamespace string, namedType string, st dsl.SymbolTable) (string, defaultValueKind) { + switch t := t.(type) { + case nil: + return "yardl.None", defaultValueKindImmutable + case *dsl.SimpleType: + return typeDefinitionDefault(t.ResolvedDefinition, contextNamespace, st) + case *dsl.GeneralizedType: + switch td := t.Dimensionality.(type) { + case nil: + defaultExpression, defaultKind := typeDefault(t.Cases[0].Type, contextNamespace, "", st) + if t.Cases.IsSingle() || t.Cases.HasNullOption() { + return defaultExpression, defaultKind + } + + var unionClassName string + if namedType != "" { + unionClassName = namedType + } else { + unionClassName, _ = common.UnionClassName(t) + } + + unionCaseConstructor := fmt.Sprintf("%s.%s", unionClassName, formatting.ToPascalCase(t.Cases[0].Tag)) + + switch defaultKind { + case defaultValueKindNone: + return "", defaultKind + case defaultValueKindImmutable: + return fmt.Sprintf(`%s(%s)`, unionCaseConstructor, defaultExpression), defaultKind + case defaultValueKindMutable: + if t, ok := dsl.GetUnderlyingType(t.Cases[0].Type).(*dsl.SimpleType); ok { + if _, ok := t.ResolvedDefinition.(*dsl.RecordDefinition); ok { + return fmt.Sprintf(`%s(%s())`, unionCaseConstructor, defaultExpression), defaultValueKindMutable + } + } + return fmt.Sprintf(`%s(%s)`, unionCaseConstructor, defaultExpression), defaultValueKindMutable + } + + return fmt.Sprintf(`("%s", %s)`, t.Cases[0].Tag, defaultExpression), defaultValueKindImmutable + case *dsl.Vector: + scalar := t.ToScalar() + if dsl.TypeContainsGenericTypeParameter(scalar) { + return "", defaultValueKindNone + } + + dtype := common.TypeSyntax(scalar, contextNamespace) + + if td.Length == nil { + return fmt.Sprintf("%s.empty()", dtype), defaultValueKindMutable + } + + scalarDefault, scalarDefaultKind := typeDefault(t.Cases[0].Type, contextNamespace, "", st) + + switch scalarDefaultKind { + case defaultValueKindNone: + return "", defaultValueKindNone + case defaultValueKindImmutable, defaultValueKindMutable: + return fmt.Sprintf("repelem(%s, %d)", scalarDefault, *td.Length), defaultValueKindMutable + } + + case *dsl.Array: + scalar := t.ToScalar() + if dsl.TypeContainsGenericTypeParameter(scalar) { + return "", defaultValueKindNone + } + + dtype := common.TypeSyntax(scalar, contextNamespace) + + if td.IsFixed() { + dims := make([]string, len(*td.Dimensions)) + for i, d := range *td.Dimensions { + dims[len(*td.Dimensions)-i-1] = strconv.FormatUint(*d.Length, 10) + } + if len(dims) == 1 { + dims = append(dims, "1") + } + + scalarDefault, _ := typeDefault(scalar, contextNamespace, "", st) + + return fmt.Sprintf("repelem(%s, %s)", scalarDefault, strings.Join(dims, ", ")), defaultValueKindMutable + } + + if td.HasKnownNumberOfDimensions() { + shape := strings.Repeat("0, ", len(*td.Dimensions))[0 : len(*td.Dimensions)*3-2] + return fmt.Sprintf("%s.empty(%s)", dtype, shape), defaultValueKindMutable + } + + return fmt.Sprintf("%s.empty()", dtype), defaultValueKindMutable + + case *dsl.Map: + return "containers.Map", defaultValueKindMutable + } + } + + return "", defaultValueKindNone +} + +func typeDefinitionDefault(t dsl.TypeDefinition, contextNamespace string, st dsl.SymbolTable) (string, defaultValueKind) { + switch t := t.(type) { + case dsl.PrimitiveDefinition: + switch t { + case dsl.Bool: + return "false", defaultValueKindImmutable + case dsl.Int8: + return "int8(0)", defaultValueKindImmutable + case dsl.Uint8: + return "uint8(0)", defaultValueKindImmutable + case dsl.Int16: + return "int16(0)", defaultValueKindImmutable + case dsl.Uint16: + return "uint16(0)", defaultValueKindImmutable + case dsl.Int32: + return "int32(0)", defaultValueKindImmutable + case dsl.Uint32: + return "uint32(0)", defaultValueKindImmutable + case dsl.Int64: + return "int64(0)", defaultValueKindImmutable + case dsl.Uint64, dsl.Size: + return "uint64(0)", defaultValueKindImmutable + case dsl.Float32: + return "single(0)", defaultValueKindImmutable + case dsl.Float64: + return "0", defaultValueKindImmutable + case dsl.ComplexFloat32, dsl.ComplexFloat64: + return "0j", defaultValueKindImmutable + case dsl.String: + return `""`, defaultValueKindImmutable + case dsl.Date: + return "yardl.Date()", defaultValueKindImmutable + case dsl.Time: + return "yardl.Time()", defaultValueKindImmutable + case dsl.DateTime: + return "yardl.DateTime()", defaultValueKindImmutable + } + case *dsl.EnumDefinition: + zeroValue := t.GetZeroValue() + if t.IsFlags { + if zeroValue == nil { + return fmt.Sprintf("%s(0)", common.TypeSyntax(t, contextNamespace)), defaultValueKindImmutable + } else { + return fmt.Sprintf("%s.%s", common.TypeSyntax(t, contextNamespace), common.EnumValueIdentifierName(zeroValue.Symbol)), defaultValueKindImmutable + } + } + + if zeroValue == nil { + return "", defaultValueKindNone + } + + return fmt.Sprintf("%s.%s", common.TypeSyntax(t, contextNamespace), common.EnumValueIdentifierName(zeroValue.Symbol)), defaultValueKindImmutable + case *dsl.NamedType: + return typeDefault(t.Type, contextNamespace, common.TypeSyntax(t, contextNamespace), st) + + case *dsl.RecordDefinition: + if len(t.TypeArguments) == 0 { + if len(t.TypeParameters) > 0 { + // *Open* Generic Record type + // Should never get here - typeDefault is only called on Fields, which must be closed if generic + panic(fmt.Sprintf("No typeDefault for open generic record %s", t.Name)) + } + + for _, f := range t.Fields { + _, fieldDefaultKind := typeDefault(f.Type, contextNamespace, "", st) + if fieldDefaultKind == defaultValueKindNone { + // Basic, closed record type + // Should never get here - a Field in a closed record should always have a default type + panic(fmt.Sprintf("No typeDefault for record field %s.%s", t.Name, f.Name)) + } + } + + // Basic record type + return fmt.Sprintf("%s()", common.TypeSyntaxWithoutTypeParameters(t, contextNamespace)), defaultValueKindMutable + } + + args := make([]string, 0) + for _, f := range t.Fields { + fieldDefaultExpr, fieldDefaultKind := typeDefault(f.Type, contextNamespace, "", st) + if fieldDefaultKind == defaultValueKindNone { + return "", defaultValueKindNone + } + args = append(args, fieldDefaultExpr) + } + + return fmt.Sprintf("%s(%s)", common.TypeSyntaxWithoutTypeParameters(t, contextNamespace), strings.Join(args, ", ")), defaultValueKindMutable + } + + return "", defaultValueKindNone +} From 1150c41dcfcee0ac6b2483c8d5cf208b56740729 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Mon, 11 Mar 2024 19:08:04 +0000 Subject: [PATCH 07/32] Fix Matlab package paths, add union equality tests --- matlab/tests/EqualityTest.m | 147 +++++++++++++---------- matlab/tests/GeneratedTypesTest.m | 103 ++++++++-------- matlab/tests/ProtocolStateTestReader.m | 2 +- matlab/tests/ProtocolStateTestWriter.m | 2 +- matlab/tests/run.m | 3 +- tooling/internal/matlab/binary/binary.go | 30 ++--- tooling/internal/matlab/common/common.go | 56 +-------- tooling/internal/matlab/matlab.go | 13 +- tooling/internal/matlab/types/types.go | 35 +++--- 9 files changed, 180 insertions(+), 211 deletions(-) diff --git a/matlab/tests/EqualityTest.m b/matlab/tests/EqualityTest.m index c138445c..33c7b4c7 100644 --- a/matlab/tests/EqualityTest.m +++ b/matlab/tests/EqualityTest.m @@ -2,105 +2,105 @@ methods (Test) function testSimpleEquality(testCase) - a = SimpleRecord(1, 2, 3); - b = SimpleRecord(1, 2, 3); + a = test_model.SimpleRecord(1, 2, 3); + b = test_model.SimpleRecord(1, 2, 3); testCase.verifyEqual(a, b); - c = SimpleRecord(1, 2, 4); + c = test_model.SimpleRecord(1, 2, 4); testCase.verifyNotEqual(a, c); end function testFlagsEquality(testCase) - a = bitor(DaysOfWeek.MONDAY, DaysOfWeek.TUESDAY); - b = bitor(DaysOfWeek.TUESDAY, DaysOfWeek.MONDAY); + a = bitor(test_model.DaysOfWeek.MONDAY, test_model.DaysOfWeek.TUESDAY); + b = bitor(test_model.DaysOfWeek.TUESDAY, test_model.DaysOfWeek.MONDAY); testCase.verifyEqual(a, b); - c = DaysOfWeek(0); - d = DaysOfWeek(0); + c = test_model.DaysOfWeek(0); + d = test_model.DaysOfWeek(0); testCase.verifyEqual(c, d); testCase.verifyNotEqual(a, c); - e = DaysOfWeek(0xFFFF); - f = DaysOfWeek(0xFFFF); + e = test_model.DaysOfWeek(0xFFFF); + f = test_model.DaysOfWeek(0xFFFF); testCase.verifyEqual(e, f); end function testEnumEquality(testCase) - a = Fruits.APPLE; - b = Fruits.APPLE; + a = test_model.Fruits.APPLE; + b = test_model.Fruits.APPLE; testCase.verifyEqual(a, b); - c = Fruits(10000); - d = Fruits(10000); + c = test_model.Fruits(10000); + d = test_model.Fruits(10000); testCase.verifyEqual(c, d); end function testRecordWithEnumEquality(testCase) - a = RecordWithEnums(Fruits.APPLE, bitor(DaysOfWeek.SATURDAY, DaysOfWeek.SUNDAY), 0); - b = RecordWithEnums(Fruits.APPLE, bitor(DaysOfWeek.SATURDAY, DaysOfWeek.SUNDAY), 0); + a = test_model.RecordWithEnums(test_model.Fruits.APPLE, bitor(test_model.DaysOfWeek.SATURDAY, test_model.DaysOfWeek.SUNDAY), 0); + b = test_model.RecordWithEnums(test_model.Fruits.APPLE, bitor(test_model.DaysOfWeek.SATURDAY, test_model.DaysOfWeek.SUNDAY), 0); testCase.verifyEqual(a, b); - c = RecordWithEnums(Fruits.APPLE, DaysOfWeek.SATURDAY, 0); + c = test_model.RecordWithEnums(test_model.Fruits.APPLE, test_model.DaysOfWeek.SATURDAY, 0); testCase.verifyNotEqual(a, c); end function testDateEquality(testCase) - a = RecordWithPrimitives(); + a = test_model.RecordWithPrimitives(); a.date_field = yardl.Date.from_components(2020, 1, 1); - b = RecordWithPrimitives(); + b = test_model.RecordWithPrimitives(); b.date_field = yardl.Date.from_components(2020, 1, 1); testCase.verifyEqual(a, b); - c = RecordWithPrimitives(); + c = test_model.RecordWithPrimitives(); c.date_field = yardl.Date.from_components(2020, 1, 2); testCase.verifyNotEqual(a, c); end function testTimeEquality(testCase) - a = RecordWithPrimitives(); + a = test_model.RecordWithPrimitives(); a.time_field = yardl.Time.from_components(12, 22, 44, 0); - b = RecordWithPrimitives(); + b = test_model.RecordWithPrimitives(); b.time_field = yardl.Time.from_components(12, 22, 44, 0); testCase.verifyEqual(a, b); - c = RecordWithPrimitives(); + c = test_model.RecordWithPrimitives(); c.time_field = yardl.Time.from_components(12, 22, 45, 0); testCase.verifyNotEqual(a, c); end function testDateTimeEquality(testCase) - a = RecordWithPrimitives(); + a = test_model.RecordWithPrimitives(); a.datetime_field = yardl.DateTime.from_components(2020, 1, 1, 12, 22, 44, 0); - b = RecordWithPrimitives(); + b = test_model.RecordWithPrimitives(); b.datetime_field = yardl.DateTime.from_components(2020, 1, 1, 12, 22, 44, 0); testCase.verifyEqual(a, b); - c = RecordWithPrimitives(); + c = test_model.RecordWithPrimitives(); c.datetime_field = yardl.DateTime.from_components(2020, 1, 1, 12, 22, 45, 0); testCase.verifyNotEqual(a, c); end function testStringEquality(testCase) - a = RecordWithStrings("a", "b"); - b = RecordWithStrings("a", "b"); + a = test_model.RecordWithStrings("a", "b"); + b = test_model.RecordWithStrings("a", "b"); testCase.verifyEqual(a, b); - c = RecordWithStrings("a", "c"); + c = test_model.RecordWithStrings("a", "c"); testCase.verifyNotEqual(a, c); end function testRecordWithPrimitiveVectorsEquality(testCase) - a = RecordWithVectors( ... + a = test_model.RecordWithVectors( ... [1, 2], ... [1, 2, 3], ... [[1, 2], [3, 4]] ... ); - b = RecordWithVectors( ... + b = test_model.RecordWithVectors( ... [1, 2], ... [1, 2, 3], ... [[1, 2], [3, 4]] ... @@ -110,72 +110,93 @@ function testRecordWithPrimitiveVectorsEquality(testCase) end function testOptionalIntEquality(testCase) - a = RecordWithOptionalFields(); + a = test_model.RecordWithOptionalFields(); a.optional_time = yardl.Time.from_components(1, 1, 1, 1); - b = RecordWithOptionalFields(); + b = test_model.RecordWithOptionalFields(); b.optional_time = yardl.Time.from_components(1, 1, 1, 1); testCase.verifyEqual(a, b); - c = RecordWithOptionalFields(); + c = test_model.RecordWithOptionalFields(); c.optional_time = yardl.Time.from_components(1, 1, 1, 2); testCase.verifyNotEqual(a, c); testCase.verifyNotEqual(b, c); - d = RecordWithOptionalFields(); - e = RecordWithOptionalFields(); + d = test_model.RecordWithOptionalFields(); + e = test_model.RecordWithOptionalFields(); testCase.verifyEqual(d, e); testCase.verifyNotEqual(a, d); end function testTimeVectorEquality(testCase) - a = RecordWithVectorOfTimes(... + a = test_model.RecordWithVectorOfTimes(... [yardl.Time.from_components(1, 1, 1, 1), yardl.Time.from_components(1, 1, 1, 1)] ... ); - b = RecordWithVectorOfTimes(... + b = test_model.RecordWithVectorOfTimes(... [yardl.Time.from_components(1, 1, 1, 1), yardl.Time.from_components(1, 1, 1, 1)] ... ); testCase.verifyEqual(a, b); - c = RecordWithVectorOfTimes(... + c = test_model.RecordWithVectorOfTimes(... [yardl.Time.from_components(1, 1, 1, 1), yardl.Time.from_components(1, 1, 1, 2)] ... ); testCase.verifyNotEqual(a, c); end function testSimpleArrayEquality(testCase) - a = RecordWithArrays(); + a = test_model.RecordWithArrays(); a.default_array = int32([1, 2, 3]); - b = RecordWithArrays(); + b = test_model.RecordWithArrays(); b.default_array = int32([1, 2, 3]); testCase.verifyEqual(a, b); - c = RecordWithArrays(); + c = test_model.RecordWithArrays(); c.default_array = int32([1, 2, 4]); testCase.verifyNotEqual(a, c); end - % function testSimpleUnionEquality(testCase) - % a = basic_types.RecordWithUnions(); - % a.null_or_int_or_string = yardl.None; - % b = basic_types.RecordWithUnions(); - % b.null_or_int_or_string = yardl.None; - % testCase.verifyEqual(a, b); - - % c = basic_types.RecordWithUnions(); - % c.null_or_int_or_string = basic_types.Int32OrString.Int32(1); - % d = basic_types.RecordWithUnions(); - % d.null_or_int_or_string = basic_types.Int32OrString.Int32(1); - % testCase.verifyEqual(c, d); - % testCase.verifyNotEqual(a, c); - - % e = basic_types.RecordWithUnions(); - % e.null_or_int_or_string = basic_types.Int32OrString.String("hello"); - % d = basic_types.RecordWithUnions(); - % d.null_or_int_or_string = basic_types.Int32OrString.String("hello"); - % testCase.verifyEqual(e, d); - % testCase.verifyNotEqual(a, e); - % testCase.verifyNotEqual(c, e); - % end + function testSimpleUnionEquality(testCase) + a = basic_types.RecordWithUnions(); + a.null_or_int_or_string = yardl.None; + b = basic_types.RecordWithUnions(); + b.null_or_int_or_string = yardl.None; + testCase.verifyEqual(a, b); + + c = basic_types.RecordWithUnions(); + c.null_or_int_or_string = basic_types.Int32OrString.Int32(1); + d = basic_types.RecordWithUnions(); + d.null_or_int_or_string = basic_types.Int32OrString.Int32(1); + testCase.verifyEqual(c, d); + testCase.verifyNotEqual(a, c); + + e = basic_types.RecordWithUnions(); + e.null_or_int_or_string = basic_types.Int32OrString.String("hello"); + d = basic_types.RecordWithUnions(); + d.null_or_int_or_string = basic_types.Int32OrString.String("hello"); + testCase.verifyEqual(e, d); + testCase.verifyNotEqual(a, e); + testCase.verifyNotEqual(c, e); + end + + function testTimeUnionEquality(testCase) + a = basic_types.RecordWithUnions(); + a.date_or_datetime = basic_types.TimeOrDatetime.Time(yardl.Time.from_components(1, 1, 1, 1)); + b = basic_types.RecordWithUnions(); + b.date_or_datetime = basic_types.TimeOrDatetime.Time(yardl.Time.from_components(1, 1, 1, 1)); + testCase.verifyEqual(a, b); + end + + function testGenericEquality(testCase) + a = test_model.GenericRecord(1, 2.0, [1, 2, 3], single([[1.1, 2.2], [3.3, 4.4]])); + b = test_model.GenericRecord(1, 2.0, [1, 2, 3], single([[1.1, 2.2], [3.3, 4.4]])); + testCase.verifyEqual(a, b); + + c = test_model.MyTuple(42.0, "hello, world"); + d = tuples.Tuple(42.0, "hello, world"); + testCase.verifyTrue(c == d) + + e = test_model.AliasedTuple(42.0, "hello, world"); + testCase.verifyTrue(c == e); + end end end diff --git a/matlab/tests/GeneratedTypesTest.m b/matlab/tests/GeneratedTypesTest.m index 10a38cab..986f0c83 100644 --- a/matlab/tests/GeneratedTypesTest.m +++ b/matlab/tests/GeneratedTypesTest.m @@ -2,100 +2,103 @@ methods (Test) function testDefaultRecordWithPrimitives(testCase) - r = RecordWithPrimitives(); + r = test_model.RecordWithPrimitives(); - assert(r.bool_field == false); - assert(r.int32_field == int32(0)); - assert(r.date_field == datetime(1970, 1, 1)); - assert(r.time_field == yardl.Time(0)); - assert(r.datetime_field == yardl.DateTime(0)); + testCase.verifyEqual(r.bool_field, false); + testCase.verifyEqual(r.int32_field, int32(0)); + testCase.verifyEqual(r.date_field, yardl.Date()); + testCase.verifyEqual(r.time_field, yardl.Time()); + testCase.verifyEqual(r.datetime_field, yardl.DateTime()); end function testDefaultRecordWithVectors(testCase) - r = RecordWithVectors(); + r = test_model.RecordWithVectors(); - assert(isequal(r.default_vector, int32([]))); - assert(isequal(r.default_vector_fixed_length, int32([0, 0, 0]))); - assert(isequal(r.default_vector, int32([]))); + testCase.verifyEqual(r.default_vector, int32([])); + testCase.verifyEqual(r.default_vector_fixed_length, int32([0, 0, 0])); + testCase.verifyEqual(r.default_vector, int32([])); end function testDefaultRecordWithArrays(testCase) - r = RecordWithArrays(); + import matlab.unittest.constraints.IsEmpty + import matlab.unittest.constraints.IsInstanceOf - assert(isequal(r.default_array, int32([]))); - assert(isempty(r.default_array_with_empty_dimension)); - assert(isempty(r.rank_1_array)); - assert(isempty(r.rank_2_array)); - assert(isequal(size(r.rank_2_array), [0, 0])); - assert(isempty(r.rank_2_array_with_named_dimensions)); - assert(isequal(size(r.rank_2_array_with_named_dimensions), [0, 0])); + r = test_model.RecordWithArrays(); - assert(isequal(r.rank_2_fixed_array, zeros(4, 3, 'int32'))); - assert(isequal(r.rank_2_fixed_array_with_named_dimensions, zeros(4, 3, 'int32'))); + testCase.verifyEqual(r.default_array, int32([])); + testCase.verifyThat(r.default_array_with_empty_dimension, IsEmpty); + testCase.verifyThat(r.rank_1_array, IsEmpty); + testCase.verifyThat(r.rank_2_array, IsEmpty); + testCase.verifyEqual(size(r.rank_2_array), [0, 0]); + testCase.verifyThat(r.rank_2_array_with_named_dimensions, IsEmpty); + testCase.verifyEqual(size(r.rank_2_array_with_named_dimensions), [0, 0]); - assert(isempty(r.dynamic_array)); - assert(isa(r.dynamic_array, 'int32')); + testCase.verifyEqual(r.rank_2_fixed_array, zeros(4, 3, 'int32')); + testCase.verifyEqual(r.rank_2_fixed_array_with_named_dimensions, zeros(4, 3, 'int32')); - assert(isa(r.array_of_vectors, 'int32')); - assert(isequal(size(r.array_of_vectors), [5, 4])); + testCase.verifyThat(r.dynamic_array, IsEmpty); + testCase.verifyThat(r.dynamic_array, IsInstanceOf('int32')); + + testCase.verifyThat(r.array_of_vectors, IsInstanceOf('int32')); + testCase.verifyEqual(size(r.array_of_vectors), [5, 4]); end function testDefaultRecordWithOptionalFields(testCase) - r = RecordWithOptionalFields(); + r = test_model.RecordWithOptionalFields(); - assert(r.optional_int == yardl.None); + testCase.verifyEqual(r.optional_int, yardl.None); end function testDefaultRecordWithUnionsOfContainers(testCase) - r = RecordWithUnionsOfContainers(); + r = test_model.RecordWithUnionsOfContainers(); - assert(r.map_or_scalar == MapOrScalar.Map(containers.Map)); - assert(r.vector_or_scalar == VectorOrScalar.Vector(int32([]))); - assert(r.array_or_scalar == ArrayOrScalar.Array(int32([]))); + testCase.verifyEqual(r.map_or_scalar, test_model.MapOrScalar.Map(containers.Map)); + testCase.verifyEqual(r.vector_or_scalar, test_model.VectorOrScalar.Vector(int32([]))); + testCase.verifyEqual(r.array_or_scalar, test_model.ArrayOrScalar.Array(int32([]))); end function testDefaultRecordWithAliasedGenerics(testCase) - r = RecordWithAliasedGenerics(); + r = test_model.RecordWithAliasedGenerics(); - assert(r.my_strings.v1 == ""); - assert(r.my_strings.v2 == ""); - assert(r.aliased_strings.v1 == ""); - assert(r.aliased_strings.v2 == ""); + testCase.verifyEqual(r.my_strings.v1, ""); + testCase.verifyEqual(r.my_strings.v2, ""); + testCase.verifyEqual(r.aliased_strings.v1, ""); + testCase.verifyEqual(r.aliased_strings.v2, ""); end function testDefaultRecordGenericEmpty(testCase) - g1 = RecordWithOptionalGenericField(); + g1 = test_model.RecordWithOptionalGenericField(); testCase.verifyEqual(g1.v, yardl.None); - g1a = RecordWithAliasedOptionalGenericField(); + g1a = test_model.RecordWithAliasedOptionalGenericField(); testCase.verifyEqual(g1a.v, g1.v); - g2 = RecordWithOptionalGenericUnionField(); + g2 = test_model.RecordWithOptionalGenericUnionField(); testCase.verifyEqual(g2.v, yardl.None); - g2a = RecordWithAliasedOptionalGenericUnionField(); + g2a = test_model.RecordWithAliasedOptionalGenericUnionField(); testCase.verifyEqual(g2a.v, g2.v) - testCase.verifyError(@() MyTuple(), 'MATLAB:minrhs'); - rm = RecordWithGenericMaps(); + testCase.verifyError(@() test_model.MyTuple(), 'MATLAB:minrhs'); + rm = test_model.RecordWithGenericMaps(); testCase.verifyEqual(rm.m, containers.Map()); testCase.verifyEqual(rm.am, rm.m); end function testDefaultRecordWithGenericRequiredArguments(testCase) - testCase.verifyError(@() RecordWithGenericArrays(), 'MATLAB:minrhs'); - testCase.verifyError(@() RecordWithGenericVectors(), 'MATLAB:minrhs'); - testCase.verifyError(@() RecordWithGenericFixedVectors(), 'MATLAB:minrhs'); + testCase.verifyError(@() test_model.RecordWithGenericArrays(), 'MATLAB:minrhs'); + testCase.verifyError(@() test_model.RecordWithGenericVectors(), 'MATLAB:minrhs'); + testCase.verifyError(@() test_model.RecordWithGenericFixedVectors(), 'MATLAB:minrhs'); end function testDefaultRecordContainingNestedGenericRecords(testCase) - r = RecordContainingNestedGenericRecords(); + r = test_model.RecordContainingNestedGenericRecords(); - g1 = RecordWithOptionalGenericField(); - g1a = RecordWithAliasedOptionalGenericField(); - g2 = RecordWithOptionalGenericUnionField(); - g2a = RecordWithAliasedOptionalGenericUnionField(); - g7 = RecordWithGenericMaps(); + g1 = test_model.RecordWithOptionalGenericField(); + g1a = test_model.RecordWithAliasedOptionalGenericField(); + g2 = test_model.RecordWithOptionalGenericUnionField(); + g2a = test_model.RecordWithAliasedOptionalGenericUnionField(); + g7 = test_model.RecordWithGenericMaps(); testCase.verifyEqual(r.f1, g1); testCase.verifyEqual(r.f1a, g1a); diff --git a/matlab/tests/ProtocolStateTestReader.m b/matlab/tests/ProtocolStateTestReader.m index c544e0e4..c803f060 100644 --- a/matlab/tests/ProtocolStateTestReader.m +++ b/matlab/tests/ProtocolStateTestReader.m @@ -1,4 +1,4 @@ -classdef ProtocolStateTestReader < StateTestReaderBase +classdef ProtocolStateTestReader < test_model.StateTestReaderBase methods (Access=protected) diff --git a/matlab/tests/ProtocolStateTestWriter.m b/matlab/tests/ProtocolStateTestWriter.m index dab837f2..ce6be5c0 100644 --- a/matlab/tests/ProtocolStateTestWriter.m +++ b/matlab/tests/ProtocolStateTestWriter.m @@ -1,4 +1,4 @@ -classdef ProtocolStateTestWriter < StateTestWriterBase +classdef ProtocolStateTestWriter < test_model.StateTestWriterBase methods (Access=protected) diff --git a/matlab/tests/run.m b/matlab/tests/run.m index f04cccad..f33d8210 100644 --- a/matlab/tests/run.m +++ b/matlab/tests/run.m @@ -1,7 +1,8 @@ -addpath("../generated/test_model/"); +addpath("../generated/"); run(YardlTypesTest); run(CodedStreamTest); run(ProtocolStateTest); + run(GeneratedTypesTest); run(EqualityTest); diff --git a/tooling/internal/matlab/binary/binary.go b/tooling/internal/matlab/binary/binary.go index 71a9d9be..8d8c7193 100644 --- a/tooling/internal/matlab/binary/binary.go +++ b/tooling/internal/matlab/binary/binary.go @@ -178,31 +178,31 @@ func recordSerializerClassName(record *dsl.RecordDefinition, contextNamespace st return className } -func typeDefinitionSerializer(t dsl.TypeDefinition, contextNamespace string) string { - switch t := t.(type) { +func typeDefinitionSerializer(td dsl.TypeDefinition, contextNamespace string) string { + switch td := td.(type) { case dsl.PrimitiveDefinition: - return fmt.Sprintf("yardl.binary.%sSerializer", formatting.ToPascalCase(string(t))) + return fmt.Sprintf("yardl.binary.%sSerializer", formatting.ToPascalCase(string(td))) case *dsl.EnumDefinition: var baseType dsl.Type - if t.BaseType != nil { - baseType = t.BaseType + if td.BaseType != nil { + baseType = td.BaseType } else { baseType = dsl.Int32Type } elementSerializer := typeSerializer(baseType, contextNamespace, nil) - return fmt.Sprintf("yardl.binary.EnumSerializer(%s, @%s)", elementSerializer, common.TypeSyntax(t, contextNamespace)) + return fmt.Sprintf("yardl.binary.EnumSerializer(%s, @%s)", elementSerializer, common.TypeSyntax(td, contextNamespace)) case *dsl.RecordDefinition: - serializerName := recordSerializerClassName(t, contextNamespace) - if len(t.TypeParameters) == 0 { + serializerName := recordSerializerClassName(td, contextNamespace) + if len(td.TypeParameters) == 0 { return fmt.Sprintf("%s()", serializerName) } - if len(t.TypeArguments) == 0 { + if len(td.TypeArguments) == 0 { panic("Expected type arguments") } - typeArguments := make([]string, 0, len(t.TypeArguments)) - for _, arg := range t.TypeArguments { + typeArguments := make([]string, 0, len(td.TypeArguments)) + for _, arg := range td.TypeArguments { typeArguments = append(typeArguments, typeSerializer(arg, contextNamespace, nil)) } @@ -212,11 +212,11 @@ func typeDefinitionSerializer(t dsl.TypeDefinition, contextNamespace string) str return fmt.Sprintf("%s(%s)", serializerName, strings.Join(typeArguments, ", ")) case *dsl.GenericTypeParameter: - return fmt.Sprintf("%s_serializer", formatting.ToSnakeCase(t.Name)) + return fmt.Sprintf("%s_serializer", formatting.ToSnakeCase(td.Name)) case *dsl.NamedType: - return typeSerializer(t.Type, contextNamespace, t) + return typeSerializer(td.Type, contextNamespace, td) default: - panic(fmt.Sprintf("Not implemented %T", t)) + panic(fmt.Sprintf("Not implemented %T", td)) } } @@ -235,7 +235,7 @@ func typeSerializer(t dsl.Type, contextNamespace string, namedType *dsl.NamedTyp return fmt.Sprintf("yardl.binary.OptionalSerializer(%s)", typeSerializer(t.Cases[1].Type, contextNamespace, namedType)) } - unionClassName, _ := common.UnionClassName(t) + unionClassName := common.UnionClassName(t) if namedType != nil { unionClassName = namedType.Name if namedType.Namespace != contextNamespace { diff --git a/tooling/internal/matlab/common/common.go b/tooling/internal/matlab/common/common.go index 39b97594..384c1199 100644 --- a/tooling/internal/matlab/common/common.go +++ b/tooling/internal/matlab/common/common.go @@ -62,14 +62,7 @@ var TypeSyntaxWriter dsl.TypeSyntaxWriter[string] = func(self dsl.TypeSyntaxWrit return TypeIdentifierName(t.Name) case dsl.TypeDefinition: meta := t.GetDefinitionMeta() - typeName := TypeIdentifierName(meta.Name) - if t.GetDefinitionMeta().Namespace != contextNamespace { - typeName = fmt.Sprintf("%s.%s", formatting.ToSnakeCase(meta.Namespace), typeName) - } - - typeSyntax := typeName - - return typeSyntax + return fmt.Sprintf("%s.%s", NamespaceIdentifierName(meta.Namespace), TypeIdentifierName(meta.Name)) case nil: return "None" @@ -84,7 +77,7 @@ var TypeSyntaxWriter dsl.TypeSyntaxWriter[string] = func(self dsl.TypeSyntaxWrit return "yardl.Optional" } - return UnionSyntax(t) + return UnionClassName(t) }() switch d := t.Dimensionality.(type) { @@ -99,35 +92,12 @@ var TypeSyntaxWriter dsl.TypeSyntaxWriter[string] = func(self dsl.TypeSyntaxWrit default: panic(fmt.Sprintf("unexpected type %T", t)) } - } func TypeSyntax(typeOrTypeDefinition dsl.Node, contextNamespace string) string { return TypeSyntaxWriter.ToSyntax(typeOrTypeDefinition, contextNamespace) } -var typeSyntaxWithoutTypeParametersWriter dsl.TypeSyntaxWriter[string] = func(self dsl.TypeSyntaxWriter[string], t dsl.Node, contextNamespace string) string { - switch t := t.(type) { - case dsl.TypeDefinition: - meta := t.GetDefinitionMeta() - if len(meta.TypeParameters) > 0 { - meta := t.GetDefinitionMeta() - typeName := TypeIdentifierName(meta.Name) - if t.GetDefinitionMeta().Namespace != contextNamespace { - typeName = fmt.Sprintf("%s.%s", formatting.ToSnakeCase(meta.Namespace), typeName) - } - - return typeName - } - } - - return TypeSyntaxWriter(self, t, contextNamespace) -} - -func TypeSyntaxWithoutTypeParameters(typeOrTypeDefinition dsl.Node, contextNamespace string) string { - return typeSyntaxWithoutTypeParametersWriter.ToSyntax(typeOrTypeDefinition, contextNamespace) -} - func ComputedFieldIdentifierName(name string) string { cased := formatting.ToSnakeCase(name) if !isReservedName[name] { @@ -171,7 +141,7 @@ func EnumValueIdentifierName(name string) string { return cased + "_" } -func UnionClassName(gt *dsl.GeneralizedType) (className string, typeParameters string) { +func UnionClassName(gt *dsl.GeneralizedType) (className string) { if !gt.Cases.IsUnion() { panic("Not a union") } @@ -184,25 +154,7 @@ func UnionClassName(gt *dsl.GeneralizedType) (className string, typeParameters s cases = append(cases, formatting.ToPascalCase(typeCase.Tag)) } - return strings.Join(cases, "Or"), "" -} - -func UnionSyntax(gt *dsl.GeneralizedType) string { - className, typeParameters := UnionClassName(gt) - var syntax string - if len(typeParameters) > 0 { - // TODO: Remove - syntax = fmt.Sprintf("%s[%s]", className, typeParameters) - } else { - syntax = className - } - - // TODO: Not needed in Matlab - // if gt.Cases.HasNullOption() { - // return fmt.Sprintf("typing.Optional[%s]", syntax) - // } - - return syntax + return strings.Join(cases, "Or") } func WriteBlockBody(w *formatting.IndentedWriter, f func()) { diff --git a/tooling/internal/matlab/matlab.go b/tooling/internal/matlab/matlab.go index 46eedd2b..31522495 100644 --- a/tooling/internal/matlab/matlab.go +++ b/tooling/internal/matlab/matlab.go @@ -8,7 +8,6 @@ import ( "os" "path" - "github.com/microsoft/yardl/tooling/internal/formatting" "github.com/microsoft/yardl/tooling/internal/iocommon" "github.com/microsoft/yardl/tooling/internal/matlab/binary" "github.com/microsoft/yardl/tooling/internal/matlab/common" @@ -22,25 +21,17 @@ import ( var staticFiles embed.FS func Generate(env *dsl.Environment, options packaging.MatlabCodegenOptions) error { - // common.AnnotateGenerics(env) - err := os.MkdirAll(options.OutputDir, 0775) if err != nil { return err } - topNamespace := env.GetTopLevelNamespace() - // topPackageDir := path.Join(options.OutputDir, common.PackageDir(topNamespace.Name)) - topPackageDir := path.Join(options.OutputDir, formatting.ToSnakeCase(topNamespace.Name)) - if err := iocommon.CopyEmbeddedStaticFiles(topPackageDir, options.InternalSymlinkStaticFiles, staticFiles); err != nil { + if err := iocommon.CopyEmbeddedStaticFiles(options.OutputDir, options.InternalSymlinkStaticFiles, staticFiles); err != nil { return err } for _, ns := range env.Namespaces { - packageDir := topPackageDir - if !ns.IsTopLevel { - packageDir = path.Join(packageDir, common.PackageDir(ns.Name)) - } + packageDir := path.Join(options.OutputDir, common.PackageDir(ns.Name)) if err := os.MkdirAll(packageDir, 0775); err != nil { return err diff --git a/tooling/internal/matlab/types/types.go b/tooling/internal/matlab/types/types.go index 2b43b03a..d4ecb894 100644 --- a/tooling/internal/matlab/types/types.go +++ b/tooling/internal/matlab/types/types.go @@ -57,14 +57,14 @@ func writeUnionClasses(fw *common.MatlabFileWriter, td dsl.TypeDefinition, union switch node := node.(type) { case *dsl.GeneralizedType: if node.Cases.IsUnion() { - unionClassName, typeParameters := common.UnionClassName(node) + unionClassName := common.UnionClassName(node) if !unionGenerated[unionClassName] { if _, isNamedType := td.(*dsl.NamedType); isNamedType { // This is a named type defining a union, so we will use the named type's name instead unionClassName = td.GetDefinitionMeta().Name } writeError = fw.WriteFile(unionClassName, func(w *formatting.IndentedWriter) { - writeUnionClass(w, unionClassName, typeParameters, node, td.GetDefinitionMeta().Namespace) + writeUnionClass(w, unionClassName, node, td.GetDefinitionMeta().Namespace) }) if writeError != nil { return @@ -79,7 +79,7 @@ func writeUnionClasses(fw *common.MatlabFileWriter, td dsl.TypeDefinition, union return writeError } -func writeUnionClass(w *formatting.IndentedWriter, className string, typeParameters string, generalizedType *dsl.GeneralizedType, contextNamespace string) error { +func writeUnionClass(w *formatting.IndentedWriter, className string, generalizedType *dsl.GeneralizedType, contextNamespace string) error { fmt.Fprintf(w, "classdef %s < yardl.Union\n", className) common.WriteBlockBody(w, func() { w.WriteStringln("methods (Static)") @@ -91,7 +91,7 @@ func writeUnionClass(w *formatting.IndentedWriter, className string, typeParamet fmt.Fprintf(w, "function res = %s(value)\n", formatting.ToPascalCase(tc.Tag)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "res = %s(%d, value);\n", className, i+1) + fmt.Fprintf(w, "res = %s.%s(%d, value);\n", common.NamespaceIdentifierName(contextNamespace), className, i+1) }) } }) @@ -101,15 +101,15 @@ func writeUnionClass(w *formatting.IndentedWriter, className string, typeParamet } func writeNamedType(fw *common.MatlabFileWriter, td *dsl.NamedType) error { - return fw.WriteFile(common.TypeSyntax(td, td.Namespace), func(w *formatting.IndentedWriter) { + return fw.WriteFile(common.TypeIdentifierName(td.Name), func(w *formatting.IndentedWriter) { common.WriteComment(w, td.Comment) - fmt.Fprintf(w, "classdef %s < %s\n", common.TypeSyntax(td, td.Namespace), common.TypeSyntax(td.Type, td.Namespace)) + fmt.Fprintf(w, "classdef %s < %s\n", common.TypeIdentifierName(td.Name), common.TypeSyntax(td.Type, td.Namespace)) w.WriteStringln("end") }) } func writeEnum(fw *common.MatlabFileWriter, enum *dsl.EnumDefinition) error { - return fw.WriteFile(common.TypeSyntax(enum, enum.Namespace), func(w *formatting.IndentedWriter) { + return fw.WriteFile(common.TypeIdentifierName(enum.Name), func(w *formatting.IndentedWriter) { var base string if enum.BaseType == nil { base = "uint64" @@ -118,8 +118,7 @@ func writeEnum(fw *common.MatlabFileWriter, enum *dsl.EnumDefinition) error { } common.WriteComment(w, enum.Comment) - enumTypeSyntax := common.TypeSyntax(enum, enum.Namespace) - fmt.Fprintf(w, "classdef %s < %s\n", enumTypeSyntax, base) + fmt.Fprintf(w, "classdef %s < %s\n", common.TypeIdentifierName(enum.Name), base) common.WriteBlockBody(w, func() { // NOTE: We don't use Matlab enumeration class because you can't inherit from it // and we use inheritance to define NamedTypes @@ -135,10 +134,10 @@ func writeEnum(fw *common.MatlabFileWriter, enum *dsl.EnumDefinition) error { } func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl.SymbolTable) error { - return fw.WriteFile(common.TypeSyntax(rec, rec.Namespace), func(w *formatting.IndentedWriter) { + return fw.WriteFile(common.TypeIdentifierName(rec.Name), func(w *formatting.IndentedWriter) { common.WriteComment(w, rec.Comment) - fmt.Fprintf(w, "classdef %s < handle\n", common.TypeSyntax(rec, rec.Namespace)) + fmt.Fprintf(w, "classdef %s < handle\n", common.TypeIdentifierName(rec.Name)) common.WriteBlockBody(w, func() { w.WriteStringln("properties") @@ -538,7 +537,7 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E self.VisitChildren(node) }) - unionClassName, _ := common.UnionClassName(targetType) + unionClassName := common.UnionClassName(targetType) if targetTypeNamespace != "" && targetTypeNamespace != contextNamespace { unionClassName = fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(targetTypeNamespace), unionClassName) } @@ -732,7 +731,9 @@ func typeDefault(t dsl.Type, contextNamespace string, namedType string, st dsl.S if namedType != "" { unionClassName = namedType } else { - unionClassName, _ = common.UnionClassName(t) + unionClassName = common.UnionClassName(t) + + unionClassName = fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(contextNamespace), unionClassName) } unionCaseConstructor := fmt.Sprintf("%s.%s", unionClassName, formatting.ToPascalCase(t.Cases[0].Tag)) @@ -779,8 +780,6 @@ func typeDefault(t dsl.Type, contextNamespace string, namedType string, st dsl.S return "", defaultValueKindNone } - dtype := common.TypeSyntax(scalar, contextNamespace) - if td.IsFixed() { dims := make([]string, len(*td.Dimensions)) for i, d := range *td.Dimensions { @@ -795,6 +794,8 @@ func typeDefault(t dsl.Type, contextNamespace string, namedType string, st dsl.S return fmt.Sprintf("repelem(%s, %s)", scalarDefault, strings.Join(dims, ", ")), defaultValueKindMutable } + dtype := common.TypeSyntax(scalar, contextNamespace) + if td.HasKnownNumberOfDimensions() { shape := strings.Repeat("0, ", len(*td.Dimensions))[0 : len(*td.Dimensions)*3-2] return fmt.Sprintf("%s.empty(%s)", dtype, shape), defaultValueKindMutable @@ -883,7 +884,7 @@ func typeDefinitionDefault(t dsl.TypeDefinition, contextNamespace string, st dsl } // Basic record type - return fmt.Sprintf("%s()", common.TypeSyntaxWithoutTypeParameters(t, contextNamespace)), defaultValueKindMutable + return fmt.Sprintf("%s()", common.TypeSyntax(t, contextNamespace)), defaultValueKindMutable } args := make([]string, 0) @@ -895,7 +896,7 @@ func typeDefinitionDefault(t dsl.TypeDefinition, contextNamespace string, st dsl args = append(args, fieldDefaultExpr) } - return fmt.Sprintf("%s(%s)", common.TypeSyntaxWithoutTypeParameters(t, contextNamespace), strings.Join(args, ", ")), defaultValueKindMutable + return fmt.Sprintf("%s(%s)", common.TypeSyntax(t, contextNamespace), strings.Join(args, ", ")), defaultValueKindMutable } return "", defaultValueKindNone From 9cb6d8bde2558cf1c3b92a8014fa13c3ac12a28f Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Fri, 22 Mar 2024 18:41:00 +0000 Subject: [PATCH 08/32] Add Matlab protocol round trip tests And lots of changes to Matlab codegen and supporting files. --- .devcontainer/Dockerfile | 17 +- .devcontainer/devcontainer.json | 3 +- matlab/tests/ComputedFieldsTest.m | 219 ++++++++ matlab/tests/EqualityTest.m | 3 + matlab/tests/GeneratedTypesTest.m | 6 +- matlab/tests/Node.m | 10 + matlab/tests/RoundTripTest.m | 488 ++++++++++++++++++ matlab/tests/YardlTypesTest.m | 75 +++ matlab/tests/run.m | 3 + models/test/_package.yml | 2 + tooling/internal/matlab/binary/binary.go | 55 +- tooling/internal/matlab/common/common.go | 19 +- tooling/internal/matlab/matlab.go | 42 +- tooling/internal/matlab/mocks/mocks.go | 181 +++++++ .../internal/matlab/protocols/protocols.go | 22 +- .../+binary/BinaryProtocolReader.m | 0 .../+binary/BinaryProtocolWriter.m | 0 .../{+yardl => }/+binary/BoolSerializer.m | 4 + .../+binary/CURRENT_BINARY_FORMAT_VERSION.m | 0 .../{+yardl => }/+binary/CodedInputStream.m | 0 .../{+yardl => }/+binary/CodedOutputStream.m | 0 .../+binary/Complexfloat32Serializer.m | 4 + .../+binary/Complexfloat64Serializer.m | 4 + .../static_files/+binary/DateSerializer.m | 23 + .../{+yardl => }/+binary/DatetimeSerializer.m | 5 +- .../+binary/DynamicNDArraySerializer.m | 0 .../{+yardl => }/+binary/EnumSerializer.m | 14 +- .../static_files/{+yardl => }/+binary/Error.m | 0 .../+binary/FixedNDArraySerializer.m | 4 +- .../+binary/FixedVectorSerializer.m | 4 + .../{+yardl => }/+binary/Float32Serializer.m | 4 + .../{+yardl => }/+binary/Float64Serializer.m | 4 + .../{+yardl => }/+binary/Int16Serializer.m | 4 + .../{+yardl => }/+binary/Int32Serializer.m | 4 + .../{+yardl => }/+binary/Int64Serializer.m | 4 + .../{+yardl => }/+binary/Int8Serializer.m | 4 + .../{+yardl => }/+binary/MAGIC_BYTES.m | 0 .../{+yardl => }/+binary/MapSerializer.m | 25 +- .../{+yardl => }/+binary/NDArraySerializer.m | 5 +- .../+binary/NDArraySerializerBase.m | 17 +- .../{+yardl => }/+binary/NoneSerializer.m | 4 + .../static_files/+binary/OptionalSerializer.m | 50 ++ .../{+yardl => }/+binary/RecordSerializer.m | 8 +- .../{+yardl => }/+binary/SizeSerializer.m | 0 .../{+yardl => }/+binary/StreamSerializer.m | 22 +- .../{+yardl => }/+binary/StringSerializer.m | 4 + .../{+yardl => }/+binary/TimeSerializer.m | 4 + .../{+yardl => }/+binary/TypeSerializer.m | 0 .../{+yardl => }/+binary/Uint16Serializer.m | 4 + .../{+yardl => }/+binary/Uint32Serializer.m | 4 + .../{+yardl => }/+binary/Uint64Serializer.m | 4 + .../{+yardl => }/+binary/Uint8Serializer.m | 4 + .../{+yardl => }/+binary/UnionSerializer.m | 40 +- .../{+yardl => }/+binary/VectorSerializer.m | 4 + .../+yardl/+binary/DateSerializer.m | 18 - .../+yardl/+binary/OptionalSerializer.m | 42 -- .../matlab/static_files/+yardl/None.m | 11 - .../matlab/static_files/+yardl/Optional.m | 28 - .../matlab/static_files/{+yardl => }/Date.m | 4 + .../static_files/{+yardl => }/DateTime.m | 4 + .../static_files/{+yardl => }/Exception.m | 0 .../static_files/{+yardl => }/KeyError.m | 0 tooling/internal/matlab/static_files/None.m | 32 ++ .../internal/matlab/static_files/Optional.m | 95 ++++ .../static_files/{+yardl => }/ProtocolError.m | 0 .../matlab/static_files/RuntimeError.m | 3 + .../matlab/static_files/{+yardl => }/Time.m | 4 + .../static_files/{+yardl => }/TypeError.m | 0 .../matlab/static_files/{+yardl => }/Union.m | 9 - .../static_files/{+yardl => }/ValueError.m | 0 .../matlab/static_files/dimension_count.m | 6 + tooling/internal/matlab/types/types.go | 291 +++++++++-- tooling/pkg/packaging/packageinfo.go | 1 + 73 files changed, 1699 insertions(+), 279 deletions(-) create mode 100644 matlab/tests/ComputedFieldsTest.m create mode 100644 matlab/tests/Node.m create mode 100644 matlab/tests/RoundTripTest.m create mode 100644 tooling/internal/matlab/mocks/mocks.go rename tooling/internal/matlab/static_files/{+yardl => }/+binary/BinaryProtocolReader.m (100%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/BinaryProtocolWriter.m (100%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/BoolSerializer.m (81%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/CURRENT_BINARY_FORMAT_VERSION.m (100%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/CodedInputStream.m (100%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/CodedOutputStream.m (100%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/Complexfloat32Serializer.m (89%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/Complexfloat64Serializer.m (87%) create mode 100755 tooling/internal/matlab/static_files/+binary/DateSerializer.m rename tooling/internal/matlab/static_files/{+yardl => }/+binary/DatetimeSerializer.m (86%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/DynamicNDArraySerializer.m (100%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/EnumSerializer.m (56%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/Error.m (100%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/FixedNDArraySerializer.m (75%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/FixedVectorSerializer.m (89%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/Float32Serializer.m (84%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/Float64Serializer.m (82%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/Int16Serializer.m (82%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/Int32Serializer.m (82%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/Int64Serializer.m (82%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/Int8Serializer.m (83%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/MAGIC_BYTES.m (100%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/MapSerializer.m (57%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/NDArraySerializer.m (85%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/NDArraySerializerBase.m (60%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/NoneSerializer.m (70%) create mode 100644 tooling/internal/matlab/static_files/+binary/OptionalSerializer.m rename tooling/internal/matlab/static_files/{+yardl => }/+binary/RecordSerializer.m (75%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/SizeSerializer.m (100%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/StreamSerializer.m (52%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/StringSerializer.m (86%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/TimeSerializer.m (86%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/TypeSerializer.m (100%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/Uint16Serializer.m (82%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/Uint32Serializer.m (82%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/Uint64Serializer.m (82%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/Uint8Serializer.m (82%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/UnionSerializer.m (53%) rename tooling/internal/matlab/static_files/{+yardl => }/+binary/VectorSerializer.m (88%) delete mode 100755 tooling/internal/matlab/static_files/+yardl/+binary/DateSerializer.m delete mode 100644 tooling/internal/matlab/static_files/+yardl/+binary/OptionalSerializer.m delete mode 100644 tooling/internal/matlab/static_files/+yardl/None.m delete mode 100644 tooling/internal/matlab/static_files/+yardl/Optional.m rename tooling/internal/matlab/static_files/{+yardl => }/Date.m (93%) rename tooling/internal/matlab/static_files/{+yardl => }/DateTime.m (95%) rename tooling/internal/matlab/static_files/{+yardl => }/Exception.m (100%) rename tooling/internal/matlab/static_files/{+yardl => }/KeyError.m (100%) create mode 100644 tooling/internal/matlab/static_files/None.m create mode 100644 tooling/internal/matlab/static_files/Optional.m rename tooling/internal/matlab/static_files/{+yardl => }/ProtocolError.m (100%) create mode 100644 tooling/internal/matlab/static_files/RuntimeError.m rename tooling/internal/matlab/static_files/{+yardl => }/Time.m (96%) rename tooling/internal/matlab/static_files/{+yardl => }/TypeError.m (100%) rename tooling/internal/matlab/static_files/{+yardl => }/Union.m (73%) rename tooling/internal/matlab/static_files/{+yardl => }/ValueError.m (100%) create mode 100644 tooling/internal/matlab/static_files/dimension_count.m diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 6d8dc8ae..25b11af1 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -122,6 +122,10 @@ RUN . /opt/conda/etc/profile.d/conda.sh \ ######################################################### # Install Matlab # Based on mathworks/{matlab-deps:r2023b,matlab:r2023b} +# +# Configure the Matlab License Server to use Matlab within the devcontainer (including VSCode extensions): +# In your HOST environment, export the environment variable MATLAB_LICENSE_FILE, e.g. +# export MATLAB_LICENSE_FILE=/mnt/c/Users/username/Documents/MATLAB/license.lic ######################################################### ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" @@ -153,6 +157,8 @@ RUN adduser --shell /bin/bash --disabled-password --gecos "" matlab \ USER matlab WORKDIR /home/matlab +ENV MLM_LICENSE_FILE=${LICENSE_SERVER} + RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm \ && chmod +x mpm \ && sudo HOME=${HOME} ./mpm install \ @@ -161,12 +167,5 @@ RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm \ --products ${MATLAB_PRODUCT_LIST} \ || (echo "MPM Installation Failure. See below for more information:" && cat /tmp/mathworks_root.log && false) \ && sudo rm -f mpm /tmp/mathworks_root.log \ - && sudo ln -s ${MATLAB_INSTALL_LOCATION}/bin/matlab /usr/local/bin/matlab - -# Configure the Matlab License Servier -# Option 1: Specify the host and port of the machine that serves the network licenses -# e.g. ENV MLM_LICENSE_FILE=27000@flexlm-server-name -ENV MLM_LICENSE_FILE=$LICENSE_SERVER - -# Option 2: Alternatively, copy your network license file into the container. -# COPY Network.lic ${MATLAB_INSTALL_LOCATION}/licenses/ + && sudo ln -s ${MATLAB_INSTALL_LOCATION}/bin/matlab /usr/local/bin/matlab \ + && sudo ln -s ${MATLAB_INSTALL_LOCATION} /opt/matlab/latest diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9cb0f896..93545a0c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -10,7 +10,8 @@ "overrideCommand": false, "mounts": [ // Bind mount docker socket under an alias to support docker-from-docker - "source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind" + "source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind", + "source=${localEnv:MATLAB_LICENSE_FILE:/dev/null},target=/opt/matlab/latest/licenses/license.lic,type=bind" ], "remoteUser": "vscode", diff --git a/matlab/tests/ComputedFieldsTest.m b/matlab/tests/ComputedFieldsTest.m new file mode 100644 index 00000000..4f27b55d --- /dev/null +++ b/matlab/tests/ComputedFieldsTest.m @@ -0,0 +1,219 @@ +classdef ComputedFieldsTest < matlab.unittest.TestCase + methods (Test) + + function testFieldAccess(testCase) + r = test_model.RecordWithComputedFields(); + + r.int_field = 42; + testCase.verifyEqual(r.access_int_field(), 42); + + r.string_field = "hello"; + testCase.verifyEqual(r.access_string_field(), "hello"); + + r.tuple_field = test_model.MyTuple(1, 1); + testCase.verifyEqual(r.access_tuple_field(), r.tuple_field); + testCase.verifyEqual(r.access_nested_tuple_field(), r.tuple_field.v2); + + r.array_field = int32([[1, 2, 3]; [4, 5, 6]]); + testCase.verifyEqual(r.access_array_field(), r.array_field); + testCase.verifyEqual(r.access_array_field_element(), r.array_field(1, 2)); + testCase.verifyEqual(r.access_array_field_element_by_name(), r.array_field(1, 2)); + + testCase.verifyEqual(r.access_other_computed_field(), r.access_int_field()); + + r.vector_of_vectors_field = [[1, 2, 3]; [4, 5, 6]]; + testCase.verifyEqual(r.access_vector_of_vectors_field(), r.vector_of_vectors_field(2, 3)); + + % NOTE: containers.Map supports only `char` keys/values, not `string` + r.map_field = containers.Map(["hello", "world"], ["world", "bye"], 'UniformValues', true); + testCase.verifyEqual(r.access_map(), r.map_field); + testCase.verifyEqual(r.access_map_entry(), 'world'); + testCase.verifyEqual(r.access_map_entry_with_computed_field(), 'world'); + testCase.verifyEqual(r.access_map_entry_with_computed_field_nested(), 'bye'); + + testCase.verifyError(@() r.access_missing_map_entry(), "MATLAB:Containers:Map:NoKey"); + end + + function testLiterals(testCase) + r = test_model.RecordWithComputedFields(); + testCase.verifyEqual(r.int_literal(), 42); + testCase.verifyEqual(int64(r.large_negative_int64_literal()), -int64(0x4000000000000000)); + testCase.verifyEqual(uint64(r.large_u_int64_literal()), 0x8000000000000000); + testCase.verifyEqual(r.string_literal(), "hello"); + end + + function testDimensionIndex(testCase) + r = test_model.RecordWithComputedFields(); + + testCase.verifyEqual(r.array_dimension_x_index(), 1); + testCase.verifyEqual(r.array_dimension_y_index(), 2); + + r.string_field = "y"; + testCase.verifyEqual(r.array_dimension_index_from_string_field(), 2); + + r.string_field = "missing"; + testCase.verifyError(@() r.array_dimension_index_from_string_field(), "yardl:KeyError"); + end + + function testDimensionCount(testCase) + r = test_model.RecordWithComputedFields(); + + testCase.verifyEqual(r.array_dimension_count(), 2); + + r.dynamic_array_field = int32([[1, 2, 3]; [4, 5, 6]]); + testCase.verifyEqual(r.dynamic_array_dimension_count(), 2); + r.dynamic_array_field = int32([1, 2, 3]); + testCase.verifyEqual(r.dynamic_array_dimension_count(), 1); + end + + function testVectorSize(testCase) + r = test_model.RecordWithComputedFields(); + testCase.verifyEqual(r.vector_size(), 0); + r.vector_field = [1, 2, 3, 4]; + testCase.verifyEqual(r.vector_size(), 4); + + testCase.verifyEqual(r.fixed_vector_size(), 3); + end + + function testMapSize(testCase) + r = test_model.RecordWithComputedFields(); + testCase.verifyEqual(r.map_size(), 0); + % r.map_field = containers.Map(["hello", "bonjour"], ["world", "monde"], 'UniformValues', true); + r.map_field = dictionary(["hello", "bonjour"], ["world", "monde"]); + testCase.verifyEqual(r.map_size(), 2); + end + + function testArraySize(testCase) + %%%%%%%%%%%%%%%%%%%%%% + % TODO: Fix 1-based array indexing + testCase.assumeFail(); + + r = test_model.RecordWithComputedFields(); + r.array_field = int32([[1, 2, 3]; [4, 5, 6]]); + + testCase.verifyEqual(r.array_size(), 6); + testCase.verifyEqual(r.array_x_size(), 2); + testCase.verifyEqual(r.array_y_size(), 3); + testCase.verifyEqual(r.array_0_size(), 2); + testCase.verifyEqual(r.array_1_size(), 3); + + + testCase.verifyEqual(r.array_size_from_int_field(), 2); + r.int_field = 1; + testCase.verifyEqual(r.array_size_from_int_field(), 3); + + % TODO: Bug in computed field codegen 1-based indexing! + r.string_field = "x"; + testCase.verifyEqual(r.array_size_from_string_field(), 2); + r.string_field = "y"; + testCase.verifyEqual(r.array_size_from_string_field(), 3); + + r.string_field = "missing"; + testCase.verifyError(@() r.array_size_from_string_field(), "yardl:KeyError"); + + r.tuple_field.v1 = 1; + testCase.verifyEqual(r.array_size_from_nested_int_field(), 3); + testCase.verifyEqual(r.fixed_array_size(), numel(r.fixed_array_field)); + % TODO: Bug in dimension ordering... + testCase.verifyEqual(r.fixed_array_x_size(), size(r.fixed_array_field, 1)); + testCase.verifyEqual(r.fixed_array_0_size(), size(r.fixed_array_field, 1)); + + r.array_field_map_dimensions = int32([[1, 2, 3]; [4, 5, 6]]); + testCase.verifyEqual(r.array_field_map_dimensions_x_size(), 2); + end + + function testSwitch(testCase) + %%%%%%%%%%%%%%%%%%%%%% + % TODO: Fix Optionals elsewhere before fixing computed switch statements + testCase.assumeFail(); + + r = test_model.RecordWithComputedFields(); + r.optional_named_array = int32([[1, 2, 3]; [4, 5, 6]]); + testCase.verifyEqual(r.optional_named_array_length(), 6); + testCase.verifyEqual(r.optional_named_array_length_with_discard(), 6); + + r.optional_named_array = yardl.None; + testCase.verifyEqual(r.optional_named_array_length(), 0); + testCase.verifyEqual(r.optional_named_array_length_with_discard(), 0); + + r.int_float_union = test_model.Int32OrFloat32.Int32(int32(42)); + testCase.verifyEqual(r.int_float_union_as_float(), single(42)); + r.int_float_union = test_model.Int32OrFloat32.Float32(single(42.9)); + testCase.verifyEqual(r.int_float_union_as_float(), single(42.9)); + + r.nullable_int_float_union = yardl.None; + testCase.verifyEqual(r.nullable_int_float_union_string(), "null"); + r.nullable_int_float_union = test_model.Int32OrFloat32.Int32(42); + testCase.verifyEqual(r.nullable_int_float_union_string(), "int"); + r.nullable_int_float_union = test_model.Int32OrFloat32.Float32(42.9); + testCase.verifyEqual(r.nullable_int_float_union_string(), "float"); + + r.union_with_nested_generic_union = test_model.IntOrGenericRecordWithComputedFields.Int(42); + testCase.verifyEqual(r.nested_switch(), -1); + testCase.verifyEqual(r.use_nested_computed_field(), -1); + + g0 = basic_types.GenericRecordWithComputedFields(basic_types.T0OrT1.T0("hi")); + r.union_with_nested_generic_union = ... + test_model.IntOrGenericRecordWithComputedFields.GenericRecordWithComputedFields(g0); + testCase.verifyEqual(r.nested_switch(), int32(10)); + testCase.verifyEqual(r.use_nested_computed_field(), int32(0)); + + g1 = basic_types.GenericRecordWithComputedFields(basic_types.T0OrT1.T1(single(42.9))); + r.union_with_nested_generic_union = ... + test_model.IntOrGenericRecordWithComputedFields.GenericRecordWithComputedFields(g1); + testCase.verifyEqual(r.nested_switch(), int32(20)); + testCase.verifyEqual(r.use_nested_computed_field(), int32(1)); + + r.int_field = int32(10); + testCase.verifyEqual(r.switch_over_single_value(), int32(10)); + + + gr = basic_types.GenericRecordWithComputedFields(basic_types.T0OrT1.T0(int32(42))); + testCase.verifyEqual(gr.type_index(), 0); + gr.f1 = basic_types.T0OrT1.T1(single(42.9)); + testCase.verifyEqual(gr.type_index(), 1); + end + + function testArithmetic(testCase) + r = test_model.RecordWithComputedFields(); + testCase.verifyEqual(r.arithmetic_1(), 3); + testCase.verifyEqual(r.arithmetic_2(), 11); + testCase.verifyEqual(r.arithmetic_3(), 13); + + r.array_field = int32([[1, 2, 3]; [4, 5, 6]]); + r.int_field = 1; + testCase.verifyEqual(r.arithmetic_4(), 5); + testCase.verifyEqual(r.arithmetic_5(), 3); + + testCase.verifyEqual(r.arithmetic_6(), 3.5); + + testCase.verifyEqual(r.arithmetic_7(), 49.0); + + r.complexfloat32_field = complex(2, 3); + testCase.verifyEqual(r.arithmetic8(), single(complex(6, 9))); + + testCase.verifyEqual(r.arithmetic_9(), 2.2); + testCase.verifyEqual(r.arithmetic_10(), 1e10 + 9e9); + end + + function testCasting(testCase) + r = test_model.RecordWithComputedFields(); + r.int_field = int32(42); + testCase.verifyEqual(r.cast_int_to_float(), single(42)); + + r.float32_field = 42.9; + % NOTE: Matlab rounds floating point numbers when casting to integer + testCase.verifyEqual(r.cast_float_to_int(), int32(43)); + + testCase.verifyEqual(r.cast_power(), int32(49)); + + r.complexfloat32_field = single(complex(2, 3)); + r.complexfloat64_field = complex(2, 3); + testCase.verifyEqual(r.cast_complex32_to_complex64(), complex(2, 3)); + testCase.verifyEqual(r.cast_complex64_to_complex32(), single(complex(2, 3))); + + testCase.verifyEqual(r.cast_float_to_complex(), complex(single(66.6), 0)); + end + + end +end diff --git a/matlab/tests/EqualityTest.m b/matlab/tests/EqualityTest.m index 33c7b4c7..335995cb 100644 --- a/matlab/tests/EqualityTest.m +++ b/matlab/tests/EqualityTest.m @@ -1,6 +1,9 @@ classdef EqualityTest < matlab.unittest.TestCase methods (Test) + % TODO: Add tests for equality of *arrays* of each type, + % since Matlab eq method applies to both scalar and non-scalar values + function testSimpleEquality(testCase) a = test_model.SimpleRecord(1, 2, 3); b = test_model.SimpleRecord(1, 2, 3); diff --git a/matlab/tests/GeneratedTypesTest.m b/matlab/tests/GeneratedTypesTest.m index 986f0c83..5f60e621 100644 --- a/matlab/tests/GeneratedTypesTest.m +++ b/matlab/tests/GeneratedTypesTest.m @@ -52,7 +52,8 @@ function testDefaultRecordWithOptionalFields(testCase) function testDefaultRecordWithUnionsOfContainers(testCase) r = test_model.RecordWithUnionsOfContainers(); - testCase.verifyEqual(r.map_or_scalar, test_model.MapOrScalar.Map(containers.Map)); + % testCase.verifyEqual(r.map_or_scalar, test_model.MapOrScalar.Map(containers.Map)); + testCase.verifyEqual(r.map_or_scalar, test_model.MapOrScalar.Map(dictionary)); testCase.verifyEqual(r.vector_or_scalar, test_model.VectorOrScalar.Vector(int32([]))); testCase.verifyEqual(r.array_or_scalar, test_model.ArrayOrScalar.Array(int32([]))); end @@ -81,7 +82,8 @@ function testDefaultRecordGenericEmpty(testCase) testCase.verifyError(@() test_model.MyTuple(), 'MATLAB:minrhs'); rm = test_model.RecordWithGenericMaps(); - testCase.verifyEqual(rm.m, containers.Map()); + % testCase.verifyEqual(rm.m, containers.Map()); + testCase.verifyEqual(rm.m, dictionary); testCase.verifyEqual(rm.am, rm.m); end diff --git a/matlab/tests/Node.m b/matlab/tests/Node.m new file mode 100644 index 00000000..c73e8a83 --- /dev/null +++ b/matlab/tests/Node.m @@ -0,0 +1,10 @@ +classdef Node < handle + properties + value + end + methods + function obj = Node(value) + obj.value = value; + end + end +end diff --git a/matlab/tests/RoundTripTest.m b/matlab/tests/RoundTripTest.m new file mode 100644 index 00000000..77c21569 --- /dev/null +++ b/matlab/tests/RoundTripTest.m @@ -0,0 +1,488 @@ +classdef RoundTripTest < matlab.unittest.TestCase + properties (TestParameter) + % format = {"Binary", "NDJson"}; + format = {"Binary"}; + end + + methods (Test) + + function testScalarPrimitives(testCase, format) + rec = test_model.RecordWithPrimitives(); + rec.bool_field = true; + rec.int8_field = int8(-88); + rec.uint8_field = uint8(88); + rec.int16_field = int16(-1616); + rec.uint16_field = uint16(1616); + rec.int32_field = int32(-3232); + rec.uint32_field = uint32(3232); + rec.int64_field = int64(-64646464); + rec.uint64_field = uint64(64646464); + rec.size_field = uint64(64646464); + rec.float32_field = single(32.0); + rec.float64_field = double(64.64); + rec.complexfloat32_field = single(complex(32.0, 64.0)); + rec.complexfloat64_field = 64.64 + 32.32j; + rec.date_field = yardl.Date.from_components(2024, 4, 2); + rec.time_field = yardl.Time.from_components(12, 34, 56, 0); + rec.datetime_field = yardl.DateTime.from_components(2024, 4, 2, 12, 34, 56, 111222333); + + w = create_validating_writer(testCase, format, 'Scalars'); + w.write_int32(int32(42)) + w.write_record(rec) + w.close(); + end + + function testScalarOptionals(testCase, format) + w = create_validating_writer(testCase, format, 'ScalarOptionals'); + w.write_optional_int(yardl.None); + w.write_optional_record(yardl.None); + w.write_record_with_optional_fields(test_model.RecordWithOptionalFields()); + w.write_optional_record_with_optional_fields(yardl.None); + w.close(); + + w = create_validating_writer(testCase, format, 'ScalarOptionals'); + w.write_optional_int(int32(55)); + w.write_optional_record(test_model.SimpleRecord(8, 9, 10)); + w.write_record_with_optional_fields(... + test_model.RecordWithOptionalFields(int32(44), int32(44), yardl.Time.from_components(12, 34, 56, 0))); + w.write_optional_record_with_optional_fields(... + test_model.RecordWithOptionalFields(int32(12), int32(12), yardl.Time.from_components(11, 32, 26, 0))); + w.close(); + end + + function testNestedRecords(testCase, format) + w = create_validating_writer(testCase, format, 'NestedRecords'); + t = test_model.TupleWithRecords(... + test_model.SimpleRecord(1, 2, 3), ... + test_model.SimpleRecord(4, 5, 6)); + w.write_tuple_with_records(t); + w.close(); + end + + function testVariableLengthVectors(testCase, format) + w = create_validating_writer(testCase, format, 'Vlens'); + w.write_int_vector(int32([1, 2, 3])); + w.write_complex_vector(single([1+2j, 3+4j])); + rec = test_model.RecordWithVlens(... + [test_model.SimpleRecord(1, 2, 3), test_model.SimpleRecord(4, 5, 6)], ... + 4, ... + 2 ... + ); + w.write_record_with_vlens(rec); + w.write_vlen_of_record_with_vlens([rec, rec]); + w.close(); + end + + function testStrings(testCase, format) + w = create_validating_writer(testCase, format, 'Strings'); + w.write_single_string("hello"); + w.write_rec_with_string(test_model.RecordWithStrings("Montréal", "臺北市")); + w.close(); + end + + function testOptionalVectors(testCase, format) + w = create_validating_writer(testCase, format, 'OptionalVectors'); + w.write_record_with_optional_vector(test_model.RecordWithOptionalVector()); + w.close(); + + w = create_validating_writer(testCase, format, 'OptionalVectors'); + w.write_record_with_optional_vector(test_model.RecordWithOptionalVector(int32([1, 2, 3]))); + w.close(); + end + + function testFixedVectors(testCase, format) + ints = int32([1, 2, 3, 4, 5]); + SR = @test_model.SimpleRecord; + simple_recs = [SR(1, 2, 3), SR(4, 5, 6), SR(7, 8, 9)]; + RV = @test_model.RecordWithVlens; + vlens_recs = [RV([SR(1, 2, 3), SR(4, 5, 6)], 4, 2), RV([SR(7, 8, 9), SR(10, 11, 12)], 5, 3)]; + rec_with_fixed = test_model.RecordWithFixedVectors(ints, simple_recs, vlens_recs); + + w = create_validating_writer(testCase, format, 'FixedVectors'); + w.write_fixed_int_vector(ints); + w.write_fixed_simple_record_vector(simple_recs); + w.write_fixed_record_with_vlens_vector(vlens_recs); + w.write_record_with_fixed_vectors(rec_with_fixed); + w.close(); + end + + function testFixedArrays(testCase, format) + ints = int32([[1, 2, 3]; [4, 5, 6]]); + ints = transpose(ints); + + SR = @test_model.SimpleRecord; + simple_recs = [... + [SR(1, 2, 3), SR(4, 5, 6)]; ... + [SR(11, 12, 13), SR(14, 15, 16)]; ... + [SR(21, 22, 23), SR(24, 25, 26)] ... + ]; + simple_recs = transpose(simple_recs); + + RV = @test_model.RecordWithVlens; + vlens_recs = [... + [... + RV([SR(1, 2, 3), SR(7, 8, 9)], 13, 14), ... + RV([SR(7, 8, 9), SR(10, 11, 12)], 5, 3)]; ... + [... + RV([SR(31, 32, 33), SR(34, 35, 36), SR(37, 38, 39)], 213, 214), ... + RV([SR(41, 42, 43)], 313, 314)] ... + ]; + vlens_recs = transpose(vlens_recs); + + rec_with_fixed = test_model.RecordWithFixedArrays(ints, simple_recs, vlens_recs); + + w = create_validating_writer(testCase, format, 'FixedArrays'); + w.write_ints(ints); + w.write_fixed_simple_record_array(simple_recs); + w.write_fixed_record_with_vlens_array(vlens_recs); + w.write_record_with_fixed_arrays(rec_with_fixed); + + % TODO: Like in Python, named fixed arrays are kind of broken since it + % doesn't seem to be possible to specify the shape of the array in the type + named_fixed_array = transpose(int32([[1, 2, 3, 4]; [5, 6, 7, 8]])); + w.write_named_array(named_fixed_array) + w.close(); + end + + function testSubarrays(testCase, format) + % TODO: Gotta figure out the (Python) subarray logic (in Matlab) + testCase.assumeFail(); + + w = create_validating_writer(testCase, format, 'Subarrays'); + + ints = transpose(int32([[1, 2, 3]; [4, 5, 6]])); + w.write_dynamic_with_fixed_int_subarray(ints); + + floats = transpose(single([[1, 2, 3]; [4, 5, 6]])); + w.write_dynamic_with_fixed_float_subarray(floats); + + ints = transpose(int32([[1, 2, 3]; [4, 5, 6]])); + w.write_known_dim_count_with_fixed_int_subarray(ints); + + floats = transpose(single([[1, 2, 3]; [4, 5, 6]])); + w.write_known_dim_count_with_fixed_float_subarray(floats); + + ints = transpose(int32([[1, 2, 3]; [4, 5, 6]])); + w.write_fixed_with_fixed_int_subarray(ints); + + floats = transpose(single([[1, 2, 3]; [4, 5, 6]])); + w.write_fixed_with_fixed_float_subarray(floats); + + ints = transpose(int32([... + [[1, 2, 3]; [4, 5, 6]]; ... + [[10, 20, 30]; [40, 50, 60]]; ... + [[100, 200, 300]; [400, 500, 600]] ... + ])); + w.write_nested_subarray(ints); + + ints = transpose(int32([[1, 2, 3]; [4, 5, 6]])); + w.write_dynamic_with_fixed_vector_subarray(ints); + + images = transpose(int32([... + [[1, 2, 3]; [4, 5, 6]]; ... + [[10, 11, 12]; [13, 14, 15]]; ... + ])); + w.write_generic_subarray(images); + + w.close(); + end + + function testSubarraysInRecords(testCase, format) + % TODO: Gotta figure out the (Python) subarray logic (in Matlab) + testCase.assumeFail(); + end + + function testNDArrays(testCase, format) + ints = transpose(int32([[1, 2, 3]; [4, 5, 6]])); + + SR = @test_model.SimpleRecord; + simple_recs = [... + [SR(1, 2, 3), SR(4, 5, 6)]; ... + [SR(11, 12, 13), SR(14, 15, 16)]; ... + [SR(21, 22, 23), SR(24, 25, 26)] ... + ]; + simple_recs = transpose(simple_recs); + + RV = @test_model.RecordWithVlens; + vlens_recs = [... + [... + RV([SR(1, 2, 3), SR(7, 8, 9)], 13, 14), ... + RV([SR(7, 8, 9), SR(10, 11, 12)], 5, 3)]; ... + [... + RV([SR(31, 32, 33), SR(34, 35, 36), SR(37, 38, 39)], 213, 214), ... + RV([SR(41, 42, 43)], 313, 314)] ... + ]; + vlens_recs = transpose(vlens_recs); + + rec_with_nds = test_model.RecordWithNDArrays(ints, simple_recs, vlens_recs); + + w = create_validating_writer(testCase, format, 'NDArrays'); + w.write_ints(ints); + w.write_simple_record_array(simple_recs); + w.write_record_with_vlens_array(vlens_recs); + w.write_record_with_nd_arrays(rec_with_nds); + w.write_named_array(ints); + w.close(); + end + + function testDynamicNDArrays(testCase, format) + ints = transpose(int32([[1, 2, 3]; [4, 5, 6]; [7, 8, 9]; [10, 11, 12]])); + SR = @test_model.SimpleRecord; + simple_recs = transpose([... + [SR(1, 2, 3), SR(4, 5, 6), SR(7, 8, 9)]; ... + [SR(11, 12, 13), SR(14, 15, 16), SR(17, 18, 19)]; ... + ]); + RV = @test_model.RecordWithVlens; + vlens_recs = transpose([... + [RV([SR(1, 2, 3)], -33, 44)]; ... + [RV([SR(8, 2, 9), SR(28, 3, 34)], 233, 347)] ... + ]); + rec_with_dynamic_nds = test_model.RecordWithDynamicNDArrays(ints, simple_recs, vlens_recs); + + w = create_validating_writer(testCase, format, 'DynamicNDArrays'); + w.write_ints(ints); + w.write_simple_record_array(simple_recs); + w.write_record_with_vlens_array(vlens_recs); + w.write_record_with_dynamic_nd_arrays(rec_with_dynamic_nds); + w.close(); + end + + function testMaps(testCase, format) + % d = containers.Map('KeyType', 'char', 'ValueType', 'int32'); + d = dictionary(); + d("a") = int32(1); + d("b") = 2; + d("c") = 3; + + w = create_validating_writer(testCase, format, 'Maps'); + w.write_string_to_int(d); + + % TODO: Need to use R2022b 'dictionary' to properly build the map in MapSerializer.read + % i.e. an "empty" containers.Map() has a KeyType of 'char' + % w.write_int_to_string(containers.Map(int32([1, 2, 3]), ["a", "b", "c"])); + w.write_int_to_string(dictionary(int32([1, 2, 3]), ["a", "b", "c"])); + + % TODO: Need to use R2022b `dictionary` to store objects as values... + % w.write_string_to_union(... + % containers.Map(... + % ["a", "b"], ... + % [test_model.StringOrInt32.Int32(1), test_model.StringOrInt32.String("2")] ... + % ) ... + % ); + w.write_string_to_union(... + dictionary(... + ["a", "b"], ... + [test_model.StringOrInt32.Int32(1), test_model.StringOrInt32.String("2")] ... + ) ... + ); + + w.write_aliased_generic(d); + w.close(); + end + + function testUnions(testCase, format) + w = create_validating_writer(testCase, format, 'Unions'); + w.write_int_or_simple_record(test_model.Int32OrSimpleRecord.Int32(1)); + w.write_int_or_record_with_vlens(test_model.Int32OrRecordWithVlens.Int32(2)); + w.write_monosotate_or_int_or_simple_record(yardl.None); + w.write_record_with_unions(basic_types.RecordWithUnions()); + w.close(); + + w = create_validating_writer(testCase, format, 'Unions'); + w.write_int_or_simple_record(test_model.Int32OrSimpleRecord.SimpleRecord(test_model.SimpleRecord(1, 2, 3))); + w.write_int_or_record_with_vlens(test_model.Int32OrRecordWithVlens.RecordWithVlens(test_model.RecordWithVlens([test_model.SimpleRecord(1, 2, 3)], 12, 13))); + w.write_monosotate_or_int_or_simple_record(test_model.Int32OrSimpleRecord.Int32(6)); + w.write_record_with_unions(basic_types.RecordWithUnions(... + basic_types.Int32OrString.Int32(7), ... + basic_types.TimeOrDatetime.Datetime(yardl.DateTime.from_components(2025, 3, 4, 12, 34, 56, 0)), ... + basic_types.GenericNullableUnion2.T1(basic_types.Fruits.APPLE) ... + )); + w.close(); + end + + function testEnums(testCase, format) + w = create_validating_writer(testCase, format, 'Enums'); + w.write_single(test_model.Fruits.APPLE); + w.write_vec([test_model.Fruits.APPLE, test_model.Fruits.BANANA, test_model.Fruits(233983)]); + w.write_size(test_model.SizeBasedEnum.C); + w.close(); + end + + function testFlags(testCase, format) + w = create_validating_writer(testCase, format, 'Flags'); + + mon_or_wed_or_fri = bitor(bitor(test_model.DaysOfWeek.MONDAY, test_model.DaysOfWeek.WEDNESDAY), test_model.DaysOfWeek.FRIDAY); + w.write_days([... + test_model.DaysOfWeek.SUNDAY, ... + test_model.DaysOfWeek(mon_or_wed_or_fri), ... +... % bitor(bitor(test_model.DaysOfWeek.MONDAY, test_model.DaysOfWeek.WEDNESDAY), test_model.DaysOfWeek.FRIDAY), ... + test_model.DaysOfWeek(0), ... + test_model.DaysOfWeek(282839), ... + test_model.DaysOfWeek(234532) ... + ]); + + w.write_formats([... + test_model.TextFormat.BOLD, ... + bitor(test_model.TextFormat.BOLD, test_model.TextFormat.ITALIC), ... + test_model.TextFormat.REGULAR, ... + test_model.TextFormat(232932) ... + ]); + + w.close(); + end + + function testSimpleStreams(testCase, format) + % TODO: Need to fix Stream read/write of multidimensional arrays (see write_fixed_vector) + testCase.assumeFail(); + + w = create_validating_writer(testCase, format, 'Streams'); + + % TODO: MockWriter can't yet handle multiple stream write calls (the result of read is always the full concatenated stream) + % w.write_int_data(int32(1:10)); + % w.write_int_data(int32(1:20)); + w.write_int_data(int32(1:30)); + + w.write_optional_int_data([1, 2, yardl.None, 4, 5, yardl.None, 7, 8, 9, 10]); + w.write_record_with_optional_vector_data([... + test_model.RecordWithOptionalVector(), ... + test_model.RecordWithOptionalVector(int32([1, 2, 3])), ... + test_model.RecordWithOptionalVector(int32(1:10)) ... + ]); + w.write_fixed_vector(... + transpose([... + [1, 2, 3]; [1, 2, 3]; [1, 2, 3]; [1, 2, 3]; + ])... + ); + w.close(); + + w = create_validating_writer(testCase, format, 'Streams'); + w.write_int_data([]); + w.write_optional_int_data([]); + w.write_record_with_optional_vector_data([]); + w.write_fixed_vector([]); + w.close(); + end + + function testStreamsOfUnions(testCase, format) + w = create_validating_writer(testCase, format, 'StreamsOfUnions'); + w.write_int_or_simple_record([... + test_model.Int32OrSimpleRecord.Int32(1), ... + test_model.Int32OrSimpleRecord.SimpleRecord(test_model.SimpleRecord(1, 2, 3)), ... + test_model.Int32OrSimpleRecord.Int32(2) ... + ]); + w.write_nullable_int_or_simple_record([... + yardl.None, ... + test_model.Int32OrSimpleRecord.Int32(1), ... + test_model.Int32OrSimpleRecord.SimpleRecord(test_model.SimpleRecord(1, 2, 3)), ... + yardl.None, ... + test_model.Int32OrSimpleRecord.Int32(2), ... + yardl.None ... + ]); + w.close(); + end + + function testStreamsOfAliasedUnions(testCase, format) + w = create_validating_writer(testCase, format, 'StreamsOfAliasedUnions'); + w.write_int_or_simple_record([... + test_model.AliasedIntOrSimpleRecord.Int32(1), ... + test_model.AliasedIntOrSimpleRecord.SimpleRecord(test_model.SimpleRecord(1, 2, 3)), ... + test_model.AliasedIntOrSimpleRecord.Int32(2) ... + ]); + w.write_nullable_int_or_simple_record([... + yardl.None, ... + test_model.AliasedNullableIntSimpleRecord.Int32(1), ... + test_model.AliasedNullableIntSimpleRecord.SimpleRecord(test_model.SimpleRecord(1, 2, 3)), ... + yardl.None, ... + test_model.AliasedNullableIntSimpleRecord.Int32(2), ... + yardl.None ... + ]); + w.close(); + end + + function testSimpleGenerics(testCase, format) + w = create_validating_writer(testCase, format, 'SimpleGenerics'); + w.write_float_image(transpose(single([[1, 2]; [3, 4]]))); + w.write_int_image(transpose(int32([[1, 2]; [3, 4]]))); + w.write_int_image_alternate_syntax(transpose(int32([[1, 2]; [3, 4]]))); + w.write_string_image(transpose([["a", "b"]; ["c", "d"]])); + w.write_int_float_tuple(test_model.MyTuple(int32(1), single(2))); + w.write_float_float_tuple(test_model.MyTuple(single(1), single(2))); + t = test_model.MyTuple(int32(1), single(2)); + w.write_int_float_tuple_alternate_syntax(t); + w.write_int_string_tuple(test_model.MyTuple(int32(1), "2")); + w.write_stream_of_type_variants([... + test_model.ImageFloatOrImageDouble.ImageFloat(transpose(single([[1, 2]; [3, 4]]))), ... + test_model.ImageFloatOrImageDouble.ImageDouble(transpose([[1, 2]; [3, 4]])) ... + ]); + w.close(); + end + + function testAdvancedGenerics(testCase, format) + % TODO: Fix NDArraySerializers for nested NDArrays + testCase.assumeFail(); + + w = create_validating_writer(testCase, format, 'AdvancedGenerics'); + + i1 = single([[3, 4, 5]; [6, 7, 8]]); + i2 = single([[30, 40, 50]; [60, 70, 80]]); + i3 = single([[300, 400, 500]; [600, 700, 800]]); + i4 = single([[3000, 4000, 5000]; [6000, 7000, 8000]]); + + % TODO: How would I declare it with zeros first, then fill it with img_img_array[:] = ... ? e.g. (in Python) + img_img_array = i1; + img_img_array(:, :, 2) = i2; + img_img_array(:, :, 3) = i3; + img_img_array(:, :, 4) = i4; + + w.write_float_image_image(img_img_array); + + w.write_generic_record_1(test_model.GenericRecord(... + int32(1), ... + "hello", ... + int32([1, 2, 3]), ... + [["abc", "def"]; ["a", "b"]] ... + )); + + w.write_tuple_of_optionals(test_model.MyTuple(yardl.None, "hello")); + w.write_tuple_of_optionals_alternate_syntax(test_model.MyTuple(int32(34), yardl.None)); + w.write_tuple_of_vectors(test_model.MyTuple(int32([1, 2, 3]), single([4, 5, 6]))); + w.close(); + end + + function testAliases(testCase, format) + w = create_validating_writer(testCase, format, 'Aliases'); + w.write_aliased_string("hello"); + w.write_aliased_enum(test_model.Fruits.APPLE); + w.write_aliased_open_generic(test_model.AliasedOpenGeneric("hello", test_model.Fruits.BANANA)); + w.write_aliased_closed_generic(test_model.AliasedClosedGeneric("hello", test_model.Fruits.PEAR)); + w.write_aliased_optional(int32(23)); + w.write_aliased_generic_optional(single(44)); + w.write_aliased_generic_union_2(test_model.AliasedGenericUnion2.T1("hello")); + w.write_aliased_generic_vector(single([1.0, 33.0, 44.0])); + w.write_aliased_generic_fixed_vector(single([1.0, 33.0, 44.0])); + w.write_stream_of_aliased_generic_union_2([ ... + test_model.AliasedGenericUnion2.T1("hello"), ... + test_model.AliasedGenericUnion2.T2(test_model.Fruits.APPLE) ... + ]); + w.close(); + end + end +end + + +function w = create_validating_writer(testCase, format, protocol) + % writer_name = 'test_model.' + format + eraseBetween(name, strlength(name)-3, strlength(name)); + % reader_name = replaceBetween(wname, strlength(wname)-5, strlength(wname), "Reader"); + + writer_name = "test_model." + format + protocol + "Writer"; + reader_name = "test_model." + format + protocol + "Reader"; + test_writer_name = "test_model.testing.Test" + protocol + "Writer"; + + create_writer = str2func(writer_name); + create_reader = str2func(reader_name); + create_test_writer = str2func(test_writer_name); + + testfile = tempname; + writer = create_writer(testfile); + w = create_test_writer(testCase, writer, @() create_reader(testfile)); +end diff --git a/matlab/tests/YardlTypesTest.m b/matlab/tests/YardlTypesTest.m index 0f56ecbe..74661007 100644 --- a/matlab/tests/YardlTypesTest.m +++ b/matlab/tests/YardlTypesTest.m @@ -71,5 +71,80 @@ function testTimeFromInvalidComponents(testCase) testCase.verifyError(@() yardl.Time.from_components(12, 22, 44, 9999999999999999), 'yardl:ValueError'); end + function testOptionals(testCase) + % None.has_value == false + testCase.verifyEqual(yardl.None().has_value, false); + % Optional(X).has_value == true + testCase.verifyEqual(yardl.Optional(42).has_value, true); + + % ERROR: None.value + testCase.verifyError(@() yardl.None().value, 'yardl:ValueError'); + + % ERROR: None.has_value = true + function setHasValueTrue() + o = yardl.None; + o.has_value = true; + end + testCase.verifyError(@setHasValueTrue, 'MATLAB:class:SetProhibited'); + + % ERROR: Optional(x).has_value = false + function setHasValueFalse() + o = yardl.Optional(42); + o.has_value = false; + end + testCase.verifyError(@setHasValueFalse, 'MATLAB:class:SetProhibited'); + + % None == None + testCase.verifyEqual(yardl.None, yardl.None); + + % Optional(X) == Optional(X) + testCase.verifyEqual(yardl.Optional(int16(42)), yardl.Optional(int16(42))); + testCase.verifyEqual(yardl.Optional("hello"), yardl.Optional("hello")); + testCase.verifyEqual(yardl.Optional([]), yardl.Optional([])); + testCase.verifyEqual(yardl.Optional([[1, 2]; [3, 4]]), yardl.Optional([[1, 2]; [3, 4]])); + + % Optional(X) == X + testCase.verifyTrue(yardl.Optional(int16(42)) == int16(42)); + testCase.verifyTrue(yardl.Optional("hello") == "hello"); + testCase.verifyTrue(isequal(yardl.Optional([]), [])); + testCase.verifyTrue(isequal(yardl.Optional([[1, 2]; [3, 4]]), [[1, 2]; [3, 4]])); + + % X == Optional(X) + testCase.verifyEqual(int16(42), yardl.Optional(int16(42))); + testCase.verifyEqual("hello", yardl.Optional("hello")); + testCase.verifyEqual([], yardl.Optional([])); + testCase.verifyEqual([[1, 2]; [3, 4]], yardl.Optional([[1, 2]; [3, 4]])); + + % None ~= Optional(X) + testCase.verifyNotEqual(yardl.None, yardl.Optional(42)); + + % Optional(X) ~= None + testCase.verifyNotEqual(yardl.Optional(42), yardl.None); + + % None ~= X + testCase.verifyNotEqual(yardl.None, 42); + % X ~= None + testCase.verifyNotEqual(42, yardl.None); + + % [Optionals] == [Optionals] + os = arrayfun(@yardl.Optional, 1:5); + testCase.verifyEqual(os, os); + + % [Nones] == [Nones] + nones = repelem(yardl.None, 5); + testCase.verifyEqual(nones, nones); + + % [Optional, None, ...] == [Optional, None, ...] + mixed1 = [1, 2, yardl.None, 4, 5, yardl.None]; + testCase.verifyEqual(mixed1, mixed1); + mixed2 = [yardl.Optional(1), yardl.Optional(2), yardl.None, yardl.Optional(4), yardl.Optional(5), yardl.None]; + testCase.verifyEqual(mixed1, mixed2); + testCase.verifyEqual(mixed2, mixed1); + + % [Optional, None, ...] ~= [None, Optional, ...] + mixed3 = [1, 2, yardl.None, 4, 5, 6]; + testCase.verifyNotEqual(mixed1, mixed3); + testCase.verifyNotEqual(mixed3, mixed1); + end end end diff --git a/matlab/tests/run.m b/matlab/tests/run.m index f33d8210..2eb4e863 100644 --- a/matlab/tests/run.m +++ b/matlab/tests/run.m @@ -6,3 +6,6 @@ run(GeneratedTypesTest); run(EqualityTest); +run(ComputedFieldsTest); + +run(RoundTripTest); diff --git a/models/test/_package.yml b/models/test/_package.yml index fc8d2e54..a079acbd 100644 --- a/models/test/_package.yml +++ b/models/test/_package.yml @@ -19,6 +19,8 @@ python: matlab: outputDir: ../../matlab/generated + internalGenerateMocks: true + internalSymlinkStaticFiles: true json: outputDir: ../../cpp/test/generated diff --git a/tooling/internal/matlab/binary/binary.go b/tooling/internal/matlab/binary/binary.go index 8d8c7193..a331249d 100644 --- a/tooling/internal/matlab/binary/binary.go +++ b/tooling/internal/matlab/binary/binary.go @@ -14,7 +14,6 @@ import ( ) func WriteBinary(fw *common.MatlabFileWriter, ns *dsl.Namespace) error { - if ns.IsTopLevel { if err := writeProtocols(fw, ns); err != nil { return err @@ -41,15 +40,16 @@ func writeProtocolWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, return fw.WriteFile(BinaryWriterName(p), func(w *formatting.IndentedWriter) { common.WriteComment(w, fmt.Sprintf("Binary writer for the %s protocol", p.Name)) common.WriteComment(w, p.Comment) - fmt.Fprintf(w, "classdef %s < yardl.binary.BinaryProtocolWriter & %s\n", BinaryWriterName(p), common.AbstractWriterName(p)) + abstractWriterName := fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(p.Namespace), common.AbstractWriterName(p)) + fmt.Fprintf(w, "classdef %s < yardl.binary.BinaryProtocolWriter & %s\n", BinaryWriterName(p), abstractWriterName) common.WriteBlockBody(w, func() { w.WriteStringln("methods") common.WriteBlockBody(w, func() { fmt.Fprintf(w, "function obj = %s(filename)\n", BinaryWriterName(p)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj@%s();\n", common.AbstractWriterName(p)) - fmt.Fprintf(w, "obj@yardl.binary.BinaryProtocolWriter(filename, %s.schema);\n", common.AbstractWriterName(p)) + fmt.Fprintf(w, "obj@%s();\n", abstractWriterName) + fmt.Fprintf(w, "obj@yardl.binary.BinaryProtocolWriter(filename, %s.schema);\n", abstractWriterName) }) }) w.WriteStringln("") @@ -75,15 +75,16 @@ func writeProtocolReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, return fw.WriteFile(BinaryReaderName(p), func(w *formatting.IndentedWriter) { common.WriteComment(w, fmt.Sprintf("Binary reader for the %s protocol", p.Name)) common.WriteComment(w, p.Comment) - fmt.Fprintf(w, "classdef %s < yardl.binary.BinaryProtocolReader & %s\n", BinaryReaderName(p), common.AbstractReaderName(p)) + abstractReaderName := fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(p.Namespace), common.AbstractReaderName(p)) + fmt.Fprintf(w, "classdef %s < yardl.binary.BinaryProtocolReader & %s\n", BinaryReaderName(p), abstractReaderName) common.WriteBlockBody(w, func() { w.WriteStringln("methods") common.WriteBlockBody(w, func() { fmt.Fprintf(w, "function obj = %s(filename)\n", BinaryReaderName(p)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj@%s();\n", common.AbstractReaderName(p)) - fmt.Fprintf(w, "obj@yardl.binary.BinaryProtocolReader(filename, %s.schema);\n", common.AbstractReaderName(p)) + fmt.Fprintf(w, "obj@%s();\n", abstractReaderName) + fmt.Fprintf(w, "obj@yardl.binary.BinaryProtocolReader(filename, %s.schema);\n", abstractReaderName) }) }) w.WriteStringln("") @@ -91,7 +92,7 @@ func writeProtocolReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, w.WriteStringln("methods (Access=protected)") common.WriteBlockBody(w, func() { for i, step := range p.Sequence { - fmt.Fprintf(w, "function value = %s(obj, value)\n", common.ProtocolReadImplMethodName(step)) + fmt.Fprintf(w, "function value = %s(obj)\n", common.ProtocolReadImplMethodName(step)) common.WriteBlockBody(w, func() { fmt.Fprintf(w, "r = %s;\n", typeSerializer(step.Type, ns.Name, nil)) w.WriteStringln("value = r.read(obj.stream_);") @@ -144,7 +145,7 @@ func writeRecordSerializer(fw *common.MatlabFileWriter, rec *dsl.RecordDefinitio for i, field := range rec.Fields { fmt.Fprintf(w, "field_serializers{%d} = %s;\n", i+1, typeSerializer(field.Type, ns.Name, nil)) } - fmt.Fprintf(w, "obj@yardl.binary.RecordSerializer(field_serializers);\n") + fmt.Fprintf(w, "obj@yardl.binary.RecordSerializer('%s', field_serializers);\n", typeSyntax) }) w.WriteStringln("") @@ -171,17 +172,14 @@ func writeRecordSerializer(fw *common.MatlabFileWriter, rec *dsl.RecordDefinitio } func recordSerializerClassName(record *dsl.RecordDefinition, contextNamespace string) string { - className := fmt.Sprintf("%sSerializer", formatting.ToPascalCase(record.Name)) - if record.Namespace != contextNamespace { - className = fmt.Sprintf("%s.binary.%s", common.NamespaceIdentifierName(record.Namespace), className) - } - return className + return fmt.Sprintf("%sSerializer", formatting.ToPascalCase(record.Name)) } func typeDefinitionSerializer(td dsl.TypeDefinition, contextNamespace string) string { switch td := td.(type) { case dsl.PrimitiveDefinition: return fmt.Sprintf("yardl.binary.%sSerializer", formatting.ToPascalCase(string(td))) + case *dsl.EnumDefinition: var baseType dsl.Type if td.BaseType != nil { @@ -191,11 +189,13 @@ func typeDefinitionSerializer(td dsl.TypeDefinition, contextNamespace string) st } elementSerializer := typeSerializer(baseType, contextNamespace, nil) - return fmt.Sprintf("yardl.binary.EnumSerializer(%s, @%s)", elementSerializer, common.TypeSyntax(td, contextNamespace)) + enumSyntax := common.TypeSyntax(td, contextNamespace) + return fmt.Sprintf("yardl.binary.EnumSerializer('%s', @%s, %s)", enumSyntax, enumSyntax, elementSerializer) + case *dsl.RecordDefinition: - serializerName := recordSerializerClassName(td, contextNamespace) + qualifiedSerializerName := fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(td.Namespace), recordSerializerClassName(td, contextNamespace)) if len(td.TypeParameters) == 0 { - return fmt.Sprintf("%s()", serializerName) + return fmt.Sprintf("%s()", qualifiedSerializerName) } if len(td.TypeArguments) == 0 { panic("Expected type arguments") @@ -207,14 +207,18 @@ func typeDefinitionSerializer(td dsl.TypeDefinition, contextNamespace string) st } if len(typeArguments) == 0 { - return fmt.Sprintf("%s()", serializerName) + panic("How could this be possible?") + return fmt.Sprintf("%s()", qualifiedSerializerName) } - return fmt.Sprintf("%s(%s)", serializerName, strings.Join(typeArguments, ", ")) + return fmt.Sprintf("%s(%s)", qualifiedSerializerName, strings.Join(typeArguments, ", ")) + case *dsl.GenericTypeParameter: return fmt.Sprintf("%s_serializer", formatting.ToSnakeCase(td.Name)) + case *dsl.NamedType: return typeSerializer(td.Type, contextNamespace, td) + default: panic(fmt.Sprintf("Not implemented %T", td)) } @@ -237,26 +241,25 @@ func typeSerializer(t dsl.Type, contextNamespace string, namedType *dsl.NamedTyp unionClassName := common.UnionClassName(t) if namedType != nil { - unionClassName = namedType.Name - if namedType.Namespace != contextNamespace { - unionClassName = fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(namedType.Namespace), unionClassName) - } + unionClassName = fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(namedType.Namespace), namedType.Name) + } else { + unionClassName = fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(contextNamespace), unionClassName) } serializers := make([]string, len(t.Cases)) factories := make([]string, len(t.Cases)) for i, c := range t.Cases { if c.Type == nil { - serializers[i] = "yardl.None" + serializers[i] = "yardl.binary.NoneSerializer" factories[i] = "yardl.None" } else { serializers[i] = typeSerializer(c.Type, contextNamespace, namedType) factories[i] = fmt.Sprintf("@%s.%s", unionClassName, formatting.ToPascalCase(c.Tag)) } } - return fmt.Sprintf("yardl.binary.UnionSerializer('%s', {%s}, {%s})", unionClassName, strings.Join(serializers, ", "), strings.Join(factories, ", ")) } + switch td := t.Dimensionality.(type) { case nil: return getScalarSerializer() @@ -266,7 +269,6 @@ func typeSerializer(t dsl.Type, contextNamespace string, namedType *dsl.NamedTyp if td.Length != nil { return fmt.Sprintf("yardl.binary.FixedVectorSerializer(%s, %d)", getScalarSerializer(), *td.Length) } - return fmt.Sprintf("yardl.binary.VectorSerializer(%s)", getScalarSerializer()) case *dsl.Array: if td.IsFixed() { @@ -289,6 +291,7 @@ func typeSerializer(t dsl.Type, contextNamespace string, namedType *dsl.NamedTyp valueSerializer := typeSerializer(t.ToScalar(), contextNamespace, namedType) return fmt.Sprintf("yardl.binary.MapSerializer(%s, %s)", keySerializer, valueSerializer) + default: panic(fmt.Sprintf("Not implemented %T", t.Dimensionality)) } diff --git a/tooling/internal/matlab/common/common.go b/tooling/internal/matlab/common/common.go index 384c1199..923a055e 100644 --- a/tooling/internal/matlab/common/common.go +++ b/tooling/internal/matlab/common/common.go @@ -39,14 +39,14 @@ var TypeSyntaxWriter dsl.TypeSyntaxWriter[string] = func(self dsl.TypeSyntaxWrit return "int64" case dsl.Uint64, dsl.Size: return "uint64" - case dsl.Float32: + case dsl.Float32, dsl.ComplexFloat32: return "single" - case dsl.Float64: + case dsl.Float64, dsl.ComplexFloat64: return "double" - case dsl.ComplexFloat32: - return "complex" - case dsl.ComplexFloat64: - return "complex" + // case dsl.ComplexFloat32: + // return "complex" + // case dsl.ComplexFloat64: + // return "complex" case dsl.String: return "string" case dsl.Date: @@ -85,7 +85,8 @@ var TypeSyntaxWriter dsl.TypeSyntaxWriter[string] = func(self dsl.TypeSyntaxWrit return scalarString case *dsl.Map: // TODO: Update to Matlab `dictionary` class when we require Matlab version >= r2023b - return "containers.Map" + // return "containers.Map" + return "dictionary" default: panic(fmt.Sprintf("unexpected type %T", d)) } @@ -197,8 +198,8 @@ func ProtocolReadImplMethodName(s *dsl.ProtocolStep) string { } func WriteGeneratedFileHeader(w *formatting.IndentedWriter) { - WriteComment(w, "This file was generated by the \"yardl\" tool. DO NOT EDIT.") - w.WriteStringln("") + // WriteComment(w, "This file was generated by the \"yardl\" tool. DO NOT EDIT.") + // w.WriteStringln("") } type MatlabFileWriter struct { diff --git a/tooling/internal/matlab/matlab.go b/tooling/internal/matlab/matlab.go index 31522495..71edf1ad 100644 --- a/tooling/internal/matlab/matlab.go +++ b/tooling/internal/matlab/matlab.go @@ -11,6 +11,7 @@ import ( "github.com/microsoft/yardl/tooling/internal/iocommon" "github.com/microsoft/yardl/tooling/internal/matlab/binary" "github.com/microsoft/yardl/tooling/internal/matlab/common" + "github.com/microsoft/yardl/tooling/internal/matlab/mocks" "github.com/microsoft/yardl/tooling/internal/matlab/protocols" "github.com/microsoft/yardl/tooling/internal/matlab/types" "github.com/microsoft/yardl/tooling/pkg/dsl" @@ -26,45 +27,44 @@ func Generate(env *dsl.Environment, options packaging.MatlabCodegenOptions) erro return err } - if err := iocommon.CopyEmbeddedStaticFiles(options.OutputDir, options.InternalSymlinkStaticFiles, staticFiles); err != nil { + staticDir := path.Join(options.OutputDir, common.PackageDir("yardl")) + if err := iocommon.CopyEmbeddedStaticFiles(staticDir, options.InternalSymlinkStaticFiles, staticFiles); err != nil { return err } for _, ns := range env.Namespaces { packageDir := path.Join(options.OutputDir, common.PackageDir(ns.Name)) - if err := os.MkdirAll(packageDir, 0775); err != nil { return err } fw := &common.MatlabFileWriter{PackageDir: packageDir} - err = writeNamespace(fw, ns, env.SymbolTable) - if err != nil { + if err := types.WriteTypes(fw, ns, env.SymbolTable); err != nil { return err } - } - return nil -} + if ns.IsTopLevel { + if err := protocols.WriteProtocols(fw, ns, env.SymbolTable); err != nil { + return err + } -func writeNamespace(fw *common.MatlabFileWriter, ns *dsl.Namespace, st dsl.SymbolTable) error { - if err := types.WriteTypes(fw, ns, st); err != nil { - return err - } + if options.InternalGenerateMocks { + mocksDir := path.Join(packageDir, common.PackageDir("testing")) + if err := os.MkdirAll(mocksDir, 0775); err != nil { + return err + } + fw := &common.MatlabFileWriter{PackageDir: mocksDir} + err = mocks.WriteMocks(fw, ns) + if err != nil { + return err + } + } + } - if ns.IsTopLevel { - if err := protocols.WriteProtocols(fw, ns, st); err != nil { + if err := binary.WriteBinary(fw, ns); err != nil { return err } } - if err := binary.WriteBinary(fw, ns); err != nil { - return err - } - - // if err := ndjson.WriteNDJson(ns, packageDir); err != nil { - // return err - // } - return nil } diff --git a/tooling/internal/matlab/mocks/mocks.go b/tooling/internal/matlab/mocks/mocks.go new file mode 100644 index 00000000..9e4cf093 --- /dev/null +++ b/tooling/internal/matlab/mocks/mocks.go @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +package mocks + +import ( + "fmt" + + "github.com/microsoft/yardl/tooling/internal/formatting" + "github.com/microsoft/yardl/tooling/internal/matlab/common" + "github.com/microsoft/yardl/tooling/pkg/dsl" +) + +func WriteMocks(fw *common.MatlabFileWriter, ns *dsl.Namespace) error { + for _, p := range ns.Protocols { + if err := writeProtocolMock(fw, p); err != nil { + return err + } + if err := writeProtocolTestWriter(fw, p); err != nil { + return err + } + } + + return nil +} + +func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) error { + return fw.WriteFile(mockWriterName(p), func(w *formatting.IndentedWriter) { + abstractWriterName := fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(p.Namespace), common.AbstractWriterName(p)) + fmt.Fprintf(w, "classdef %s < %s\n", mockWriterName(p), abstractWriterName) + common.WriteBlockBody(w, func() { + w.WriteStringln("properties") + common.WriteBlockBody(w, func() { + w.WriteStringln("testCase_") + for _, step := range p.Sequence { + fmt.Fprintf(w, "%swritten\n", common.ProtocolWriteImplMethodName(step)) + } + }) + w.WriteStringln("") + + w.WriteStringln("methods") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "function obj = %s(testCase)\n", mockWriterName(p)) + common.WriteBlockBody(w, func() { + w.WriteStringln("obj.testCase_ = testCase;") + for _, step := range p.Sequence { + fmt.Fprintf(w, "obj.%swritten = Node.empty();\n", common.ProtocolWriteImplMethodName(step)) + } + }) + w.WriteStringln("") + + for _, step := range p.Sequence { + fmt.Fprintf(w, "function expect_%s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "obj.%swritten(end+1) = Node(value);\n", common.ProtocolWriteImplMethodName(step)) + }) + w.WriteStringln("") + } + + w.WriteStringln("function verify(obj)") + common.WriteBlockBody(w, func() { + for _, step := range p.Sequence { + // fmt.Fprintf(w, "if ~isempty(obj.%swritten)\n", common.ProtocolWriteImplMethodName(step)) + // common.WriteBlockBody(w, func() { + // fmt.Fprintf(w, "throw(yardl.RuntimeError(\"Expected call to %s was not received\"));\n", common.ProtocolWriteImplMethodName(step)) + // }) + diagnostic := fmt.Sprintf("Expected call to %s was not received", common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "obj.testCase_.verifyTrue(isempty(obj.%swritten), \"%s\");\n", common.ProtocolWriteImplMethodName(step), diagnostic) + } + }) + }) + w.WriteStringln("") + + w.WriteStringln("methods (Access=protected)") + common.WriteBlockBody(w, func() { + for _, step := range p.Sequence { + fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) + common.WriteBlockBody(w, func() { + // fmt.Fprintf(w, "if isempty(obj.%swritten)\n", common.ProtocolWriteImplMethodName(step)) + // common.WriteBlockBody(w, func() { + // fmt.Fprintf(w, "throw(yardl.RuntimeError(\"Unexpected call to %s\"));\n", common.ProtocolWriteImplMethodName(step)) + // }) + fmt.Fprintf(w, "obj.testCase_.verifyTrue(~isempty(obj.%swritten), \"Unexpected call to %s\");\n", common.ProtocolWriteImplMethodName(step), common.ProtocolWriteImplMethodName(step)) + + // fmt.Fprintf(w, "if value ~= obj.%swritten(1)\n", common.ProtocolWriteImplMethodName(step)) + // common.WriteBlockBody(w, func() { + // fmt.Fprintf(w, "throw(yardl.RuntimeError(\"Unexpected argument value for call to %s\"));\n", common.ProtocolWriteImplMethodName(step)) + // }) + fmt.Fprintf(w, "expected = obj.%swritten(1).value;\n", common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "obj.testCase_.verifyEqual(value, expected, \"Unexpected argument value for call to %s\");\n", common.ProtocolWriteImplMethodName(step)) + + fmt.Fprintf(w, "obj.%swritten = obj.%swritten(2:end);\n", common.ProtocolWriteImplMethodName(step), common.ProtocolWriteImplMethodName(step)) + }) + w.WriteStringln("") + } + + w.WriteStringln("function close_(obj)") + w.WriteStringln("end") + + w.WriteStringln("function end_stream_(obj)") + w.WriteStringln("end") + }) + }) + }) +} + +func writeProtocolTestWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) error { + return fw.WriteFile(testWriterName(p), func(w *formatting.IndentedWriter) { + abstractWriterName := fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(p.Namespace), common.AbstractWriterName(p)) + fmt.Fprintf(w, "classdef %s < %s\n", testWriterName(p), abstractWriterName) + common.WriteBlockBody(w, func() { + w.WriteStringln("properties (Access = private)") + common.WriteBlockBody(w, func() { + w.WriteStringln("writer_") + w.WriteStringln("create_reader_") + w.WriteStringln("mock_writer_") + w.WriteStringln("close_called_") + }) + w.WriteStringln("") + + w.WriteStringln("methods") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "function obj = %s(testCase, writer, create_reader)\n", testWriterName(p)) + common.WriteBlockBody(w, func() { + w.WriteStringln("obj.writer_ = writer;") + w.WriteStringln("obj.create_reader_ = create_reader;") + mockWriterName := fmt.Sprintf("%s.testing.%s", common.NamespaceIdentifierName(p.Namespace), mockWriterName(p)) + fmt.Fprintf(w, "obj.mock_writer_ = %s(testCase);\n", mockWriterName) + w.WriteStringln("obj.close_called_ = false;") + }) + w.WriteStringln("") + + w.WriteStringln("function delete(obj)") + common.WriteBlockBody(w, func() { + w.WriteStringln("if ~obj.close_called_") + common.WriteBlockBody(w, func() { + common.WriteComment(w, "ADD_FAILURE() << ...;") + fmt.Fprintf(w, "throw(yardl.RuntimeError(\"Close() must be called on '%s' to verify mocks\"));\n", testWriterName(p)) + }) + }) + }) + w.WriteStringln("") + + w.WriteStringln("methods (Access=protected)") + common.WriteBlockBody(w, func() { + for _, step := range p.Sequence { + fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "obj.writer_.%s(value);\n", common.ProtocolWriteMethodName(step)) + fmt.Fprintf(w, "obj.mock_writer_.expect_%s(value);\n", common.ProtocolWriteImplMethodName(step)) + }) + w.WriteStringln("") + } + + w.WriteStringln("function close_(obj)") + common.WriteBlockBody(w, func() { + w.WriteStringln("obj.close_called_ = true;") + w.WriteStringln("obj.writer_.close();") + w.WriteStringln("reader = obj.create_reader_();") + w.WriteStringln("reader.copy_to(obj.mock_writer_);") + w.WriteStringln("reader.close();") + w.WriteStringln("obj.mock_writer_.verify();") + }) + w.WriteStringln("") + + w.WriteStringln("function end_stream_(obj)") + common.WriteBlockBody(w, func() {}) + }) + + }) + + }) +} + +func mockWriterName(p *dsl.ProtocolDefinition) string { + return fmt.Sprintf("Mock%sWriter", p.Name) +} + +func testWriterName(p *dsl.ProtocolDefinition) string { + return fmt.Sprintf("Test%sWriter", p.Name) +} diff --git a/tooling/internal/matlab/protocols/protocols.go b/tooling/internal/matlab/protocols/protocols.go index f5bba51b..e644c1f6 100644 --- a/tooling/internal/matlab/protocols/protocols.go +++ b/tooling/internal/matlab/protocols/protocols.go @@ -43,12 +43,6 @@ func writeAbstractWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, common.WriteBlockBody(w, func() { w.WriteStringln("obj.state_ = 0;") }) w.WriteStringln("") - // Destructor - // w.WriteStringln("function delete(obj)") - // common.WriteBlockBody(w, func() { - // }) - // w.WriteStringln("") - // Close method w.WriteStringln("function close(obj)") common.WriteBlockBody(w, func() { @@ -187,12 +181,6 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, }) w.WriteStringln("") - // Destructor - // w.WriteStringln("function delete(obj)") - // common.WriteBlockBody(w, func() { - // }) - // w.WriteStringln("") - // Close method w.WriteStringln("function close(obj)") common.WriteBlockBody(w, func() { @@ -249,7 +237,7 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, common.WriteBlockBody(w, func() { w.WriteStringln("function res = schema()") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "res = %s.schema;\n", common.AbstractWriterName(p)) + fmt.Fprintf(w, "res = %s.%s.schema;\n", common.NamespaceIdentifierName(ns.Name), common.AbstractWriterName(p)) }) }) w.WriteStringln("") @@ -282,11 +270,15 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, common.WriteBlockBody(w, func() { for i, step := range p.Sequence { fmt.Fprintf(w, "if state == %d\n", i*2) - common.WriteBlockBody(w, func() { + w.Indented(func() { fmt.Fprintf(w, "name = '%s';\n", common.ProtocolReadMethodName(step)) }) + w.WriteString("else") } - w.WriteStringln("name = '';") + w.WriteStringln("") + common.WriteBlockBody(w, func() { + w.WriteStringln("name = '';") + }) }) }) }) diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolReader.m b/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m similarity index 100% rename from tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolReader.m rename to tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolWriter.m b/tooling/internal/matlab/static_files/+binary/BinaryProtocolWriter.m similarity index 100% rename from tooling/internal/matlab/static_files/+yardl/+binary/BinaryProtocolWriter.m rename to tooling/internal/matlab/static_files/+binary/BinaryProtocolWriter.m diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/BoolSerializer.m b/tooling/internal/matlab/static_files/+binary/BoolSerializer.m similarity index 81% rename from tooling/internal/matlab/static_files/+yardl/+binary/BoolSerializer.m rename to tooling/internal/matlab/static_files/+binary/BoolSerializer.m index 3983a778..e0f227bc 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/BoolSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/BoolSerializer.m @@ -10,5 +10,9 @@ function write( outstream, value) byte = instream.read_byte(); res = cast(byte, "logical"); end + + function c = getClass() + c = 'logical'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/CURRENT_BINARY_FORMAT_VERSION.m b/tooling/internal/matlab/static_files/+binary/CURRENT_BINARY_FORMAT_VERSION.m similarity index 100% rename from tooling/internal/matlab/static_files/+yardl/+binary/CURRENT_BINARY_FORMAT_VERSION.m rename to tooling/internal/matlab/static_files/+binary/CURRENT_BINARY_FORMAT_VERSION.m diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/CodedInputStream.m b/tooling/internal/matlab/static_files/+binary/CodedInputStream.m similarity index 100% rename from tooling/internal/matlab/static_files/+yardl/+binary/CodedInputStream.m rename to tooling/internal/matlab/static_files/+binary/CodedInputStream.m diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/CodedOutputStream.m b/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m similarity index 100% rename from tooling/internal/matlab/static_files/+yardl/+binary/CodedOutputStream.m rename to tooling/internal/matlab/static_files/+binary/CodedOutputStream.m diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Complexfloat32Serializer.m b/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m similarity index 89% rename from tooling/internal/matlab/static_files/+yardl/+binary/Complexfloat32Serializer.m rename to tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m index 1b924429..1a3f0775 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/Complexfloat32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m @@ -18,5 +18,9 @@ function write(outstream, value) imag_bytes = instream.read(4); res = complex(typecast(real_bytes, "single"), typecast(imag_bytes, "single")); end + + function c = getClass() + c = 'single'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Complexfloat64Serializer.m b/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m similarity index 87% rename from tooling/internal/matlab/static_files/+yardl/+binary/Complexfloat64Serializer.m rename to tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m index 1d79ed6e..5aeeb0db 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/Complexfloat64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m @@ -13,5 +13,9 @@ function write(outstream, value) imag_bytes = instream.read(8); res = complex(typecast(real_bytes, "double"), typecast(imag_bytes, "double")); end + + function c = getClass() + c = 'double'; + end end end diff --git a/tooling/internal/matlab/static_files/+binary/DateSerializer.m b/tooling/internal/matlab/static_files/+binary/DateSerializer.m new file mode 100755 index 00000000..3a55f7a0 --- /dev/null +++ b/tooling/internal/matlab/static_files/+binary/DateSerializer.m @@ -0,0 +1,23 @@ +classdef DateSerializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + if isa(value, 'datetime') + value = yardl.Date.from_datetime(value).value; + elseif isa(value, 'yardl.Date') + value = value.value; + else + throw(yardl.TypeError("Expected datetime or yardl.Date, got %s", class(value))); + end + outstream.write_signed_varint(value); + end + + function res = read(instream) + value = instream.read_signed_varint(); + res = yardl.Date(value); + end + + function c = getClass() + c = 'yardl.Date'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/DatetimeSerializer.m b/tooling/internal/matlab/static_files/+binary/DatetimeSerializer.m similarity index 86% rename from tooling/internal/matlab/static_files/+yardl/+binary/DatetimeSerializer.m rename to tooling/internal/matlab/static_files/+binary/DatetimeSerializer.m index 51d50c0a..44875874 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/DatetimeSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/DatetimeSerializer.m @@ -8,7 +8,6 @@ function write(outstream, value) else throw(yardl.TypeError("Expected datetime or yardl.DateTime, got %s", class(value))); end - outstream.write_signed_varint(value); end @@ -16,5 +15,9 @@ function write(outstream, value) value = instream.read_signed_varint(); res = yardl.DateTime(value); end + + function c = getClass() + c = 'yardl.DateTime'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/DynamicNDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m similarity index 100% rename from tooling/internal/matlab/static_files/+yardl/+binary/DynamicNDArraySerializer.m rename to tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/EnumSerializer.m b/tooling/internal/matlab/static_files/+binary/EnumSerializer.m similarity index 56% rename from tooling/internal/matlab/static_files/+yardl/+binary/EnumSerializer.m rename to tooling/internal/matlab/static_files/+binary/EnumSerializer.m index e623ee7d..7af674f9 100644 --- a/tooling/internal/matlab/static_files/+yardl/+binary/EnumSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/EnumSerializer.m @@ -1,13 +1,15 @@ classdef EnumSerializer < yardl.binary.TypeSerializer properties + classname_; + constructor_; integer_serializer_; - enum_class_; end methods - function obj = EnumSerializer(integer_serializer, enum_class) + function obj = EnumSerializer(classname, classconstructor, integer_serializer) + obj.classname_ = classname; + obj.constructor_ = classconstructor; obj.integer_serializer_ = integer_serializer; - obj.enum_class_ = enum_class; end function write(obj, outstream, value) @@ -16,7 +18,11 @@ function write(obj, outstream, value) function res = read(obj, instream) int_value = obj.integer_serializer_.read(instream); - res = obj.enum_class_(int_value); + res = obj.constructor_(int_value); + end + + function c = getClass(obj) + c = obj.classname_; end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Error.m b/tooling/internal/matlab/static_files/+binary/Error.m similarity index 100% rename from tooling/internal/matlab/static_files/+yardl/+binary/Error.m rename to tooling/internal/matlab/static_files/+binary/Error.m diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/FixedNDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m similarity index 75% rename from tooling/internal/matlab/static_files/+yardl/+binary/FixedNDArraySerializer.m rename to tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m index ff7c3433..a92d7260 100644 --- a/tooling/internal/matlab/static_files/+yardl/+binary/FixedNDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m @@ -13,7 +13,9 @@ function write(self, outstream, value) if size(value) ~= self.shape_ - throw(yardl.ValueError("Expected shape %s, got %s", self.shape_, size(value))); + expected = sprintf("%d ", self.shape_); + actual = sprintf("%d ", size(value)); + throw(yardl.ValueError("Expected shape [%s], got [%s]", expected, actual)); end self.write_data_(outstream, value); diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/FixedVectorSerializer.m b/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m similarity index 89% rename from tooling/internal/matlab/static_files/+yardl/+binary/FixedVectorSerializer.m rename to tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m index daf8efc5..5e4732fd 100644 --- a/tooling/internal/matlab/static_files/+yardl/+binary/FixedVectorSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m @@ -25,5 +25,9 @@ function write(obj, outstream, value) res(i) = obj.element_serializer_.read(instream); end end + + function c = getClass(obj) + c = obj.element_serializer_.getClass(); + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Float32Serializer.m b/tooling/internal/matlab/static_files/+binary/Float32Serializer.m similarity index 84% rename from tooling/internal/matlab/static_files/+yardl/+binary/Float32Serializer.m rename to tooling/internal/matlab/static_files/+binary/Float32Serializer.m index 1ae751fb..5f97e6d2 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/Float32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Float32Serializer.m @@ -13,5 +13,9 @@ function write(outstream, value) bytes = instream.read(4); res = typecast(bytes, "single"); end + + function c = getClass() + c = 'single'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Float64Serializer.m b/tooling/internal/matlab/static_files/+binary/Float64Serializer.m similarity index 82% rename from tooling/internal/matlab/static_files/+yardl/+binary/Float64Serializer.m rename to tooling/internal/matlab/static_files/+binary/Float64Serializer.m index 99d7766c..625f5d60 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/Float64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Float64Serializer.m @@ -10,5 +10,9 @@ function write(outstream, value) bytes = instream.read(8); res = typecast(bytes, "double"); end + + function c = getClass() + c = 'double'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Int16Serializer.m b/tooling/internal/matlab/static_files/+binary/Int16Serializer.m similarity index 82% rename from tooling/internal/matlab/static_files/+yardl/+binary/Int16Serializer.m rename to tooling/internal/matlab/static_files/+binary/Int16Serializer.m index 155972c4..5fc57b25 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/Int16Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int16Serializer.m @@ -10,5 +10,9 @@ function write(outstream, value) function res = read(instream) res = int16(instream.read_signed_varint()); end + + function c = getClass() + c = 'int16'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Int32Serializer.m b/tooling/internal/matlab/static_files/+binary/Int32Serializer.m similarity index 82% rename from tooling/internal/matlab/static_files/+yardl/+binary/Int32Serializer.m rename to tooling/internal/matlab/static_files/+binary/Int32Serializer.m index 17eac542..6de34c40 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/Int32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int32Serializer.m @@ -10,5 +10,9 @@ function write(outstream, value) function res = read(instream) res = int32(instream.read_signed_varint()); end + + function c = getClass() + c = 'int32'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Int64Serializer.m b/tooling/internal/matlab/static_files/+binary/Int64Serializer.m similarity index 82% rename from tooling/internal/matlab/static_files/+yardl/+binary/Int64Serializer.m rename to tooling/internal/matlab/static_files/+binary/Int64Serializer.m index 45cf2c2d..f8903963 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/Int64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int64Serializer.m @@ -10,5 +10,9 @@ function write(outstream, value) function res = read(instream) res = int64(instream.read_signed_varint()); end + + function c = getClass() + c = 'int64'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Int8Serializer.m b/tooling/internal/matlab/static_files/+binary/Int8Serializer.m similarity index 83% rename from tooling/internal/matlab/static_files/+yardl/+binary/Int8Serializer.m rename to tooling/internal/matlab/static_files/+binary/Int8Serializer.m index 1cc6a052..6d382ce5 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/Int8Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int8Serializer.m @@ -10,5 +10,9 @@ function write(outstream, value) function res = read(instream) res = typecast(instream.read_byte(), "int8"); end + + function c = getClass() + c = 'int8'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/MAGIC_BYTES.m b/tooling/internal/matlab/static_files/+binary/MAGIC_BYTES.m similarity index 100% rename from tooling/internal/matlab/static_files/+yardl/+binary/MAGIC_BYTES.m rename to tooling/internal/matlab/static_files/+binary/MAGIC_BYTES.m diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/MapSerializer.m b/tooling/internal/matlab/static_files/+binary/MapSerializer.m similarity index 57% rename from tooling/internal/matlab/static_files/+yardl/+binary/MapSerializer.m rename to tooling/internal/matlab/static_files/+binary/MapSerializer.m index 302b373c..2ff209e9 100644 --- a/tooling/internal/matlab/static_files/+yardl/+binary/MapSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/MapSerializer.m @@ -13,26 +13,39 @@ function write(obj, outstream, value) % assert(isa(value, 'containers.Map')) % OR, starting in R2022, Mathworks recommends using `dictionary` - % assert(isa(value, 'dictionary')) + assert(isa(value, 'dictionary')) - outstream.write_unsigned_varint(length(value)); + % count = length(value); + count = numEntries(value); + + outstream.write_unsigned_varint(count); ks = keys(value); vs = values(value); - for i = 1:length(value) - obj.key_serializer_.write(outstream, ks{i}); - obj.value_serializer_.write(outstream, vs{i}); + for i = 1:count + % obj.key_serializer_.write(outstream, ks{i}); + % obj.value_serializer_.write(outstream, vs{i}); + obj.key_serializer_.write(outstream, ks(i)); + obj.value_serializer_.write(outstream, vs(i)); end end function res = read(obj, instream) count = instream.read_unsigned_varint(); + % TODO: If we can require R2022, should use `dictionary` - res = containers.Map; + % res = containers.Map('KeyType', obj.key_serializer_.getClass(), 'ValueType', obj.value_serializer_.getClass()); + res = dictionary(); + for i = 1:count k = obj.key_serializer_.read(instream); v = obj.value_serializer_.read(instream); res(k) = v; end end + + function c = getClass(obj) + % c = 'containers.Map'; + c = 'dictionary'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/NDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m similarity index 85% rename from tooling/internal/matlab/static_files/+yardl/+binary/NDArraySerializer.m rename to tooling/internal/matlab/static_files/+binary/NDArraySerializer.m index 46fffc79..6da46c59 100644 --- a/tooling/internal/matlab/static_files/+yardl/+binary/NDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m @@ -4,7 +4,6 @@ ndims_ end - methods function self = NDArraySerializer(element_serializer, ndims) self@yardl.binary.NDArraySerializerBase(element_serializer); @@ -12,8 +11,8 @@ end function write(self, outstream, value) - if ndims(value) ~= self.ndims_ - throw(yardl.ValueError("Expected %s dimensions, got %s", self.ndims_, ndims(value))); + if ndims(value) ~= max(2, self.ndims_) + throw(yardl.ValueError("Expected %d dimensions, got %d", self.ndims_, ndims(value))); end for dim = self.ndims_: -1: 1 diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/NDArraySerializerBase.m b/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m similarity index 60% rename from tooling/internal/matlab/static_files/+yardl/+binary/NDArraySerializerBase.m rename to tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m index 77d4b494..0df2088e 100644 --- a/tooling/internal/matlab/static_files/+yardl/+binary/NDArraySerializerBase.m +++ b/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m @@ -9,9 +9,20 @@ read(self, instream) end + methods + function c = getClass(obj) + c = obj.element_serializer_.getClass(); + end + end + methods (Access=protected) function self = NDArraySerializerBase(element_serializer) - self.element_serializer_ = element_serializer; + if isa(element_serializer, 'yardl.binary.FixedNDArraySerializer') || ... + isa(element_serializer, 'yardl.binary.FixedVectorSerializer') + self.element_serializer_ = element_serializer.element_serializer_; + else + self.element_serializer_ = element_serializer; + end end function write_data_(self, outstream, value) @@ -29,7 +40,9 @@ function write_data_(self, outstream, value) value(i) = self.element_serializer_.read(instream); end - value = reshape(value, shape); + if length(shape) > 1 + value = reshape(value, shape); + end end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/NoneSerializer.m b/tooling/internal/matlab/static_files/+binary/NoneSerializer.m similarity index 70% rename from tooling/internal/matlab/static_files/+yardl/+binary/NoneSerializer.m rename to tooling/internal/matlab/static_files/+binary/NoneSerializer.m index 29032438..b6241ede 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/NoneSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/NoneSerializer.m @@ -6,5 +6,9 @@ function write(outstream, value) function res = read(instream) res = yardl.None; end + + function c = getClass() + c = 'yardl.Optional'; + end end end diff --git a/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m b/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m new file mode 100644 index 00000000..b9929da5 --- /dev/null +++ b/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m @@ -0,0 +1,50 @@ +classdef OptionalSerializer < yardl.binary.TypeSerializer + properties + element_serializer_; + end + + methods + function obj = OptionalSerializer(element_serializer) + obj.element_serializer_ = element_serializer; + end + + function write(obj, outstream, value) + % if isa(value, 'yardl.None') + % outstream.write_byte_no_check(0); + % return + % end + % outstream.write_byte_no_check(1); + % obj.element_serializer_.write(outstream, value); + + if isa(value, 'yardl.Optional') + if value.has_value() + outstream.write_byte_no_check(1); + obj.element_serializer_.write(outstream, value.value()); + else + outstream.write_byte_no_check(0); + return + end + else + outstream.write_byte_no_check(1); + obj.element_serializer_.write(outstream, value); + end + end + + function res = read(obj, instream) + has_value = instream.read_byte(); + if has_value == 0 + res = yardl.None; + else + res = obj.element_serializer_.read(instream); + + % value = obj.element_serializer_.read(instream); + % res = yardl.Optional(value); + end + end + + function c = getClass(obj) + % c = obj.element_serializer_.getClass(); + c = 'yardl.Optional'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/RecordSerializer.m b/tooling/internal/matlab/static_files/+binary/RecordSerializer.m similarity index 75% rename from tooling/internal/matlab/static_files/+yardl/+binary/RecordSerializer.m rename to tooling/internal/matlab/static_files/+binary/RecordSerializer.m index 0e41f040..79ec35dd 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/RecordSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/RecordSerializer.m @@ -2,14 +2,18 @@ properties field_serializers + classname end methods - - function obj = RecordSerializer(field_serializers) + function obj = RecordSerializer(classname, field_serializers) + obj.classname = classname; obj.field_serializers = field_serializers; end + function c = getClass(obj) + c = obj.classname; + end end methods (Access=protected) diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/SizeSerializer.m b/tooling/internal/matlab/static_files/+binary/SizeSerializer.m similarity index 100% rename from tooling/internal/matlab/static_files/+yardl/+binary/SizeSerializer.m rename to tooling/internal/matlab/static_files/+binary/SizeSerializer.m diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/StreamSerializer.m b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m similarity index 52% rename from tooling/internal/matlab/static_files/+yardl/+binary/StreamSerializer.m rename to tooling/internal/matlab/static_files/+binary/StreamSerializer.m index d3fbf6fc..9d307416 100644 --- a/tooling/internal/matlab/static_files/+yardl/+binary/StreamSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m @@ -9,24 +9,34 @@ end function write(obj, outstream, value) - outstream.write_unsigned_varint(length(value)); - % TODO: Optimize this? - for i = 1:length(value) - obj.element_serializer_.write(outstream, value(i)); + len = size(value, 2); + outstream.write_unsigned_varint(len); + for i = 1:len + obj.element_serializer_.write(outstream, value(:, i)); end end function res = read(obj, instream) count = instream.read_unsigned_varint(); + if count == 0 + res = []; + return; + end + + % Preallocate the result vector (THIS DOESN'T WORK if the element is a vector or array) + res = zeros(1, count, obj.getClass); idx = 1; while count > 0 for c = 1:count - % TODO: Optimize this "append" approach - res(idx) = obj.element_serializer_.read(instream); + res(:, idx) = obj.element_serializer_.read(instream); idx = idx + 1; end count = instream.read_unsigned_varint(); end end + + function c = getClass(obj) + c = obj.element_serializer_.getClass(); + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/StringSerializer.m b/tooling/internal/matlab/static_files/+binary/StringSerializer.m similarity index 86% rename from tooling/internal/matlab/static_files/+yardl/+binary/StringSerializer.m rename to tooling/internal/matlab/static_files/+binary/StringSerializer.m index faa09fad..3beb9e97 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/StringSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/StringSerializer.m @@ -14,5 +14,9 @@ function write(outstream, value) bytes = instream.read(len); res = convertCharsToStrings(native2unicode(bytes, "utf-8")); end + + function c = getClass() + c = 'string'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/TimeSerializer.m b/tooling/internal/matlab/static_files/+binary/TimeSerializer.m similarity index 86% rename from tooling/internal/matlab/static_files/+yardl/+binary/TimeSerializer.m rename to tooling/internal/matlab/static_files/+binary/TimeSerializer.m index 488c81b6..ae7362f8 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/TimeSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/TimeSerializer.m @@ -16,5 +16,9 @@ function write(outstream, value) value = instream.read_signed_varint(); res = yardl.Time(value); end + + function c = getClass() + c = 'yardl.Time'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/TypeSerializer.m b/tooling/internal/matlab/static_files/+binary/TypeSerializer.m similarity index 100% rename from tooling/internal/matlab/static_files/+yardl/+binary/TypeSerializer.m rename to tooling/internal/matlab/static_files/+binary/TypeSerializer.m diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Uint16Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint16Serializer.m similarity index 82% rename from tooling/internal/matlab/static_files/+yardl/+binary/Uint16Serializer.m rename to tooling/internal/matlab/static_files/+binary/Uint16Serializer.m index 7a91c28f..c8605176 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/Uint16Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint16Serializer.m @@ -10,5 +10,9 @@ function write(outstream, value) function res = read(instream) res = uint16(instream.read_unsigned_varint()); end + + function c = getClass() + c = 'uint16'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Uint32Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint32Serializer.m similarity index 82% rename from tooling/internal/matlab/static_files/+yardl/+binary/Uint32Serializer.m rename to tooling/internal/matlab/static_files/+binary/Uint32Serializer.m index 4f425dda..e82d4fc2 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/Uint32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint32Serializer.m @@ -10,5 +10,9 @@ function write(outstream, value) function res = read(instream) res = uint32(instream.read_unsigned_varint()); end + + function c = getClass() + c = 'uint32'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Uint64Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint64Serializer.m similarity index 82% rename from tooling/internal/matlab/static_files/+yardl/+binary/Uint64Serializer.m rename to tooling/internal/matlab/static_files/+binary/Uint64Serializer.m index 94046c73..ecd59892 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/Uint64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint64Serializer.m @@ -10,5 +10,9 @@ function write(outstream, value) function res = read(instream) res = uint64(instream.read_unsigned_varint()); end + + function c = getClass() + c = 'uint64'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/Uint8Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m similarity index 82% rename from tooling/internal/matlab/static_files/+yardl/+binary/Uint8Serializer.m rename to tooling/internal/matlab/static_files/+binary/Uint8Serializer.m index 936ad113..5300ac5b 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/Uint8Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m @@ -10,5 +10,9 @@ function write(outstream, value) function res = read(instream) res = instream.read_byte(); end + + function c = getClass() + c = 'uint8'; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/UnionSerializer.m b/tooling/internal/matlab/static_files/+binary/UnionSerializer.m similarity index 53% rename from tooling/internal/matlab/static_files/+yardl/+binary/UnionSerializer.m rename to tooling/internal/matlab/static_files/+binary/UnionSerializer.m index 955ed22d..4fc5a65e 100755 --- a/tooling/internal/matlab/static_files/+yardl/+binary/UnionSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/UnionSerializer.m @@ -1,7 +1,7 @@ classdef UnionSerializer < handle properties (Access=protected) - union_class_ + classname_ case_serializers_ case_factories_ offset_ @@ -10,11 +10,11 @@ methods function obj = UnionSerializer(union_class, case_serializers, case_factories) - obj.union_class_ = union_class; + obj.classname_ = union_class; obj.case_serializers_ = case_serializers; obj.case_factories_ = case_factories; - if isa(case_serializers{1}, 'yardl.None') + if isa(case_serializers{1}, 'yardl.binary.NoneSerializer') obj.offset_ = 1; else obj.offset_ = 0; @@ -22,17 +22,31 @@ end function write(obj, outstream, value) - if isa(value, 'yardl.None') - if isa(obj.case_serializers_{1}, 'yardl.None') + + if isa(value, 'yardl.Optional') + if ~isa(obj.case_serializers_{1}, 'yardl.binary.NoneSerializer') + throw(yardl.TypeError("Optional is not valid for this union type")) + end + + if value.has_value() + value = value.value; + else outstream.write_byte_no_check(0); return; - else - throw(yardl.TypeError("None is not valid for this union type")) end end - if ~isa(value, obj.union_class_) - throw(yardl.TypeError("Expected union value of type %s, got %s", obj.union_class_, class(value))) + % if isa(value, 'yardl.Optional') && ~value.has_value() + % if isa(obj.case_serializers_{1}, 'yardl.binary.NoneSerializer') + % outstream.write_byte_no_check(0); + % return; + % else + % throw(yardl.TypeError("None is not valid for this union type")) + % end + % end + + if ~isa(value, obj.classname_) + throw(yardl.TypeError("Expected union value of type %s, got %s", obj.classname_, class(value))) end tag_index = uint8(value.index + obj.offset_); @@ -56,5 +70,13 @@ function write(obj, outstream, value) factory = obj.case_factories_{case_index}; res = factory(value); end + + function c = getClass(obj) + if isa(obj.case_serializers_{1}, 'yardl.binary.NoneSerializer') + c = 'yardl.Optional'; + else + c = obj.classname_; + end + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/VectorSerializer.m b/tooling/internal/matlab/static_files/+binary/VectorSerializer.m similarity index 88% rename from tooling/internal/matlab/static_files/+yardl/+binary/VectorSerializer.m rename to tooling/internal/matlab/static_files/+binary/VectorSerializer.m index ce20d1cc..1b10edbe 100644 --- a/tooling/internal/matlab/static_files/+yardl/+binary/VectorSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/VectorSerializer.m @@ -21,5 +21,9 @@ function write(obj, outstream, value) res(i) = obj.element_serializer_.read(instream); end end + + function c = getClass(obj) + c = obj.element_serializer_.getClass; + end end end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/DateSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/DateSerializer.m deleted file mode 100755 index 96eff3d4..00000000 --- a/tooling/internal/matlab/static_files/+yardl/+binary/DateSerializer.m +++ /dev/null @@ -1,18 +0,0 @@ -classdef DateSerializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - assert(isdatetime(value)); - dur = int32(days(value - EPOCH_ORDINAL_DAYS)); - outstream.write_signed_varint(dur); - end - - function res = read(instream) - days_since_epoch = instream.read_signed_varint(); - res = EPOCH_ORDINAL_DAYS + days(days_since_epoch); - end - end -end - -function res = EPOCH_ORDINAL_DAYS - res = datetime(1970, 1, 1); -end diff --git a/tooling/internal/matlab/static_files/+yardl/+binary/OptionalSerializer.m b/tooling/internal/matlab/static_files/+yardl/+binary/OptionalSerializer.m deleted file mode 100644 index c6daa124..00000000 --- a/tooling/internal/matlab/static_files/+yardl/+binary/OptionalSerializer.m +++ /dev/null @@ -1,42 +0,0 @@ -classdef OptionalSerializer < yardl.binary.TypeSerializer - properties - element_serializer_; - end - - methods - function obj = OptionalSerializer(element_serializer) - obj.element_serializer_ = element_serializer; - end - - function write(obj, outstream, value) - if isa(value, 'yardl.None') - outstream.write_byte_no_check(0); - return - end - outstream.write_byte_no_check(1); - obj.element_serializer_.write(outstream, value); - - % if isa(value, 'yardl.Optional') - % if value.has_value() - % outstream.write_byte_no_check(1); - % obj.element_serializer_.write(outstream, value.get_value()); - % else - % outstream.write_byte_no_check(0); - % return - % end - % else - % outstream.write_byte_no_check(1); - % obj.element_serializer_.write(outstream, value); - % end - end - - function res = read(obj, instream) - has_value = instream.read_byte(); - if has_value == 0 - res = yardl.None; - else - res = obj.element_serializer_.read(instream); - end - end - end -end diff --git a/tooling/internal/matlab/static_files/+yardl/None.m b/tooling/internal/matlab/static_files/+yardl/None.m deleted file mode 100644 index 51d151b5..00000000 --- a/tooling/internal/matlab/static_files/+yardl/None.m +++ /dev/null @@ -1,11 +0,0 @@ -classdef None - methods - function eq = eq(~, ~) - eq = true; - end - - function neq = neq(~, ~) - neq = false; - end - end -end diff --git a/tooling/internal/matlab/static_files/+yardl/Optional.m b/tooling/internal/matlab/static_files/+yardl/Optional.m deleted file mode 100644 index d6853742..00000000 --- a/tooling/internal/matlab/static_files/+yardl/Optional.m +++ /dev/null @@ -1,28 +0,0 @@ -classdef Optional < handle - properties (Access=protected) - has_value_ - value_ - end - - methods - function obj = Optional(varargin) - if nargin > 0 - obj.value_ = varargin{1}; - obj.has_value_ = true; - else - obj.has_value_ = false; - end - end - - function has_value = has_value(obj) - has_value = obj.has_value_; - end - - function value = value(obj) - if ~obj.has_value() - throw(yardl.TypeError("Optional type does not have a value")); - end - value = obj.value_; - end - end -end diff --git a/tooling/internal/matlab/static_files/+yardl/Date.m b/tooling/internal/matlab/static_files/Date.m similarity index 93% rename from tooling/internal/matlab/static_files/+yardl/Date.m rename to tooling/internal/matlab/static_files/Date.m index 9a692c4e..1dcc8548 100644 --- a/tooling/internal/matlab/static_files/+yardl/Date.m +++ b/tooling/internal/matlab/static_files/Date.m @@ -29,6 +29,10 @@ eq = isa(other, 'yardl.Date') && ... all([obj.value] == [other.value]); end + + function ne = new(obj, other) + ne = ~obj.eq(other); + end end methods (Static) diff --git a/tooling/internal/matlab/static_files/+yardl/DateTime.m b/tooling/internal/matlab/static_files/DateTime.m similarity index 95% rename from tooling/internal/matlab/static_files/+yardl/DateTime.m rename to tooling/internal/matlab/static_files/DateTime.m index fb94d3aa..25526abf 100644 --- a/tooling/internal/matlab/static_files/+yardl/DateTime.m +++ b/tooling/internal/matlab/static_files/DateTime.m @@ -30,6 +30,10 @@ eq = isa(other, 'yardl.DateTime') && ... all([obj.value] == [other.value]); end + + function ne = new(obj, other) + ne = ~obj.eq(other); + end end methods (Static) diff --git a/tooling/internal/matlab/static_files/+yardl/Exception.m b/tooling/internal/matlab/static_files/Exception.m similarity index 100% rename from tooling/internal/matlab/static_files/+yardl/Exception.m rename to tooling/internal/matlab/static_files/Exception.m diff --git a/tooling/internal/matlab/static_files/+yardl/KeyError.m b/tooling/internal/matlab/static_files/KeyError.m similarity index 100% rename from tooling/internal/matlab/static_files/+yardl/KeyError.m rename to tooling/internal/matlab/static_files/KeyError.m diff --git a/tooling/internal/matlab/static_files/None.m b/tooling/internal/matlab/static_files/None.m new file mode 100644 index 00000000..4a436fcc --- /dev/null +++ b/tooling/internal/matlab/static_files/None.m @@ -0,0 +1,32 @@ +% classdef None < handle +% methods +% function eq = eq(~, other) +% eq = isa(other, 'yardl.None'); +% end + +% function ne = ne(obj, other) +% ne = ~eq(obj, other); +% end +% end +% end + +% classdef None < yardl.Optional +% methods +% function obj = None() +% obj.value_ = NaN; +% obj.has_value_ = false; +% end + +% % function eq = eq(~, other) +% % eq = isa(other, 'yardl.None'); +% % end + +% % function ne = ne(obj, other) +% % ne = ~eq(obj, other); +% % end +% end +% end + +function n = None() + n = yardl.Optional(); +end diff --git a/tooling/internal/matlab/static_files/Optional.m b/tooling/internal/matlab/static_files/Optional.m new file mode 100644 index 00000000..57e5ab4d --- /dev/null +++ b/tooling/internal/matlab/static_files/Optional.m @@ -0,0 +1,95 @@ +classdef Optional < handle + properties (SetAccess=protected) + has_value + value + end + + methods + function obj = Optional(varargin) + if nargin > 0 && ~isa(varargin{1}, 'yardl.Optional') + obj.value = varargin{1}; + obj.has_value = true; + else + obj.value = NaN; + obj.has_value = false; + end + end + + function v = get.value(obj) + if ~obj.has_value + throw(yardl.ValueError("Optional type does not have a value")); + end + v = obj.value; + end + + function eq = eq(a, b) + % if isa(a, 'yardl.Optional') + % if isa(b, 'yardl.Optional') + % if a.has_value && b.has_value + % eq = a.value == b.value; + % else + % eq = a.has_value == b.has_value; + % end + % else + % eq = a.has_value && b == a.value; + % end + % else + % % b is the Optional + % eq = b.has_value && a == b.value; + % end + + if isa(a, 'yardl.Optional') + if isa(b, 'yardl.Optional') + if all([a.has_value]) && all([b.has_value]) + % eq = [a.value] == [b.value]; + eq = isequal([a.value], [b.value]); + else + eq = [a.has_value] == [b.has_value]; + end + else + if all([a.has_value]) + % eq = b == [a.value]; + eq = isequal(b, [a.value]); + else + eq = false; + end + end + else + % b is the Optional + if all([b.has_value]) + % eq = a == [b.value]; + eq = isequal(a, [b.value]); + else + eq = false; + end + end + end + + function ne = ne(a, b) + ne = ~eq(a, b); + end + + function isequal = isequal(a, b) + isequal = all(eq(a, b)); + end + + function isequaln = isequaln(a, b) + isequaln = all(eq(a, b)); + end + end + + methods (Static) + function z = zeros(varargin) + elem = yardl.None; + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/tooling/internal/matlab/static_files/+yardl/ProtocolError.m b/tooling/internal/matlab/static_files/ProtocolError.m similarity index 100% rename from tooling/internal/matlab/static_files/+yardl/ProtocolError.m rename to tooling/internal/matlab/static_files/ProtocolError.m diff --git a/tooling/internal/matlab/static_files/RuntimeError.m b/tooling/internal/matlab/static_files/RuntimeError.m new file mode 100644 index 00000000..3a9c17d7 --- /dev/null +++ b/tooling/internal/matlab/static_files/RuntimeError.m @@ -0,0 +1,3 @@ +function err = RuntimeError(varargin) + err = yardl.Exception("yardl:RuntimeError", varargin{:}); +end diff --git a/tooling/internal/matlab/static_files/+yardl/Time.m b/tooling/internal/matlab/static_files/Time.m similarity index 96% rename from tooling/internal/matlab/static_files/+yardl/Time.m rename to tooling/internal/matlab/static_files/Time.m index ca647ed5..bf19e670 100644 --- a/tooling/internal/matlab/static_files/+yardl/Time.m +++ b/tooling/internal/matlab/static_files/Time.m @@ -34,6 +34,10 @@ eq = isa(other, 'yardl.Time') && ... all([obj.value] == [other.value]); end + + function ne = new(obj, other) + ne = ~obj.eq(other); + end end methods (Static) diff --git a/tooling/internal/matlab/static_files/+yardl/TypeError.m b/tooling/internal/matlab/static_files/TypeError.m similarity index 100% rename from tooling/internal/matlab/static_files/+yardl/TypeError.m rename to tooling/internal/matlab/static_files/TypeError.m diff --git a/tooling/internal/matlab/static_files/+yardl/Union.m b/tooling/internal/matlab/static_files/Union.m similarity index 73% rename from tooling/internal/matlab/static_files/+yardl/Union.m rename to tooling/internal/matlab/static_files/Union.m index 680ff948..4abbae38 100644 --- a/tooling/internal/matlab/static_files/+yardl/Union.m +++ b/tooling/internal/matlab/static_files/Union.m @@ -5,7 +5,6 @@ end methods - function obj = Union(index, value) obj.index_ = index; obj.value_ = value; @@ -18,13 +17,5 @@ function v = value(obj) v = obj.value_; end - - function eq = eq(~, ~) - eq = true; - end - - function neq = neq(~, ~) - neq = false; - end end end diff --git a/tooling/internal/matlab/static_files/+yardl/ValueError.m b/tooling/internal/matlab/static_files/ValueError.m similarity index 100% rename from tooling/internal/matlab/static_files/+yardl/ValueError.m rename to tooling/internal/matlab/static_files/ValueError.m diff --git a/tooling/internal/matlab/static_files/dimension_count.m b/tooling/internal/matlab/static_files/dimension_count.m new file mode 100644 index 00000000..78a48c3c --- /dev/null +++ b/tooling/internal/matlab/static_files/dimension_count.m @@ -0,0 +1,6 @@ +% Alternative to Matlab's `ndims` function +% Collapses dimensions of size 1 (making it behave like numpy.array.ndim) +function c = dimension_count(arr) + s = size(arr); + c = length(s(s > 1)); +end diff --git a/tooling/internal/matlab/types/types.go b/tooling/internal/matlab/types/types.go index d4ecb894..ff4d0612 100644 --- a/tooling/internal/matlab/types/types.go +++ b/tooling/internal/matlab/types/types.go @@ -31,7 +31,7 @@ func WriteTypes(fw *common.MatlabFileWriter, ns *dsl.Namespace, st dsl.SymbolTab err = writeNamedType(fw, td) } case *dsl.EnumDefinition: - err = writeEnum(fw, td) + err = writeEnum(fw, td, nil) case *dsl.RecordDefinition: err = writeRecord(fw, td, st) default: @@ -80,21 +80,42 @@ func writeUnionClasses(fw *common.MatlabFileWriter, td dsl.TypeDefinition, union } func writeUnionClass(w *formatting.IndentedWriter, className string, generalizedType *dsl.GeneralizedType, contextNamespace string) error { + qualifiedClassName := fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(contextNamespace), className) fmt.Fprintf(w, "classdef %s < yardl.Union\n", className) common.WriteBlockBody(w, func() { w.WriteStringln("methods (Static)") common.WriteBlockBody(w, func() { - for i, tc := range generalizedType.Cases { + index := 1 + for _, tc := range generalizedType.Cases { if tc.Type == nil { continue } fmt.Fprintf(w, "function res = %s(value)\n", formatting.ToPascalCase(tc.Tag)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "res = %s.%s(%d, value);\n", common.NamespaceIdentifierName(contextNamespace), className, i+1) + fmt.Fprintf(w, "res = %s(%d, value);\n", qualifiedClassName, index) }) + index += 1 + w.WriteStringln("") } + + writeZerosStaticMethod(w, qualifiedClassName, []string{"0", "yardl.None"}) + }) + w.WriteStringln("") + + w.WriteStringln("methods") + common.WriteBlockBody(w, func() { + w.WriteStringln("function eq = eq(self, other)") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "eq = isa(other, '%s') && other.index == self.index && other.value == self.value;\n", qualifiedClassName) + }) + w.WriteStringln("") + w.WriteStringln("function ne = ne(self, other)") + common.WriteBlockBody(w, func() { + w.WriteStringln("ne = ~self.eq(other);") + }) }) + }) return nil @@ -103,13 +124,103 @@ func writeUnionClass(w *formatting.IndentedWriter, className string, generalized func writeNamedType(fw *common.MatlabFileWriter, td *dsl.NamedType) error { return fw.WriteFile(common.TypeIdentifierName(td.Name), func(w *formatting.IndentedWriter) { common.WriteComment(w, td.Comment) + + ut := dsl.GetUnderlyingType(td.Type) + // If the underlying type is a RecordDefinition or Optional, we will generate a "function" alias + if st, ok := ut.(*dsl.SimpleType); ok { + if _, ok := st.ResolvedDefinition.(*dsl.RecordDefinition); ok { + fmt.Fprintf(w, "function c = %s(varargin) \n", common.TypeIdentifierName(td.Name)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "c = %s(varargin{:});\n", common.TypeSyntax(td.Type, td.Namespace)) + }) + return + } + } else if gt, ok := ut.(*dsl.GeneralizedType); ok { + if gt.Cases.IsOptional() { + innerType := gt.Cases[1].Type + fmt.Fprintf(w, "function o = %s(value) \n", common.TypeIdentifierName(td.Name)) + common.WriteBlockBody(w, func() { + if !dsl.TypeContainsGenericTypeParameter(innerType) { + fmt.Fprintf(w, "assert(isa(value, '%s'));\n", common.TypeSyntax(innerType, td.Namespace)) + } + fmt.Fprintf(w, "o = %s(value);\n", common.TypeSyntax(td.Type, td.Namespace)) + }) + return + } + + switch gt.Dimensionality.(type) { + case *dsl.Vector, *dsl.Array: + scalar := gt.ToScalar() + fmt.Fprintf(w, "function a = %s(array) \n", common.TypeIdentifierName(td.Name)) + common.WriteBlockBody(w, func() { + if !dsl.TypeContainsGenericTypeParameter(scalar) { + fmt.Fprintf(w, "assert(isa(array, '%s'));\n", common.TypeSyntax(scalar, td.Namespace)) + } + // fmt.Fprintf(w, "a = array;\n", common.TypeSyntax(td.Type, td.Namespace)) + w.WriteStringln("a = array;") + }) + return + } + } + + // Otherwise, it's a subclass of the underlying type fmt.Fprintf(w, "classdef %s < %s\n", common.TypeIdentifierName(td.Name), common.TypeSyntax(td.Type, td.Namespace)) w.WriteStringln("end") }) + + // writeClassdefAlias := func() error { + // return fw.WriteFile(common.TypeIdentifierName(td.Name), func(w *formatting.IndentedWriter) { + // common.WriteComment(w, td.Comment) + // fmt.Fprintf(w, "classdef %s < %s\n", common.TypeIdentifierName(td.Name), common.TypeSyntax(td.Type, td.Namespace)) + // w.WriteStringln("end") + // }) + // } + + // writeFunctionAlias := func(t dsl.Type) error { + // return fw.WriteFile(common.TypeIdentifierName(td.Name), func(w *formatting.IndentedWriter) { + // common.WriteComment(w, td.Comment) + // fmt.Fprintf(w, "function c = %s(varargin) \n", common.TypeIdentifierName(td.Name)) + // common.WriteBlockBody(w, func() { + // if t == nil { + // w.WriteStringln("c = varargin{:};") + // } else { + // fmt.Fprintf(w, "c = %s(varargin{:});\n", common.TypeSyntax(t, td.Namespace)) + // } + // }) + // }) + // } + + // ut := dsl.GetUnderlyingType(td.Type) + // // If the underlying type is a RecordDefinition or Optional, we will generate a "function" alias + // if st, ok := ut.(*dsl.SimpleType); ok { + // if _, ok := st.ResolvedDefinition.(*dsl.RecordDefinition); ok { + // return writeFunctionAlias(td.Type) + // } + // } else if gt, ok := ut.(*dsl.GeneralizedType); ok { + // if gt.Cases.IsOptional() { + // return writeFunctionAlias(td.Type) + // } + + // switch gt.Dimensionality.(type) { + // case *dsl.Vector, *dsl.Array: + // // scalar := gt.ToScalar() + // // if dsl.TypeContainsGenericTypeParameter(scalar) { + // // return writeFunctionAlias(nil) + // // } + // // return writeFunctionAlias(scalar) + // return writeFunctionAlias(nil) + // } + // } + + // return writeClassdefAlias() } -func writeEnum(fw *common.MatlabFileWriter, enum *dsl.EnumDefinition) error { - return fw.WriteFile(common.TypeIdentifierName(enum.Name), func(w *formatting.IndentedWriter) { +func writeEnum(fw *common.MatlabFileWriter, enum *dsl.EnumDefinition, namedType *dsl.NamedType) error { + enumName := common.TypeIdentifierName(enum.Name) + if namedType != nil { + enumName = common.TypeIdentifierName(namedType.Name) + } + return fw.WriteFile(enumName, func(w *formatting.IndentedWriter) { var base string if enum.BaseType == nil { base = "uint64" @@ -118,26 +229,30 @@ func writeEnum(fw *common.MatlabFileWriter, enum *dsl.EnumDefinition) error { } common.WriteComment(w, enum.Comment) - fmt.Fprintf(w, "classdef %s < %s\n", common.TypeIdentifierName(enum.Name), base) + fmt.Fprintf(w, "classdef %s < %s\n", enumName, base) common.WriteBlockBody(w, func() { - // NOTE: We don't use Matlab enumeration class because you can't inherit from it - // and we use inheritance to define NamedTypes - w.WriteStringln("properties (Constant)") + w.WriteStringln("methods (Static)") common.WriteBlockBody(w, func() { for _, value := range enum.Values { common.WriteComment(w, value.Comment) - fmt.Fprintf(w, "%s = %d\n", common.EnumValueIdentifierName(value.Symbol), &value.IntegerValue) + fmt.Fprintf(w, "function e = %s\n", common.EnumValueIdentifierName(value.Symbol)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "e = %s(%d);\n", common.TypeSyntax(enum, enum.Namespace), &value.IntegerValue) + }) } + w.WriteStringln("") + writeZerosStaticMethod(w, common.TypeSyntax(enum, enum.Namespace), []string{"0"}) }) }) }) } func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl.SymbolTable) error { - return fw.WriteFile(common.TypeIdentifierName(rec.Name), func(w *formatting.IndentedWriter) { + recordName := common.TypeIdentifierName(rec.Name) + return fw.WriteFile(recordName, func(w *formatting.IndentedWriter) { common.WriteComment(w, rec.Comment) - fmt.Fprintf(w, "classdef %s < handle\n", common.TypeIdentifierName(rec.Name)) + fmt.Fprintf(w, "classdef %s < handle\n", recordName) common.WriteBlockBody(w, func() { w.WriteStringln("properties") @@ -163,10 +278,9 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. common.WriteBlockBody(w, func() { // Record Constructor - fmt.Fprintf(w, "function obj = %s(%s)\n", rec.Name, strings.Join(fieldNames, ", ")) + fmt.Fprintf(w, "function obj = %s(%s)\n", recordName, strings.Join(fieldNames, ", ")) common.WriteBlockBody(w, func() { if requireConstructorArgs { - log.Warn().Msgf("Record %s requires constructor arguments", rec.Name) for _, field := range rec.Fields { fmt.Fprintf(w, "obj.%s = %s;\n", common.FieldIdentifierName(field.Name), common.FieldIdentifierName(field.Name)) } @@ -191,7 +305,6 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. } }) } - }) w.WriteStringln("") @@ -224,24 +337,54 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. w.WriteStringln(";") }) }) + w.WriteStringln("") // neq method + w.WriteStringln("function res = ne(obj, other)") + common.WriteBlockBody(w, func() { + w.WriteStringln("res = ~obj.eq(other);") + }) }) + w.WriteStringln("") + + if !requireConstructorArgs { + w.WriteStringln("methods (Static)") + common.WriteBlockBody(w, func() { + writeZerosStaticMethod(w, common.TypeSyntax(rec, rec.Namespace), []string{}) + }) + } + }) + }) +} +func writeZerosStaticMethod(w *formatting.IndentedWriter, typeSyntax string, defaultArgs []string) { + // zeros method, only if can be constructed without arguments + w.WriteStringln("function z = zeros(varargin)") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "elem = %s(%s);\n", typeSyntax, strings.Join(defaultArgs, ", ")) + w.WriteStringln("if nargin == 0") + w.Indented(func() { + w.WriteStringln("z = elem;") + }) + w.WriteStringln("elseif nargin == 1") + w.Indented(func() { + w.WriteStringln("n = varargin{1};") + w.WriteStringln("z = reshape(repelem(elem, n*n), [n, n]);") + }) + w.WriteStringln("else") + common.WriteBlockBody(w, func() { + w.WriteStringln("sz = [varargin{:}];") + w.WriteStringln("z = reshape(repelem(elem, prod(sz)), sz);") }) }) } func typeEqualityExpression(t dsl.Type, a, b string) string { - // TODO: Figure out equality because in Matlab both 'a' and 'b' can be scalar or non-scalar... if hasSimpleEquality(t) { - // return fmt.Sprintf("%s == %s", a, b) - return fmt.Sprintf("all(%s == %s)", a, b) - // return fmt.Sprintf("all([%s] == [%s])", a, b) + return fmt.Sprintf("all([%s] == [%s])", a, b) } - // TODO: Other forms - return fmt.Sprintf("all(%s == %s)", a, b) + return fmt.Sprintf("isequal(%s, %s)", a, b) } func hasSimpleEquality(t dsl.Node) bool { @@ -306,7 +449,8 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E for i, d := range *dims { fmt.Fprintf(w, "if dim_name == \"%s\"\n", *d.Name) w.Indented(func() { - fmt.Fprintf(w, "dim = %d;\n", len(*dims)-i) + // fmt.Fprintf(w, "dim = %d;\n", len(*dims)-i) + fmt.Fprintf(w, "dim = %d;\n", i) }) w.WriteString("else") } @@ -441,8 +585,24 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E tail.Run(func() { self.Visit(target, tailWrapper{}) - w.WriteString("(") - formatting.Delimited(w, ", ", arguments, func(w *formatting.IndentedWriter, i int, a *dsl.SubscriptArgument) { + + startSubscript := "(" + delimeter := ", " + dsl.Visit(target.GetResolvedType(), func(self dsl.Visitor, node dsl.Node) { + switch t := node.(type) { + case *dsl.GeneralizedType: + switch t.Dimensionality.(type) { + case *dsl.Vector, *dsl.Array: + startSubscript = "(1+" + delimeter = ", 1+" + return + } + } + self.VisitChildren(node) + }) + + w.WriteString(startSubscript) + formatting.Delimited(w, delimeter, arguments, func(w *formatting.IndentedWriter, i int, a *dsl.SubscriptArgument) { self.Visit(a.Value, tailWrapper{}) }) w.WriteString(")") @@ -453,40 +613,48 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E switch t.FunctionName { case dsl.FunctionSize: switch dsl.ToGeneralizedType(dsl.GetUnderlyingType(t.Arguments[0].GetResolvedType())).Dimensionality.(type) { - case *dsl.Vector, *dsl.Map: - fmt.Fprintf(w, "length(") + case *dsl.Map: + // length for containers.Map, numEntries for dictionary + fmt.Fprintf(w, "numEntries(") self.Visit(t.Arguments[0], tailWrapper{}) fmt.Fprintf(w, ")") - case *dsl.Array: - w.WriteString("size(") + + case *dsl.Vector: + fmt.Fprintf(w, "length(") self.Visit(t.Arguments[0], tailWrapper{}) + fmt.Fprintf(w, ")") + case *dsl.Array: if len(t.Arguments) > 1 { - w.WriteString(", [") + w.WriteString("size(") + self.Visit(t.Arguments[0], tailWrapper{}) + w.WriteString(", 1+") remainingArgs := t.Arguments[1:] - formatting.Delimited(w, ", ", remainingArgs, func(w *formatting.IndentedWriter, i int, arg dsl.Expression) { - if _, ok := arg.(*dsl.IntegerLiteralExpression); ok { - // Need to adjust integer literals for 1-based indexing in Matlab - // fmt.Fprintf(w, "%d", big.NewInt(0).Add(&intArg.Value, big.NewInt(1))) - w.WriteString("ndims(") - self.Visit(t.Arguments[0], tailWrapper{}) - w.WriteString(")-") - } + formatting.Delimited(w, ", 1+", remainingArgs, func(w *formatting.IndentedWriter, i int, arg dsl.Expression) { + // if _, ok := arg.(*dsl.IntegerLiteralExpression); ok { + // // Need to adjust integer literals for 1-based indexing in Matlab + // // fmt.Fprintf(w, "%d", big.NewInt(0).Add(&intArg.Value, big.NewInt(1))) + // w.WriteString("ndims(") + // self.Visit(t.Arguments[0], tailWrapper{}) + // w.WriteString(")-") + // } self.Visit(arg, tailWrapper{}) }) - fmt.Fprintf(w, "]") + } else { + w.WriteString("numel(") + self.Visit(t.Arguments[0], tailWrapper{}) } w.WriteString(")") } case dsl.FunctionDimensionIndex: helperFuncName := helperFunctionLookup[t.Arguments[0].GetResolvedType()] - fmt.Fprintf(w, "%s(", helperFuncName) + fmt.Fprintf(w, "1 + %s(", helperFuncName) self.Visit(t.Arguments[1], tailWrapper{}) w.WriteString(")") case dsl.FunctionDimensionCount: - w.WriteString("ndims(") + w.WriteString("yardl.dimension_count(") self.Visit(t.Arguments[0], tailWrapper{}) w.WriteString(")") @@ -546,7 +714,7 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E writeSwitchCaseOverUnion(w, targetType, unionClassName, switchCase, unionVariableName, self, tail) } - w.WriteStringln(`throw(yardl.Error("Unexpected union case"))`) + w.WriteStringln(`throw(yardl.RuntimeError("Unexpected union case"))`) return } @@ -593,9 +761,13 @@ func writeSwitchCaseOverOptional(w *formatting.IndentedWriter, switchCase *dsl.S } if typePattern.Type == nil { - fmt.Fprintf(w, "if isa(%s, yardl.None)\n", variableName) + // fmt.Fprintf(w, "if isa(%s, 'yardl.None')\n", variableName) + // fmt.Fprintf(w, "if isa(%s, 'yardl.Optional') && ~%s.has_value()\n", variableName, variableName) + fmt.Fprintf(w, "if %s == yardl.None\n", variableName) } else { - fmt.Fprintf(w, "if ~isa(%s, yardl.None)\n", variableName) + // fmt.Fprintf(w, "if ~isa(%s, 'yardl.None')\n", variableName) + // fmt.Fprintf(w, "if isa(%s, 'yardl.Optional') && %s.has_value()\n", variableName, variableName) + fmt.Fprintf(w, "if %s ~= yardl.None\n", variableName) } common.WriteBlockBody(w, func() { @@ -616,20 +788,29 @@ func writeSwitchCaseOverOptional(w *formatting.IndentedWriter, switchCase *dsl.S } func writeSwitchCaseOverUnion(w *formatting.IndentedWriter, unionType *dsl.GeneralizedType, unionClassName string, switchCase *dsl.SwitchCase, variableName string, visitor dsl.VisitorWithContext[tailWrapper], tail tailWrapper) { + caseIndexOffset := 1 writeTypeCase := func(typePattern *dsl.TypePattern, declarationIdentifier string) { for i, typeCase := range unionType.Cases { + if typeCase.Type == nil { + caseIndexOffset = 0 + } + + log.Warn().Msgf("%d: %s | %d", i, typeCase.Tag, caseIndexOffset) + if dsl.TypesEqual(typePattern.Type, typeCase.Type) { if typePattern.Type == nil { - fmt.Fprintf(w, "if isa(%s, 'yardl.None')\n", variableName) + // fmt.Fprintf(w, "if isa(%s, 'yardl.None')\n", variableName) + // fmt.Fprintf(w, "if isa(%s, 'yardl.Optional') && ~%s.has_value()\n", variableName, variableName) + fmt.Fprintf(w, "if %s == yardl.None\n", variableName) common.WriteBlockBody(w, func() { visitor.Visit(switchCase.Expression, tail) }) } else { // fmt.Fprintf(w, "if isa(%s, %s.%s):\n", variableName, unionClassName, formatting.ToPascalCase(typeCase.Tag)) - fmt.Fprintf(w, "if %s.index == %d\n", variableName, i+1) + fmt.Fprintf(w, "if %s.index == %d\n", variableName, i+caseIndexOffset) common.WriteBlockBody(w, func() { if declarationIdentifier != "" { - fmt.Fprintf(w, "%s = %s.value\n", declarationIdentifier, variableName) + fmt.Fprintf(w, "%s = %s.value;\n", declarationIdentifier, variableName) } visitor.Visit(switchCase.Expression, tail) }) @@ -753,6 +934,7 @@ func typeDefault(t dsl.Type, contextNamespace string, namedType string, st dsl.S } return fmt.Sprintf(`("%s", %s)`, t.Cases[0].Tag, defaultExpression), defaultValueKindImmutable + case *dsl.Vector: scalar := t.ToScalar() if dsl.TypeContainsGenericTypeParameter(scalar) { @@ -760,13 +942,11 @@ func typeDefault(t dsl.Type, contextNamespace string, namedType string, st dsl.S } dtype := common.TypeSyntax(scalar, contextNamespace) - if td.Length == nil { return fmt.Sprintf("%s.empty()", dtype), defaultValueKindMutable } scalarDefault, scalarDefaultKind := typeDefault(t.Cases[0].Type, contextNamespace, "", st) - switch scalarDefaultKind { case defaultValueKindNone: return "", defaultValueKindNone @@ -795,16 +975,15 @@ func typeDefault(t dsl.Type, contextNamespace string, namedType string, st dsl.S } dtype := common.TypeSyntax(scalar, contextNamespace) - if td.HasKnownNumberOfDimensions() { shape := strings.Repeat("0, ", len(*td.Dimensions))[0 : len(*td.Dimensions)*3-2] return fmt.Sprintf("%s.empty(%s)", dtype, shape), defaultValueKindMutable } - return fmt.Sprintf("%s.empty()", dtype), defaultValueKindMutable case *dsl.Map: - return "containers.Map", defaultValueKindMutable + // return "containers.Map", defaultValueKindMutable + return "dictionary", defaultValueKindMutable } } @@ -836,9 +1015,11 @@ func typeDefinitionDefault(t dsl.TypeDefinition, contextNamespace string, st dsl case dsl.Float32: return "single(0)", defaultValueKindImmutable case dsl.Float64: - return "0", defaultValueKindImmutable - case dsl.ComplexFloat32, dsl.ComplexFloat64: - return "0j", defaultValueKindImmutable + return "double(0)", defaultValueKindImmutable + case dsl.ComplexFloat32: + return "complex(single(0))", defaultValueKindImmutable + case dsl.ComplexFloat64: + return "complex(0)", defaultValueKindImmutable case dsl.String: return `""`, defaultValueKindImmutable case dsl.Date: @@ -848,6 +1029,7 @@ func typeDefinitionDefault(t dsl.TypeDefinition, contextNamespace string, st dsl case dsl.DateTime: return "yardl.DateTime()", defaultValueKindImmutable } + case *dsl.EnumDefinition: zeroValue := t.GetZeroValue() if t.IsFlags { @@ -863,6 +1045,7 @@ func typeDefinitionDefault(t dsl.TypeDefinition, contextNamespace string, st dsl } return fmt.Sprintf("%s.%s", common.TypeSyntax(t, contextNamespace), common.EnumValueIdentifierName(zeroValue.Symbol)), defaultValueKindImmutable + case *dsl.NamedType: return typeDefault(t.Type, contextNamespace, common.TypeSyntax(t, contextNamespace), st) diff --git a/tooling/pkg/packaging/packageinfo.go b/tooling/pkg/packaging/packageinfo.go index 982006e6..175de620 100644 --- a/tooling/pkg/packaging/packageinfo.go +++ b/tooling/pkg/packaging/packageinfo.go @@ -220,6 +220,7 @@ type MatlabCodegenOptions struct { PackageInfo *PackageInfo `yaml:"-"` OutputDir string `yaml:"outputDir"` InternalSymlinkStaticFiles bool `yaml:"internalSymlinkStaticFiles"` + InternalGenerateMocks bool `yaml:"internalGenerateMocks"` } // Parses PackageInfo in dir then loads all package Imports and Predecessors From 6e6f5fa57452ea3c7073330c0aca81f2884ece78 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Fri, 22 Mar 2024 18:53:06 +0000 Subject: [PATCH 09/32] Move Matlab binary serializers to "binary" package --- matlab/tests/RoundTripTest.m | 11 ++++------- tooling/internal/matlab/binary/binary.go | 8 +++++--- tooling/internal/matlab/matlab.go | 16 ++++++++++------ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/matlab/tests/RoundTripTest.m b/matlab/tests/RoundTripTest.m index 77c21569..47663008 100644 --- a/matlab/tests/RoundTripTest.m +++ b/matlab/tests/RoundTripTest.m @@ -1,7 +1,7 @@ classdef RoundTripTest < matlab.unittest.TestCase properties (TestParameter) - % format = {"Binary", "NDJson"}; - format = {"Binary"}; + % format = {"binary", "ndjson"}; + format = {"binary"}; end methods (Test) @@ -471,11 +471,8 @@ function testAliases(testCase, format) function w = create_validating_writer(testCase, format, protocol) - % writer_name = 'test_model.' + format + eraseBetween(name, strlength(name)-3, strlength(name)); - % reader_name = replaceBetween(wname, strlength(wname)-5, strlength(wname), "Reader"); - - writer_name = "test_model." + format + protocol + "Writer"; - reader_name = "test_model." + format + protocol + "Reader"; + writer_name = "test_model." + format + "." + protocol + "Writer"; + reader_name = "test_model." + format + "." + protocol + "Reader"; test_writer_name = "test_model.testing.Test" + protocol + "Writer"; create_writer = str2func(writer_name); diff --git a/tooling/internal/matlab/binary/binary.go b/tooling/internal/matlab/binary/binary.go index a331249d..88ad2101 100644 --- a/tooling/internal/matlab/binary/binary.go +++ b/tooling/internal/matlab/binary/binary.go @@ -193,7 +193,7 @@ func typeDefinitionSerializer(td dsl.TypeDefinition, contextNamespace string) st return fmt.Sprintf("yardl.binary.EnumSerializer('%s', @%s, %s)", enumSyntax, enumSyntax, elementSerializer) case *dsl.RecordDefinition: - qualifiedSerializerName := fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(td.Namespace), recordSerializerClassName(td, contextNamespace)) + qualifiedSerializerName := fmt.Sprintf("%s.binary.%s", common.NamespaceIdentifierName(td.Namespace), recordSerializerClassName(td, contextNamespace)) if len(td.TypeParameters) == 0 { return fmt.Sprintf("%s()", qualifiedSerializerName) } @@ -301,9 +301,11 @@ func typeSerializer(t dsl.Type, contextNamespace string, namedType *dsl.NamedTyp } func BinaryWriterName(p *dsl.ProtocolDefinition) string { - return fmt.Sprintf("Binary%sWriter", formatting.ToPascalCase(p.Name)) + // return fmt.Sprintf("Binary%sWriter", formatting.ToPascalCase(p.Name)) + return fmt.Sprintf("%sWriter", formatting.ToPascalCase(p.Name)) } func BinaryReaderName(p *dsl.ProtocolDefinition) string { - return fmt.Sprintf("Binary%sReader", formatting.ToPascalCase(p.Name)) + // return fmt.Sprintf("Binary%sReader", formatting.ToPascalCase(p.Name)) + return fmt.Sprintf("%sReader", formatting.ToPascalCase(p.Name)) } diff --git a/tooling/internal/matlab/matlab.go b/tooling/internal/matlab/matlab.go index 71edf1ad..d7c7a2dc 100644 --- a/tooling/internal/matlab/matlab.go +++ b/tooling/internal/matlab/matlab.go @@ -38,13 +38,13 @@ func Generate(env *dsl.Environment, options packaging.MatlabCodegenOptions) erro return err } - fw := &common.MatlabFileWriter{PackageDir: packageDir} - if err := types.WriteTypes(fw, ns, env.SymbolTable); err != nil { + topLevelFileWriter := &common.MatlabFileWriter{PackageDir: packageDir} + if err := types.WriteTypes(topLevelFileWriter, ns, env.SymbolTable); err != nil { return err } if ns.IsTopLevel { - if err := protocols.WriteProtocols(fw, ns, env.SymbolTable); err != nil { + if err := protocols.WriteProtocols(topLevelFileWriter, ns, env.SymbolTable); err != nil { return err } @@ -54,14 +54,18 @@ func Generate(env *dsl.Environment, options packaging.MatlabCodegenOptions) erro return err } fw := &common.MatlabFileWriter{PackageDir: mocksDir} - err = mocks.WriteMocks(fw, ns) - if err != nil { + if err := mocks.WriteMocks(fw, ns); err != nil { return err } } } - if err := binary.WriteBinary(fw, ns); err != nil { + binaryDir := path.Join(packageDir, common.PackageDir("binary")) + if err := os.MkdirAll(binaryDir, 0775); err != nil { + return err + } + binaryFileWriter := &common.MatlabFileWriter{PackageDir: binaryDir} + if err := binary.WriteBinary(binaryFileWriter, ns); err != nil { return err } } From 6ff51259b7e99aab7efc55c615a7a7f0bc6aa153 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Fri, 22 Mar 2024 18:57:08 +0000 Subject: [PATCH 10/32] Adding generated Matlab files for the first time --- ...enericRecordWithComputedFieldsSerializer.m | 18 + .../+binary/RecordWithUnionsSerializer.m | 20 + matlab/generated/+basic_types/AliasedMap.m | 2 + matlab/generated/+basic_types/DaysOfWeek.m | 38 ++ matlab/generated/+basic_types/Fruits.m | 26 + .../+basic_types/GenericNullableUnion2.m | 34 + .../GenericRecordWithComputedFields.m | 36 ++ matlab/generated/+basic_types/GenericUnion2.m | 34 + matlab/generated/+basic_types/GenericVector.m | 3 + matlab/generated/+basic_types/Int32OrString.m | 34 + matlab/generated/+basic_types/MyTuple.m | 3 + .../generated/+basic_types/RecordWithUnions.m | 48 ++ matlab/generated/+basic_types/T0OrT1.m | 34 + matlab/generated/+basic_types/TextFormat.m | 32 + .../generated/+basic_types/TimeOrDatetime.m | 34 + matlab/generated/+image/FloatImage.m | 4 + matlab/generated/+image/Image.m | 3 + matlab/generated/+image/IntImage.m | 4 + .../+binary/AdvancedGenericsReader.m | 36 ++ .../+binary/AdvancedGenericsWriter.m | 36 ++ .../+test_model/+binary/AliasesReader.m | 61 ++ .../+test_model/+binary/AliasesWriter.m | 61 ++ .../+binary/BenchmarkFloat256x256Reader.m | 16 + .../+binary/BenchmarkFloat256x256Writer.m | 16 + .../+binary/BenchmarkFloatVlenReader.m | 16 + .../+binary/BenchmarkFloatVlenWriter.m | 16 + .../+binary/BenchmarkInt256x256Reader.m | 16 + .../+binary/BenchmarkInt256x256Writer.m | 16 + .../+binary/BenchmarkSimpleMrdReader.m | 16 + .../+binary/BenchmarkSimpleMrdWriter.m | 16 + .../+binary/BenchmarkSmallRecordReader.m | 16 + .../BenchmarkSmallRecordWithOptionalsReader.m | 16 + .../BenchmarkSmallRecordWithOptionalsWriter.m | 16 + .../+binary/BenchmarkSmallRecordWriter.m | 16 + .../+binary/DynamicNDArraysReader.m | 31 + .../+binary/DynamicNDArraysWriter.m | 31 + .../+test_model/+binary/EnumsReader.m | 26 + .../+test_model/+binary/EnumsWriter.m | 26 + .../+test_model/+binary/FixedArraysReader.m | 36 ++ .../+test_model/+binary/FixedArraysWriter.m | 36 ++ .../+test_model/+binary/FixedVectorsReader.m | 31 + .../+test_model/+binary/FixedVectorsWriter.m | 31 + .../+test_model/+binary/FlagsReader.m | 21 + .../+test_model/+binary/FlagsWriter.m | 21 + .../+binary/GenericRecordSerializer.m | 21 + .../+test_model/+binary/MapsReader.m | 31 + .../+test_model/+binary/MapsWriter.m | 31 + .../+test_model/+binary/NDArraysReader.m | 36 ++ .../+binary/NDArraysSingleDimensionReader.m | 31 + .../+binary/NDArraysSingleDimensionWriter.m | 31 + .../+test_model/+binary/NDArraysWriter.m | 36 ++ .../+test_model/+binary/NestedRecordsReader.m | 16 + .../+test_model/+binary/NestedRecordsWriter.m | 16 + .../+binary/OptionalVectorsReader.m | 16 + .../+binary/OptionalVectorsWriter.m | 16 + .../ProtocolWithComputedFieldsReader.m | 16 + .../ProtocolWithComputedFieldsWriter.m | 16 + .../+binary/ProtocolWithKeywordStepsReader.m | 21 + .../+binary/ProtocolWithKeywordStepsWriter.m | 21 + ...RecordContainingGenericRecordsSerializer.m | 27 + ...ContainingNestedGenericRecordsSerializer.m | 22 + .../RecordNotUsedInProtocolSerializer.m | 19 + .../RecordWithAliasedGenericsSerializer.m | 19 + ...ithAliasedOptionalGenericFieldSerializer.m | 18 + ...iasedOptionalGenericUnionFieldSerializer.m | 18 + .../+binary/RecordWithArraysSerializer.m | 26 + .../RecordWithArraysSimpleSyntaxSerializer.m | 26 + .../RecordWithComputedFieldsSerializer.m | 44 ++ .../RecordWithDynamicNDArraysSerializer.m | 20 + .../+binary/RecordWithEnumsSerializer.m | 20 + .../+binary/RecordWithFixedArraysSerializer.m | 20 + .../RecordWithFixedCollectionsSerializer.m | 19 + .../RecordWithFixedVectorsSerializer.m | 20 + .../RecordWithGenericArraysSerializer.m | 23 + .../RecordWithGenericFixedVectorsSerializer.m | 19 + .../+binary/RecordWithGenericMapsSerializer.m | 19 + ...cordWithGenericVectorOfRecordsSerializer.m | 18 + .../RecordWithGenericVectorsSerializer.m | 19 + .../RecordWithKeywordFieldsSerializer.m | 20 + .../+binary/RecordWithNDArraysSerializer.m | 20 + ...ordWithNDArraysSingleDimensionSerializer.m | 20 + .../RecordWithNamedFixedArraysSerializer.m | 20 + .../RecordWithOptionalFieldsSerializer.m | 20 + ...RecordWithOptionalGenericFieldSerializer.m | 18 + ...dWithOptionalGenericUnionFieldSerializer.m | 18 + .../RecordWithOptionalVectorSerializer.m | 18 + .../RecordWithPrimitiveAliasesSerializer.m | 26 + .../+binary/RecordWithPrimitivesSerializer.m | 34 + .../+binary/RecordWithStringsSerializer.m | 19 + .../RecordWithUnionsOfContainersSerializer.m | 20 + .../RecordWithVectorOfTimesSerializer.m | 18 + .../+binary/RecordWithVectorsSerializer.m | 20 + .../RecordWithVlenCollectionsSerializer.m | 19 + .../+binary/RecordWithVlensSerializer.m | 20 + .../+binary/ScalarOptionalsReader.m | 31 + .../+binary/ScalarOptionalsWriter.m | 31 + .../+test_model/+binary/ScalarsReader.m | 21 + .../+test_model/+binary/ScalarsWriter.m | 21 + .../+binary/SimpleAcquisitionSerializer.m | 21 + .../SimpleEncodingCountersSerializer.m | 21 + .../+binary/SimpleGenericsReader.m | 56 ++ .../+binary/SimpleGenericsWriter.m | 56 ++ .../+binary/SimpleRecordSerializer.m | 20 + .../+binary/SmallBenchmarkRecordSerializer.m | 20 + .../+test_model/+binary/StateTestReader.m | 26 + .../+test_model/+binary/StateTestWriter.m | 26 + .../+binary/StreamsOfAliasedUnionsReader.m | 21 + .../+binary/StreamsOfAliasedUnionsWriter.m | 21 + .../+binary/StreamsOfUnionsReader.m | 21 + .../+binary/StreamsOfUnionsWriter.m | 21 + .../+test_model/+binary/StreamsReader.m | 31 + .../+test_model/+binary/StreamsWriter.m | 31 + .../+test_model/+binary/StringsReader.m | 21 + .../+test_model/+binary/StringsWriter.m | 21 + .../+binary/SubarraysInRecordsReader.m | 21 + .../+binary/SubarraysInRecordsWriter.m | 21 + .../+test_model/+binary/SubarraysReader.m | 56 ++ .../+test_model/+binary/SubarraysWriter.m | 56 ++ .../+binary/TupleWithRecordsSerializer.m | 19 + .../+test_model/+binary/UnionsReader.m | 31 + .../+test_model/+binary/UnionsWriter.m | 31 + .../+test_model/+binary/VlensReader.m | 31 + .../+test_model/+binary/VlensWriter.m | 31 + .../+testing/MockAdvancedGenericsWriter.m | 91 +++ .../+test_model/+testing/MockAliasesWriter.m | 161 +++++ .../MockBenchmarkFloat256x256Writer.m | 35 ++ .../+testing/MockBenchmarkFloatVlenWriter.m | 35 ++ .../+testing/MockBenchmarkInt256x256Writer.m | 35 ++ .../+testing/MockBenchmarkSimpleMrdWriter.m | 35 ++ ...kBenchmarkSmallRecordWithOptionalsWriter.m | 35 ++ .../+testing/MockBenchmarkSmallRecordWriter.m | 35 ++ .../+testing/MockDynamicNDArraysWriter.m | 77 +++ .../+test_model/+testing/MockEnumsWriter.m | 63 ++ .../+testing/MockFixedArraysWriter.m | 91 +++ .../+testing/MockFixedVectorsWriter.m | 77 +++ .../+test_model/+testing/MockFlagsWriter.m | 49 ++ .../+test_model/+testing/MockMapsWriter.m | 77 +++ .../MockNDArraysSingleDimensionWriter.m | 77 +++ .../+test_model/+testing/MockNDArraysWriter.m | 91 +++ .../+testing/MockNestedRecordsWriter.m | 35 ++ .../+testing/MockOptionalVectorsWriter.m | 35 ++ .../MockProtocolWithComputedFieldsWriter.m | 35 ++ .../MockProtocolWithKeywordStepsWriter.m | 49 ++ .../+testing/MockScalarOptionalsWriter.m | 77 +++ .../+test_model/+testing/MockScalarsWriter.m | 49 ++ .../+testing/MockSimpleGenericsWriter.m | 147 +++++ .../+testing/MockStateTestWriter.m | 63 ++ .../MockStreamsOfAliasedUnionsWriter.m | 49 ++ .../+testing/MockStreamsOfUnionsWriter.m | 49 ++ .../+test_model/+testing/MockStreamsWriter.m | 77 +++ .../+test_model/+testing/MockStringsWriter.m | 49 ++ .../+testing/MockSubarraysInRecordsWriter.m | 49 ++ .../+testing/MockSubarraysWriter.m | 147 +++++ .../+test_model/+testing/MockUnionsWriter.m | 77 +++ .../+test_model/+testing/MockVlensWriter.m | 77 +++ .../+testing/TestAdvancedGenericsWriter.m | 63 ++ .../+test_model/+testing/TestAliasesWriter.m | 88 +++ .../TestBenchmarkFloat256x256Writer.m | 43 ++ .../+testing/TestBenchmarkFloatVlenWriter.m | 43 ++ .../+testing/TestBenchmarkInt256x256Writer.m | 43 ++ .../+testing/TestBenchmarkSimpleMrdWriter.m | 43 ++ ...tBenchmarkSmallRecordWithOptionalsWriter.m | 43 ++ .../+testing/TestBenchmarkSmallRecordWriter.m | 43 ++ .../+testing/TestDynamicNDArraysWriter.m | 58 ++ .../+test_model/+testing/TestEnumsWriter.m | 53 ++ .../+testing/TestFixedArraysWriter.m | 63 ++ .../+testing/TestFixedVectorsWriter.m | 58 ++ .../+test_model/+testing/TestFlagsWriter.m | 48 ++ .../+test_model/+testing/TestMapsWriter.m | 58 ++ .../TestNDArraysSingleDimensionWriter.m | 58 ++ .../+test_model/+testing/TestNDArraysWriter.m | 63 ++ .../+testing/TestNestedRecordsWriter.m | 43 ++ .../+testing/TestOptionalVectorsWriter.m | 43 ++ .../TestProtocolWithComputedFieldsWriter.m | 43 ++ .../TestProtocolWithKeywordStepsWriter.m | 48 ++ .../+testing/TestScalarOptionalsWriter.m | 58 ++ .../+test_model/+testing/TestScalarsWriter.m | 48 ++ .../+testing/TestSimpleGenericsWriter.m | 83 +++ .../+testing/TestStateTestWriter.m | 53 ++ .../TestStreamsOfAliasedUnionsWriter.m | 48 ++ .../+testing/TestStreamsOfUnionsWriter.m | 48 ++ .../+test_model/+testing/TestStreamsWriter.m | 58 ++ .../+test_model/+testing/TestStringsWriter.m | 48 ++ .../+testing/TestSubarraysInRecordsWriter.m | 48 ++ .../+testing/TestSubarraysWriter.m | 83 +++ .../+test_model/+testing/TestUnionsWriter.m | 58 ++ .../+test_model/+testing/TestVlensWriter.m | 58 ++ .../+test_model/AcquisitionOrImage.m | 34 + .../+test_model/AdvancedGenericsReaderBase.m | 122 ++++ .../+test_model/AdvancedGenericsWriterBase.m | 111 ++++ .../+test_model/AliasedClosedGeneric.m | 3 + matlab/generated/+test_model/AliasedEnum.m | 2 + .../+test_model/AliasedGenericDynamicArray.m | 3 + .../+test_model/AliasedGenericFixedArray.m | 3 + .../+test_model/AliasedGenericFixedVector.m | 3 + .../+test_model/AliasedGenericOptional.m | 3 + .../+test_model/AliasedGenericRank2Array.m | 3 + .../+test_model/AliasedGenericUnion2.m | 2 + .../+test_model/AliasedGenericVector.m | 3 + .../+test_model/AliasedIntOrSimpleRecord.m | 34 + matlab/generated/+test_model/AliasedMap.m | 2 + .../+test_model/AliasedMultiGenericOptional.m | 34 + .../AliasedNullableIntSimpleRecord.m | 34 + .../+test_model/AliasedOpenGeneric.m | 3 + .../generated/+test_model/AliasedOptional.m | 4 + matlab/generated/+test_model/AliasedString.m | 2 + matlab/generated/+test_model/AliasedTuple.m | 3 + .../AliasedVectorOfGenericRecords.m | 3 + .../generated/+test_model/AliasesReaderBase.m | 192 ++++++ .../generated/+test_model/AliasesWriterBase.m | 181 ++++++ matlab/generated/+test_model/ArrayOrScalar.m | 34 + .../ArrayWithKeywordDimensionNames.m | 4 + .../BenchmarkFloat256x256ReaderBase.m | 66 ++ .../BenchmarkFloat256x256WriterBase.m | 64 ++ .../BenchmarkFloatVlenReaderBase.m | 66 ++ .../BenchmarkFloatVlenWriterBase.m | 64 ++ .../BenchmarkInt256x256ReaderBase.m | 66 ++ .../BenchmarkInt256x256WriterBase.m | 64 ++ .../BenchmarkSimpleMrdReaderBase.m | 66 ++ .../BenchmarkSimpleMrdWriterBase.m | 64 ++ .../BenchmarkSmallRecordReaderBase.m | 66 ++ ...chmarkSmallRecordWithOptionalsReaderBase.m | 66 ++ ...chmarkSmallRecordWithOptionalsWriterBase.m | 64 ++ .../BenchmarkSmallRecordWriterBase.m | 64 ++ matlab/generated/+test_model/DaysOfWeek.m | 2 + .../+test_model/DynamicNDArraysReaderBase.m | 108 ++++ .../+test_model/DynamicNDArraysWriterBase.m | 98 +++ .../+test_model/EnumWithKeywordSymbols.m | 23 + .../generated/+test_model/EnumsReaderBase.m | 94 +++ .../generated/+test_model/EnumsWriterBase.m | 85 +++ .../+test_model/FixedArraysReaderBase.m | 122 ++++ .../+test_model/FixedArraysWriterBase.m | 111 ++++ .../+test_model/FixedVectorsReaderBase.m | 108 ++++ .../+test_model/FixedVectorsWriterBase.m | 98 +++ .../generated/+test_model/FlagsReaderBase.m | 80 +++ .../generated/+test_model/FlagsWriterBase.m | 80 +++ matlab/generated/+test_model/Fruits.m | 2 + matlab/generated/+test_model/GenericRecord.m | 31 + matlab/generated/+test_model/GenericUnion3.m | 38 ++ .../+test_model/GenericUnion3Alternate.m | 38 ++ .../GenericUnionWithRepeatedTypeParameters.m | 38 ++ matlab/generated/+test_model/Image.m | 3 + .../+test_model/ImageFloatOrImageDouble.m | 34 + matlab/generated/+test_model/Int32OrFloat32.m | 34 + .../+test_model/Int32OrRecordWithVlens.m | 34 + .../+test_model/Int32OrSimpleRecord.m | 34 + matlab/generated/+test_model/Int64Enum.m | 20 + matlab/generated/+test_model/IntArray.m | 4 + matlab/generated/+test_model/IntFixedArray.m | 4 + .../IntOrGenericRecordWithComputedFields.m | 34 + matlab/generated/+test_model/IntRank2Array.m | 4 + matlab/generated/+test_model/MapOrScalar.m | 34 + matlab/generated/+test_model/MapsReaderBase.m | 108 ++++ matlab/generated/+test_model/MapsWriterBase.m | 98 +++ matlab/generated/+test_model/MyTuple.m | 3 + .../+test_model/NDArraysReaderBase.m | 122 ++++ .../NDArraysSingleDimensionReaderBase.m | 108 ++++ .../NDArraysSingleDimensionWriterBase.m | 98 +++ .../+test_model/NDArraysWriterBase.m | 111 ++++ .../generated/+test_model/NamedFixedNDArray.m | 4 + matlab/generated/+test_model/NamedNDArray.m | 4 + .../+test_model/NestedRecordsReaderBase.m | 66 ++ .../+test_model/NestedRecordsWriterBase.m | 59 ++ .../+test_model/OptionalVectorsReaderBase.m | 66 ++ .../+test_model/OptionalVectorsWriterBase.m | 59 ++ .../ProtocolWithComputedFieldsReaderBase.m | 66 ++ .../ProtocolWithComputedFieldsWriterBase.m | 59 ++ .../ProtocolWithKeywordStepsReaderBase.m | 80 +++ .../ProtocolWithKeywordStepsWriterBase.m | 75 +++ .../RecordContainingGenericRecords.m | 49 ++ .../RecordContainingNestedGenericRecords.m | 56 ++ .../+test_model/RecordNotUsedInProtocol.m | 44 ++ .../+test_model/RecordWithAliasedGenerics.m | 44 ++ .../RecordWithAliasedOptionalGenericField.m | 40 ++ ...cordWithAliasedOptionalGenericUnionField.m | 40 ++ .../generated/+test_model/RecordWithArrays.m | 72 +++ .../RecordWithArraysSimpleSyntax.m | 72 +++ .../+test_model/RecordWithComputedFields.m | 585 ++++++++++++++++++ .../+test_model/RecordWithDynamicNDArrays.m | 48 ++ .../generated/+test_model/RecordWithEnums.m | 48 ++ .../+test_model/RecordWithFixedArrays.m | 48 ++ .../+test_model/RecordWithFixedCollections.m | 44 ++ .../+test_model/RecordWithFixedVectors.m | 48 ++ .../+test_model/RecordWithGenericArrays.m | 37 ++ .../RecordWithGenericFixedVectors.m | 25 + .../+test_model/RecordWithGenericMaps.m | 44 ++ .../RecordWithGenericVectorOfRecords.m | 22 + .../+test_model/RecordWithGenericVectors.m | 25 + .../+test_model/RecordWithKeywordFields.m | 44 ++ .../+test_model/RecordWithNDArrays.m | 48 ++ .../RecordWithNDArraysSingleDimension.m | 48 ++ .../+test_model/RecordWithNamedFixedArrays.m | 48 ++ .../+test_model/RecordWithOptionalFields.m | 48 ++ .../RecordWithOptionalGenericField.m | 40 ++ .../RecordWithOptionalGenericUnionField.m | 40 ++ .../+test_model/RecordWithOptionalVector.m | 40 ++ .../+test_model/RecordWithPrimitiveAliases.m | 72 +++ .../+test_model/RecordWithPrimitives.m | 104 ++++ .../generated/+test_model/RecordWithStrings.m | 44 ++ .../RecordWithUnionsOfContainers.m | 48 ++ .../+test_model/RecordWithVectorOfTimes.m | 40 ++ .../generated/+test_model/RecordWithVectors.m | 48 ++ .../+test_model/RecordWithVlenCollections.m | 44 ++ .../generated/+test_model/RecordWithVlens.m | 48 ++ .../+test_model/RecordWithVlensFixedArray.m | 4 + .../+test_model/ScalarOptionalsReaderBase.m | 108 ++++ .../+test_model/ScalarOptionalsWriterBase.m | 98 +++ .../generated/+test_model/ScalarsReaderBase.m | 80 +++ .../generated/+test_model/ScalarsWriterBase.m | 72 +++ .../generated/+test_model/SimpleAcquisition.m | 52 ++ .../+test_model/SimpleEncodingCounters.m | 52 ++ .../+test_model/SimpleGenericsReaderBase.m | 178 ++++++ .../+test_model/SimpleGenericsWriterBase.m | 168 +++++ matlab/generated/+test_model/SimpleRecord.m | 48 ++ .../+test_model/SimpleRecordFixedArray.m | 4 + matlab/generated/+test_model/SizeBasedEnum.m | 26 + .../+test_model/SmallBenchmarkRecord.m | 48 ++ .../+test_model/StateTestReaderBase.m | 94 +++ .../+test_model/StateTestWriterBase.m | 88 +++ .../StreamsOfAliasedUnionsReaderBase.m | 80 +++ .../StreamsOfAliasedUnionsWriterBase.m | 80 +++ .../+test_model/StreamsOfUnionsReaderBase.m | 80 +++ .../+test_model/StreamsOfUnionsWriterBase.m | 80 +++ .../generated/+test_model/StreamsReaderBase.m | 108 ++++ .../generated/+test_model/StreamsWriterBase.m | 112 ++++ matlab/generated/+test_model/StringOrInt32.m | 34 + .../generated/+test_model/StringsReaderBase.m | 80 +++ .../generated/+test_model/StringsWriterBase.m | 72 +++ .../SubarraysInRecordsReaderBase.m | 80 +++ .../SubarraysInRecordsWriterBase.m | 72 +++ .../+test_model/SubarraysReaderBase.m | 178 ++++++ .../+test_model/SubarraysWriterBase.m | 163 +++++ matlab/generated/+test_model/TextFormat.m | 2 + .../generated/+test_model/TupleWithRecords.m | 44 ++ matlab/generated/+test_model/UInt64Enum.m | 20 + matlab/generated/+test_model/UOrV.m | 34 + .../generated/+test_model/UnionsReaderBase.m | 108 ++++ .../generated/+test_model/UnionsWriterBase.m | 98 +++ .../+test_model/VectorOfGenericRecords.m | 3 + matlab/generated/+test_model/VectorOrScalar.m | 34 + .../generated/+test_model/VlensReaderBase.m | 108 ++++ .../generated/+test_model/VlensWriterBase.m | 98 +++ .../+tuples/+binary/TupleSerializer.m | 19 + matlab/generated/+tuples/Tuple.m | 25 + matlab/generated/+yardl | 1 + 345 files changed, 16194 insertions(+) create mode 100644 matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m create mode 100644 matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m create mode 100644 matlab/generated/+basic_types/AliasedMap.m create mode 100644 matlab/generated/+basic_types/DaysOfWeek.m create mode 100644 matlab/generated/+basic_types/Fruits.m create mode 100644 matlab/generated/+basic_types/GenericNullableUnion2.m create mode 100644 matlab/generated/+basic_types/GenericRecordWithComputedFields.m create mode 100644 matlab/generated/+basic_types/GenericUnion2.m create mode 100644 matlab/generated/+basic_types/GenericVector.m create mode 100644 matlab/generated/+basic_types/Int32OrString.m create mode 100644 matlab/generated/+basic_types/MyTuple.m create mode 100644 matlab/generated/+basic_types/RecordWithUnions.m create mode 100644 matlab/generated/+basic_types/T0OrT1.m create mode 100644 matlab/generated/+basic_types/TextFormat.m create mode 100644 matlab/generated/+basic_types/TimeOrDatetime.m create mode 100644 matlab/generated/+image/FloatImage.m create mode 100644 matlab/generated/+image/Image.m create mode 100644 matlab/generated/+image/IntImage.m create mode 100644 matlab/generated/+test_model/+binary/AdvancedGenericsReader.m create mode 100644 matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m create mode 100644 matlab/generated/+test_model/+binary/AliasesReader.m create mode 100644 matlab/generated/+test_model/+binary/AliasesWriter.m create mode 100644 matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m create mode 100644 matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m create mode 100644 matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m create mode 100644 matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m create mode 100644 matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m create mode 100644 matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m create mode 100644 matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m create mode 100644 matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m create mode 100644 matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m create mode 100644 matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m create mode 100644 matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m create mode 100644 matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m create mode 100644 matlab/generated/+test_model/+binary/DynamicNDArraysReader.m create mode 100644 matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m create mode 100644 matlab/generated/+test_model/+binary/EnumsReader.m create mode 100644 matlab/generated/+test_model/+binary/EnumsWriter.m create mode 100644 matlab/generated/+test_model/+binary/FixedArraysReader.m create mode 100644 matlab/generated/+test_model/+binary/FixedArraysWriter.m create mode 100644 matlab/generated/+test_model/+binary/FixedVectorsReader.m create mode 100644 matlab/generated/+test_model/+binary/FixedVectorsWriter.m create mode 100644 matlab/generated/+test_model/+binary/FlagsReader.m create mode 100644 matlab/generated/+test_model/+binary/FlagsWriter.m create mode 100644 matlab/generated/+test_model/+binary/GenericRecordSerializer.m create mode 100644 matlab/generated/+test_model/+binary/MapsReader.m create mode 100644 matlab/generated/+test_model/+binary/MapsWriter.m create mode 100644 matlab/generated/+test_model/+binary/NDArraysReader.m create mode 100644 matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m create mode 100644 matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m create mode 100644 matlab/generated/+test_model/+binary/NDArraysWriter.m create mode 100644 matlab/generated/+test_model/+binary/NestedRecordsReader.m create mode 100644 matlab/generated/+test_model/+binary/NestedRecordsWriter.m create mode 100644 matlab/generated/+test_model/+binary/OptionalVectorsReader.m create mode 100644 matlab/generated/+test_model/+binary/OptionalVectorsWriter.m create mode 100644 matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m create mode 100644 matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m create mode 100644 matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m create mode 100644 matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m create mode 100644 matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m create mode 100644 matlab/generated/+test_model/+binary/ScalarOptionalsReader.m create mode 100644 matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m create mode 100644 matlab/generated/+test_model/+binary/ScalarsReader.m create mode 100644 matlab/generated/+test_model/+binary/ScalarsWriter.m create mode 100644 matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m create mode 100644 matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m create mode 100644 matlab/generated/+test_model/+binary/SimpleGenericsReader.m create mode 100644 matlab/generated/+test_model/+binary/SimpleGenericsWriter.m create mode 100644 matlab/generated/+test_model/+binary/SimpleRecordSerializer.m create mode 100644 matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m create mode 100644 matlab/generated/+test_model/+binary/StateTestReader.m create mode 100644 matlab/generated/+test_model/+binary/StateTestWriter.m create mode 100644 matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m create mode 100644 matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m create mode 100644 matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m create mode 100644 matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m create mode 100644 matlab/generated/+test_model/+binary/StreamsReader.m create mode 100644 matlab/generated/+test_model/+binary/StreamsWriter.m create mode 100644 matlab/generated/+test_model/+binary/StringsReader.m create mode 100644 matlab/generated/+test_model/+binary/StringsWriter.m create mode 100644 matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m create mode 100644 matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m create mode 100644 matlab/generated/+test_model/+binary/SubarraysReader.m create mode 100644 matlab/generated/+test_model/+binary/SubarraysWriter.m create mode 100644 matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m create mode 100644 matlab/generated/+test_model/+binary/UnionsReader.m create mode 100644 matlab/generated/+test_model/+binary/UnionsWriter.m create mode 100644 matlab/generated/+test_model/+binary/VlensReader.m create mode 100644 matlab/generated/+test_model/+binary/VlensWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockAliasesWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m create mode 100644 matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m create mode 100644 matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockEnumsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockFixedArraysWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockFlagsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockMapsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockNDArraysWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockScalarsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockStateTestWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockStreamsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockStringsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockSubarraysWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockUnionsWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockVlensWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestAliasesWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m create mode 100644 matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m create mode 100644 matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestEnumsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestFixedArraysWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestFlagsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestMapsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestNDArraysWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestScalarsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestStateTestWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestStreamsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestStringsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestSubarraysWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestUnionsWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestVlensWriter.m create mode 100644 matlab/generated/+test_model/AcquisitionOrImage.m create mode 100644 matlab/generated/+test_model/AdvancedGenericsReaderBase.m create mode 100644 matlab/generated/+test_model/AdvancedGenericsWriterBase.m create mode 100644 matlab/generated/+test_model/AliasedClosedGeneric.m create mode 100644 matlab/generated/+test_model/AliasedEnum.m create mode 100644 matlab/generated/+test_model/AliasedGenericDynamicArray.m create mode 100644 matlab/generated/+test_model/AliasedGenericFixedArray.m create mode 100644 matlab/generated/+test_model/AliasedGenericFixedVector.m create mode 100644 matlab/generated/+test_model/AliasedGenericOptional.m create mode 100644 matlab/generated/+test_model/AliasedGenericRank2Array.m create mode 100644 matlab/generated/+test_model/AliasedGenericUnion2.m create mode 100644 matlab/generated/+test_model/AliasedGenericVector.m create mode 100644 matlab/generated/+test_model/AliasedIntOrSimpleRecord.m create mode 100644 matlab/generated/+test_model/AliasedMap.m create mode 100644 matlab/generated/+test_model/AliasedMultiGenericOptional.m create mode 100644 matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m create mode 100644 matlab/generated/+test_model/AliasedOpenGeneric.m create mode 100644 matlab/generated/+test_model/AliasedOptional.m create mode 100644 matlab/generated/+test_model/AliasedString.m create mode 100644 matlab/generated/+test_model/AliasedTuple.m create mode 100644 matlab/generated/+test_model/AliasedVectorOfGenericRecords.m create mode 100644 matlab/generated/+test_model/AliasesReaderBase.m create mode 100644 matlab/generated/+test_model/AliasesWriterBase.m create mode 100644 matlab/generated/+test_model/ArrayOrScalar.m create mode 100644 matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m create mode 100644 matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m create mode 100644 matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m create mode 100644 matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m create mode 100644 matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m create mode 100644 matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m create mode 100644 matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m create mode 100644 matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m create mode 100644 matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m create mode 100644 matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m create mode 100644 matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m create mode 100644 matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m create mode 100644 matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m create mode 100644 matlab/generated/+test_model/DaysOfWeek.m create mode 100644 matlab/generated/+test_model/DynamicNDArraysReaderBase.m create mode 100644 matlab/generated/+test_model/DynamicNDArraysWriterBase.m create mode 100644 matlab/generated/+test_model/EnumWithKeywordSymbols.m create mode 100644 matlab/generated/+test_model/EnumsReaderBase.m create mode 100644 matlab/generated/+test_model/EnumsWriterBase.m create mode 100644 matlab/generated/+test_model/FixedArraysReaderBase.m create mode 100644 matlab/generated/+test_model/FixedArraysWriterBase.m create mode 100644 matlab/generated/+test_model/FixedVectorsReaderBase.m create mode 100644 matlab/generated/+test_model/FixedVectorsWriterBase.m create mode 100644 matlab/generated/+test_model/FlagsReaderBase.m create mode 100644 matlab/generated/+test_model/FlagsWriterBase.m create mode 100644 matlab/generated/+test_model/Fruits.m create mode 100644 matlab/generated/+test_model/GenericRecord.m create mode 100644 matlab/generated/+test_model/GenericUnion3.m create mode 100644 matlab/generated/+test_model/GenericUnion3Alternate.m create mode 100644 matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m create mode 100644 matlab/generated/+test_model/Image.m create mode 100644 matlab/generated/+test_model/ImageFloatOrImageDouble.m create mode 100644 matlab/generated/+test_model/Int32OrFloat32.m create mode 100644 matlab/generated/+test_model/Int32OrRecordWithVlens.m create mode 100644 matlab/generated/+test_model/Int32OrSimpleRecord.m create mode 100644 matlab/generated/+test_model/Int64Enum.m create mode 100644 matlab/generated/+test_model/IntArray.m create mode 100644 matlab/generated/+test_model/IntFixedArray.m create mode 100644 matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m create mode 100644 matlab/generated/+test_model/IntRank2Array.m create mode 100644 matlab/generated/+test_model/MapOrScalar.m create mode 100644 matlab/generated/+test_model/MapsReaderBase.m create mode 100644 matlab/generated/+test_model/MapsWriterBase.m create mode 100644 matlab/generated/+test_model/MyTuple.m create mode 100644 matlab/generated/+test_model/NDArraysReaderBase.m create mode 100644 matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m create mode 100644 matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m create mode 100644 matlab/generated/+test_model/NDArraysWriterBase.m create mode 100644 matlab/generated/+test_model/NamedFixedNDArray.m create mode 100644 matlab/generated/+test_model/NamedNDArray.m create mode 100644 matlab/generated/+test_model/NestedRecordsReaderBase.m create mode 100644 matlab/generated/+test_model/NestedRecordsWriterBase.m create mode 100644 matlab/generated/+test_model/OptionalVectorsReaderBase.m create mode 100644 matlab/generated/+test_model/OptionalVectorsWriterBase.m create mode 100644 matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m create mode 100644 matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m create mode 100644 matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m create mode 100644 matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m create mode 100644 matlab/generated/+test_model/RecordContainingGenericRecords.m create mode 100644 matlab/generated/+test_model/RecordContainingNestedGenericRecords.m create mode 100644 matlab/generated/+test_model/RecordNotUsedInProtocol.m create mode 100644 matlab/generated/+test_model/RecordWithAliasedGenerics.m create mode 100644 matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m create mode 100644 matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m create mode 100644 matlab/generated/+test_model/RecordWithArrays.m create mode 100644 matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m create mode 100644 matlab/generated/+test_model/RecordWithComputedFields.m create mode 100644 matlab/generated/+test_model/RecordWithDynamicNDArrays.m create mode 100644 matlab/generated/+test_model/RecordWithEnums.m create mode 100644 matlab/generated/+test_model/RecordWithFixedArrays.m create mode 100644 matlab/generated/+test_model/RecordWithFixedCollections.m create mode 100644 matlab/generated/+test_model/RecordWithFixedVectors.m create mode 100644 matlab/generated/+test_model/RecordWithGenericArrays.m create mode 100644 matlab/generated/+test_model/RecordWithGenericFixedVectors.m create mode 100644 matlab/generated/+test_model/RecordWithGenericMaps.m create mode 100644 matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m create mode 100644 matlab/generated/+test_model/RecordWithGenericVectors.m create mode 100644 matlab/generated/+test_model/RecordWithKeywordFields.m create mode 100644 matlab/generated/+test_model/RecordWithNDArrays.m create mode 100644 matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m create mode 100644 matlab/generated/+test_model/RecordWithNamedFixedArrays.m create mode 100644 matlab/generated/+test_model/RecordWithOptionalFields.m create mode 100644 matlab/generated/+test_model/RecordWithOptionalGenericField.m create mode 100644 matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m create mode 100644 matlab/generated/+test_model/RecordWithOptionalVector.m create mode 100644 matlab/generated/+test_model/RecordWithPrimitiveAliases.m create mode 100644 matlab/generated/+test_model/RecordWithPrimitives.m create mode 100644 matlab/generated/+test_model/RecordWithStrings.m create mode 100644 matlab/generated/+test_model/RecordWithUnionsOfContainers.m create mode 100644 matlab/generated/+test_model/RecordWithVectorOfTimes.m create mode 100644 matlab/generated/+test_model/RecordWithVectors.m create mode 100644 matlab/generated/+test_model/RecordWithVlenCollections.m create mode 100644 matlab/generated/+test_model/RecordWithVlens.m create mode 100644 matlab/generated/+test_model/RecordWithVlensFixedArray.m create mode 100644 matlab/generated/+test_model/ScalarOptionalsReaderBase.m create mode 100644 matlab/generated/+test_model/ScalarOptionalsWriterBase.m create mode 100644 matlab/generated/+test_model/ScalarsReaderBase.m create mode 100644 matlab/generated/+test_model/ScalarsWriterBase.m create mode 100644 matlab/generated/+test_model/SimpleAcquisition.m create mode 100644 matlab/generated/+test_model/SimpleEncodingCounters.m create mode 100644 matlab/generated/+test_model/SimpleGenericsReaderBase.m create mode 100644 matlab/generated/+test_model/SimpleGenericsWriterBase.m create mode 100644 matlab/generated/+test_model/SimpleRecord.m create mode 100644 matlab/generated/+test_model/SimpleRecordFixedArray.m create mode 100644 matlab/generated/+test_model/SizeBasedEnum.m create mode 100644 matlab/generated/+test_model/SmallBenchmarkRecord.m create mode 100644 matlab/generated/+test_model/StateTestReaderBase.m create mode 100644 matlab/generated/+test_model/StateTestWriterBase.m create mode 100644 matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m create mode 100644 matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m create mode 100644 matlab/generated/+test_model/StreamsOfUnionsReaderBase.m create mode 100644 matlab/generated/+test_model/StreamsOfUnionsWriterBase.m create mode 100644 matlab/generated/+test_model/StreamsReaderBase.m create mode 100644 matlab/generated/+test_model/StreamsWriterBase.m create mode 100644 matlab/generated/+test_model/StringOrInt32.m create mode 100644 matlab/generated/+test_model/StringsReaderBase.m create mode 100644 matlab/generated/+test_model/StringsWriterBase.m create mode 100644 matlab/generated/+test_model/SubarraysInRecordsReaderBase.m create mode 100644 matlab/generated/+test_model/SubarraysInRecordsWriterBase.m create mode 100644 matlab/generated/+test_model/SubarraysReaderBase.m create mode 100644 matlab/generated/+test_model/SubarraysWriterBase.m create mode 100644 matlab/generated/+test_model/TextFormat.m create mode 100644 matlab/generated/+test_model/TupleWithRecords.m create mode 100644 matlab/generated/+test_model/UInt64Enum.m create mode 100644 matlab/generated/+test_model/UOrV.m create mode 100644 matlab/generated/+test_model/UnionsReaderBase.m create mode 100644 matlab/generated/+test_model/UnionsWriterBase.m create mode 100644 matlab/generated/+test_model/VectorOfGenericRecords.m create mode 100644 matlab/generated/+test_model/VectorOrScalar.m create mode 100644 matlab/generated/+test_model/VlensReaderBase.m create mode 100644 matlab/generated/+test_model/VlensWriterBase.m create mode 100644 matlab/generated/+tuples/+binary/TupleSerializer.m create mode 100644 matlab/generated/+tuples/Tuple.m create mode 120000 matlab/generated/+yardl diff --git a/matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m b/matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m new file mode 100644 index 00000000..c1925006 --- /dev/null +++ b/matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m @@ -0,0 +1,18 @@ +classdef GenericRecordWithComputedFieldsSerializer < yardl.binary.RecordSerializer + methods + function obj = GenericRecordWithComputedFieldsSerializer(t0_serializer, t1_serializer) + field_serializers{1} = yardl.binary.UnionSerializer('basic_types.T0OrT1', {t0_serializer, t1_serializer}, {@basic_types.T0OrT1.T0, @basic_types.T0OrT1.T1}); + obj@yardl.binary.RecordSerializer('basic_types.GenericRecordWithComputedFields', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'basic_types.GenericRecordWithComputedFields')); + obj.write_(outstream, value.f1) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = basic_types.GenericRecordWithComputedFields(field_values{:}); + end + end +end diff --git a/matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m b/matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m new file mode 100644 index 00000000..b636a682 --- /dev/null +++ b/matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m @@ -0,0 +1,20 @@ +classdef RecordWithUnionsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithUnionsSerializer() + field_serializers{1} = yardl.binary.UnionSerializer('basic_types.Int32OrString', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, yardl.binary.StringSerializer}, {yardl.None, @basic_types.Int32OrString.Int32, @basic_types.Int32OrString.String}); + field_serializers{2} = yardl.binary.UnionSerializer('basic_types.TimeOrDatetime', {yardl.binary.TimeSerializer, yardl.binary.DatetimeSerializer}, {@basic_types.TimeOrDatetime.Time, @basic_types.TimeOrDatetime.Datetime}); + field_serializers{3} = yardl.binary.UnionSerializer('basic_types.GenericNullableUnion2', {yardl.binary.NoneSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer), yardl.binary.EnumSerializer('basic_types.DaysOfWeek', @basic_types.DaysOfWeek, yardl.binary.Int32Serializer)}, {yardl.None, @basic_types.GenericNullableUnion2.T1, @basic_types.GenericNullableUnion2.T2}); + obj@yardl.binary.RecordSerializer('basic_types.RecordWithUnions', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'basic_types.RecordWithUnions')); + obj.write_(outstream, value.null_or_int_or_string, value.date_or_datetime, value.null_or_fruits_or_days_of_week) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = basic_types.RecordWithUnions(field_values{:}); + end + end +end diff --git a/matlab/generated/+basic_types/AliasedMap.m b/matlab/generated/+basic_types/AliasedMap.m new file mode 100644 index 00000000..fe48071b --- /dev/null +++ b/matlab/generated/+basic_types/AliasedMap.m @@ -0,0 +1,2 @@ +classdef AliasedMap < dictionary +end diff --git a/matlab/generated/+basic_types/DaysOfWeek.m b/matlab/generated/+basic_types/DaysOfWeek.m new file mode 100644 index 00000000..7fbc0976 --- /dev/null +++ b/matlab/generated/+basic_types/DaysOfWeek.m @@ -0,0 +1,38 @@ +classdef DaysOfWeek < uint64 + methods (Static) + function e = MONDAY + e = basic_types.DaysOfWeek(1); + end + function e = TUESDAY + e = basic_types.DaysOfWeek(2); + end + function e = WEDNESDAY + e = basic_types.DaysOfWeek(4); + end + function e = THURSDAY + e = basic_types.DaysOfWeek(8); + end + function e = FRIDAY + e = basic_types.DaysOfWeek(16); + end + function e = SATURDAY + e = basic_types.DaysOfWeek(32); + end + function e = SUNDAY + e = basic_types.DaysOfWeek(64); + end + + function z = zeros(varargin) + elem = basic_types.DaysOfWeek(0); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+basic_types/Fruits.m b/matlab/generated/+basic_types/Fruits.m new file mode 100644 index 00000000..5c80e6a5 --- /dev/null +++ b/matlab/generated/+basic_types/Fruits.m @@ -0,0 +1,26 @@ +classdef Fruits < uint64 + methods (Static) + function e = APPLE + e = basic_types.Fruits(0); + end + function e = BANANA + e = basic_types.Fruits(1); + end + function e = PEAR + e = basic_types.Fruits(2); + end + + function z = zeros(varargin) + elem = basic_types.Fruits(0); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+basic_types/GenericNullableUnion2.m b/matlab/generated/+basic_types/GenericNullableUnion2.m new file mode 100644 index 00000000..297fd5e7 --- /dev/null +++ b/matlab/generated/+basic_types/GenericNullableUnion2.m @@ -0,0 +1,34 @@ +classdef GenericNullableUnion2 < yardl.Union + methods (Static) + function res = T1(value) + res = basic_types.GenericNullableUnion2(1, value); + end + + function res = T2(value) + res = basic_types.GenericNullableUnion2(2, value); + end + + function z = zeros(varargin) + elem = basic_types.GenericNullableUnion2(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'basic_types.GenericNullableUnion2') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+basic_types/GenericRecordWithComputedFields.m b/matlab/generated/+basic_types/GenericRecordWithComputedFields.m new file mode 100644 index 00000000..da4c0136 --- /dev/null +++ b/matlab/generated/+basic_types/GenericRecordWithComputedFields.m @@ -0,0 +1,36 @@ +classdef GenericRecordWithComputedFields < handle + properties + f1 + end + + methods + function obj = GenericRecordWithComputedFields(f1) + obj.f1 = f1; + end + + function res = type_index(self) + var1 = self.f1; + if var1.index == 1 + res = 0; + return + end + if var1.index == 2 + res = 1; + return + end + throw(yardl.RuntimeError("Unexpected union case")) + end + + + function res = eq(obj, other) + res = ... + isa(other, 'basic_types.GenericRecordWithComputedFields') && ... + isequal(obj.f1, other.f1); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + +end diff --git a/matlab/generated/+basic_types/GenericUnion2.m b/matlab/generated/+basic_types/GenericUnion2.m new file mode 100644 index 00000000..7a21a90d --- /dev/null +++ b/matlab/generated/+basic_types/GenericUnion2.m @@ -0,0 +1,34 @@ +classdef GenericUnion2 < yardl.Union + methods (Static) + function res = T1(value) + res = basic_types.GenericUnion2(1, value); + end + + function res = T2(value) + res = basic_types.GenericUnion2(2, value); + end + + function z = zeros(varargin) + elem = basic_types.GenericUnion2(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'basic_types.GenericUnion2') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+basic_types/GenericVector.m b/matlab/generated/+basic_types/GenericVector.m new file mode 100644 index 00000000..b838ba3c --- /dev/null +++ b/matlab/generated/+basic_types/GenericVector.m @@ -0,0 +1,3 @@ +function a = GenericVector(array) + a = array; +end diff --git a/matlab/generated/+basic_types/Int32OrString.m b/matlab/generated/+basic_types/Int32OrString.m new file mode 100644 index 00000000..921b5b34 --- /dev/null +++ b/matlab/generated/+basic_types/Int32OrString.m @@ -0,0 +1,34 @@ +classdef Int32OrString < yardl.Union + methods (Static) + function res = Int32(value) + res = basic_types.Int32OrString(1, value); + end + + function res = String(value) + res = basic_types.Int32OrString(2, value); + end + + function z = zeros(varargin) + elem = basic_types.Int32OrString(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'basic_types.Int32OrString') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+basic_types/MyTuple.m b/matlab/generated/+basic_types/MyTuple.m new file mode 100644 index 00000000..99abe277 --- /dev/null +++ b/matlab/generated/+basic_types/MyTuple.m @@ -0,0 +1,3 @@ +function c = MyTuple(varargin) + c = tuples.Tuple(varargin{:}); +end diff --git a/matlab/generated/+basic_types/RecordWithUnions.m b/matlab/generated/+basic_types/RecordWithUnions.m new file mode 100644 index 00000000..e6ab9f3b --- /dev/null +++ b/matlab/generated/+basic_types/RecordWithUnions.m @@ -0,0 +1,48 @@ +classdef RecordWithUnions < handle + properties + null_or_int_or_string + date_or_datetime + null_or_fruits_or_days_of_week + end + + methods + function obj = RecordWithUnions(null_or_int_or_string, date_or_datetime, null_or_fruits_or_days_of_week) + if nargin > 0 + obj.null_or_int_or_string = null_or_int_or_string; + obj.date_or_datetime = date_or_datetime; + obj.null_or_fruits_or_days_of_week = null_or_fruits_or_days_of_week; + else + obj.null_or_int_or_string = yardl.None; + obj.date_or_datetime = basic_types.TimeOrDatetime.Time(yardl.Time()); + obj.null_or_fruits_or_days_of_week = yardl.None; + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'basic_types.RecordWithUnions') && ... + all([obj.null_or_int_or_string] == [other.null_or_int_or_string]) && ... + all([obj.date_or_datetime] == [other.date_or_datetime]) && ... + all([obj.null_or_fruits_or_days_of_week] == [other.null_or_fruits_or_days_of_week]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = basic_types.RecordWithUnions(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+basic_types/T0OrT1.m b/matlab/generated/+basic_types/T0OrT1.m new file mode 100644 index 00000000..289d2064 --- /dev/null +++ b/matlab/generated/+basic_types/T0OrT1.m @@ -0,0 +1,34 @@ +classdef T0OrT1 < yardl.Union + methods (Static) + function res = T0(value) + res = basic_types.T0OrT1(1, value); + end + + function res = T1(value) + res = basic_types.T0OrT1(2, value); + end + + function z = zeros(varargin) + elem = basic_types.T0OrT1(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'basic_types.T0OrT1') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+basic_types/TextFormat.m b/matlab/generated/+basic_types/TextFormat.m new file mode 100644 index 00000000..187fddca --- /dev/null +++ b/matlab/generated/+basic_types/TextFormat.m @@ -0,0 +1,32 @@ +classdef TextFormat < uint64 + methods (Static) + function e = REGULAR + e = basic_types.TextFormat(0); + end + function e = BOLD + e = basic_types.TextFormat(1); + end + function e = ITALIC + e = basic_types.TextFormat(2); + end + function e = UNDERLINE + e = basic_types.TextFormat(4); + end + function e = STRIKETHROUGH + e = basic_types.TextFormat(8); + end + + function z = zeros(varargin) + elem = basic_types.TextFormat(0); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+basic_types/TimeOrDatetime.m b/matlab/generated/+basic_types/TimeOrDatetime.m new file mode 100644 index 00000000..9abd79dc --- /dev/null +++ b/matlab/generated/+basic_types/TimeOrDatetime.m @@ -0,0 +1,34 @@ +classdef TimeOrDatetime < yardl.Union + methods (Static) + function res = Time(value) + res = basic_types.TimeOrDatetime(1, value); + end + + function res = Datetime(value) + res = basic_types.TimeOrDatetime(2, value); + end + + function z = zeros(varargin) + elem = basic_types.TimeOrDatetime(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'basic_types.TimeOrDatetime') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+image/FloatImage.m b/matlab/generated/+image/FloatImage.m new file mode 100644 index 00000000..0d41d970 --- /dev/null +++ b/matlab/generated/+image/FloatImage.m @@ -0,0 +1,4 @@ +function a = FloatImage(array) + assert(isa(array, 'single')); + a = array; +end diff --git a/matlab/generated/+image/Image.m b/matlab/generated/+image/Image.m new file mode 100644 index 00000000..4a551748 --- /dev/null +++ b/matlab/generated/+image/Image.m @@ -0,0 +1,3 @@ +function a = Image(array) + a = array; +end diff --git a/matlab/generated/+image/IntImage.m b/matlab/generated/+image/IntImage.m new file mode 100644 index 00000000..f807307e --- /dev/null +++ b/matlab/generated/+image/IntImage.m @@ -0,0 +1,4 @@ +function a = IntImage(array) + assert(isa(array, 'int32')); + a = array; +end diff --git a/matlab/generated/+test_model/+binary/AdvancedGenericsReader.m b/matlab/generated/+test_model/+binary/AdvancedGenericsReader.m new file mode 100644 index 00000000..947fa959 --- /dev/null +++ b/matlab/generated/+test_model/+binary/AdvancedGenericsReader.m @@ -0,0 +1,36 @@ +% Binary reader for the AdvancedGenerics protocol +classdef AdvancedGenericsReader < yardl.binary.BinaryProtocolReader & test_model.AdvancedGenericsReaderBase + methods + function obj = AdvancedGenericsReader(filename) + obj@test_model.AdvancedGenericsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.AdvancedGenericsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_float_image_image_(obj) + r = yardl.binary.NDArraySerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), 2); + value = r.read(obj.stream_); + end + + function value = read_generic_record_1_(obj) + r = test_model.binary.GenericRecordSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + value = r.read(obj.stream_); + end + + function value = read_tuple_of_optionals_(obj) + r = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); + value = r.read(obj.stream_); + end + + function value = read_tuple_of_optionals_alternate_syntax_(obj) + r = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); + value = r.read(obj.stream_); + end + + function value = read_tuple_of_vectors_(obj) + r = tuples.binary.TupleSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), yardl.binary.VectorSerializer(yardl.binary.Float32Serializer)); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m b/matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m new file mode 100644 index 00000000..9d354ecc --- /dev/null +++ b/matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m @@ -0,0 +1,36 @@ +% Binary writer for the AdvancedGenerics protocol +classdef AdvancedGenericsWriter < yardl.binary.BinaryProtocolWriter & test_model.AdvancedGenericsWriterBase + methods + function obj = AdvancedGenericsWriter(filename) + obj@test_model.AdvancedGenericsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.AdvancedGenericsWriterBase.schema); + end + end + + methods (Access=protected) + function write_float_image_image_(obj, value) + w = yardl.binary.NDArraySerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), 2); + w.write(obj.stream_, value); + end + + function write_generic_record_1_(obj, value) + w = test_model.binary.GenericRecordSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + w.write(obj.stream_, value); + end + + function write_tuple_of_optionals_(obj, value) + w = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); + w.write(obj.stream_, value); + end + + function write_tuple_of_optionals_alternate_syntax_(obj, value) + w = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); + w.write(obj.stream_, value); + end + + function write_tuple_of_vectors_(obj, value) + w = tuples.binary.TupleSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), yardl.binary.VectorSerializer(yardl.binary.Float32Serializer)); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/AliasesReader.m b/matlab/generated/+test_model/+binary/AliasesReader.m new file mode 100644 index 00000000..3db7114c --- /dev/null +++ b/matlab/generated/+test_model/+binary/AliasesReader.m @@ -0,0 +1,61 @@ +% Binary reader for the Aliases protocol +classdef AliasesReader < yardl.binary.BinaryProtocolReader & test_model.AliasesReaderBase + methods + function obj = AliasesReader(filename) + obj@test_model.AliasesReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.AliasesReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_aliased_string_(obj) + r = yardl.binary.StringSerializer; + value = r.read(obj.stream_); + end + + function value = read_aliased_enum_(obj) + r = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); + value = r.read(obj.stream_); + end + + function value = read_aliased_open_generic_(obj) + r = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + value = r.read(obj.stream_); + end + + function value = read_aliased_closed_generic_(obj) + r = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + value = r.read(obj.stream_); + end + + function value = read_aliased_optional_(obj) + r = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); + value = r.read(obj.stream_); + end + + function value = read_aliased_generic_optional_(obj) + r = yardl.binary.OptionalSerializer(yardl.binary.Float32Serializer); + value = r.read(obj.stream_); + end + + function value = read_aliased_generic_union_2_(obj) + r = yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2}); + value = r.read(obj.stream_); + end + + function value = read_aliased_generic_vector_(obj) + r = yardl.binary.VectorSerializer(yardl.binary.Float32Serializer); + value = r.read(obj.stream_); + end + + function value = read_aliased_generic_fixed_vector_(obj) + r = yardl.binary.FixedVectorSerializer(yardl.binary.Float32Serializer, 3); + value = r.read(obj.stream_); + end + + function value = read_stream_of_aliased_generic_union_2_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2})); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/AliasesWriter.m b/matlab/generated/+test_model/+binary/AliasesWriter.m new file mode 100644 index 00000000..776701b1 --- /dev/null +++ b/matlab/generated/+test_model/+binary/AliasesWriter.m @@ -0,0 +1,61 @@ +% Binary writer for the Aliases protocol +classdef AliasesWriter < yardl.binary.BinaryProtocolWriter & test_model.AliasesWriterBase + methods + function obj = AliasesWriter(filename) + obj@test_model.AliasesWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.AliasesWriterBase.schema); + end + end + + methods (Access=protected) + function write_aliased_string_(obj, value) + w = yardl.binary.StringSerializer; + w.write(obj.stream_, value); + end + + function write_aliased_enum_(obj, value) + w = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); + w.write(obj.stream_, value); + end + + function write_aliased_open_generic_(obj, value) + w = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + w.write(obj.stream_, value); + end + + function write_aliased_closed_generic_(obj, value) + w = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + w.write(obj.stream_, value); + end + + function write_aliased_optional_(obj, value) + w = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); + w.write(obj.stream_, value); + end + + function write_aliased_generic_optional_(obj, value) + w = yardl.binary.OptionalSerializer(yardl.binary.Float32Serializer); + w.write(obj.stream_, value); + end + + function write_aliased_generic_union_2_(obj, value) + w = yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2}); + w.write(obj.stream_, value); + end + + function write_aliased_generic_vector_(obj, value) + w = yardl.binary.VectorSerializer(yardl.binary.Float32Serializer); + w.write(obj.stream_, value); + end + + function write_aliased_generic_fixed_vector_(obj, value) + w = yardl.binary.FixedVectorSerializer(yardl.binary.Float32Serializer, 3); + w.write(obj.stream_, value); + end + + function write_stream_of_aliased_generic_union_2_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2})); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m new file mode 100644 index 00000000..f6d88bdc --- /dev/null +++ b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m @@ -0,0 +1,16 @@ +% Binary reader for the BenchmarkFloat256x256 protocol +classdef BenchmarkFloat256x256Reader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkFloat256x256ReaderBase + methods + function obj = BenchmarkFloat256x256Reader(filename) + obj@test_model.BenchmarkFloat256x256ReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkFloat256x256ReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_float256x256_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [256, 256])); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m new file mode 100644 index 00000000..9d61aac1 --- /dev/null +++ b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m @@ -0,0 +1,16 @@ +% Binary writer for the BenchmarkFloat256x256 protocol +classdef BenchmarkFloat256x256Writer < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkFloat256x256WriterBase + methods + function obj = BenchmarkFloat256x256Writer(filename) + obj@test_model.BenchmarkFloat256x256WriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkFloat256x256WriterBase.schema); + end + end + + methods (Access=protected) + function write_float256x256_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [256, 256])); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m new file mode 100644 index 00000000..a324b0be --- /dev/null +++ b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m @@ -0,0 +1,16 @@ +% Binary reader for the BenchmarkFloatVlen protocol +classdef BenchmarkFloatVlenReader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkFloatVlenReaderBase + methods + function obj = BenchmarkFloatVlenReader(filename) + obj@test_model.BenchmarkFloatVlenReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkFloatVlenReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_float_array_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m new file mode 100644 index 00000000..412697b9 --- /dev/null +++ b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m @@ -0,0 +1,16 @@ +% Binary writer for the BenchmarkFloatVlen protocol +classdef BenchmarkFloatVlenWriter < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkFloatVlenWriterBase + methods + function obj = BenchmarkFloatVlenWriter(filename) + obj@test_model.BenchmarkFloatVlenWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkFloatVlenWriterBase.schema); + end + end + + methods (Access=protected) + function write_float_array_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m new file mode 100644 index 00000000..7bc2cb55 --- /dev/null +++ b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m @@ -0,0 +1,16 @@ +% Binary reader for the BenchmarkInt256x256 protocol +classdef BenchmarkInt256x256Reader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkInt256x256ReaderBase + methods + function obj = BenchmarkInt256x256Reader(filename) + obj@test_model.BenchmarkInt256x256ReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkInt256x256ReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_int256x256_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [256, 256])); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m new file mode 100644 index 00000000..1e17d965 --- /dev/null +++ b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m @@ -0,0 +1,16 @@ +% Binary writer for the BenchmarkInt256x256 protocol +classdef BenchmarkInt256x256Writer < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkInt256x256WriterBase + methods + function obj = BenchmarkInt256x256Writer(filename) + obj@test_model.BenchmarkInt256x256WriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkInt256x256WriterBase.schema); + end + end + + methods (Access=protected) + function write_int256x256_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [256, 256])); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m new file mode 100644 index 00000000..d2a04f0b --- /dev/null +++ b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m @@ -0,0 +1,16 @@ +% Binary reader for the BenchmarkSimpleMrd protocol +classdef BenchmarkSimpleMrdReader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkSimpleMrdReaderBase + methods + function obj = BenchmarkSimpleMrdReader(filename) + obj@test_model.BenchmarkSimpleMrdReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkSimpleMrdReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_data_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AcquisitionOrImage', {test_model.binary.SimpleAcquisitionSerializer(), yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)}, {@test_model.AcquisitionOrImage.Acquisition, @test_model.AcquisitionOrImage.Image})); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m new file mode 100644 index 00000000..43e75e6b --- /dev/null +++ b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m @@ -0,0 +1,16 @@ +% Binary writer for the BenchmarkSimpleMrd protocol +classdef BenchmarkSimpleMrdWriter < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkSimpleMrdWriterBase + methods + function obj = BenchmarkSimpleMrdWriter(filename) + obj@test_model.BenchmarkSimpleMrdWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkSimpleMrdWriterBase.schema); + end + end + + methods (Access=protected) + function write_data_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AcquisitionOrImage', {test_model.binary.SimpleAcquisitionSerializer(), yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)}, {@test_model.AcquisitionOrImage.Acquisition, @test_model.AcquisitionOrImage.Image})); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m new file mode 100644 index 00000000..f811aee7 --- /dev/null +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m @@ -0,0 +1,16 @@ +% Binary reader for the BenchmarkSmallRecord protocol +classdef BenchmarkSmallRecordReader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkSmallRecordReaderBase + methods + function obj = BenchmarkSmallRecordReader(filename) + obj@test_model.BenchmarkSmallRecordReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkSmallRecordReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_small_record_(obj) + r = yardl.binary.StreamSerializer(test_model.binary.SmallBenchmarkRecordSerializer()); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m new file mode 100644 index 00000000..40df03aa --- /dev/null +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m @@ -0,0 +1,16 @@ +% Binary reader for the BenchmarkSmallRecordWithOptionals protocol +classdef BenchmarkSmallRecordWithOptionalsReader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkSmallRecordWithOptionalsReaderBase + methods + function obj = BenchmarkSmallRecordWithOptionalsReader(filename) + obj@test_model.BenchmarkSmallRecordWithOptionalsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkSmallRecordWithOptionalsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_small_record_(obj) + r = yardl.binary.StreamSerializer(test_model.binary.SimpleEncodingCountersSerializer()); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m new file mode 100644 index 00000000..f11d54f7 --- /dev/null +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m @@ -0,0 +1,16 @@ +% Binary writer for the BenchmarkSmallRecordWithOptionals protocol +classdef BenchmarkSmallRecordWithOptionalsWriter < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkSmallRecordWithOptionalsWriterBase + methods + function obj = BenchmarkSmallRecordWithOptionalsWriter(filename) + obj@test_model.BenchmarkSmallRecordWithOptionalsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkSmallRecordWithOptionalsWriterBase.schema); + end + end + + methods (Access=protected) + function write_small_record_(obj, value) + w = yardl.binary.StreamSerializer(test_model.binary.SimpleEncodingCountersSerializer()); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m new file mode 100644 index 00000000..30bfa239 --- /dev/null +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m @@ -0,0 +1,16 @@ +% Binary writer for the BenchmarkSmallRecord protocol +classdef BenchmarkSmallRecordWriter < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkSmallRecordWriterBase + methods + function obj = BenchmarkSmallRecordWriter(filename) + obj@test_model.BenchmarkSmallRecordWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkSmallRecordWriterBase.schema); + end + end + + methods (Access=protected) + function write_small_record_(obj, value) + w = yardl.binary.StreamSerializer(test_model.binary.SmallBenchmarkRecordSerializer()); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/DynamicNDArraysReader.m b/matlab/generated/+test_model/+binary/DynamicNDArraysReader.m new file mode 100644 index 00000000..534f996f --- /dev/null +++ b/matlab/generated/+test_model/+binary/DynamicNDArraysReader.m @@ -0,0 +1,31 @@ +% Binary reader for the DynamicNDArrays protocol +classdef DynamicNDArraysReader < yardl.binary.BinaryProtocolReader & test_model.DynamicNDArraysReaderBase + methods + function obj = DynamicNDArraysReader(filename) + obj@test_model.DynamicNDArraysReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.DynamicNDArraysReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_ints_(obj) + r = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); + value = r.read(obj.stream_); + end + + function value = read_simple_record_array_(obj) + r = yardl.binary.DynamicNDArraySerializer(test_model.binary.SimpleRecordSerializer()); + value = r.read(obj.stream_); + end + + function value = read_record_with_vlens_array_(obj) + r = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlensSerializer()); + value = r.read(obj.stream_); + end + + function value = read_record_with_dynamic_nd_arrays_(obj) + r = test_model.binary.RecordWithDynamicNDArraysSerializer(); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m b/matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m new file mode 100644 index 00000000..0dcf1cfe --- /dev/null +++ b/matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m @@ -0,0 +1,31 @@ +% Binary writer for the DynamicNDArrays protocol +classdef DynamicNDArraysWriter < yardl.binary.BinaryProtocolWriter & test_model.DynamicNDArraysWriterBase + methods + function obj = DynamicNDArraysWriter(filename) + obj@test_model.DynamicNDArraysWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.DynamicNDArraysWriterBase.schema); + end + end + + methods (Access=protected) + function write_ints_(obj, value) + w = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); + w.write(obj.stream_, value); + end + + function write_simple_record_array_(obj, value) + w = yardl.binary.DynamicNDArraySerializer(test_model.binary.SimpleRecordSerializer()); + w.write(obj.stream_, value); + end + + function write_record_with_vlens_array_(obj, value) + w = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlensSerializer()); + w.write(obj.stream_, value); + end + + function write_record_with_dynamic_nd_arrays_(obj, value) + w = test_model.binary.RecordWithDynamicNDArraysSerializer(); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/EnumsReader.m b/matlab/generated/+test_model/+binary/EnumsReader.m new file mode 100644 index 00000000..b3b6e085 --- /dev/null +++ b/matlab/generated/+test_model/+binary/EnumsReader.m @@ -0,0 +1,26 @@ +% Binary reader for the Enums protocol +classdef EnumsReader < yardl.binary.BinaryProtocolReader & test_model.EnumsReaderBase + methods + function obj = EnumsReader(filename) + obj@test_model.EnumsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.EnumsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_single_(obj) + r = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); + value = r.read(obj.stream_); + end + + function value = read_vec_(obj) + r = yardl.binary.VectorSerializer(yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + value = r.read(obj.stream_); + end + + function value = read_size_(obj) + r = yardl.binary.EnumSerializer('test_model.SizeBasedEnum', @test_model.SizeBasedEnum, yardl.binary.SizeSerializer); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/EnumsWriter.m b/matlab/generated/+test_model/+binary/EnumsWriter.m new file mode 100644 index 00000000..47460811 --- /dev/null +++ b/matlab/generated/+test_model/+binary/EnumsWriter.m @@ -0,0 +1,26 @@ +% Binary writer for the Enums protocol +classdef EnumsWriter < yardl.binary.BinaryProtocolWriter & test_model.EnumsWriterBase + methods + function obj = EnumsWriter(filename) + obj@test_model.EnumsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.EnumsWriterBase.schema); + end + end + + methods (Access=protected) + function write_single_(obj, value) + w = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); + w.write(obj.stream_, value); + end + + function write_vec_(obj, value) + w = yardl.binary.VectorSerializer(yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + w.write(obj.stream_, value); + end + + function write_size_(obj, value) + w = yardl.binary.EnumSerializer('test_model.SizeBasedEnum', @test_model.SizeBasedEnum, yardl.binary.SizeSerializer); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/FixedArraysReader.m b/matlab/generated/+test_model/+binary/FixedArraysReader.m new file mode 100644 index 00000000..a0363fba --- /dev/null +++ b/matlab/generated/+test_model/+binary/FixedArraysReader.m @@ -0,0 +1,36 @@ +% Binary reader for the FixedArrays protocol +classdef FixedArraysReader < yardl.binary.BinaryProtocolReader & test_model.FixedArraysReaderBase + methods + function obj = FixedArraysReader(filename) + obj@test_model.FixedArraysReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.FixedArraysReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_ints_(obj) + r = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); + value = r.read(obj.stream_); + end + + function value = read_fixed_simple_record_array_(obj) + r = yardl.binary.FixedNDArraySerializer(test_model.binary.SimpleRecordSerializer(), [2, 3]); + value = r.read(obj.stream_); + end + + function value = read_fixed_record_with_vlens_array_(obj) + r = yardl.binary.FixedNDArraySerializer(test_model.binary.RecordWithVlensSerializer(), [2, 2]); + value = r.read(obj.stream_); + end + + function value = read_record_with_fixed_arrays_(obj) + r = test_model.binary.RecordWithFixedArraysSerializer(); + value = r.read(obj.stream_); + end + + function value = read_named_array_(obj) + r = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 2]); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/FixedArraysWriter.m b/matlab/generated/+test_model/+binary/FixedArraysWriter.m new file mode 100644 index 00000000..ad2bdd80 --- /dev/null +++ b/matlab/generated/+test_model/+binary/FixedArraysWriter.m @@ -0,0 +1,36 @@ +% Binary writer for the FixedArrays protocol +classdef FixedArraysWriter < yardl.binary.BinaryProtocolWriter & test_model.FixedArraysWriterBase + methods + function obj = FixedArraysWriter(filename) + obj@test_model.FixedArraysWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.FixedArraysWriterBase.schema); + end + end + + methods (Access=protected) + function write_ints_(obj, value) + w = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); + w.write(obj.stream_, value); + end + + function write_fixed_simple_record_array_(obj, value) + w = yardl.binary.FixedNDArraySerializer(test_model.binary.SimpleRecordSerializer(), [2, 3]); + w.write(obj.stream_, value); + end + + function write_fixed_record_with_vlens_array_(obj, value) + w = yardl.binary.FixedNDArraySerializer(test_model.binary.RecordWithVlensSerializer(), [2, 2]); + w.write(obj.stream_, value); + end + + function write_record_with_fixed_arrays_(obj, value) + w = test_model.binary.RecordWithFixedArraysSerializer(); + w.write(obj.stream_, value); + end + + function write_named_array_(obj, value) + w = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 2]); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/FixedVectorsReader.m b/matlab/generated/+test_model/+binary/FixedVectorsReader.m new file mode 100644 index 00000000..3c9565f0 --- /dev/null +++ b/matlab/generated/+test_model/+binary/FixedVectorsReader.m @@ -0,0 +1,31 @@ +% Binary reader for the FixedVectors protocol +classdef FixedVectorsReader < yardl.binary.BinaryProtocolReader & test_model.FixedVectorsReaderBase + methods + function obj = FixedVectorsReader(filename) + obj@test_model.FixedVectorsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.FixedVectorsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_fixed_int_vector_(obj) + r = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 5); + value = r.read(obj.stream_); + end + + function value = read_fixed_simple_record_vector_(obj) + r = yardl.binary.FixedVectorSerializer(test_model.binary.SimpleRecordSerializer(), 3); + value = r.read(obj.stream_); + end + + function value = read_fixed_record_with_vlens_vector_(obj) + r = yardl.binary.FixedVectorSerializer(test_model.binary.RecordWithVlensSerializer(), 2); + value = r.read(obj.stream_); + end + + function value = read_record_with_fixed_vectors_(obj) + r = test_model.binary.RecordWithFixedVectorsSerializer(); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/FixedVectorsWriter.m b/matlab/generated/+test_model/+binary/FixedVectorsWriter.m new file mode 100644 index 00000000..7df6b24f --- /dev/null +++ b/matlab/generated/+test_model/+binary/FixedVectorsWriter.m @@ -0,0 +1,31 @@ +% Binary writer for the FixedVectors protocol +classdef FixedVectorsWriter < yardl.binary.BinaryProtocolWriter & test_model.FixedVectorsWriterBase + methods + function obj = FixedVectorsWriter(filename) + obj@test_model.FixedVectorsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.FixedVectorsWriterBase.schema); + end + end + + methods (Access=protected) + function write_fixed_int_vector_(obj, value) + w = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 5); + w.write(obj.stream_, value); + end + + function write_fixed_simple_record_vector_(obj, value) + w = yardl.binary.FixedVectorSerializer(test_model.binary.SimpleRecordSerializer(), 3); + w.write(obj.stream_, value); + end + + function write_fixed_record_with_vlens_vector_(obj, value) + w = yardl.binary.FixedVectorSerializer(test_model.binary.RecordWithVlensSerializer(), 2); + w.write(obj.stream_, value); + end + + function write_record_with_fixed_vectors_(obj, value) + w = test_model.binary.RecordWithFixedVectorsSerializer(); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/FlagsReader.m b/matlab/generated/+test_model/+binary/FlagsReader.m new file mode 100644 index 00000000..a38e2b61 --- /dev/null +++ b/matlab/generated/+test_model/+binary/FlagsReader.m @@ -0,0 +1,21 @@ +% Binary reader for the Flags protocol +classdef FlagsReader < yardl.binary.BinaryProtocolReader & test_model.FlagsReaderBase + methods + function obj = FlagsReader(filename) + obj@test_model.FlagsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.FlagsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_days_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.DaysOfWeek', @basic_types.DaysOfWeek, yardl.binary.Int32Serializer)); + value = r.read(obj.stream_); + end + + function value = read_formats_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.TextFormat', @basic_types.TextFormat, yardl.binary.Uint64Serializer)); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/FlagsWriter.m b/matlab/generated/+test_model/+binary/FlagsWriter.m new file mode 100644 index 00000000..18479ba6 --- /dev/null +++ b/matlab/generated/+test_model/+binary/FlagsWriter.m @@ -0,0 +1,21 @@ +% Binary writer for the Flags protocol +classdef FlagsWriter < yardl.binary.BinaryProtocolWriter & test_model.FlagsWriterBase + methods + function obj = FlagsWriter(filename) + obj@test_model.FlagsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.FlagsWriterBase.schema); + end + end + + methods (Access=protected) + function write_days_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.DaysOfWeek', @basic_types.DaysOfWeek, yardl.binary.Int32Serializer)); + w.write(obj.stream_, value); + end + + function write_formats_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.TextFormat', @basic_types.TextFormat, yardl.binary.Uint64Serializer)); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/GenericRecordSerializer.m b/matlab/generated/+test_model/+binary/GenericRecordSerializer.m new file mode 100644 index 00000000..74c412d5 --- /dev/null +++ b/matlab/generated/+test_model/+binary/GenericRecordSerializer.m @@ -0,0 +1,21 @@ +classdef GenericRecordSerializer < yardl.binary.RecordSerializer + methods + function obj = GenericRecordSerializer(t1_serializer, t2_serializer) + field_serializers{1} = t1_serializer; + field_serializers{2} = t2_serializer; + field_serializers{3} = yardl.binary.VectorSerializer(t1_serializer); + field_serializers{4} = yardl.binary.NDArraySerializer(t2_serializer, 2); + obj@yardl.binary.RecordSerializer('test_model.GenericRecord', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.GenericRecord')); + obj.write_(outstream, value.scalar_1, value.scalar_2, value.vector_1, value.image_2) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.GenericRecord(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/MapsReader.m b/matlab/generated/+test_model/+binary/MapsReader.m new file mode 100644 index 00000000..321ef6f4 --- /dev/null +++ b/matlab/generated/+test_model/+binary/MapsReader.m @@ -0,0 +1,31 @@ +% Binary reader for the Maps protocol +classdef MapsReader < yardl.binary.BinaryProtocolReader & test_model.MapsReaderBase + methods + function obj = MapsReader(filename) + obj@test_model.MapsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.MapsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_string_to_int_(obj) + r = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); + value = r.read(obj.stream_); + end + + function value = read_int_to_string_(obj) + r = yardl.binary.MapSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + value = r.read(obj.stream_); + end + + function value = read_string_to_union_(obj) + r = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.UnionSerializer('test_model.StringOrInt32', {yardl.binary.StringSerializer, yardl.binary.Int32Serializer}, {@test_model.StringOrInt32.String, @test_model.StringOrInt32.Int32})); + value = r.read(obj.stream_); + end + + function value = read_aliased_generic_(obj) + r = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/MapsWriter.m b/matlab/generated/+test_model/+binary/MapsWriter.m new file mode 100644 index 00000000..6d63fff6 --- /dev/null +++ b/matlab/generated/+test_model/+binary/MapsWriter.m @@ -0,0 +1,31 @@ +% Binary writer for the Maps protocol +classdef MapsWriter < yardl.binary.BinaryProtocolWriter & test_model.MapsWriterBase + methods + function obj = MapsWriter(filename) + obj@test_model.MapsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.MapsWriterBase.schema); + end + end + + methods (Access=protected) + function write_string_to_int_(obj, value) + w = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); + w.write(obj.stream_, value); + end + + function write_int_to_string_(obj, value) + w = yardl.binary.MapSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + w.write(obj.stream_, value); + end + + function write_string_to_union_(obj, value) + w = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.UnionSerializer('test_model.StringOrInt32', {yardl.binary.StringSerializer, yardl.binary.Int32Serializer}, {@test_model.StringOrInt32.String, @test_model.StringOrInt32.Int32})); + w.write(obj.stream_, value); + end + + function write_aliased_generic_(obj, value) + w = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/NDArraysReader.m b/matlab/generated/+test_model/+binary/NDArraysReader.m new file mode 100644 index 00000000..99fe28fa --- /dev/null +++ b/matlab/generated/+test_model/+binary/NDArraysReader.m @@ -0,0 +1,36 @@ +% Binary reader for the NDArrays protocol +classdef NDArraysReader < yardl.binary.BinaryProtocolReader & test_model.NDArraysReaderBase + methods + function obj = NDArraysReader(filename) + obj@test_model.NDArraysReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.NDArraysReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_ints_(obj) + r = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + value = r.read(obj.stream_); + end + + function value = read_simple_record_array_(obj) + r = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 2); + value = r.read(obj.stream_); + end + + function value = read_record_with_vlens_array_(obj) + r = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 2); + value = r.read(obj.stream_); + end + + function value = read_record_with_nd_arrays_(obj) + r = test_model.binary.RecordWithNDArraysSerializer(); + value = r.read(obj.stream_); + end + + function value = read_named_array_(obj) + r = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m new file mode 100644 index 00000000..9fc9b075 --- /dev/null +++ b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m @@ -0,0 +1,31 @@ +% Binary reader for the NDArraysSingleDimension protocol +classdef NDArraysSingleDimensionReader < yardl.binary.BinaryProtocolReader & test_model.NDArraysSingleDimensionReaderBase + methods + function obj = NDArraysSingleDimensionReader(filename) + obj@test_model.NDArraysSingleDimensionReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.NDArraysSingleDimensionReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_ints_(obj) + r = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); + value = r.read(obj.stream_); + end + + function value = read_simple_record_array_(obj) + r = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 1); + value = r.read(obj.stream_); + end + + function value = read_record_with_vlens_array_(obj) + r = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 1); + value = r.read(obj.stream_); + end + + function value = read_record_with_nd_arrays_(obj) + r = test_model.binary.RecordWithNDArraysSingleDimensionSerializer(); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m new file mode 100644 index 00000000..a43894db --- /dev/null +++ b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m @@ -0,0 +1,31 @@ +% Binary writer for the NDArraysSingleDimension protocol +classdef NDArraysSingleDimensionWriter < yardl.binary.BinaryProtocolWriter & test_model.NDArraysSingleDimensionWriterBase + methods + function obj = NDArraysSingleDimensionWriter(filename) + obj@test_model.NDArraysSingleDimensionWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.NDArraysSingleDimensionWriterBase.schema); + end + end + + methods (Access=protected) + function write_ints_(obj, value) + w = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); + w.write(obj.stream_, value); + end + + function write_simple_record_array_(obj, value) + w = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 1); + w.write(obj.stream_, value); + end + + function write_record_with_vlens_array_(obj, value) + w = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 1); + w.write(obj.stream_, value); + end + + function write_record_with_nd_arrays_(obj, value) + w = test_model.binary.RecordWithNDArraysSingleDimensionSerializer(); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/NDArraysWriter.m b/matlab/generated/+test_model/+binary/NDArraysWriter.m new file mode 100644 index 00000000..d03ada99 --- /dev/null +++ b/matlab/generated/+test_model/+binary/NDArraysWriter.m @@ -0,0 +1,36 @@ +% Binary writer for the NDArrays protocol +classdef NDArraysWriter < yardl.binary.BinaryProtocolWriter & test_model.NDArraysWriterBase + methods + function obj = NDArraysWriter(filename) + obj@test_model.NDArraysWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.NDArraysWriterBase.schema); + end + end + + methods (Access=protected) + function write_ints_(obj, value) + w = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + w.write(obj.stream_, value); + end + + function write_simple_record_array_(obj, value) + w = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 2); + w.write(obj.stream_, value); + end + + function write_record_with_vlens_array_(obj, value) + w = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 2); + w.write(obj.stream_, value); + end + + function write_record_with_nd_arrays_(obj, value) + w = test_model.binary.RecordWithNDArraysSerializer(); + w.write(obj.stream_, value); + end + + function write_named_array_(obj, value) + w = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/NestedRecordsReader.m b/matlab/generated/+test_model/+binary/NestedRecordsReader.m new file mode 100644 index 00000000..d18a6313 --- /dev/null +++ b/matlab/generated/+test_model/+binary/NestedRecordsReader.m @@ -0,0 +1,16 @@ +% Binary reader for the NestedRecords protocol +classdef NestedRecordsReader < yardl.binary.BinaryProtocolReader & test_model.NestedRecordsReaderBase + methods + function obj = NestedRecordsReader(filename) + obj@test_model.NestedRecordsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.NestedRecordsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_tuple_with_records_(obj) + r = test_model.binary.TupleWithRecordsSerializer(); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/NestedRecordsWriter.m b/matlab/generated/+test_model/+binary/NestedRecordsWriter.m new file mode 100644 index 00000000..3405f2e5 --- /dev/null +++ b/matlab/generated/+test_model/+binary/NestedRecordsWriter.m @@ -0,0 +1,16 @@ +% Binary writer for the NestedRecords protocol +classdef NestedRecordsWriter < yardl.binary.BinaryProtocolWriter & test_model.NestedRecordsWriterBase + methods + function obj = NestedRecordsWriter(filename) + obj@test_model.NestedRecordsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.NestedRecordsWriterBase.schema); + end + end + + methods (Access=protected) + function write_tuple_with_records_(obj, value) + w = test_model.binary.TupleWithRecordsSerializer(); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/OptionalVectorsReader.m b/matlab/generated/+test_model/+binary/OptionalVectorsReader.m new file mode 100644 index 00000000..a59cec89 --- /dev/null +++ b/matlab/generated/+test_model/+binary/OptionalVectorsReader.m @@ -0,0 +1,16 @@ +% Binary reader for the OptionalVectors protocol +classdef OptionalVectorsReader < yardl.binary.BinaryProtocolReader & test_model.OptionalVectorsReaderBase + methods + function obj = OptionalVectorsReader(filename) + obj@test_model.OptionalVectorsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.OptionalVectorsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_record_with_optional_vector_(obj) + r = test_model.binary.RecordWithOptionalVectorSerializer(); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/OptionalVectorsWriter.m b/matlab/generated/+test_model/+binary/OptionalVectorsWriter.m new file mode 100644 index 00000000..3bcd3230 --- /dev/null +++ b/matlab/generated/+test_model/+binary/OptionalVectorsWriter.m @@ -0,0 +1,16 @@ +% Binary writer for the OptionalVectors protocol +classdef OptionalVectorsWriter < yardl.binary.BinaryProtocolWriter & test_model.OptionalVectorsWriterBase + methods + function obj = OptionalVectorsWriter(filename) + obj@test_model.OptionalVectorsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.OptionalVectorsWriterBase.schema); + end + end + + methods (Access=protected) + function write_record_with_optional_vector_(obj, value) + w = test_model.binary.RecordWithOptionalVectorSerializer(); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m new file mode 100644 index 00000000..d838300d --- /dev/null +++ b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m @@ -0,0 +1,16 @@ +% Binary reader for the ProtocolWithComputedFields protocol +classdef ProtocolWithComputedFieldsReader < yardl.binary.BinaryProtocolReader & test_model.ProtocolWithComputedFieldsReaderBase + methods + function obj = ProtocolWithComputedFieldsReader(filename) + obj@test_model.ProtocolWithComputedFieldsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.ProtocolWithComputedFieldsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_record_with_computed_fields_(obj) + r = test_model.binary.RecordWithComputedFieldsSerializer(); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m new file mode 100644 index 00000000..2c5acf92 --- /dev/null +++ b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m @@ -0,0 +1,16 @@ +% Binary writer for the ProtocolWithComputedFields protocol +classdef ProtocolWithComputedFieldsWriter < yardl.binary.BinaryProtocolWriter & test_model.ProtocolWithComputedFieldsWriterBase + methods + function obj = ProtocolWithComputedFieldsWriter(filename) + obj@test_model.ProtocolWithComputedFieldsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.ProtocolWithComputedFieldsWriterBase.schema); + end + end + + methods (Access=protected) + function write_record_with_computed_fields_(obj, value) + w = test_model.binary.RecordWithComputedFieldsSerializer(); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m new file mode 100644 index 00000000..62fc290e --- /dev/null +++ b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m @@ -0,0 +1,21 @@ +% Binary reader for the ProtocolWithKeywordSteps protocol +classdef ProtocolWithKeywordStepsReader < yardl.binary.BinaryProtocolReader & test_model.ProtocolWithKeywordStepsReaderBase + methods + function obj = ProtocolWithKeywordStepsReader(filename) + obj@test_model.ProtocolWithKeywordStepsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.ProtocolWithKeywordStepsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_int_(obj) + r = yardl.binary.StreamSerializer(test_model.binary.RecordWithKeywordFieldsSerializer()); + value = r.read(obj.stream_); + end + + function value = read_float_(obj) + r = yardl.binary.EnumSerializer('test_model.EnumWithKeywordSymbols', @test_model.EnumWithKeywordSymbols, yardl.binary.Int32Serializer); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m new file mode 100644 index 00000000..014284ca --- /dev/null +++ b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m @@ -0,0 +1,21 @@ +% Binary writer for the ProtocolWithKeywordSteps protocol +classdef ProtocolWithKeywordStepsWriter < yardl.binary.BinaryProtocolWriter & test_model.ProtocolWithKeywordStepsWriterBase + methods + function obj = ProtocolWithKeywordStepsWriter(filename) + obj@test_model.ProtocolWithKeywordStepsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.ProtocolWithKeywordStepsWriterBase.schema); + end + end + + methods (Access=protected) + function write_int_(obj, value) + w = yardl.binary.StreamSerializer(test_model.binary.RecordWithKeywordFieldsSerializer()); + w.write(obj.stream_, value); + end + + function write_float_(obj, value) + w = yardl.binary.EnumSerializer('test_model.EnumWithKeywordSymbols', @test_model.EnumWithKeywordSymbols, yardl.binary.Int32Serializer); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m b/matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m new file mode 100644 index 00000000..6fb98103 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m @@ -0,0 +1,27 @@ +classdef RecordContainingGenericRecordsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordContainingGenericRecordsSerializer(a_serializer, b_serializer) + field_serializers{1} = test_model.binary.RecordWithOptionalGenericFieldSerializer(a_serializer); + field_serializers{2} = test_model.binary.RecordWithAliasedOptionalGenericFieldSerializer(a_serializer); + field_serializers{3} = test_model.binary.RecordWithOptionalGenericUnionFieldSerializer(a_serializer, b_serializer); + field_serializers{4} = test_model.binary.RecordWithAliasedOptionalGenericUnionFieldSerializer(a_serializer, b_serializer); + field_serializers{5} = tuples.binary.TupleSerializer(a_serializer, b_serializer); + field_serializers{6} = tuples.binary.TupleSerializer(a_serializer, b_serializer); + field_serializers{7} = test_model.binary.RecordWithGenericVectorsSerializer(b_serializer); + field_serializers{8} = test_model.binary.RecordWithGenericFixedVectorsSerializer(b_serializer); + field_serializers{9} = test_model.binary.RecordWithGenericArraysSerializer(b_serializer); + field_serializers{10} = test_model.binary.RecordWithGenericMapsSerializer(a_serializer, b_serializer); + obj@yardl.binary.RecordSerializer('test_model.RecordContainingGenericRecords', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordContainingGenericRecords')); + obj.write_(outstream, value.g1, value.g1a, value.g2, value.g2a, value.g3, value.g3a, value.g4, value.g5, value.g6, value.g7) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordContainingGenericRecords(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m b/matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m new file mode 100644 index 00000000..391a6532 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m @@ -0,0 +1,22 @@ +classdef RecordContainingNestedGenericRecordsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordContainingNestedGenericRecordsSerializer() + field_serializers{1} = test_model.binary.RecordWithOptionalGenericFieldSerializer(yardl.binary.StringSerializer); + field_serializers{2} = test_model.binary.RecordWithAliasedOptionalGenericFieldSerializer(yardl.binary.StringSerializer); + field_serializers{3} = test_model.binary.RecordWithOptionalGenericUnionFieldSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); + field_serializers{4} = test_model.binary.RecordWithAliasedOptionalGenericUnionFieldSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); + field_serializers{5} = test_model.binary.RecordContainingGenericRecordsSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); + obj@yardl.binary.RecordSerializer('test_model.RecordContainingNestedGenericRecords', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordContainingNestedGenericRecords')); + obj.write_(outstream, value.f1, value.f1a, value.f2, value.f2a, value.nested) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordContainingNestedGenericRecords(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m b/matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m new file mode 100644 index 00000000..5ebf2dfd --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m @@ -0,0 +1,19 @@ +classdef RecordNotUsedInProtocolSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordNotUsedInProtocolSerializer() + field_serializers{1} = yardl.binary.UnionSerializer('test_model.GenericUnion3', {yardl.binary.Int32Serializer, yardl.binary.Float32Serializer, yardl.binary.StringSerializer}, {@test_model.GenericUnion3.T, @test_model.GenericUnion3.U, @test_model.GenericUnion3.V}); + field_serializers{2} = yardl.binary.UnionSerializer('test_model.GenericUnion3Alternate', {yardl.binary.Int32Serializer, yardl.binary.Float32Serializer, yardl.binary.StringSerializer}, {@test_model.GenericUnion3Alternate.U, @test_model.GenericUnion3Alternate.V, @test_model.GenericUnion3Alternate.W}); + obj@yardl.binary.RecordSerializer('test_model.RecordNotUsedInProtocol', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordNotUsedInProtocol')); + obj.write_(outstream, value.u1, value.u2) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordNotUsedInProtocol(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m new file mode 100644 index 00000000..b1cfd4f5 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m @@ -0,0 +1,19 @@ +classdef RecordWithAliasedGenericsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithAliasedGenericsSerializer() + field_serializers{1} = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.StringSerializer); + field_serializers{2} = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.StringSerializer); + obj@yardl.binary.RecordSerializer('test_model.RecordWithAliasedGenerics', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithAliasedGenerics')); + obj.write_(outstream, value.my_strings, value.aliased_strings) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithAliasedGenerics(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m new file mode 100644 index 00000000..74b92cf3 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m @@ -0,0 +1,18 @@ +classdef RecordWithAliasedOptionalGenericFieldSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithAliasedOptionalGenericFieldSerializer(t_serializer) + field_serializers{1} = yardl.binary.OptionalSerializer(t_serializer); + obj@yardl.binary.RecordSerializer('test_model.RecordWithAliasedOptionalGenericField', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithAliasedOptionalGenericField')); + obj.write_(outstream, value.v) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithAliasedOptionalGenericField(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m new file mode 100644 index 00000000..d7bb27d3 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m @@ -0,0 +1,18 @@ +classdef RecordWithAliasedOptionalGenericUnionFieldSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithAliasedOptionalGenericUnionFieldSerializer(u_serializer, v_serializer) + field_serializers{1} = yardl.binary.UnionSerializer('test_model.AliasedMultiGenericOptional', {yardl.binary.NoneSerializer, u_serializer, v_serializer}, {yardl.None, @test_model.AliasedMultiGenericOptional.T, @test_model.AliasedMultiGenericOptional.U}); + obj@yardl.binary.RecordSerializer('test_model.RecordWithAliasedOptionalGenericUnionField', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithAliasedOptionalGenericUnionField')); + obj.write_(outstream, value.v) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithAliasedOptionalGenericUnionField(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m new file mode 100644 index 00000000..7c6cd298 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m @@ -0,0 +1,26 @@ +classdef RecordWithArraysSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithArraysSerializer() + field_serializers{1} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); + field_serializers{2} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); + field_serializers{3} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); + field_serializers{4} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + field_serializers{5} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + field_serializers{6} = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 3]); + field_serializers{7} = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 3]); + field_serializers{8} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); + field_serializers{9} = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 4), [5]); + obj@yardl.binary.RecordSerializer('test_model.RecordWithArrays', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithArrays')); + obj.write_(outstream, value.default_array, value.default_array_with_empty_dimension, value.rank_1_array, value.rank_2_array, value.rank_2_array_with_named_dimensions, value.rank_2_fixed_array, value.rank_2_fixed_array_with_named_dimensions, value.dynamic_array, value.array_of_vectors) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithArrays(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m b/matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m new file mode 100644 index 00000000..60d0bd9f --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m @@ -0,0 +1,26 @@ +classdef RecordWithArraysSimpleSyntaxSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithArraysSimpleSyntaxSerializer() + field_serializers{1} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); + field_serializers{2} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); + field_serializers{3} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); + field_serializers{4} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + field_serializers{5} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + field_serializers{6} = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 3]); + field_serializers{7} = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 3]); + field_serializers{8} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); + field_serializers{9} = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 4), [5]); + obj@yardl.binary.RecordSerializer('test_model.RecordWithArraysSimpleSyntax', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithArraysSimpleSyntax')); + obj.write_(outstream, value.default_array, value.default_array_with_empty_dimension, value.rank_1_array, value.rank_2_array, value.rank_2_array_with_named_dimensions, value.rank_2_fixed_array, value.rank_2_fixed_array_with_named_dimensions, value.dynamic_array, value.array_of_vectors) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithArraysSimpleSyntax(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m new file mode 100644 index 00000000..cd1c77ce --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m @@ -0,0 +1,44 @@ +classdef RecordWithComputedFieldsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithComputedFieldsSerializer() + field_serializers{1} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + field_serializers{2} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + field_serializers{3} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); + field_serializers{4} = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 3]); + field_serializers{5} = yardl.binary.Int32Serializer; + field_serializers{6} = yardl.binary.Int8Serializer; + field_serializers{7} = yardl.binary.Uint8Serializer; + field_serializers{8} = yardl.binary.Int16Serializer; + field_serializers{9} = yardl.binary.Uint16Serializer; + field_serializers{10} = yardl.binary.Uint32Serializer; + field_serializers{11} = yardl.binary.Int64Serializer; + field_serializers{12} = yardl.binary.Uint64Serializer; + field_serializers{13} = yardl.binary.SizeSerializer; + field_serializers{14} = yardl.binary.Float32Serializer; + field_serializers{15} = yardl.binary.Float64Serializer; + field_serializers{16} = yardl.binary.Complexfloat32Serializer; + field_serializers{17} = yardl.binary.Complexfloat64Serializer; + field_serializers{18} = yardl.binary.StringSerializer; + field_serializers{19} = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Int32Serializer); + field_serializers{20} = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); + field_serializers{21} = yardl.binary.VectorSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer)); + field_serializers{22} = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3); + field_serializers{23} = yardl.binary.OptionalSerializer(yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2)); + field_serializers{24} = yardl.binary.UnionSerializer('test_model.Int32OrFloat32', {yardl.binary.Int32Serializer, yardl.binary.Float32Serializer}, {@test_model.Int32OrFloat32.Int32, @test_model.Int32OrFloat32.Float32}); + field_serializers{25} = yardl.binary.UnionSerializer('test_model.Int32OrFloat32', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, yardl.binary.Float32Serializer}, {yardl.None, @test_model.Int32OrFloat32.Int32, @test_model.Int32OrFloat32.Float32}); + field_serializers{26} = yardl.binary.UnionSerializer('test_model.IntOrGenericRecordWithComputedFields', {yardl.binary.Int32Serializer, basic_types.binary.GenericRecordWithComputedFieldsSerializer(yardl.binary.StringSerializer, yardl.binary.Float32Serializer)}, {@test_model.IntOrGenericRecordWithComputedFields.Int, @test_model.IntOrGenericRecordWithComputedFields.GenericRecordWithComputedFields}); + field_serializers{27} = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.StringSerializer); + obj@yardl.binary.RecordSerializer('test_model.RecordWithComputedFields', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithComputedFields')); + obj.write_(outstream, value.array_field, value.array_field_map_dimensions, value.dynamic_array_field, value.fixed_array_field, value.int_field, value.int8_field, value.uint8_field, value.int16_field, value.uint16_field, value.uint32_field, value.int64_field, value.uint64_field, value.size_field, value.float32_field, value.float64_field, value.complexfloat32_field, value.complexfloat64_field, value.string_field, value.tuple_field, value.vector_field, value.vector_of_vectors_field, value.fixed_vector_field, value.optional_named_array, value.int_float_union, value.nullable_int_float_union, value.union_with_nested_generic_union, value.map_field) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithComputedFields(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m new file mode 100644 index 00000000..aa835e28 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m @@ -0,0 +1,20 @@ +classdef RecordWithDynamicNDArraysSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithDynamicNDArraysSerializer() + field_serializers{1} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); + field_serializers{2} = yardl.binary.DynamicNDArraySerializer(test_model.binary.SimpleRecordSerializer()); + field_serializers{3} = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlensSerializer()); + obj@yardl.binary.RecordSerializer('test_model.RecordWithDynamicNDArrays', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithDynamicNDArrays')); + obj.write_(outstream, value.ints, value.simple_record_array, value.record_with_vlens_array) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithDynamicNDArrays(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m new file mode 100644 index 00000000..d496b28d --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m @@ -0,0 +1,20 @@ +classdef RecordWithEnumsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithEnumsSerializer() + field_serializers{1} = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); + field_serializers{2} = yardl.binary.EnumSerializer('basic_types.DaysOfWeek', @basic_types.DaysOfWeek, yardl.binary.Int32Serializer); + field_serializers{3} = yardl.binary.EnumSerializer('basic_types.TextFormat', @basic_types.TextFormat, yardl.binary.Uint64Serializer); + obj@yardl.binary.RecordSerializer('test_model.RecordWithEnums', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithEnums')); + obj.write_(outstream, value.enum, value.flags, value.flags_2) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithEnums(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m new file mode 100644 index 00000000..1dc0f50a --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m @@ -0,0 +1,20 @@ +classdef RecordWithFixedArraysSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithFixedArraysSerializer() + field_serializers{1} = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); + field_serializers{2} = yardl.binary.FixedNDArraySerializer(test_model.binary.SimpleRecordSerializer(), [2, 3]); + field_serializers{3} = yardl.binary.FixedNDArraySerializer(test_model.binary.RecordWithVlensSerializer(), [2, 2]); + obj@yardl.binary.RecordSerializer('test_model.RecordWithFixedArrays', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithFixedArrays')); + obj.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithFixedArrays(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m new file mode 100644 index 00000000..39fa759f --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m @@ -0,0 +1,19 @@ +classdef RecordWithFixedCollectionsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithFixedCollectionsSerializer() + field_serializers{1} = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3); + field_serializers{2} = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); + obj@yardl.binary.RecordSerializer('test_model.RecordWithFixedCollections', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithFixedCollections')); + obj.write_(outstream, value.fixed_vector, value.fixed_array) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithFixedCollections(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m new file mode 100644 index 00000000..ea685c88 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m @@ -0,0 +1,20 @@ +classdef RecordWithFixedVectorsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithFixedVectorsSerializer() + field_serializers{1} = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 5); + field_serializers{2} = yardl.binary.FixedVectorSerializer(test_model.binary.SimpleRecordSerializer(), 3); + field_serializers{3} = yardl.binary.FixedVectorSerializer(test_model.binary.RecordWithVlensSerializer(), 2); + obj@yardl.binary.RecordSerializer('test_model.RecordWithFixedVectors', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithFixedVectors')); + obj.write_(outstream, value.fixed_int_vector, value.fixed_simple_record_vector, value.fixed_record_with_vlens_vector) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithFixedVectors(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m new file mode 100644 index 00000000..96d273d8 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m @@ -0,0 +1,23 @@ +classdef RecordWithGenericArraysSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithGenericArraysSerializer(t_serializer) + field_serializers{1} = yardl.binary.NDArraySerializer(t_serializer, 2); + field_serializers{2} = yardl.binary.FixedNDArraySerializer(t_serializer, [8, 16]); + field_serializers{3} = yardl.binary.DynamicNDArraySerializer(t_serializer); + field_serializers{4} = yardl.binary.NDArraySerializer(t_serializer, 2); + field_serializers{5} = yardl.binary.FixedNDArraySerializer(t_serializer, [8, 16]); + field_serializers{6} = yardl.binary.DynamicNDArraySerializer(t_serializer); + obj@yardl.binary.RecordSerializer('test_model.RecordWithGenericArrays', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithGenericArrays')); + obj.write_(outstream, value.nd, value.fixed_nd, value.dynamic_nd, value.aliased_nd, value.aliased_fixed_nd, value.aliased_dynamic_nd) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithGenericArrays(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m new file mode 100644 index 00000000..28b081d5 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m @@ -0,0 +1,19 @@ +classdef RecordWithGenericFixedVectorsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithGenericFixedVectorsSerializer(t_serializer) + field_serializers{1} = yardl.binary.FixedVectorSerializer(t_serializer, 3); + field_serializers{2} = yardl.binary.FixedVectorSerializer(t_serializer, 3); + obj@yardl.binary.RecordSerializer('test_model.RecordWithGenericFixedVectors', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithGenericFixedVectors')); + obj.write_(outstream, value.fv, value.afv) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithGenericFixedVectors(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m new file mode 100644 index 00000000..18070243 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m @@ -0,0 +1,19 @@ +classdef RecordWithGenericMapsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithGenericMapsSerializer(t_serializer, u_serializer) + field_serializers{1} = yardl.binary.MapSerializer(t_serializer, u_serializer); + field_serializers{2} = yardl.binary.MapSerializer(t_serializer, u_serializer); + obj@yardl.binary.RecordSerializer('test_model.RecordWithGenericMaps', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithGenericMaps')); + obj.write_(outstream, value.m, value.am) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithGenericMaps(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m new file mode 100644 index 00000000..195a2769 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m @@ -0,0 +1,18 @@ +classdef RecordWithGenericVectorOfRecordsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithGenericVectorOfRecordsSerializer(t_serializer, u_serializer) + field_serializers{1} = yardl.binary.VectorSerializer(yardl.binary.VectorSerializer(test_model.binary.GenericRecordSerializer(t_serializer, u_serializer))); + obj@yardl.binary.RecordSerializer('test_model.RecordWithGenericVectorOfRecords', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithGenericVectorOfRecords')); + obj.write_(outstream, value.v) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithGenericVectorOfRecords(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m new file mode 100644 index 00000000..4d4f9722 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m @@ -0,0 +1,19 @@ +classdef RecordWithGenericVectorsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithGenericVectorsSerializer(t_serializer) + field_serializers{1} = yardl.binary.VectorSerializer(t_serializer); + field_serializers{2} = yardl.binary.VectorSerializer(t_serializer); + obj@yardl.binary.RecordSerializer('test_model.RecordWithGenericVectors', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithGenericVectors')); + obj.write_(outstream, value.v, value.av) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithGenericVectors(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m new file mode 100644 index 00000000..3206f89c --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m @@ -0,0 +1,20 @@ +classdef RecordWithKeywordFieldsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithKeywordFieldsSerializer() + field_serializers{1} = yardl.binary.StringSerializer; + field_serializers{2} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + field_serializers{3} = yardl.binary.EnumSerializer('test_model.EnumWithKeywordSymbols', @test_model.EnumWithKeywordSymbols, yardl.binary.Int32Serializer); + obj@yardl.binary.RecordSerializer('test_model.RecordWithKeywordFields', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithKeywordFields')); + obj.write_(outstream, value.int, value.sizeof, value.if) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithKeywordFields(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m new file mode 100644 index 00000000..c7a3679a --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m @@ -0,0 +1,20 @@ +classdef RecordWithNDArraysSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithNDArraysSerializer() + field_serializers{1} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + field_serializers{2} = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 2); + field_serializers{3} = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 2); + obj@yardl.binary.RecordSerializer('test_model.RecordWithNDArrays', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithNDArrays')); + obj.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithNDArrays(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m b/matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m new file mode 100644 index 00000000..9e2ed0d8 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m @@ -0,0 +1,20 @@ +classdef RecordWithNDArraysSingleDimensionSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithNDArraysSingleDimensionSerializer() + field_serializers{1} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); + field_serializers{2} = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 1); + field_serializers{3} = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 1); + obj@yardl.binary.RecordSerializer('test_model.RecordWithNDArraysSingleDimension', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithNDArraysSingleDimension')); + obj.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithNDArraysSingleDimension(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m new file mode 100644 index 00000000..6050b003 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m @@ -0,0 +1,20 @@ +classdef RecordWithNamedFixedArraysSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithNamedFixedArraysSerializer() + field_serializers{1} = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); + field_serializers{2} = yardl.binary.FixedNDArraySerializer(test_model.binary.SimpleRecordSerializer(), [2, 3]); + field_serializers{3} = yardl.binary.FixedNDArraySerializer(test_model.binary.RecordWithVlensSerializer(), [2, 2]); + obj@yardl.binary.RecordSerializer('test_model.RecordWithNamedFixedArrays', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithNamedFixedArrays')); + obj.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithNamedFixedArrays(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m new file mode 100644 index 00000000..ca0fd4f7 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m @@ -0,0 +1,20 @@ +classdef RecordWithOptionalFieldsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithOptionalFieldsSerializer() + field_serializers{1} = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); + field_serializers{2} = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); + field_serializers{3} = yardl.binary.OptionalSerializer(yardl.binary.TimeSerializer); + obj@yardl.binary.RecordSerializer('test_model.RecordWithOptionalFields', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithOptionalFields')); + obj.write_(outstream, value.optional_int, value.optional_int_alternate_syntax, value.optional_time) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithOptionalFields(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m new file mode 100644 index 00000000..443f477f --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m @@ -0,0 +1,18 @@ +classdef RecordWithOptionalGenericFieldSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithOptionalGenericFieldSerializer(t_serializer) + field_serializers{1} = yardl.binary.OptionalSerializer(t_serializer); + obj@yardl.binary.RecordSerializer('test_model.RecordWithOptionalGenericField', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithOptionalGenericField')); + obj.write_(outstream, value.v) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithOptionalGenericField(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m new file mode 100644 index 00000000..6b41543a --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m @@ -0,0 +1,18 @@ +classdef RecordWithOptionalGenericUnionFieldSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithOptionalGenericUnionFieldSerializer(u_serializer, v_serializer) + field_serializers{1} = yardl.binary.UnionSerializer('test_model.UOrV', {yardl.binary.NoneSerializer, u_serializer, v_serializer}, {yardl.None, @test_model.UOrV.U, @test_model.UOrV.V}); + obj@yardl.binary.RecordSerializer('test_model.RecordWithOptionalGenericUnionField', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithOptionalGenericUnionField')); + obj.write_(outstream, value.v) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithOptionalGenericUnionField(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m new file mode 100644 index 00000000..45b59224 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m @@ -0,0 +1,18 @@ +classdef RecordWithOptionalVectorSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithOptionalVectorSerializer() + field_serializers{1} = yardl.binary.OptionalSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer)); + obj@yardl.binary.RecordSerializer('test_model.RecordWithOptionalVector', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithOptionalVector')); + obj.write_(outstream, value.optional_vector) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithOptionalVector(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m b/matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m new file mode 100644 index 00000000..4f499625 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m @@ -0,0 +1,26 @@ +classdef RecordWithPrimitiveAliasesSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithPrimitiveAliasesSerializer() + field_serializers{1} = yardl.binary.Uint8Serializer; + field_serializers{2} = yardl.binary.Int32Serializer; + field_serializers{3} = yardl.binary.Uint32Serializer; + field_serializers{4} = yardl.binary.Int64Serializer; + field_serializers{5} = yardl.binary.Uint64Serializer; + field_serializers{6} = yardl.binary.Float32Serializer; + field_serializers{7} = yardl.binary.Float64Serializer; + field_serializers{8} = yardl.binary.Complexfloat32Serializer; + field_serializers{9} = yardl.binary.Complexfloat64Serializer; + obj@yardl.binary.RecordSerializer('test_model.RecordWithPrimitiveAliases', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithPrimitiveAliases')); + obj.write_(outstream, value.byte_field, value.int_field, value.uint_field, value.long_field, value.ulong_field, value.float_field, value.double_field, value.complexfloat_field, value.complexdouble_field) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithPrimitiveAliases(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m b/matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m new file mode 100644 index 00000000..9e52323f --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m @@ -0,0 +1,34 @@ +classdef RecordWithPrimitivesSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithPrimitivesSerializer() + field_serializers{1} = yardl.binary.BoolSerializer; + field_serializers{2} = yardl.binary.Int8Serializer; + field_serializers{3} = yardl.binary.Uint8Serializer; + field_serializers{4} = yardl.binary.Int16Serializer; + field_serializers{5} = yardl.binary.Uint16Serializer; + field_serializers{6} = yardl.binary.Int32Serializer; + field_serializers{7} = yardl.binary.Uint32Serializer; + field_serializers{8} = yardl.binary.Int64Serializer; + field_serializers{9} = yardl.binary.Uint64Serializer; + field_serializers{10} = yardl.binary.SizeSerializer; + field_serializers{11} = yardl.binary.Float32Serializer; + field_serializers{12} = yardl.binary.Float64Serializer; + field_serializers{13} = yardl.binary.Complexfloat32Serializer; + field_serializers{14} = yardl.binary.Complexfloat64Serializer; + field_serializers{15} = yardl.binary.DateSerializer; + field_serializers{16} = yardl.binary.TimeSerializer; + field_serializers{17} = yardl.binary.DatetimeSerializer; + obj@yardl.binary.RecordSerializer('test_model.RecordWithPrimitives', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithPrimitives')); + obj.write_(outstream, value.bool_field, value.int8_field, value.uint8_field, value.int16_field, value.uint16_field, value.int32_field, value.uint32_field, value.int64_field, value.uint64_field, value.size_field, value.float32_field, value.float64_field, value.complexfloat32_field, value.complexfloat64_field, value.date_field, value.time_field, value.datetime_field) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithPrimitives(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m new file mode 100644 index 00000000..067ff7ff --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m @@ -0,0 +1,19 @@ +classdef RecordWithStringsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithStringsSerializer() + field_serializers{1} = yardl.binary.StringSerializer; + field_serializers{2} = yardl.binary.StringSerializer; + obj@yardl.binary.RecordSerializer('test_model.RecordWithStrings', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithStrings')); + obj.write_(outstream, value.a, value.b) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithStrings(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m b/matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m new file mode 100644 index 00000000..086e03a3 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m @@ -0,0 +1,20 @@ +classdef RecordWithUnionsOfContainersSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithUnionsOfContainersSerializer() + field_serializers{1} = yardl.binary.UnionSerializer('test_model.MapOrScalar', {yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer), yardl.binary.Int32Serializer}, {@test_model.MapOrScalar.Map, @test_model.MapOrScalar.Scalar}); + field_serializers{2} = yardl.binary.UnionSerializer('test_model.VectorOrScalar', {yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), yardl.binary.Int32Serializer}, {@test_model.VectorOrScalar.Vector, @test_model.VectorOrScalar.Scalar}); + field_serializers{3} = yardl.binary.UnionSerializer('test_model.ArrayOrScalar', {yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer), yardl.binary.Int32Serializer}, {@test_model.ArrayOrScalar.Array, @test_model.ArrayOrScalar.Scalar}); + obj@yardl.binary.RecordSerializer('test_model.RecordWithUnionsOfContainers', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithUnionsOfContainers')); + obj.write_(outstream, value.map_or_scalar, value.vector_or_scalar, value.array_or_scalar) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithUnionsOfContainers(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m new file mode 100644 index 00000000..efb313a7 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m @@ -0,0 +1,18 @@ +classdef RecordWithVectorOfTimesSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithVectorOfTimesSerializer() + field_serializers{1} = yardl.binary.VectorSerializer(yardl.binary.TimeSerializer); + obj@yardl.binary.RecordSerializer('test_model.RecordWithVectorOfTimes', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithVectorOfTimes')); + obj.write_(outstream, value.times) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithVectorOfTimes(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m new file mode 100644 index 00000000..aa98288b --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m @@ -0,0 +1,20 @@ +classdef RecordWithVectorsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithVectorsSerializer() + field_serializers{1} = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); + field_serializers{2} = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3); + field_serializers{3} = yardl.binary.VectorSerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 2)); + obj@yardl.binary.RecordSerializer('test_model.RecordWithVectors', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithVectors')); + obj.write_(outstream, value.default_vector, value.default_vector_fixed_length, value.vector_of_vectors) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithVectors(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m new file mode 100644 index 00000000..a6f40d17 --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m @@ -0,0 +1,19 @@ +classdef RecordWithVlenCollectionsSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithVlenCollectionsSerializer() + field_serializers{1} = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); + field_serializers{2} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + obj@yardl.binary.RecordSerializer('test_model.RecordWithVlenCollections', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithVlenCollections')); + obj.write_(outstream, value.vector, value.array) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithVlenCollections(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m new file mode 100644 index 00000000..18f801db --- /dev/null +++ b/matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m @@ -0,0 +1,20 @@ +classdef RecordWithVlensSerializer < yardl.binary.RecordSerializer + methods + function obj = RecordWithVlensSerializer() + field_serializers{1} = yardl.binary.VectorSerializer(test_model.binary.SimpleRecordSerializer()); + field_serializers{2} = yardl.binary.Int32Serializer; + field_serializers{3} = yardl.binary.Int32Serializer; + obj@yardl.binary.RecordSerializer('test_model.RecordWithVlens', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.RecordWithVlens')); + obj.write_(outstream, value.a, value.b, value.c) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.RecordWithVlens(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/ScalarOptionalsReader.m b/matlab/generated/+test_model/+binary/ScalarOptionalsReader.m new file mode 100644 index 00000000..56858833 --- /dev/null +++ b/matlab/generated/+test_model/+binary/ScalarOptionalsReader.m @@ -0,0 +1,31 @@ +% Binary reader for the ScalarOptionals protocol +classdef ScalarOptionalsReader < yardl.binary.BinaryProtocolReader & test_model.ScalarOptionalsReaderBase + methods + function obj = ScalarOptionalsReader(filename) + obj@test_model.ScalarOptionalsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.ScalarOptionalsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_optional_int_(obj) + r = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); + value = r.read(obj.stream_); + end + + function value = read_optional_record_(obj) + r = yardl.binary.OptionalSerializer(test_model.binary.SimpleRecordSerializer()); + value = r.read(obj.stream_); + end + + function value = read_record_with_optional_fields_(obj) + r = test_model.binary.RecordWithOptionalFieldsSerializer(); + value = r.read(obj.stream_); + end + + function value = read_optional_record_with_optional_fields_(obj) + r = yardl.binary.OptionalSerializer(test_model.binary.RecordWithOptionalFieldsSerializer()); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m b/matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m new file mode 100644 index 00000000..8661622d --- /dev/null +++ b/matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m @@ -0,0 +1,31 @@ +% Binary writer for the ScalarOptionals protocol +classdef ScalarOptionalsWriter < yardl.binary.BinaryProtocolWriter & test_model.ScalarOptionalsWriterBase + methods + function obj = ScalarOptionalsWriter(filename) + obj@test_model.ScalarOptionalsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.ScalarOptionalsWriterBase.schema); + end + end + + methods (Access=protected) + function write_optional_int_(obj, value) + w = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); + w.write(obj.stream_, value); + end + + function write_optional_record_(obj, value) + w = yardl.binary.OptionalSerializer(test_model.binary.SimpleRecordSerializer()); + w.write(obj.stream_, value); + end + + function write_record_with_optional_fields_(obj, value) + w = test_model.binary.RecordWithOptionalFieldsSerializer(); + w.write(obj.stream_, value); + end + + function write_optional_record_with_optional_fields_(obj, value) + w = yardl.binary.OptionalSerializer(test_model.binary.RecordWithOptionalFieldsSerializer()); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/ScalarsReader.m b/matlab/generated/+test_model/+binary/ScalarsReader.m new file mode 100644 index 00000000..2cbee512 --- /dev/null +++ b/matlab/generated/+test_model/+binary/ScalarsReader.m @@ -0,0 +1,21 @@ +% Binary reader for the Scalars protocol +classdef ScalarsReader < yardl.binary.BinaryProtocolReader & test_model.ScalarsReaderBase + methods + function obj = ScalarsReader(filename) + obj@test_model.ScalarsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.ScalarsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_int32_(obj) + r = yardl.binary.Int32Serializer; + value = r.read(obj.stream_); + end + + function value = read_record_(obj) + r = test_model.binary.RecordWithPrimitivesSerializer(); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/ScalarsWriter.m b/matlab/generated/+test_model/+binary/ScalarsWriter.m new file mode 100644 index 00000000..ac9f1207 --- /dev/null +++ b/matlab/generated/+test_model/+binary/ScalarsWriter.m @@ -0,0 +1,21 @@ +% Binary writer for the Scalars protocol +classdef ScalarsWriter < yardl.binary.BinaryProtocolWriter & test_model.ScalarsWriterBase + methods + function obj = ScalarsWriter(filename) + obj@test_model.ScalarsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.ScalarsWriterBase.schema); + end + end + + methods (Access=protected) + function write_int32_(obj, value) + w = yardl.binary.Int32Serializer; + w.write(obj.stream_, value); + end + + function write_record_(obj, value) + w = test_model.binary.RecordWithPrimitivesSerializer(); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m b/matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m new file mode 100644 index 00000000..f6764ae4 --- /dev/null +++ b/matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m @@ -0,0 +1,21 @@ +classdef SimpleAcquisitionSerializer < yardl.binary.RecordSerializer + methods + function obj = SimpleAcquisitionSerializer() + field_serializers{1} = yardl.binary.Uint64Serializer; + field_serializers{2} = test_model.binary.SimpleEncodingCountersSerializer(); + field_serializers{3} = yardl.binary.NDArraySerializer(yardl.binary.Complexfloat32Serializer, 2); + field_serializers{4} = yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2); + obj@yardl.binary.RecordSerializer('test_model.SimpleAcquisition', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.SimpleAcquisition')); + obj.write_(outstream, value.flags, value.idx, value.data, value.trajectory) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.SimpleAcquisition(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m b/matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m new file mode 100644 index 00000000..5430bc91 --- /dev/null +++ b/matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m @@ -0,0 +1,21 @@ +classdef SimpleEncodingCountersSerializer < yardl.binary.RecordSerializer + methods + function obj = SimpleEncodingCountersSerializer() + field_serializers{1} = yardl.binary.OptionalSerializer(yardl.binary.Uint32Serializer); + field_serializers{2} = yardl.binary.OptionalSerializer(yardl.binary.Uint32Serializer); + field_serializers{3} = yardl.binary.OptionalSerializer(yardl.binary.Uint32Serializer); + field_serializers{4} = yardl.binary.OptionalSerializer(yardl.binary.Uint32Serializer); + obj@yardl.binary.RecordSerializer('test_model.SimpleEncodingCounters', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.SimpleEncodingCounters')); + obj.write_(outstream, value.e1, value.e2, value.slice, value.repetition) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.SimpleEncodingCounters(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/SimpleGenericsReader.m b/matlab/generated/+test_model/+binary/SimpleGenericsReader.m new file mode 100644 index 00000000..f8ba4040 --- /dev/null +++ b/matlab/generated/+test_model/+binary/SimpleGenericsReader.m @@ -0,0 +1,56 @@ +% Binary reader for the SimpleGenerics protocol +classdef SimpleGenericsReader < yardl.binary.BinaryProtocolReader & test_model.SimpleGenericsReaderBase + methods + function obj = SimpleGenericsReader(filename) + obj@test_model.SimpleGenericsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.SimpleGenericsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_float_image_(obj) + r = yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2); + value = r.read(obj.stream_); + end + + function value = read_int_image_(obj) + r = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + value = r.read(obj.stream_); + end + + function value = read_int_image_alternate_syntax_(obj) + r = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + value = r.read(obj.stream_); + end + + function value = read_string_image_(obj) + r = yardl.binary.NDArraySerializer(yardl.binary.StringSerializer, 2); + value = r.read(obj.stream_); + end + + function value = read_int_float_tuple_(obj) + r = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); + value = r.read(obj.stream_); + end + + function value = read_float_float_tuple_(obj) + r = tuples.binary.TupleSerializer(yardl.binary.Float32Serializer, yardl.binary.Float32Serializer); + value = r.read(obj.stream_); + end + + function value = read_int_float_tuple_alternate_syntax_(obj) + r = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); + value = r.read(obj.stream_); + end + + function value = read_int_string_tuple_(obj) + r = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + value = r.read(obj.stream_); + end + + function value = read_stream_of_type_variants_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.ImageFloatOrImageDouble', {yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), yardl.binary.NDArraySerializer(yardl.binary.Float64Serializer, 2)}, {@test_model.ImageFloatOrImageDouble.ImageFloat, @test_model.ImageFloatOrImageDouble.ImageDouble})); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/SimpleGenericsWriter.m b/matlab/generated/+test_model/+binary/SimpleGenericsWriter.m new file mode 100644 index 00000000..15d49ac9 --- /dev/null +++ b/matlab/generated/+test_model/+binary/SimpleGenericsWriter.m @@ -0,0 +1,56 @@ +% Binary writer for the SimpleGenerics protocol +classdef SimpleGenericsWriter < yardl.binary.BinaryProtocolWriter & test_model.SimpleGenericsWriterBase + methods + function obj = SimpleGenericsWriter(filename) + obj@test_model.SimpleGenericsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.SimpleGenericsWriterBase.schema); + end + end + + methods (Access=protected) + function write_float_image_(obj, value) + w = yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2); + w.write(obj.stream_, value); + end + + function write_int_image_(obj, value) + w = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + w.write(obj.stream_, value); + end + + function write_int_image_alternate_syntax_(obj, value) + w = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + w.write(obj.stream_, value); + end + + function write_string_image_(obj, value) + w = yardl.binary.NDArraySerializer(yardl.binary.StringSerializer, 2); + w.write(obj.stream_, value); + end + + function write_int_float_tuple_(obj, value) + w = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); + w.write(obj.stream_, value); + end + + function write_float_float_tuple_(obj, value) + w = tuples.binary.TupleSerializer(yardl.binary.Float32Serializer, yardl.binary.Float32Serializer); + w.write(obj.stream_, value); + end + + function write_int_float_tuple_alternate_syntax_(obj, value) + w = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); + w.write(obj.stream_, value); + end + + function write_int_string_tuple_(obj, value) + w = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + w.write(obj.stream_, value); + end + + function write_stream_of_type_variants_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.ImageFloatOrImageDouble', {yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), yardl.binary.NDArraySerializer(yardl.binary.Float64Serializer, 2)}, {@test_model.ImageFloatOrImageDouble.ImageFloat, @test_model.ImageFloatOrImageDouble.ImageDouble})); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/SimpleRecordSerializer.m b/matlab/generated/+test_model/+binary/SimpleRecordSerializer.m new file mode 100644 index 00000000..4431faf2 --- /dev/null +++ b/matlab/generated/+test_model/+binary/SimpleRecordSerializer.m @@ -0,0 +1,20 @@ +classdef SimpleRecordSerializer < yardl.binary.RecordSerializer + methods + function obj = SimpleRecordSerializer() + field_serializers{1} = yardl.binary.Int32Serializer; + field_serializers{2} = yardl.binary.Int32Serializer; + field_serializers{3} = yardl.binary.Int32Serializer; + obj@yardl.binary.RecordSerializer('test_model.SimpleRecord', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.SimpleRecord')); + obj.write_(outstream, value.x, value.y, value.z) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.SimpleRecord(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m b/matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m new file mode 100644 index 00000000..2a38fb5d --- /dev/null +++ b/matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m @@ -0,0 +1,20 @@ +classdef SmallBenchmarkRecordSerializer < yardl.binary.RecordSerializer + methods + function obj = SmallBenchmarkRecordSerializer() + field_serializers{1} = yardl.binary.Float64Serializer; + field_serializers{2} = yardl.binary.Float32Serializer; + field_serializers{3} = yardl.binary.Float32Serializer; + obj@yardl.binary.RecordSerializer('test_model.SmallBenchmarkRecord', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.SmallBenchmarkRecord')); + obj.write_(outstream, value.a, value.b, value.c) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.SmallBenchmarkRecord(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/StateTestReader.m b/matlab/generated/+test_model/+binary/StateTestReader.m new file mode 100644 index 00000000..a8079f18 --- /dev/null +++ b/matlab/generated/+test_model/+binary/StateTestReader.m @@ -0,0 +1,26 @@ +% Binary reader for the StateTest protocol +classdef StateTestReader < yardl.binary.BinaryProtocolReader & test_model.StateTestReaderBase + methods + function obj = StateTestReader(filename) + obj@test_model.StateTestReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.StateTestReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_an_int_(obj) + r = yardl.binary.Int32Serializer; + value = r.read(obj.stream_); + end + + function value = read_a_stream_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); + value = r.read(obj.stream_); + end + + function value = read_another_int_(obj) + r = yardl.binary.Int32Serializer; + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/StateTestWriter.m b/matlab/generated/+test_model/+binary/StateTestWriter.m new file mode 100644 index 00000000..32428cd3 --- /dev/null +++ b/matlab/generated/+test_model/+binary/StateTestWriter.m @@ -0,0 +1,26 @@ +% Binary writer for the StateTest protocol +classdef StateTestWriter < yardl.binary.BinaryProtocolWriter & test_model.StateTestWriterBase + methods + function obj = StateTestWriter(filename) + obj@test_model.StateTestWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.StateTestWriterBase.schema); + end + end + + methods (Access=protected) + function write_an_int_(obj, value) + w = yardl.binary.Int32Serializer; + w.write(obj.stream_, value); + end + + function write_a_stream_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); + w.write(obj.stream_, value); + end + + function write_another_int_(obj, value) + w = yardl.binary.Int32Serializer; + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m new file mode 100644 index 00000000..4275c5f6 --- /dev/null +++ b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m @@ -0,0 +1,21 @@ +% Binary reader for the StreamsOfAliasedUnions protocol +classdef StreamsOfAliasedUnionsReader < yardl.binary.BinaryProtocolReader & test_model.StreamsOfAliasedUnionsReaderBase + methods + function obj = StreamsOfAliasedUnionsReader(filename) + obj@test_model.StreamsOfAliasedUnionsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.StreamsOfAliasedUnionsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_int_or_simple_record_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedIntOrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.AliasedIntOrSimpleRecord.Int32, @test_model.AliasedIntOrSimpleRecord.SimpleRecord})); + value = r.read(obj.stream_); + end + + function value = read_nullable_int_or_simple_record_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedNullableIntSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.AliasedNullableIntSimpleRecord.Int32, @test_model.AliasedNullableIntSimpleRecord.SimpleRecord})); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m new file mode 100644 index 00000000..cd7e50f6 --- /dev/null +++ b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m @@ -0,0 +1,21 @@ +% Binary writer for the StreamsOfAliasedUnions protocol +classdef StreamsOfAliasedUnionsWriter < yardl.binary.BinaryProtocolWriter & test_model.StreamsOfAliasedUnionsWriterBase + methods + function obj = StreamsOfAliasedUnionsWriter(filename) + obj@test_model.StreamsOfAliasedUnionsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.StreamsOfAliasedUnionsWriterBase.schema); + end + end + + methods (Access=protected) + function write_int_or_simple_record_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedIntOrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.AliasedIntOrSimpleRecord.Int32, @test_model.AliasedIntOrSimpleRecord.SimpleRecord})); + w.write(obj.stream_, value); + end + + function write_nullable_int_or_simple_record_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedNullableIntSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.AliasedNullableIntSimpleRecord.Int32, @test_model.AliasedNullableIntSimpleRecord.SimpleRecord})); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m b/matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m new file mode 100644 index 00000000..d2509755 --- /dev/null +++ b/matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m @@ -0,0 +1,21 @@ +% Binary reader for the StreamsOfUnions protocol +classdef StreamsOfUnionsReader < yardl.binary.BinaryProtocolReader & test_model.StreamsOfUnionsReaderBase + methods + function obj = StreamsOfUnionsReader(filename) + obj@test_model.StreamsOfUnionsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.StreamsOfUnionsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_int_or_simple_record_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); + value = r.read(obj.stream_); + end + + function value = read_nullable_int_or_simple_record_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m b/matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m new file mode 100644 index 00000000..22ca0318 --- /dev/null +++ b/matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m @@ -0,0 +1,21 @@ +% Binary writer for the StreamsOfUnions protocol +classdef StreamsOfUnionsWriter < yardl.binary.BinaryProtocolWriter & test_model.StreamsOfUnionsWriterBase + methods + function obj = StreamsOfUnionsWriter(filename) + obj@test_model.StreamsOfUnionsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.StreamsOfUnionsWriterBase.schema); + end + end + + methods (Access=protected) + function write_int_or_simple_record_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); + w.write(obj.stream_, value); + end + + function write_nullable_int_or_simple_record_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/StreamsReader.m b/matlab/generated/+test_model/+binary/StreamsReader.m new file mode 100644 index 00000000..29497048 --- /dev/null +++ b/matlab/generated/+test_model/+binary/StreamsReader.m @@ -0,0 +1,31 @@ +% Binary reader for the Streams protocol +classdef StreamsReader < yardl.binary.BinaryProtocolReader & test_model.StreamsReaderBase + methods + function obj = StreamsReader(filename) + obj@test_model.StreamsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.StreamsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_int_data_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); + value = r.read(obj.stream_); + end + + function value = read_optional_int_data_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer)); + value = r.read(obj.stream_); + end + + function value = read_record_with_optional_vector_data_(obj) + r = yardl.binary.StreamSerializer(test_model.binary.RecordWithOptionalVectorSerializer()); + value = r.read(obj.stream_); + end + + function value = read_fixed_vector_(obj) + r = yardl.binary.StreamSerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/StreamsWriter.m b/matlab/generated/+test_model/+binary/StreamsWriter.m new file mode 100644 index 00000000..b73e2cf7 --- /dev/null +++ b/matlab/generated/+test_model/+binary/StreamsWriter.m @@ -0,0 +1,31 @@ +% Binary writer for the Streams protocol +classdef StreamsWriter < yardl.binary.BinaryProtocolWriter & test_model.StreamsWriterBase + methods + function obj = StreamsWriter(filename) + obj@test_model.StreamsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.StreamsWriterBase.schema); + end + end + + methods (Access=protected) + function write_int_data_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); + w.write(obj.stream_, value); + end + + function write_optional_int_data_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer)); + w.write(obj.stream_, value); + end + + function write_record_with_optional_vector_data_(obj, value) + w = yardl.binary.StreamSerializer(test_model.binary.RecordWithOptionalVectorSerializer()); + w.write(obj.stream_, value); + end + + function write_fixed_vector_(obj, value) + w = yardl.binary.StreamSerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/StringsReader.m b/matlab/generated/+test_model/+binary/StringsReader.m new file mode 100644 index 00000000..29cceb0e --- /dev/null +++ b/matlab/generated/+test_model/+binary/StringsReader.m @@ -0,0 +1,21 @@ +% Binary reader for the Strings protocol +classdef StringsReader < yardl.binary.BinaryProtocolReader & test_model.StringsReaderBase + methods + function obj = StringsReader(filename) + obj@test_model.StringsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.StringsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_single_string_(obj) + r = yardl.binary.StringSerializer; + value = r.read(obj.stream_); + end + + function value = read_rec_with_string_(obj) + r = test_model.binary.RecordWithStringsSerializer(); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/StringsWriter.m b/matlab/generated/+test_model/+binary/StringsWriter.m new file mode 100644 index 00000000..7807f6cd --- /dev/null +++ b/matlab/generated/+test_model/+binary/StringsWriter.m @@ -0,0 +1,21 @@ +% Binary writer for the Strings protocol +classdef StringsWriter < yardl.binary.BinaryProtocolWriter & test_model.StringsWriterBase + methods + function obj = StringsWriter(filename) + obj@test_model.StringsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.StringsWriterBase.schema); + end + end + + methods (Access=protected) + function write_single_string_(obj, value) + w = yardl.binary.StringSerializer; + w.write(obj.stream_, value); + end + + function write_rec_with_string_(obj, value) + w = test_model.binary.RecordWithStringsSerializer(); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m b/matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m new file mode 100644 index 00000000..017ecf1c --- /dev/null +++ b/matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m @@ -0,0 +1,21 @@ +% Binary reader for the SubarraysInRecords protocol +classdef SubarraysInRecordsReader < yardl.binary.BinaryProtocolReader & test_model.SubarraysInRecordsReaderBase + methods + function obj = SubarraysInRecordsReader(filename) + obj@test_model.SubarraysInRecordsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.SubarraysInRecordsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_with_fixed_subarrays_(obj) + r = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithFixedCollectionsSerializer()); + value = r.read(obj.stream_); + end + + function value = read_with_vlen_subarrays_(obj) + r = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlenCollectionsSerializer()); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m b/matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m new file mode 100644 index 00000000..43e6c855 --- /dev/null +++ b/matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m @@ -0,0 +1,21 @@ +% Binary writer for the SubarraysInRecords protocol +classdef SubarraysInRecordsWriter < yardl.binary.BinaryProtocolWriter & test_model.SubarraysInRecordsWriterBase + methods + function obj = SubarraysInRecordsWriter(filename) + obj@test_model.SubarraysInRecordsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.SubarraysInRecordsWriterBase.schema); + end + end + + methods (Access=protected) + function write_with_fixed_subarrays_(obj, value) + w = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithFixedCollectionsSerializer()); + w.write(obj.stream_, value); + end + + function write_with_vlen_subarrays_(obj, value) + w = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlenCollectionsSerializer()); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/SubarraysReader.m b/matlab/generated/+test_model/+binary/SubarraysReader.m new file mode 100644 index 00000000..d8753e77 --- /dev/null +++ b/matlab/generated/+test_model/+binary/SubarraysReader.m @@ -0,0 +1,56 @@ +% Binary reader for the Subarrays protocol +classdef SubarraysReader < yardl.binary.BinaryProtocolReader & test_model.SubarraysReaderBase + methods + function obj = SubarraysReader(filename) + obj@test_model.SubarraysReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.SubarraysReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_dynamic_with_fixed_int_subarray_(obj) + r = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3])); + value = r.read(obj.stream_); + end + + function value = read_dynamic_with_fixed_float_subarray_(obj) + r = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3])); + value = r.read(obj.stream_); + end + + function value = read_known_dim_count_with_fixed_int_subarray_(obj) + r = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 1); + value = r.read(obj.stream_); + end + + function value = read_known_dim_count_with_fixed_float_subarray_(obj) + r = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), 1); + value = r.read(obj.stream_); + end + + function value = read_fixed_with_fixed_int_subarray_(obj) + r = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2]); + value = r.read(obj.stream_); + end + + function value = read_fixed_with_fixed_float_subarray_(obj) + r = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), [2]); + value = r.read(obj.stream_); + end + + function value = read_nested_subarray_(obj) + r = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2])); + value = r.read(obj.stream_); + end + + function value = read_dynamic_with_fixed_vector_subarray_(obj) + r = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); + value = r.read(obj.stream_); + end + + function value = read_generic_subarray_(obj) + r = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 2); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/SubarraysWriter.m b/matlab/generated/+test_model/+binary/SubarraysWriter.m new file mode 100644 index 00000000..abcc8d3c --- /dev/null +++ b/matlab/generated/+test_model/+binary/SubarraysWriter.m @@ -0,0 +1,56 @@ +% Binary writer for the Subarrays protocol +classdef SubarraysWriter < yardl.binary.BinaryProtocolWriter & test_model.SubarraysWriterBase + methods + function obj = SubarraysWriter(filename) + obj@test_model.SubarraysWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.SubarraysWriterBase.schema); + end + end + + methods (Access=protected) + function write_dynamic_with_fixed_int_subarray_(obj, value) + w = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3])); + w.write(obj.stream_, value); + end + + function write_dynamic_with_fixed_float_subarray_(obj, value) + w = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3])); + w.write(obj.stream_, value); + end + + function write_known_dim_count_with_fixed_int_subarray_(obj, value) + w = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 1); + w.write(obj.stream_, value); + end + + function write_known_dim_count_with_fixed_float_subarray_(obj, value) + w = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), 1); + w.write(obj.stream_, value); + end + + function write_fixed_with_fixed_int_subarray_(obj, value) + w = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2]); + w.write(obj.stream_, value); + end + + function write_fixed_with_fixed_float_subarray_(obj, value) + w = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), [2]); + w.write(obj.stream_, value); + end + + function write_nested_subarray_(obj, value) + w = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2])); + w.write(obj.stream_, value); + end + + function write_dynamic_with_fixed_vector_subarray_(obj, value) + w = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); + w.write(obj.stream_, value); + end + + function write_generic_subarray_(obj, value) + w = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 2); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m b/matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m new file mode 100644 index 00000000..97d9d107 --- /dev/null +++ b/matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m @@ -0,0 +1,19 @@ +classdef TupleWithRecordsSerializer < yardl.binary.RecordSerializer + methods + function obj = TupleWithRecordsSerializer() + field_serializers{1} = test_model.binary.SimpleRecordSerializer(); + field_serializers{2} = test_model.binary.SimpleRecordSerializer(); + obj@yardl.binary.RecordSerializer('test_model.TupleWithRecords', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'test_model.TupleWithRecords')); + obj.write_(outstream, value.a, value.b) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = test_model.TupleWithRecords(field_values{:}); + end + end +end diff --git a/matlab/generated/+test_model/+binary/UnionsReader.m b/matlab/generated/+test_model/+binary/UnionsReader.m new file mode 100644 index 00000000..a93e35a5 --- /dev/null +++ b/matlab/generated/+test_model/+binary/UnionsReader.m @@ -0,0 +1,31 @@ +% Binary reader for the Unions protocol +classdef UnionsReader < yardl.binary.BinaryProtocolReader & test_model.UnionsReaderBase + methods + function obj = UnionsReader(filename) + obj@test_model.UnionsReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.UnionsReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_int_or_simple_record_(obj) + r = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); + value = r.read(obj.stream_); + end + + function value = read_int_or_record_with_vlens_(obj) + r = yardl.binary.UnionSerializer('test_model.Int32OrRecordWithVlens', {yardl.binary.Int32Serializer, test_model.binary.RecordWithVlensSerializer()}, {@test_model.Int32OrRecordWithVlens.Int32, @test_model.Int32OrRecordWithVlens.RecordWithVlens}); + value = r.read(obj.stream_); + end + + function value = read_monosotate_or_int_or_simple_record_(obj) + r = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); + value = r.read(obj.stream_); + end + + function value = read_record_with_unions_(obj) + r = basic_types.binary.RecordWithUnionsSerializer(); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/UnionsWriter.m b/matlab/generated/+test_model/+binary/UnionsWriter.m new file mode 100644 index 00000000..e04d8568 --- /dev/null +++ b/matlab/generated/+test_model/+binary/UnionsWriter.m @@ -0,0 +1,31 @@ +% Binary writer for the Unions protocol +classdef UnionsWriter < yardl.binary.BinaryProtocolWriter & test_model.UnionsWriterBase + methods + function obj = UnionsWriter(filename) + obj@test_model.UnionsWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.UnionsWriterBase.schema); + end + end + + methods (Access=protected) + function write_int_or_simple_record_(obj, value) + w = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); + w.write(obj.stream_, value); + end + + function write_int_or_record_with_vlens_(obj, value) + w = yardl.binary.UnionSerializer('test_model.Int32OrRecordWithVlens', {yardl.binary.Int32Serializer, test_model.binary.RecordWithVlensSerializer()}, {@test_model.Int32OrRecordWithVlens.Int32, @test_model.Int32OrRecordWithVlens.RecordWithVlens}); + w.write(obj.stream_, value); + end + + function write_monosotate_or_int_or_simple_record_(obj, value) + w = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); + w.write(obj.stream_, value); + end + + function write_record_with_unions_(obj, value) + w = basic_types.binary.RecordWithUnionsSerializer(); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+binary/VlensReader.m b/matlab/generated/+test_model/+binary/VlensReader.m new file mode 100644 index 00000000..1aa8c8e2 --- /dev/null +++ b/matlab/generated/+test_model/+binary/VlensReader.m @@ -0,0 +1,31 @@ +% Binary reader for the Vlens protocol +classdef VlensReader < yardl.binary.BinaryProtocolReader & test_model.VlensReaderBase + methods + function obj = VlensReader(filename) + obj@test_model.VlensReaderBase(); + obj@yardl.binary.BinaryProtocolReader(filename, test_model.VlensReaderBase.schema); + end + end + + methods (Access=protected) + function value = read_int_vector_(obj) + r = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); + value = r.read(obj.stream_); + end + + function value = read_complex_vector_(obj) + r = yardl.binary.VectorSerializer(yardl.binary.Complexfloat32Serializer); + value = r.read(obj.stream_); + end + + function value = read_record_with_vlens_(obj) + r = test_model.binary.RecordWithVlensSerializer(); + value = r.read(obj.stream_); + end + + function value = read_vlen_of_record_with_vlens_(obj) + r = yardl.binary.VectorSerializer(test_model.binary.RecordWithVlensSerializer()); + value = r.read(obj.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/VlensWriter.m b/matlab/generated/+test_model/+binary/VlensWriter.m new file mode 100644 index 00000000..4596c416 --- /dev/null +++ b/matlab/generated/+test_model/+binary/VlensWriter.m @@ -0,0 +1,31 @@ +% Binary writer for the Vlens protocol +classdef VlensWriter < yardl.binary.BinaryProtocolWriter & test_model.VlensWriterBase + methods + function obj = VlensWriter(filename) + obj@test_model.VlensWriterBase(); + obj@yardl.binary.BinaryProtocolWriter(filename, test_model.VlensWriterBase.schema); + end + end + + methods (Access=protected) + function write_int_vector_(obj, value) + w = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); + w.write(obj.stream_, value); + end + + function write_complex_vector_(obj, value) + w = yardl.binary.VectorSerializer(yardl.binary.Complexfloat32Serializer); + w.write(obj.stream_, value); + end + + function write_record_with_vlens_(obj, value) + w = test_model.binary.RecordWithVlensSerializer(); + w.write(obj.stream_, value); + end + + function write_vlen_of_record_with_vlens_(obj, value) + w = yardl.binary.VectorSerializer(test_model.binary.RecordWithVlensSerializer()); + w.write(obj.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m b/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m new file mode 100644 index 00000000..c471a3d1 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m @@ -0,0 +1,91 @@ +classdef MockAdvancedGenericsWriter < test_model.AdvancedGenericsWriterBase + properties + testCase_ + write_float_image_image_written + write_generic_record_1_written + write_tuple_of_optionals_written + write_tuple_of_optionals_alternate_syntax_written + write_tuple_of_vectors_written + end + + methods + function obj = MockAdvancedGenericsWriter(testCase) + obj.testCase_ = testCase; + obj.write_float_image_image_written = Node.empty(); + obj.write_generic_record_1_written = Node.empty(); + obj.write_tuple_of_optionals_written = Node.empty(); + obj.write_tuple_of_optionals_alternate_syntax_written = Node.empty(); + obj.write_tuple_of_vectors_written = Node.empty(); + end + + function expect_write_float_image_image_(obj, value) + obj.write_float_image_image_written(end+1) = Node(value); + end + + function expect_write_generic_record_1_(obj, value) + obj.write_generic_record_1_written(end+1) = Node(value); + end + + function expect_write_tuple_of_optionals_(obj, value) + obj.write_tuple_of_optionals_written(end+1) = Node(value); + end + + function expect_write_tuple_of_optionals_alternate_syntax_(obj, value) + obj.write_tuple_of_optionals_alternate_syntax_written(end+1) = Node(value); + end + + function expect_write_tuple_of_vectors_(obj, value) + obj.write_tuple_of_vectors_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_float_image_image_written), "Expected call to write_float_image_image_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_generic_record_1_written), "Expected call to write_generic_record_1_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_tuple_of_optionals_written), "Expected call to write_tuple_of_optionals_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_tuple_of_optionals_alternate_syntax_written), "Expected call to write_tuple_of_optionals_alternate_syntax_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_tuple_of_vectors_written), "Expected call to write_tuple_of_vectors_ was not received"); + end + end + + methods (Access=protected) + function write_float_image_image_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_float_image_image_written), "Unexpected call to write_float_image_image_"); + expected = obj.write_float_image_image_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_image_image_"); + obj.write_float_image_image_written = obj.write_float_image_image_written(2:end); + end + + function write_generic_record_1_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_generic_record_1_written), "Unexpected call to write_generic_record_1_"); + expected = obj.write_generic_record_1_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_generic_record_1_"); + obj.write_generic_record_1_written = obj.write_generic_record_1_written(2:end); + end + + function write_tuple_of_optionals_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_tuple_of_optionals_written), "Unexpected call to write_tuple_of_optionals_"); + expected = obj.write_tuple_of_optionals_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_of_optionals_"); + obj.write_tuple_of_optionals_written = obj.write_tuple_of_optionals_written(2:end); + end + + function write_tuple_of_optionals_alternate_syntax_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_tuple_of_optionals_alternate_syntax_written), "Unexpected call to write_tuple_of_optionals_alternate_syntax_"); + expected = obj.write_tuple_of_optionals_alternate_syntax_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_of_optionals_alternate_syntax_"); + obj.write_tuple_of_optionals_alternate_syntax_written = obj.write_tuple_of_optionals_alternate_syntax_written(2:end); + end + + function write_tuple_of_vectors_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_tuple_of_vectors_written), "Unexpected call to write_tuple_of_vectors_"); + expected = obj.write_tuple_of_vectors_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_of_vectors_"); + obj.write_tuple_of_vectors_written = obj.write_tuple_of_vectors_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockAliasesWriter.m b/matlab/generated/+test_model/+testing/MockAliasesWriter.m new file mode 100644 index 00000000..2c109b0f --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockAliasesWriter.m @@ -0,0 +1,161 @@ +classdef MockAliasesWriter < test_model.AliasesWriterBase + properties + testCase_ + write_aliased_string_written + write_aliased_enum_written + write_aliased_open_generic_written + write_aliased_closed_generic_written + write_aliased_optional_written + write_aliased_generic_optional_written + write_aliased_generic_union_2_written + write_aliased_generic_vector_written + write_aliased_generic_fixed_vector_written + write_stream_of_aliased_generic_union_2_written + end + + methods + function obj = MockAliasesWriter(testCase) + obj.testCase_ = testCase; + obj.write_aliased_string_written = Node.empty(); + obj.write_aliased_enum_written = Node.empty(); + obj.write_aliased_open_generic_written = Node.empty(); + obj.write_aliased_closed_generic_written = Node.empty(); + obj.write_aliased_optional_written = Node.empty(); + obj.write_aliased_generic_optional_written = Node.empty(); + obj.write_aliased_generic_union_2_written = Node.empty(); + obj.write_aliased_generic_vector_written = Node.empty(); + obj.write_aliased_generic_fixed_vector_written = Node.empty(); + obj.write_stream_of_aliased_generic_union_2_written = Node.empty(); + end + + function expect_write_aliased_string_(obj, value) + obj.write_aliased_string_written(end+1) = Node(value); + end + + function expect_write_aliased_enum_(obj, value) + obj.write_aliased_enum_written(end+1) = Node(value); + end + + function expect_write_aliased_open_generic_(obj, value) + obj.write_aliased_open_generic_written(end+1) = Node(value); + end + + function expect_write_aliased_closed_generic_(obj, value) + obj.write_aliased_closed_generic_written(end+1) = Node(value); + end + + function expect_write_aliased_optional_(obj, value) + obj.write_aliased_optional_written(end+1) = Node(value); + end + + function expect_write_aliased_generic_optional_(obj, value) + obj.write_aliased_generic_optional_written(end+1) = Node(value); + end + + function expect_write_aliased_generic_union_2_(obj, value) + obj.write_aliased_generic_union_2_written(end+1) = Node(value); + end + + function expect_write_aliased_generic_vector_(obj, value) + obj.write_aliased_generic_vector_written(end+1) = Node(value); + end + + function expect_write_aliased_generic_fixed_vector_(obj, value) + obj.write_aliased_generic_fixed_vector_written(end+1) = Node(value); + end + + function expect_write_stream_of_aliased_generic_union_2_(obj, value) + obj.write_stream_of_aliased_generic_union_2_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_aliased_string_written), "Expected call to write_aliased_string_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_aliased_enum_written), "Expected call to write_aliased_enum_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_aliased_open_generic_written), "Expected call to write_aliased_open_generic_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_aliased_closed_generic_written), "Expected call to write_aliased_closed_generic_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_aliased_optional_written), "Expected call to write_aliased_optional_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_aliased_generic_optional_written), "Expected call to write_aliased_generic_optional_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_aliased_generic_union_2_written), "Expected call to write_aliased_generic_union_2_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_aliased_generic_vector_written), "Expected call to write_aliased_generic_vector_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_aliased_generic_fixed_vector_written), "Expected call to write_aliased_generic_fixed_vector_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_stream_of_aliased_generic_union_2_written), "Expected call to write_stream_of_aliased_generic_union_2_ was not received"); + end + end + + methods (Access=protected) + function write_aliased_string_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_aliased_string_written), "Unexpected call to write_aliased_string_"); + expected = obj.write_aliased_string_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_string_"); + obj.write_aliased_string_written = obj.write_aliased_string_written(2:end); + end + + function write_aliased_enum_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_aliased_enum_written), "Unexpected call to write_aliased_enum_"); + expected = obj.write_aliased_enum_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_enum_"); + obj.write_aliased_enum_written = obj.write_aliased_enum_written(2:end); + end + + function write_aliased_open_generic_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_aliased_open_generic_written), "Unexpected call to write_aliased_open_generic_"); + expected = obj.write_aliased_open_generic_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_open_generic_"); + obj.write_aliased_open_generic_written = obj.write_aliased_open_generic_written(2:end); + end + + function write_aliased_closed_generic_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_aliased_closed_generic_written), "Unexpected call to write_aliased_closed_generic_"); + expected = obj.write_aliased_closed_generic_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_closed_generic_"); + obj.write_aliased_closed_generic_written = obj.write_aliased_closed_generic_written(2:end); + end + + function write_aliased_optional_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_aliased_optional_written), "Unexpected call to write_aliased_optional_"); + expected = obj.write_aliased_optional_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_optional_"); + obj.write_aliased_optional_written = obj.write_aliased_optional_written(2:end); + end + + function write_aliased_generic_optional_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_aliased_generic_optional_written), "Unexpected call to write_aliased_generic_optional_"); + expected = obj.write_aliased_generic_optional_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_optional_"); + obj.write_aliased_generic_optional_written = obj.write_aliased_generic_optional_written(2:end); + end + + function write_aliased_generic_union_2_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_aliased_generic_union_2_written), "Unexpected call to write_aliased_generic_union_2_"); + expected = obj.write_aliased_generic_union_2_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_union_2_"); + obj.write_aliased_generic_union_2_written = obj.write_aliased_generic_union_2_written(2:end); + end + + function write_aliased_generic_vector_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_aliased_generic_vector_written), "Unexpected call to write_aliased_generic_vector_"); + expected = obj.write_aliased_generic_vector_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_vector_"); + obj.write_aliased_generic_vector_written = obj.write_aliased_generic_vector_written(2:end); + end + + function write_aliased_generic_fixed_vector_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_aliased_generic_fixed_vector_written), "Unexpected call to write_aliased_generic_fixed_vector_"); + expected = obj.write_aliased_generic_fixed_vector_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_fixed_vector_"); + obj.write_aliased_generic_fixed_vector_written = obj.write_aliased_generic_fixed_vector_written(2:end); + end + + function write_stream_of_aliased_generic_union_2_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_stream_of_aliased_generic_union_2_written), "Unexpected call to write_stream_of_aliased_generic_union_2_"); + expected = obj.write_stream_of_aliased_generic_union_2_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_stream_of_aliased_generic_union_2_"); + obj.write_stream_of_aliased_generic_union_2_written = obj.write_stream_of_aliased_generic_union_2_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m new file mode 100644 index 00000000..2a3f1082 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m @@ -0,0 +1,35 @@ +classdef MockBenchmarkFloat256x256Writer < test_model.BenchmarkFloat256x256WriterBase + properties + testCase_ + write_float256x256_written + end + + methods + function obj = MockBenchmarkFloat256x256Writer(testCase) + obj.testCase_ = testCase; + obj.write_float256x256_written = Node.empty(); + end + + function expect_write_float256x256_(obj, value) + obj.write_float256x256_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_float256x256_written), "Expected call to write_float256x256_ was not received"); + end + end + + methods (Access=protected) + function write_float256x256_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_float256x256_written), "Unexpected call to write_float256x256_"); + expected = obj.write_float256x256_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float256x256_"); + obj.write_float256x256_written = obj.write_float256x256_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m new file mode 100644 index 00000000..7608c98b --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m @@ -0,0 +1,35 @@ +classdef MockBenchmarkFloatVlenWriter < test_model.BenchmarkFloatVlenWriterBase + properties + testCase_ + write_float_array_written + end + + methods + function obj = MockBenchmarkFloatVlenWriter(testCase) + obj.testCase_ = testCase; + obj.write_float_array_written = Node.empty(); + end + + function expect_write_float_array_(obj, value) + obj.write_float_array_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_float_array_written), "Expected call to write_float_array_ was not received"); + end + end + + methods (Access=protected) + function write_float_array_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_float_array_written), "Unexpected call to write_float_array_"); + expected = obj.write_float_array_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_array_"); + obj.write_float_array_written = obj.write_float_array_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m new file mode 100644 index 00000000..6223226c --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m @@ -0,0 +1,35 @@ +classdef MockBenchmarkInt256x256Writer < test_model.BenchmarkInt256x256WriterBase + properties + testCase_ + write_int256x256_written + end + + methods + function obj = MockBenchmarkInt256x256Writer(testCase) + obj.testCase_ = testCase; + obj.write_int256x256_written = Node.empty(); + end + + function expect_write_int256x256_(obj, value) + obj.write_int256x256_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_int256x256_written), "Expected call to write_int256x256_ was not received"); + end + end + + methods (Access=protected) + function write_int256x256_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_int256x256_written), "Unexpected call to write_int256x256_"); + expected = obj.write_int256x256_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int256x256_"); + obj.write_int256x256_written = obj.write_int256x256_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m new file mode 100644 index 00000000..447e5e86 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m @@ -0,0 +1,35 @@ +classdef MockBenchmarkSimpleMrdWriter < test_model.BenchmarkSimpleMrdWriterBase + properties + testCase_ + write_data_written + end + + methods + function obj = MockBenchmarkSimpleMrdWriter(testCase) + obj.testCase_ = testCase; + obj.write_data_written = Node.empty(); + end + + function expect_write_data_(obj, value) + obj.write_data_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_data_written), "Expected call to write_data_ was not received"); + end + end + + methods (Access=protected) + function write_data_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_data_written), "Unexpected call to write_data_"); + expected = obj.write_data_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_data_"); + obj.write_data_written = obj.write_data_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m new file mode 100644 index 00000000..6f46a935 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m @@ -0,0 +1,35 @@ +classdef MockBenchmarkSmallRecordWithOptionalsWriter < test_model.BenchmarkSmallRecordWithOptionalsWriterBase + properties + testCase_ + write_small_record_written + end + + methods + function obj = MockBenchmarkSmallRecordWithOptionalsWriter(testCase) + obj.testCase_ = testCase; + obj.write_small_record_written = Node.empty(); + end + + function expect_write_small_record_(obj, value) + obj.write_small_record_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_small_record_written), "Expected call to write_small_record_ was not received"); + end + end + + methods (Access=protected) + function write_small_record_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_small_record_written), "Unexpected call to write_small_record_"); + expected = obj.write_small_record_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_small_record_"); + obj.write_small_record_written = obj.write_small_record_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m new file mode 100644 index 00000000..de7295dd --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m @@ -0,0 +1,35 @@ +classdef MockBenchmarkSmallRecordWriter < test_model.BenchmarkSmallRecordWriterBase + properties + testCase_ + write_small_record_written + end + + methods + function obj = MockBenchmarkSmallRecordWriter(testCase) + obj.testCase_ = testCase; + obj.write_small_record_written = Node.empty(); + end + + function expect_write_small_record_(obj, value) + obj.write_small_record_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_small_record_written), "Expected call to write_small_record_ was not received"); + end + end + + methods (Access=protected) + function write_small_record_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_small_record_written), "Unexpected call to write_small_record_"); + expected = obj.write_small_record_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_small_record_"); + obj.write_small_record_written = obj.write_small_record_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m b/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m new file mode 100644 index 00000000..e9c24e4a --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m @@ -0,0 +1,77 @@ +classdef MockDynamicNDArraysWriter < test_model.DynamicNDArraysWriterBase + properties + testCase_ + write_ints_written + write_simple_record_array_written + write_record_with_vlens_array_written + write_record_with_dynamic_nd_arrays_written + end + + methods + function obj = MockDynamicNDArraysWriter(testCase) + obj.testCase_ = testCase; + obj.write_ints_written = Node.empty(); + obj.write_simple_record_array_written = Node.empty(); + obj.write_record_with_vlens_array_written = Node.empty(); + obj.write_record_with_dynamic_nd_arrays_written = Node.empty(); + end + + function expect_write_ints_(obj, value) + obj.write_ints_written(end+1) = Node(value); + end + + function expect_write_simple_record_array_(obj, value) + obj.write_simple_record_array_written(end+1) = Node(value); + end + + function expect_write_record_with_vlens_array_(obj, value) + obj.write_record_with_vlens_array_written(end+1) = Node(value); + end + + function expect_write_record_with_dynamic_nd_arrays_(obj, value) + obj.write_record_with_dynamic_nd_arrays_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_ints_written), "Expected call to write_ints_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_simple_record_array_written), "Expected call to write_simple_record_array_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_record_with_vlens_array_written), "Expected call to write_record_with_vlens_array_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_record_with_dynamic_nd_arrays_written), "Expected call to write_record_with_dynamic_nd_arrays_ was not received"); + end + end + + methods (Access=protected) + function write_ints_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_ints_written), "Unexpected call to write_ints_"); + expected = obj.write_ints_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); + obj.write_ints_written = obj.write_ints_written(2:end); + end + + function write_simple_record_array_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_simple_record_array_written), "Unexpected call to write_simple_record_array_"); + expected = obj.write_simple_record_array_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_simple_record_array_"); + obj.write_simple_record_array_written = obj.write_simple_record_array_written(2:end); + end + + function write_record_with_vlens_array_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_record_with_vlens_array_written), "Unexpected call to write_record_with_vlens_array_"); + expected = obj.write_record_with_vlens_array_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_array_"); + obj.write_record_with_vlens_array_written = obj.write_record_with_vlens_array_written(2:end); + end + + function write_record_with_dynamic_nd_arrays_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_record_with_dynamic_nd_arrays_written), "Unexpected call to write_record_with_dynamic_nd_arrays_"); + expected = obj.write_record_with_dynamic_nd_arrays_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_dynamic_nd_arrays_"); + obj.write_record_with_dynamic_nd_arrays_written = obj.write_record_with_dynamic_nd_arrays_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockEnumsWriter.m b/matlab/generated/+test_model/+testing/MockEnumsWriter.m new file mode 100644 index 00000000..e8d677af --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockEnumsWriter.m @@ -0,0 +1,63 @@ +classdef MockEnumsWriter < test_model.EnumsWriterBase + properties + testCase_ + write_single_written + write_vec_written + write_size_written + end + + methods + function obj = MockEnumsWriter(testCase) + obj.testCase_ = testCase; + obj.write_single_written = Node.empty(); + obj.write_vec_written = Node.empty(); + obj.write_size_written = Node.empty(); + end + + function expect_write_single_(obj, value) + obj.write_single_written(end+1) = Node(value); + end + + function expect_write_vec_(obj, value) + obj.write_vec_written(end+1) = Node(value); + end + + function expect_write_size_(obj, value) + obj.write_size_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_single_written), "Expected call to write_single_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_vec_written), "Expected call to write_vec_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_size_written), "Expected call to write_size_ was not received"); + end + end + + methods (Access=protected) + function write_single_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_single_written), "Unexpected call to write_single_"); + expected = obj.write_single_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_single_"); + obj.write_single_written = obj.write_single_written(2:end); + end + + function write_vec_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_vec_written), "Unexpected call to write_vec_"); + expected = obj.write_vec_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_vec_"); + obj.write_vec_written = obj.write_vec_written(2:end); + end + + function write_size_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_size_written), "Unexpected call to write_size_"); + expected = obj.write_size_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_size_"); + obj.write_size_written = obj.write_size_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m b/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m new file mode 100644 index 00000000..459a9a53 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m @@ -0,0 +1,91 @@ +classdef MockFixedArraysWriter < test_model.FixedArraysWriterBase + properties + testCase_ + write_ints_written + write_fixed_simple_record_array_written + write_fixed_record_with_vlens_array_written + write_record_with_fixed_arrays_written + write_named_array_written + end + + methods + function obj = MockFixedArraysWriter(testCase) + obj.testCase_ = testCase; + obj.write_ints_written = Node.empty(); + obj.write_fixed_simple_record_array_written = Node.empty(); + obj.write_fixed_record_with_vlens_array_written = Node.empty(); + obj.write_record_with_fixed_arrays_written = Node.empty(); + obj.write_named_array_written = Node.empty(); + end + + function expect_write_ints_(obj, value) + obj.write_ints_written(end+1) = Node(value); + end + + function expect_write_fixed_simple_record_array_(obj, value) + obj.write_fixed_simple_record_array_written(end+1) = Node(value); + end + + function expect_write_fixed_record_with_vlens_array_(obj, value) + obj.write_fixed_record_with_vlens_array_written(end+1) = Node(value); + end + + function expect_write_record_with_fixed_arrays_(obj, value) + obj.write_record_with_fixed_arrays_written(end+1) = Node(value); + end + + function expect_write_named_array_(obj, value) + obj.write_named_array_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_ints_written), "Expected call to write_ints_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_fixed_simple_record_array_written), "Expected call to write_fixed_simple_record_array_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_fixed_record_with_vlens_array_written), "Expected call to write_fixed_record_with_vlens_array_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_record_with_fixed_arrays_written), "Expected call to write_record_with_fixed_arrays_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_named_array_written), "Expected call to write_named_array_ was not received"); + end + end + + methods (Access=protected) + function write_ints_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_ints_written), "Unexpected call to write_ints_"); + expected = obj.write_ints_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); + obj.write_ints_written = obj.write_ints_written(2:end); + end + + function write_fixed_simple_record_array_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_fixed_simple_record_array_written), "Unexpected call to write_fixed_simple_record_array_"); + expected = obj.write_fixed_simple_record_array_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_simple_record_array_"); + obj.write_fixed_simple_record_array_written = obj.write_fixed_simple_record_array_written(2:end); + end + + function write_fixed_record_with_vlens_array_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_fixed_record_with_vlens_array_written), "Unexpected call to write_fixed_record_with_vlens_array_"); + expected = obj.write_fixed_record_with_vlens_array_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_record_with_vlens_array_"); + obj.write_fixed_record_with_vlens_array_written = obj.write_fixed_record_with_vlens_array_written(2:end); + end + + function write_record_with_fixed_arrays_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_record_with_fixed_arrays_written), "Unexpected call to write_record_with_fixed_arrays_"); + expected = obj.write_record_with_fixed_arrays_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_fixed_arrays_"); + obj.write_record_with_fixed_arrays_written = obj.write_record_with_fixed_arrays_written(2:end); + end + + function write_named_array_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_named_array_written), "Unexpected call to write_named_array_"); + expected = obj.write_named_array_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_named_array_"); + obj.write_named_array_written = obj.write_named_array_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m b/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m new file mode 100644 index 00000000..9a40c937 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m @@ -0,0 +1,77 @@ +classdef MockFixedVectorsWriter < test_model.FixedVectorsWriterBase + properties + testCase_ + write_fixed_int_vector_written + write_fixed_simple_record_vector_written + write_fixed_record_with_vlens_vector_written + write_record_with_fixed_vectors_written + end + + methods + function obj = MockFixedVectorsWriter(testCase) + obj.testCase_ = testCase; + obj.write_fixed_int_vector_written = Node.empty(); + obj.write_fixed_simple_record_vector_written = Node.empty(); + obj.write_fixed_record_with_vlens_vector_written = Node.empty(); + obj.write_record_with_fixed_vectors_written = Node.empty(); + end + + function expect_write_fixed_int_vector_(obj, value) + obj.write_fixed_int_vector_written(end+1) = Node(value); + end + + function expect_write_fixed_simple_record_vector_(obj, value) + obj.write_fixed_simple_record_vector_written(end+1) = Node(value); + end + + function expect_write_fixed_record_with_vlens_vector_(obj, value) + obj.write_fixed_record_with_vlens_vector_written(end+1) = Node(value); + end + + function expect_write_record_with_fixed_vectors_(obj, value) + obj.write_record_with_fixed_vectors_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_fixed_int_vector_written), "Expected call to write_fixed_int_vector_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_fixed_simple_record_vector_written), "Expected call to write_fixed_simple_record_vector_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_fixed_record_with_vlens_vector_written), "Expected call to write_fixed_record_with_vlens_vector_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_record_with_fixed_vectors_written), "Expected call to write_record_with_fixed_vectors_ was not received"); + end + end + + methods (Access=protected) + function write_fixed_int_vector_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_fixed_int_vector_written), "Unexpected call to write_fixed_int_vector_"); + expected = obj.write_fixed_int_vector_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_int_vector_"); + obj.write_fixed_int_vector_written = obj.write_fixed_int_vector_written(2:end); + end + + function write_fixed_simple_record_vector_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_fixed_simple_record_vector_written), "Unexpected call to write_fixed_simple_record_vector_"); + expected = obj.write_fixed_simple_record_vector_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_simple_record_vector_"); + obj.write_fixed_simple_record_vector_written = obj.write_fixed_simple_record_vector_written(2:end); + end + + function write_fixed_record_with_vlens_vector_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_fixed_record_with_vlens_vector_written), "Unexpected call to write_fixed_record_with_vlens_vector_"); + expected = obj.write_fixed_record_with_vlens_vector_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_record_with_vlens_vector_"); + obj.write_fixed_record_with_vlens_vector_written = obj.write_fixed_record_with_vlens_vector_written(2:end); + end + + function write_record_with_fixed_vectors_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_record_with_fixed_vectors_written), "Unexpected call to write_record_with_fixed_vectors_"); + expected = obj.write_record_with_fixed_vectors_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_fixed_vectors_"); + obj.write_record_with_fixed_vectors_written = obj.write_record_with_fixed_vectors_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockFlagsWriter.m b/matlab/generated/+test_model/+testing/MockFlagsWriter.m new file mode 100644 index 00000000..b9a3e5d1 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockFlagsWriter.m @@ -0,0 +1,49 @@ +classdef MockFlagsWriter < test_model.FlagsWriterBase + properties + testCase_ + write_days_written + write_formats_written + end + + methods + function obj = MockFlagsWriter(testCase) + obj.testCase_ = testCase; + obj.write_days_written = Node.empty(); + obj.write_formats_written = Node.empty(); + end + + function expect_write_days_(obj, value) + obj.write_days_written(end+1) = Node(value); + end + + function expect_write_formats_(obj, value) + obj.write_formats_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_days_written), "Expected call to write_days_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_formats_written), "Expected call to write_formats_ was not received"); + end + end + + methods (Access=protected) + function write_days_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_days_written), "Unexpected call to write_days_"); + expected = obj.write_days_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_days_"); + obj.write_days_written = obj.write_days_written(2:end); + end + + function write_formats_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_formats_written), "Unexpected call to write_formats_"); + expected = obj.write_formats_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_formats_"); + obj.write_formats_written = obj.write_formats_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockMapsWriter.m b/matlab/generated/+test_model/+testing/MockMapsWriter.m new file mode 100644 index 00000000..52f35124 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockMapsWriter.m @@ -0,0 +1,77 @@ +classdef MockMapsWriter < test_model.MapsWriterBase + properties + testCase_ + write_string_to_int_written + write_int_to_string_written + write_string_to_union_written + write_aliased_generic_written + end + + methods + function obj = MockMapsWriter(testCase) + obj.testCase_ = testCase; + obj.write_string_to_int_written = Node.empty(); + obj.write_int_to_string_written = Node.empty(); + obj.write_string_to_union_written = Node.empty(); + obj.write_aliased_generic_written = Node.empty(); + end + + function expect_write_string_to_int_(obj, value) + obj.write_string_to_int_written(end+1) = Node(value); + end + + function expect_write_int_to_string_(obj, value) + obj.write_int_to_string_written(end+1) = Node(value); + end + + function expect_write_string_to_union_(obj, value) + obj.write_string_to_union_written(end+1) = Node(value); + end + + function expect_write_aliased_generic_(obj, value) + obj.write_aliased_generic_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_string_to_int_written), "Expected call to write_string_to_int_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_int_to_string_written), "Expected call to write_int_to_string_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_string_to_union_written), "Expected call to write_string_to_union_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_aliased_generic_written), "Expected call to write_aliased_generic_ was not received"); + end + end + + methods (Access=protected) + function write_string_to_int_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_string_to_int_written), "Unexpected call to write_string_to_int_"); + expected = obj.write_string_to_int_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_string_to_int_"); + obj.write_string_to_int_written = obj.write_string_to_int_written(2:end); + end + + function write_int_to_string_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_int_to_string_written), "Unexpected call to write_int_to_string_"); + expected = obj.write_int_to_string_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_to_string_"); + obj.write_int_to_string_written = obj.write_int_to_string_written(2:end); + end + + function write_string_to_union_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_string_to_union_written), "Unexpected call to write_string_to_union_"); + expected = obj.write_string_to_union_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_string_to_union_"); + obj.write_string_to_union_written = obj.write_string_to_union_written(2:end); + end + + function write_aliased_generic_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_aliased_generic_written), "Unexpected call to write_aliased_generic_"); + expected = obj.write_aliased_generic_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_"); + obj.write_aliased_generic_written = obj.write_aliased_generic_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m b/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m new file mode 100644 index 00000000..747dab93 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m @@ -0,0 +1,77 @@ +classdef MockNDArraysSingleDimensionWriter < test_model.NDArraysSingleDimensionWriterBase + properties + testCase_ + write_ints_written + write_simple_record_array_written + write_record_with_vlens_array_written + write_record_with_nd_arrays_written + end + + methods + function obj = MockNDArraysSingleDimensionWriter(testCase) + obj.testCase_ = testCase; + obj.write_ints_written = Node.empty(); + obj.write_simple_record_array_written = Node.empty(); + obj.write_record_with_vlens_array_written = Node.empty(); + obj.write_record_with_nd_arrays_written = Node.empty(); + end + + function expect_write_ints_(obj, value) + obj.write_ints_written(end+1) = Node(value); + end + + function expect_write_simple_record_array_(obj, value) + obj.write_simple_record_array_written(end+1) = Node(value); + end + + function expect_write_record_with_vlens_array_(obj, value) + obj.write_record_with_vlens_array_written(end+1) = Node(value); + end + + function expect_write_record_with_nd_arrays_(obj, value) + obj.write_record_with_nd_arrays_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_ints_written), "Expected call to write_ints_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_simple_record_array_written), "Expected call to write_simple_record_array_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_record_with_vlens_array_written), "Expected call to write_record_with_vlens_array_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_record_with_nd_arrays_written), "Expected call to write_record_with_nd_arrays_ was not received"); + end + end + + methods (Access=protected) + function write_ints_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_ints_written), "Unexpected call to write_ints_"); + expected = obj.write_ints_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); + obj.write_ints_written = obj.write_ints_written(2:end); + end + + function write_simple_record_array_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_simple_record_array_written), "Unexpected call to write_simple_record_array_"); + expected = obj.write_simple_record_array_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_simple_record_array_"); + obj.write_simple_record_array_written = obj.write_simple_record_array_written(2:end); + end + + function write_record_with_vlens_array_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_record_with_vlens_array_written), "Unexpected call to write_record_with_vlens_array_"); + expected = obj.write_record_with_vlens_array_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_array_"); + obj.write_record_with_vlens_array_written = obj.write_record_with_vlens_array_written(2:end); + end + + function write_record_with_nd_arrays_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_record_with_nd_arrays_written), "Unexpected call to write_record_with_nd_arrays_"); + expected = obj.write_record_with_nd_arrays_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_nd_arrays_"); + obj.write_record_with_nd_arrays_written = obj.write_record_with_nd_arrays_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockNDArraysWriter.m b/matlab/generated/+test_model/+testing/MockNDArraysWriter.m new file mode 100644 index 00000000..5dafcf71 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockNDArraysWriter.m @@ -0,0 +1,91 @@ +classdef MockNDArraysWriter < test_model.NDArraysWriterBase + properties + testCase_ + write_ints_written + write_simple_record_array_written + write_record_with_vlens_array_written + write_record_with_nd_arrays_written + write_named_array_written + end + + methods + function obj = MockNDArraysWriter(testCase) + obj.testCase_ = testCase; + obj.write_ints_written = Node.empty(); + obj.write_simple_record_array_written = Node.empty(); + obj.write_record_with_vlens_array_written = Node.empty(); + obj.write_record_with_nd_arrays_written = Node.empty(); + obj.write_named_array_written = Node.empty(); + end + + function expect_write_ints_(obj, value) + obj.write_ints_written(end+1) = Node(value); + end + + function expect_write_simple_record_array_(obj, value) + obj.write_simple_record_array_written(end+1) = Node(value); + end + + function expect_write_record_with_vlens_array_(obj, value) + obj.write_record_with_vlens_array_written(end+1) = Node(value); + end + + function expect_write_record_with_nd_arrays_(obj, value) + obj.write_record_with_nd_arrays_written(end+1) = Node(value); + end + + function expect_write_named_array_(obj, value) + obj.write_named_array_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_ints_written), "Expected call to write_ints_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_simple_record_array_written), "Expected call to write_simple_record_array_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_record_with_vlens_array_written), "Expected call to write_record_with_vlens_array_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_record_with_nd_arrays_written), "Expected call to write_record_with_nd_arrays_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_named_array_written), "Expected call to write_named_array_ was not received"); + end + end + + methods (Access=protected) + function write_ints_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_ints_written), "Unexpected call to write_ints_"); + expected = obj.write_ints_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); + obj.write_ints_written = obj.write_ints_written(2:end); + end + + function write_simple_record_array_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_simple_record_array_written), "Unexpected call to write_simple_record_array_"); + expected = obj.write_simple_record_array_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_simple_record_array_"); + obj.write_simple_record_array_written = obj.write_simple_record_array_written(2:end); + end + + function write_record_with_vlens_array_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_record_with_vlens_array_written), "Unexpected call to write_record_with_vlens_array_"); + expected = obj.write_record_with_vlens_array_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_array_"); + obj.write_record_with_vlens_array_written = obj.write_record_with_vlens_array_written(2:end); + end + + function write_record_with_nd_arrays_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_record_with_nd_arrays_written), "Unexpected call to write_record_with_nd_arrays_"); + expected = obj.write_record_with_nd_arrays_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_nd_arrays_"); + obj.write_record_with_nd_arrays_written = obj.write_record_with_nd_arrays_written(2:end); + end + + function write_named_array_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_named_array_written), "Unexpected call to write_named_array_"); + expected = obj.write_named_array_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_named_array_"); + obj.write_named_array_written = obj.write_named_array_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m b/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m new file mode 100644 index 00000000..e7feb8b1 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m @@ -0,0 +1,35 @@ +classdef MockNestedRecordsWriter < test_model.NestedRecordsWriterBase + properties + testCase_ + write_tuple_with_records_written + end + + methods + function obj = MockNestedRecordsWriter(testCase) + obj.testCase_ = testCase; + obj.write_tuple_with_records_written = Node.empty(); + end + + function expect_write_tuple_with_records_(obj, value) + obj.write_tuple_with_records_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_tuple_with_records_written), "Expected call to write_tuple_with_records_ was not received"); + end + end + + methods (Access=protected) + function write_tuple_with_records_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_tuple_with_records_written), "Unexpected call to write_tuple_with_records_"); + expected = obj.write_tuple_with_records_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_with_records_"); + obj.write_tuple_with_records_written = obj.write_tuple_with_records_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m b/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m new file mode 100644 index 00000000..892e421a --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m @@ -0,0 +1,35 @@ +classdef MockOptionalVectorsWriter < test_model.OptionalVectorsWriterBase + properties + testCase_ + write_record_with_optional_vector_written + end + + methods + function obj = MockOptionalVectorsWriter(testCase) + obj.testCase_ = testCase; + obj.write_record_with_optional_vector_written = Node.empty(); + end + + function expect_write_record_with_optional_vector_(obj, value) + obj.write_record_with_optional_vector_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_record_with_optional_vector_written), "Expected call to write_record_with_optional_vector_ was not received"); + end + end + + methods (Access=protected) + function write_record_with_optional_vector_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_record_with_optional_vector_written), "Unexpected call to write_record_with_optional_vector_"); + expected = obj.write_record_with_optional_vector_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_optional_vector_"); + obj.write_record_with_optional_vector_written = obj.write_record_with_optional_vector_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m b/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m new file mode 100644 index 00000000..e48fa697 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m @@ -0,0 +1,35 @@ +classdef MockProtocolWithComputedFieldsWriter < test_model.ProtocolWithComputedFieldsWriterBase + properties + testCase_ + write_record_with_computed_fields_written + end + + methods + function obj = MockProtocolWithComputedFieldsWriter(testCase) + obj.testCase_ = testCase; + obj.write_record_with_computed_fields_written = Node.empty(); + end + + function expect_write_record_with_computed_fields_(obj, value) + obj.write_record_with_computed_fields_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_record_with_computed_fields_written), "Expected call to write_record_with_computed_fields_ was not received"); + end + end + + methods (Access=protected) + function write_record_with_computed_fields_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_record_with_computed_fields_written), "Unexpected call to write_record_with_computed_fields_"); + expected = obj.write_record_with_computed_fields_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_computed_fields_"); + obj.write_record_with_computed_fields_written = obj.write_record_with_computed_fields_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m new file mode 100644 index 00000000..0f90fe98 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m @@ -0,0 +1,49 @@ +classdef MockProtocolWithKeywordStepsWriter < test_model.ProtocolWithKeywordStepsWriterBase + properties + testCase_ + write_int_written + write_float_written + end + + methods + function obj = MockProtocolWithKeywordStepsWriter(testCase) + obj.testCase_ = testCase; + obj.write_int_written = Node.empty(); + obj.write_float_written = Node.empty(); + end + + function expect_write_int_(obj, value) + obj.write_int_written(end+1) = Node(value); + end + + function expect_write_float_(obj, value) + obj.write_float_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_int_written), "Expected call to write_int_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_float_written), "Expected call to write_float_ was not received"); + end + end + + methods (Access=protected) + function write_int_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_int_written), "Unexpected call to write_int_"); + expected = obj.write_int_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_"); + obj.write_int_written = obj.write_int_written(2:end); + end + + function write_float_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_float_written), "Unexpected call to write_float_"); + expected = obj.write_float_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_"); + obj.write_float_written = obj.write_float_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m b/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m new file mode 100644 index 00000000..06280141 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m @@ -0,0 +1,77 @@ +classdef MockScalarOptionalsWriter < test_model.ScalarOptionalsWriterBase + properties + testCase_ + write_optional_int_written + write_optional_record_written + write_record_with_optional_fields_written + write_optional_record_with_optional_fields_written + end + + methods + function obj = MockScalarOptionalsWriter(testCase) + obj.testCase_ = testCase; + obj.write_optional_int_written = Node.empty(); + obj.write_optional_record_written = Node.empty(); + obj.write_record_with_optional_fields_written = Node.empty(); + obj.write_optional_record_with_optional_fields_written = Node.empty(); + end + + function expect_write_optional_int_(obj, value) + obj.write_optional_int_written(end+1) = Node(value); + end + + function expect_write_optional_record_(obj, value) + obj.write_optional_record_written(end+1) = Node(value); + end + + function expect_write_record_with_optional_fields_(obj, value) + obj.write_record_with_optional_fields_written(end+1) = Node(value); + end + + function expect_write_optional_record_with_optional_fields_(obj, value) + obj.write_optional_record_with_optional_fields_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_optional_int_written), "Expected call to write_optional_int_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_optional_record_written), "Expected call to write_optional_record_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_record_with_optional_fields_written), "Expected call to write_record_with_optional_fields_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_optional_record_with_optional_fields_written), "Expected call to write_optional_record_with_optional_fields_ was not received"); + end + end + + methods (Access=protected) + function write_optional_int_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_optional_int_written), "Unexpected call to write_optional_int_"); + expected = obj.write_optional_int_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_int_"); + obj.write_optional_int_written = obj.write_optional_int_written(2:end); + end + + function write_optional_record_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_optional_record_written), "Unexpected call to write_optional_record_"); + expected = obj.write_optional_record_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_record_"); + obj.write_optional_record_written = obj.write_optional_record_written(2:end); + end + + function write_record_with_optional_fields_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_record_with_optional_fields_written), "Unexpected call to write_record_with_optional_fields_"); + expected = obj.write_record_with_optional_fields_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_optional_fields_"); + obj.write_record_with_optional_fields_written = obj.write_record_with_optional_fields_written(2:end); + end + + function write_optional_record_with_optional_fields_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_optional_record_with_optional_fields_written), "Unexpected call to write_optional_record_with_optional_fields_"); + expected = obj.write_optional_record_with_optional_fields_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_record_with_optional_fields_"); + obj.write_optional_record_with_optional_fields_written = obj.write_optional_record_with_optional_fields_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockScalarsWriter.m b/matlab/generated/+test_model/+testing/MockScalarsWriter.m new file mode 100644 index 00000000..174440e3 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockScalarsWriter.m @@ -0,0 +1,49 @@ +classdef MockScalarsWriter < test_model.ScalarsWriterBase + properties + testCase_ + write_int32_written + write_record_written + end + + methods + function obj = MockScalarsWriter(testCase) + obj.testCase_ = testCase; + obj.write_int32_written = Node.empty(); + obj.write_record_written = Node.empty(); + end + + function expect_write_int32_(obj, value) + obj.write_int32_written(end+1) = Node(value); + end + + function expect_write_record_(obj, value) + obj.write_record_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_int32_written), "Expected call to write_int32_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_record_written), "Expected call to write_record_ was not received"); + end + end + + methods (Access=protected) + function write_int32_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_int32_written), "Unexpected call to write_int32_"); + expected = obj.write_int32_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int32_"); + obj.write_int32_written = obj.write_int32_written(2:end); + end + + function write_record_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_record_written), "Unexpected call to write_record_"); + expected = obj.write_record_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_"); + obj.write_record_written = obj.write_record_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m b/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m new file mode 100644 index 00000000..01f97802 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m @@ -0,0 +1,147 @@ +classdef MockSimpleGenericsWriter < test_model.SimpleGenericsWriterBase + properties + testCase_ + write_float_image_written + write_int_image_written + write_int_image_alternate_syntax_written + write_string_image_written + write_int_float_tuple_written + write_float_float_tuple_written + write_int_float_tuple_alternate_syntax_written + write_int_string_tuple_written + write_stream_of_type_variants_written + end + + methods + function obj = MockSimpleGenericsWriter(testCase) + obj.testCase_ = testCase; + obj.write_float_image_written = Node.empty(); + obj.write_int_image_written = Node.empty(); + obj.write_int_image_alternate_syntax_written = Node.empty(); + obj.write_string_image_written = Node.empty(); + obj.write_int_float_tuple_written = Node.empty(); + obj.write_float_float_tuple_written = Node.empty(); + obj.write_int_float_tuple_alternate_syntax_written = Node.empty(); + obj.write_int_string_tuple_written = Node.empty(); + obj.write_stream_of_type_variants_written = Node.empty(); + end + + function expect_write_float_image_(obj, value) + obj.write_float_image_written(end+1) = Node(value); + end + + function expect_write_int_image_(obj, value) + obj.write_int_image_written(end+1) = Node(value); + end + + function expect_write_int_image_alternate_syntax_(obj, value) + obj.write_int_image_alternate_syntax_written(end+1) = Node(value); + end + + function expect_write_string_image_(obj, value) + obj.write_string_image_written(end+1) = Node(value); + end + + function expect_write_int_float_tuple_(obj, value) + obj.write_int_float_tuple_written(end+1) = Node(value); + end + + function expect_write_float_float_tuple_(obj, value) + obj.write_float_float_tuple_written(end+1) = Node(value); + end + + function expect_write_int_float_tuple_alternate_syntax_(obj, value) + obj.write_int_float_tuple_alternate_syntax_written(end+1) = Node(value); + end + + function expect_write_int_string_tuple_(obj, value) + obj.write_int_string_tuple_written(end+1) = Node(value); + end + + function expect_write_stream_of_type_variants_(obj, value) + obj.write_stream_of_type_variants_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_float_image_written), "Expected call to write_float_image_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_int_image_written), "Expected call to write_int_image_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_int_image_alternate_syntax_written), "Expected call to write_int_image_alternate_syntax_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_string_image_written), "Expected call to write_string_image_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_int_float_tuple_written), "Expected call to write_int_float_tuple_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_float_float_tuple_written), "Expected call to write_float_float_tuple_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_int_float_tuple_alternate_syntax_written), "Expected call to write_int_float_tuple_alternate_syntax_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_int_string_tuple_written), "Expected call to write_int_string_tuple_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_stream_of_type_variants_written), "Expected call to write_stream_of_type_variants_ was not received"); + end + end + + methods (Access=protected) + function write_float_image_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_float_image_written), "Unexpected call to write_float_image_"); + expected = obj.write_float_image_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_image_"); + obj.write_float_image_written = obj.write_float_image_written(2:end); + end + + function write_int_image_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_int_image_written), "Unexpected call to write_int_image_"); + expected = obj.write_int_image_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_image_"); + obj.write_int_image_written = obj.write_int_image_written(2:end); + end + + function write_int_image_alternate_syntax_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_int_image_alternate_syntax_written), "Unexpected call to write_int_image_alternate_syntax_"); + expected = obj.write_int_image_alternate_syntax_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_image_alternate_syntax_"); + obj.write_int_image_alternate_syntax_written = obj.write_int_image_alternate_syntax_written(2:end); + end + + function write_string_image_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_string_image_written), "Unexpected call to write_string_image_"); + expected = obj.write_string_image_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_string_image_"); + obj.write_string_image_written = obj.write_string_image_written(2:end); + end + + function write_int_float_tuple_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_int_float_tuple_written), "Unexpected call to write_int_float_tuple_"); + expected = obj.write_int_float_tuple_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_float_tuple_"); + obj.write_int_float_tuple_written = obj.write_int_float_tuple_written(2:end); + end + + function write_float_float_tuple_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_float_float_tuple_written), "Unexpected call to write_float_float_tuple_"); + expected = obj.write_float_float_tuple_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_float_tuple_"); + obj.write_float_float_tuple_written = obj.write_float_float_tuple_written(2:end); + end + + function write_int_float_tuple_alternate_syntax_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_int_float_tuple_alternate_syntax_written), "Unexpected call to write_int_float_tuple_alternate_syntax_"); + expected = obj.write_int_float_tuple_alternate_syntax_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_float_tuple_alternate_syntax_"); + obj.write_int_float_tuple_alternate_syntax_written = obj.write_int_float_tuple_alternate_syntax_written(2:end); + end + + function write_int_string_tuple_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_int_string_tuple_written), "Unexpected call to write_int_string_tuple_"); + expected = obj.write_int_string_tuple_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_string_tuple_"); + obj.write_int_string_tuple_written = obj.write_int_string_tuple_written(2:end); + end + + function write_stream_of_type_variants_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_stream_of_type_variants_written), "Unexpected call to write_stream_of_type_variants_"); + expected = obj.write_stream_of_type_variants_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_stream_of_type_variants_"); + obj.write_stream_of_type_variants_written = obj.write_stream_of_type_variants_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockStateTestWriter.m b/matlab/generated/+test_model/+testing/MockStateTestWriter.m new file mode 100644 index 00000000..334b7523 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockStateTestWriter.m @@ -0,0 +1,63 @@ +classdef MockStateTestWriter < test_model.StateTestWriterBase + properties + testCase_ + write_an_int_written + write_a_stream_written + write_another_int_written + end + + methods + function obj = MockStateTestWriter(testCase) + obj.testCase_ = testCase; + obj.write_an_int_written = Node.empty(); + obj.write_a_stream_written = Node.empty(); + obj.write_another_int_written = Node.empty(); + end + + function expect_write_an_int_(obj, value) + obj.write_an_int_written(end+1) = Node(value); + end + + function expect_write_a_stream_(obj, value) + obj.write_a_stream_written(end+1) = Node(value); + end + + function expect_write_another_int_(obj, value) + obj.write_another_int_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_an_int_written), "Expected call to write_an_int_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_a_stream_written), "Expected call to write_a_stream_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_another_int_written), "Expected call to write_another_int_ was not received"); + end + end + + methods (Access=protected) + function write_an_int_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_an_int_written), "Unexpected call to write_an_int_"); + expected = obj.write_an_int_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_an_int_"); + obj.write_an_int_written = obj.write_an_int_written(2:end); + end + + function write_a_stream_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_a_stream_written), "Unexpected call to write_a_stream_"); + expected = obj.write_a_stream_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_a_stream_"); + obj.write_a_stream_written = obj.write_a_stream_written(2:end); + end + + function write_another_int_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_another_int_written), "Unexpected call to write_another_int_"); + expected = obj.write_another_int_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_another_int_"); + obj.write_another_int_written = obj.write_another_int_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m new file mode 100644 index 00000000..fa7c035f --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m @@ -0,0 +1,49 @@ +classdef MockStreamsOfAliasedUnionsWriter < test_model.StreamsOfAliasedUnionsWriterBase + properties + testCase_ + write_int_or_simple_record_written + write_nullable_int_or_simple_record_written + end + + methods + function obj = MockStreamsOfAliasedUnionsWriter(testCase) + obj.testCase_ = testCase; + obj.write_int_or_simple_record_written = Node.empty(); + obj.write_nullable_int_or_simple_record_written = Node.empty(); + end + + function expect_write_int_or_simple_record_(obj, value) + obj.write_int_or_simple_record_written(end+1) = Node(value); + end + + function expect_write_nullable_int_or_simple_record_(obj, value) + obj.write_nullable_int_or_simple_record_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_int_or_simple_record_written), "Expected call to write_int_or_simple_record_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_nullable_int_or_simple_record_written), "Expected call to write_nullable_int_or_simple_record_ was not received"); + end + end + + methods (Access=protected) + function write_int_or_simple_record_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_int_or_simple_record_written), "Unexpected call to write_int_or_simple_record_"); + expected = obj.write_int_or_simple_record_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_simple_record_"); + obj.write_int_or_simple_record_written = obj.write_int_or_simple_record_written(2:end); + end + + function write_nullable_int_or_simple_record_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_nullable_int_or_simple_record_written), "Unexpected call to write_nullable_int_or_simple_record_"); + expected = obj.write_nullable_int_or_simple_record_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_nullable_int_or_simple_record_"); + obj.write_nullable_int_or_simple_record_written = obj.write_nullable_int_or_simple_record_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m new file mode 100644 index 00000000..ead871c2 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m @@ -0,0 +1,49 @@ +classdef MockStreamsOfUnionsWriter < test_model.StreamsOfUnionsWriterBase + properties + testCase_ + write_int_or_simple_record_written + write_nullable_int_or_simple_record_written + end + + methods + function obj = MockStreamsOfUnionsWriter(testCase) + obj.testCase_ = testCase; + obj.write_int_or_simple_record_written = Node.empty(); + obj.write_nullable_int_or_simple_record_written = Node.empty(); + end + + function expect_write_int_or_simple_record_(obj, value) + obj.write_int_or_simple_record_written(end+1) = Node(value); + end + + function expect_write_nullable_int_or_simple_record_(obj, value) + obj.write_nullable_int_or_simple_record_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_int_or_simple_record_written), "Expected call to write_int_or_simple_record_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_nullable_int_or_simple_record_written), "Expected call to write_nullable_int_or_simple_record_ was not received"); + end + end + + methods (Access=protected) + function write_int_or_simple_record_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_int_or_simple_record_written), "Unexpected call to write_int_or_simple_record_"); + expected = obj.write_int_or_simple_record_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_simple_record_"); + obj.write_int_or_simple_record_written = obj.write_int_or_simple_record_written(2:end); + end + + function write_nullable_int_or_simple_record_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_nullable_int_or_simple_record_written), "Unexpected call to write_nullable_int_or_simple_record_"); + expected = obj.write_nullable_int_or_simple_record_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_nullable_int_or_simple_record_"); + obj.write_nullable_int_or_simple_record_written = obj.write_nullable_int_or_simple_record_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockStreamsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsWriter.m new file mode 100644 index 00000000..225199e4 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockStreamsWriter.m @@ -0,0 +1,77 @@ +classdef MockStreamsWriter < test_model.StreamsWriterBase + properties + testCase_ + write_int_data_written + write_optional_int_data_written + write_record_with_optional_vector_data_written + write_fixed_vector_written + end + + methods + function obj = MockStreamsWriter(testCase) + obj.testCase_ = testCase; + obj.write_int_data_written = Node.empty(); + obj.write_optional_int_data_written = Node.empty(); + obj.write_record_with_optional_vector_data_written = Node.empty(); + obj.write_fixed_vector_written = Node.empty(); + end + + function expect_write_int_data_(obj, value) + obj.write_int_data_written(end+1) = Node(value); + end + + function expect_write_optional_int_data_(obj, value) + obj.write_optional_int_data_written(end+1) = Node(value); + end + + function expect_write_record_with_optional_vector_data_(obj, value) + obj.write_record_with_optional_vector_data_written(end+1) = Node(value); + end + + function expect_write_fixed_vector_(obj, value) + obj.write_fixed_vector_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_int_data_written), "Expected call to write_int_data_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_optional_int_data_written), "Expected call to write_optional_int_data_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_record_with_optional_vector_data_written), "Expected call to write_record_with_optional_vector_data_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_fixed_vector_written), "Expected call to write_fixed_vector_ was not received"); + end + end + + methods (Access=protected) + function write_int_data_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_int_data_written), "Unexpected call to write_int_data_"); + expected = obj.write_int_data_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_data_"); + obj.write_int_data_written = obj.write_int_data_written(2:end); + end + + function write_optional_int_data_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_optional_int_data_written), "Unexpected call to write_optional_int_data_"); + expected = obj.write_optional_int_data_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_int_data_"); + obj.write_optional_int_data_written = obj.write_optional_int_data_written(2:end); + end + + function write_record_with_optional_vector_data_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_record_with_optional_vector_data_written), "Unexpected call to write_record_with_optional_vector_data_"); + expected = obj.write_record_with_optional_vector_data_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_optional_vector_data_"); + obj.write_record_with_optional_vector_data_written = obj.write_record_with_optional_vector_data_written(2:end); + end + + function write_fixed_vector_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_fixed_vector_written), "Unexpected call to write_fixed_vector_"); + expected = obj.write_fixed_vector_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_vector_"); + obj.write_fixed_vector_written = obj.write_fixed_vector_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockStringsWriter.m b/matlab/generated/+test_model/+testing/MockStringsWriter.m new file mode 100644 index 00000000..6b52554f --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockStringsWriter.m @@ -0,0 +1,49 @@ +classdef MockStringsWriter < test_model.StringsWriterBase + properties + testCase_ + write_single_string_written + write_rec_with_string_written + end + + methods + function obj = MockStringsWriter(testCase) + obj.testCase_ = testCase; + obj.write_single_string_written = Node.empty(); + obj.write_rec_with_string_written = Node.empty(); + end + + function expect_write_single_string_(obj, value) + obj.write_single_string_written(end+1) = Node(value); + end + + function expect_write_rec_with_string_(obj, value) + obj.write_rec_with_string_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_single_string_written), "Expected call to write_single_string_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_rec_with_string_written), "Expected call to write_rec_with_string_ was not received"); + end + end + + methods (Access=protected) + function write_single_string_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_single_string_written), "Unexpected call to write_single_string_"); + expected = obj.write_single_string_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_single_string_"); + obj.write_single_string_written = obj.write_single_string_written(2:end); + end + + function write_rec_with_string_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_rec_with_string_written), "Unexpected call to write_rec_with_string_"); + expected = obj.write_rec_with_string_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_rec_with_string_"); + obj.write_rec_with_string_written = obj.write_rec_with_string_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m b/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m new file mode 100644 index 00000000..b3a3d8a1 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m @@ -0,0 +1,49 @@ +classdef MockSubarraysInRecordsWriter < test_model.SubarraysInRecordsWriterBase + properties + testCase_ + write_with_fixed_subarrays_written + write_with_vlen_subarrays_written + end + + methods + function obj = MockSubarraysInRecordsWriter(testCase) + obj.testCase_ = testCase; + obj.write_with_fixed_subarrays_written = Node.empty(); + obj.write_with_vlen_subarrays_written = Node.empty(); + end + + function expect_write_with_fixed_subarrays_(obj, value) + obj.write_with_fixed_subarrays_written(end+1) = Node(value); + end + + function expect_write_with_vlen_subarrays_(obj, value) + obj.write_with_vlen_subarrays_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_with_fixed_subarrays_written), "Expected call to write_with_fixed_subarrays_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_with_vlen_subarrays_written), "Expected call to write_with_vlen_subarrays_ was not received"); + end + end + + methods (Access=protected) + function write_with_fixed_subarrays_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_with_fixed_subarrays_written), "Unexpected call to write_with_fixed_subarrays_"); + expected = obj.write_with_fixed_subarrays_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_with_fixed_subarrays_"); + obj.write_with_fixed_subarrays_written = obj.write_with_fixed_subarrays_written(2:end); + end + + function write_with_vlen_subarrays_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_with_vlen_subarrays_written), "Unexpected call to write_with_vlen_subarrays_"); + expected = obj.write_with_vlen_subarrays_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_with_vlen_subarrays_"); + obj.write_with_vlen_subarrays_written = obj.write_with_vlen_subarrays_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockSubarraysWriter.m b/matlab/generated/+test_model/+testing/MockSubarraysWriter.m new file mode 100644 index 00000000..f1e91901 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockSubarraysWriter.m @@ -0,0 +1,147 @@ +classdef MockSubarraysWriter < test_model.SubarraysWriterBase + properties + testCase_ + write_dynamic_with_fixed_int_subarray_written + write_dynamic_with_fixed_float_subarray_written + write_known_dim_count_with_fixed_int_subarray_written + write_known_dim_count_with_fixed_float_subarray_written + write_fixed_with_fixed_int_subarray_written + write_fixed_with_fixed_float_subarray_written + write_nested_subarray_written + write_dynamic_with_fixed_vector_subarray_written + write_generic_subarray_written + end + + methods + function obj = MockSubarraysWriter(testCase) + obj.testCase_ = testCase; + obj.write_dynamic_with_fixed_int_subarray_written = Node.empty(); + obj.write_dynamic_with_fixed_float_subarray_written = Node.empty(); + obj.write_known_dim_count_with_fixed_int_subarray_written = Node.empty(); + obj.write_known_dim_count_with_fixed_float_subarray_written = Node.empty(); + obj.write_fixed_with_fixed_int_subarray_written = Node.empty(); + obj.write_fixed_with_fixed_float_subarray_written = Node.empty(); + obj.write_nested_subarray_written = Node.empty(); + obj.write_dynamic_with_fixed_vector_subarray_written = Node.empty(); + obj.write_generic_subarray_written = Node.empty(); + end + + function expect_write_dynamic_with_fixed_int_subarray_(obj, value) + obj.write_dynamic_with_fixed_int_subarray_written(end+1) = Node(value); + end + + function expect_write_dynamic_with_fixed_float_subarray_(obj, value) + obj.write_dynamic_with_fixed_float_subarray_written(end+1) = Node(value); + end + + function expect_write_known_dim_count_with_fixed_int_subarray_(obj, value) + obj.write_known_dim_count_with_fixed_int_subarray_written(end+1) = Node(value); + end + + function expect_write_known_dim_count_with_fixed_float_subarray_(obj, value) + obj.write_known_dim_count_with_fixed_float_subarray_written(end+1) = Node(value); + end + + function expect_write_fixed_with_fixed_int_subarray_(obj, value) + obj.write_fixed_with_fixed_int_subarray_written(end+1) = Node(value); + end + + function expect_write_fixed_with_fixed_float_subarray_(obj, value) + obj.write_fixed_with_fixed_float_subarray_written(end+1) = Node(value); + end + + function expect_write_nested_subarray_(obj, value) + obj.write_nested_subarray_written(end+1) = Node(value); + end + + function expect_write_dynamic_with_fixed_vector_subarray_(obj, value) + obj.write_dynamic_with_fixed_vector_subarray_written(end+1) = Node(value); + end + + function expect_write_generic_subarray_(obj, value) + obj.write_generic_subarray_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_dynamic_with_fixed_int_subarray_written), "Expected call to write_dynamic_with_fixed_int_subarray_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_dynamic_with_fixed_float_subarray_written), "Expected call to write_dynamic_with_fixed_float_subarray_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_known_dim_count_with_fixed_int_subarray_written), "Expected call to write_known_dim_count_with_fixed_int_subarray_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_known_dim_count_with_fixed_float_subarray_written), "Expected call to write_known_dim_count_with_fixed_float_subarray_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_fixed_with_fixed_int_subarray_written), "Expected call to write_fixed_with_fixed_int_subarray_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_fixed_with_fixed_float_subarray_written), "Expected call to write_fixed_with_fixed_float_subarray_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_nested_subarray_written), "Expected call to write_nested_subarray_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_dynamic_with_fixed_vector_subarray_written), "Expected call to write_dynamic_with_fixed_vector_subarray_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_generic_subarray_written), "Expected call to write_generic_subarray_ was not received"); + end + end + + methods (Access=protected) + function write_dynamic_with_fixed_int_subarray_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_dynamic_with_fixed_int_subarray_written), "Unexpected call to write_dynamic_with_fixed_int_subarray_"); + expected = obj.write_dynamic_with_fixed_int_subarray_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_dynamic_with_fixed_int_subarray_"); + obj.write_dynamic_with_fixed_int_subarray_written = obj.write_dynamic_with_fixed_int_subarray_written(2:end); + end + + function write_dynamic_with_fixed_float_subarray_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_dynamic_with_fixed_float_subarray_written), "Unexpected call to write_dynamic_with_fixed_float_subarray_"); + expected = obj.write_dynamic_with_fixed_float_subarray_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_dynamic_with_fixed_float_subarray_"); + obj.write_dynamic_with_fixed_float_subarray_written = obj.write_dynamic_with_fixed_float_subarray_written(2:end); + end + + function write_known_dim_count_with_fixed_int_subarray_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_known_dim_count_with_fixed_int_subarray_written), "Unexpected call to write_known_dim_count_with_fixed_int_subarray_"); + expected = obj.write_known_dim_count_with_fixed_int_subarray_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_known_dim_count_with_fixed_int_subarray_"); + obj.write_known_dim_count_with_fixed_int_subarray_written = obj.write_known_dim_count_with_fixed_int_subarray_written(2:end); + end + + function write_known_dim_count_with_fixed_float_subarray_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_known_dim_count_with_fixed_float_subarray_written), "Unexpected call to write_known_dim_count_with_fixed_float_subarray_"); + expected = obj.write_known_dim_count_with_fixed_float_subarray_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_known_dim_count_with_fixed_float_subarray_"); + obj.write_known_dim_count_with_fixed_float_subarray_written = obj.write_known_dim_count_with_fixed_float_subarray_written(2:end); + end + + function write_fixed_with_fixed_int_subarray_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_fixed_with_fixed_int_subarray_written), "Unexpected call to write_fixed_with_fixed_int_subarray_"); + expected = obj.write_fixed_with_fixed_int_subarray_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_with_fixed_int_subarray_"); + obj.write_fixed_with_fixed_int_subarray_written = obj.write_fixed_with_fixed_int_subarray_written(2:end); + end + + function write_fixed_with_fixed_float_subarray_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_fixed_with_fixed_float_subarray_written), "Unexpected call to write_fixed_with_fixed_float_subarray_"); + expected = obj.write_fixed_with_fixed_float_subarray_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_with_fixed_float_subarray_"); + obj.write_fixed_with_fixed_float_subarray_written = obj.write_fixed_with_fixed_float_subarray_written(2:end); + end + + function write_nested_subarray_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_nested_subarray_written), "Unexpected call to write_nested_subarray_"); + expected = obj.write_nested_subarray_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_nested_subarray_"); + obj.write_nested_subarray_written = obj.write_nested_subarray_written(2:end); + end + + function write_dynamic_with_fixed_vector_subarray_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_dynamic_with_fixed_vector_subarray_written), "Unexpected call to write_dynamic_with_fixed_vector_subarray_"); + expected = obj.write_dynamic_with_fixed_vector_subarray_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_dynamic_with_fixed_vector_subarray_"); + obj.write_dynamic_with_fixed_vector_subarray_written = obj.write_dynamic_with_fixed_vector_subarray_written(2:end); + end + + function write_generic_subarray_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_generic_subarray_written), "Unexpected call to write_generic_subarray_"); + expected = obj.write_generic_subarray_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_generic_subarray_"); + obj.write_generic_subarray_written = obj.write_generic_subarray_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockUnionsWriter.m b/matlab/generated/+test_model/+testing/MockUnionsWriter.m new file mode 100644 index 00000000..bd1c2a38 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockUnionsWriter.m @@ -0,0 +1,77 @@ +classdef MockUnionsWriter < test_model.UnionsWriterBase + properties + testCase_ + write_int_or_simple_record_written + write_int_or_record_with_vlens_written + write_monosotate_or_int_or_simple_record_written + write_record_with_unions_written + end + + methods + function obj = MockUnionsWriter(testCase) + obj.testCase_ = testCase; + obj.write_int_or_simple_record_written = Node.empty(); + obj.write_int_or_record_with_vlens_written = Node.empty(); + obj.write_monosotate_or_int_or_simple_record_written = Node.empty(); + obj.write_record_with_unions_written = Node.empty(); + end + + function expect_write_int_or_simple_record_(obj, value) + obj.write_int_or_simple_record_written(end+1) = Node(value); + end + + function expect_write_int_or_record_with_vlens_(obj, value) + obj.write_int_or_record_with_vlens_written(end+1) = Node(value); + end + + function expect_write_monosotate_or_int_or_simple_record_(obj, value) + obj.write_monosotate_or_int_or_simple_record_written(end+1) = Node(value); + end + + function expect_write_record_with_unions_(obj, value) + obj.write_record_with_unions_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_int_or_simple_record_written), "Expected call to write_int_or_simple_record_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_int_or_record_with_vlens_written), "Expected call to write_int_or_record_with_vlens_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_monosotate_or_int_or_simple_record_written), "Expected call to write_monosotate_or_int_or_simple_record_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_record_with_unions_written), "Expected call to write_record_with_unions_ was not received"); + end + end + + methods (Access=protected) + function write_int_or_simple_record_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_int_or_simple_record_written), "Unexpected call to write_int_or_simple_record_"); + expected = obj.write_int_or_simple_record_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_simple_record_"); + obj.write_int_or_simple_record_written = obj.write_int_or_simple_record_written(2:end); + end + + function write_int_or_record_with_vlens_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_int_or_record_with_vlens_written), "Unexpected call to write_int_or_record_with_vlens_"); + expected = obj.write_int_or_record_with_vlens_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_record_with_vlens_"); + obj.write_int_or_record_with_vlens_written = obj.write_int_or_record_with_vlens_written(2:end); + end + + function write_monosotate_or_int_or_simple_record_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_monosotate_or_int_or_simple_record_written), "Unexpected call to write_monosotate_or_int_or_simple_record_"); + expected = obj.write_monosotate_or_int_or_simple_record_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_monosotate_or_int_or_simple_record_"); + obj.write_monosotate_or_int_or_simple_record_written = obj.write_monosotate_or_int_or_simple_record_written(2:end); + end + + function write_record_with_unions_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_record_with_unions_written), "Unexpected call to write_record_with_unions_"); + expected = obj.write_record_with_unions_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_unions_"); + obj.write_record_with_unions_written = obj.write_record_with_unions_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockVlensWriter.m b/matlab/generated/+test_model/+testing/MockVlensWriter.m new file mode 100644 index 00000000..a9af6253 --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockVlensWriter.m @@ -0,0 +1,77 @@ +classdef MockVlensWriter < test_model.VlensWriterBase + properties + testCase_ + write_int_vector_written + write_complex_vector_written + write_record_with_vlens_written + write_vlen_of_record_with_vlens_written + end + + methods + function obj = MockVlensWriter(testCase) + obj.testCase_ = testCase; + obj.write_int_vector_written = Node.empty(); + obj.write_complex_vector_written = Node.empty(); + obj.write_record_with_vlens_written = Node.empty(); + obj.write_vlen_of_record_with_vlens_written = Node.empty(); + end + + function expect_write_int_vector_(obj, value) + obj.write_int_vector_written(end+1) = Node(value); + end + + function expect_write_complex_vector_(obj, value) + obj.write_complex_vector_written(end+1) = Node(value); + end + + function expect_write_record_with_vlens_(obj, value) + obj.write_record_with_vlens_written(end+1) = Node(value); + end + + function expect_write_vlen_of_record_with_vlens_(obj, value) + obj.write_vlen_of_record_with_vlens_written(end+1) = Node(value); + end + + function verify(obj) + obj.testCase_.verifyTrue(isempty(obj.write_int_vector_written), "Expected call to write_int_vector_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_complex_vector_written), "Expected call to write_complex_vector_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_record_with_vlens_written), "Expected call to write_record_with_vlens_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.write_vlen_of_record_with_vlens_written), "Expected call to write_vlen_of_record_with_vlens_ was not received"); + end + end + + methods (Access=protected) + function write_int_vector_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_int_vector_written), "Unexpected call to write_int_vector_"); + expected = obj.write_int_vector_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_vector_"); + obj.write_int_vector_written = obj.write_int_vector_written(2:end); + end + + function write_complex_vector_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_complex_vector_written), "Unexpected call to write_complex_vector_"); + expected = obj.write_complex_vector_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_complex_vector_"); + obj.write_complex_vector_written = obj.write_complex_vector_written(2:end); + end + + function write_record_with_vlens_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_record_with_vlens_written), "Unexpected call to write_record_with_vlens_"); + expected = obj.write_record_with_vlens_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_"); + obj.write_record_with_vlens_written = obj.write_record_with_vlens_written(2:end); + end + + function write_vlen_of_record_with_vlens_(obj, value) + obj.testCase_.verifyTrue(~isempty(obj.write_vlen_of_record_with_vlens_written), "Unexpected call to write_vlen_of_record_with_vlens_"); + expected = obj.write_vlen_of_record_with_vlens_written(1).value; + obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_vlen_of_record_with_vlens_"); + obj.write_vlen_of_record_with_vlens_written = obj.write_vlen_of_record_with_vlens_written(2:end); + end + + function close_(obj) + end + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m b/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m new file mode 100644 index 00000000..b2011d03 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m @@ -0,0 +1,63 @@ +classdef TestAdvancedGenericsWriter < test_model.AdvancedGenericsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestAdvancedGenericsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockAdvancedGenericsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestAdvancedGenericsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_float_image_image_(obj, value) + obj.writer_.write_float_image_image(value); + obj.mock_writer_.expect_write_float_image_image_(value); + end + + function write_generic_record_1_(obj, value) + obj.writer_.write_generic_record_1(value); + obj.mock_writer_.expect_write_generic_record_1_(value); + end + + function write_tuple_of_optionals_(obj, value) + obj.writer_.write_tuple_of_optionals(value); + obj.mock_writer_.expect_write_tuple_of_optionals_(value); + end + + function write_tuple_of_optionals_alternate_syntax_(obj, value) + obj.writer_.write_tuple_of_optionals_alternate_syntax(value); + obj.mock_writer_.expect_write_tuple_of_optionals_alternate_syntax_(value); + end + + function write_tuple_of_vectors_(obj, value) + obj.writer_.write_tuple_of_vectors(value); + obj.mock_writer_.expect_write_tuple_of_vectors_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestAliasesWriter.m b/matlab/generated/+test_model/+testing/TestAliasesWriter.m new file mode 100644 index 00000000..7045e138 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestAliasesWriter.m @@ -0,0 +1,88 @@ +classdef TestAliasesWriter < test_model.AliasesWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestAliasesWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockAliasesWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestAliasesWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_aliased_string_(obj, value) + obj.writer_.write_aliased_string(value); + obj.mock_writer_.expect_write_aliased_string_(value); + end + + function write_aliased_enum_(obj, value) + obj.writer_.write_aliased_enum(value); + obj.mock_writer_.expect_write_aliased_enum_(value); + end + + function write_aliased_open_generic_(obj, value) + obj.writer_.write_aliased_open_generic(value); + obj.mock_writer_.expect_write_aliased_open_generic_(value); + end + + function write_aliased_closed_generic_(obj, value) + obj.writer_.write_aliased_closed_generic(value); + obj.mock_writer_.expect_write_aliased_closed_generic_(value); + end + + function write_aliased_optional_(obj, value) + obj.writer_.write_aliased_optional(value); + obj.mock_writer_.expect_write_aliased_optional_(value); + end + + function write_aliased_generic_optional_(obj, value) + obj.writer_.write_aliased_generic_optional(value); + obj.mock_writer_.expect_write_aliased_generic_optional_(value); + end + + function write_aliased_generic_union_2_(obj, value) + obj.writer_.write_aliased_generic_union_2(value); + obj.mock_writer_.expect_write_aliased_generic_union_2_(value); + end + + function write_aliased_generic_vector_(obj, value) + obj.writer_.write_aliased_generic_vector(value); + obj.mock_writer_.expect_write_aliased_generic_vector_(value); + end + + function write_aliased_generic_fixed_vector_(obj, value) + obj.writer_.write_aliased_generic_fixed_vector(value); + obj.mock_writer_.expect_write_aliased_generic_fixed_vector_(value); + end + + function write_stream_of_aliased_generic_union_2_(obj, value) + obj.writer_.write_stream_of_aliased_generic_union_2(value); + obj.mock_writer_.expect_write_stream_of_aliased_generic_union_2_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m new file mode 100644 index 00000000..cb82f0b7 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m @@ -0,0 +1,43 @@ +classdef TestBenchmarkFloat256x256Writer < test_model.BenchmarkFloat256x256WriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestBenchmarkFloat256x256Writer(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockBenchmarkFloat256x256Writer(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkFloat256x256Writer' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_float256x256_(obj, value) + obj.writer_.write_float256x256(value); + obj.mock_writer_.expect_write_float256x256_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m new file mode 100644 index 00000000..20c83b4d --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m @@ -0,0 +1,43 @@ +classdef TestBenchmarkFloatVlenWriter < test_model.BenchmarkFloatVlenWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestBenchmarkFloatVlenWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockBenchmarkFloatVlenWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkFloatVlenWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_float_array_(obj, value) + obj.writer_.write_float_array(value); + obj.mock_writer_.expect_write_float_array_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m new file mode 100644 index 00000000..762f2e9e --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m @@ -0,0 +1,43 @@ +classdef TestBenchmarkInt256x256Writer < test_model.BenchmarkInt256x256WriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestBenchmarkInt256x256Writer(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockBenchmarkInt256x256Writer(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkInt256x256Writer' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_int256x256_(obj, value) + obj.writer_.write_int256x256(value); + obj.mock_writer_.expect_write_int256x256_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m new file mode 100644 index 00000000..f826d6fc --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m @@ -0,0 +1,43 @@ +classdef TestBenchmarkSimpleMrdWriter < test_model.BenchmarkSimpleMrdWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestBenchmarkSimpleMrdWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockBenchmarkSimpleMrdWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkSimpleMrdWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_data_(obj, value) + obj.writer_.write_data(value); + obj.mock_writer_.expect_write_data_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m new file mode 100644 index 00000000..47437359 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m @@ -0,0 +1,43 @@ +classdef TestBenchmarkSmallRecordWithOptionalsWriter < test_model.BenchmarkSmallRecordWithOptionalsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestBenchmarkSmallRecordWithOptionalsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockBenchmarkSmallRecordWithOptionalsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkSmallRecordWithOptionalsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_small_record_(obj, value) + obj.writer_.write_small_record(value); + obj.mock_writer_.expect_write_small_record_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m new file mode 100644 index 00000000..3713a2cb --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m @@ -0,0 +1,43 @@ +classdef TestBenchmarkSmallRecordWriter < test_model.BenchmarkSmallRecordWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestBenchmarkSmallRecordWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockBenchmarkSmallRecordWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkSmallRecordWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_small_record_(obj, value) + obj.writer_.write_small_record(value); + obj.mock_writer_.expect_write_small_record_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m b/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m new file mode 100644 index 00000000..ccd7b1d4 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m @@ -0,0 +1,58 @@ +classdef TestDynamicNDArraysWriter < test_model.DynamicNDArraysWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestDynamicNDArraysWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockDynamicNDArraysWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestDynamicNDArraysWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_ints_(obj, value) + obj.writer_.write_ints(value); + obj.mock_writer_.expect_write_ints_(value); + end + + function write_simple_record_array_(obj, value) + obj.writer_.write_simple_record_array(value); + obj.mock_writer_.expect_write_simple_record_array_(value); + end + + function write_record_with_vlens_array_(obj, value) + obj.writer_.write_record_with_vlens_array(value); + obj.mock_writer_.expect_write_record_with_vlens_array_(value); + end + + function write_record_with_dynamic_nd_arrays_(obj, value) + obj.writer_.write_record_with_dynamic_nd_arrays(value); + obj.mock_writer_.expect_write_record_with_dynamic_nd_arrays_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestEnumsWriter.m b/matlab/generated/+test_model/+testing/TestEnumsWriter.m new file mode 100644 index 00000000..96d179bc --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestEnumsWriter.m @@ -0,0 +1,53 @@ +classdef TestEnumsWriter < test_model.EnumsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestEnumsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockEnumsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestEnumsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_single_(obj, value) + obj.writer_.write_single(value); + obj.mock_writer_.expect_write_single_(value); + end + + function write_vec_(obj, value) + obj.writer_.write_vec(value); + obj.mock_writer_.expect_write_vec_(value); + end + + function write_size_(obj, value) + obj.writer_.write_size(value); + obj.mock_writer_.expect_write_size_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m b/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m new file mode 100644 index 00000000..53708af2 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m @@ -0,0 +1,63 @@ +classdef TestFixedArraysWriter < test_model.FixedArraysWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestFixedArraysWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockFixedArraysWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestFixedArraysWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_ints_(obj, value) + obj.writer_.write_ints(value); + obj.mock_writer_.expect_write_ints_(value); + end + + function write_fixed_simple_record_array_(obj, value) + obj.writer_.write_fixed_simple_record_array(value); + obj.mock_writer_.expect_write_fixed_simple_record_array_(value); + end + + function write_fixed_record_with_vlens_array_(obj, value) + obj.writer_.write_fixed_record_with_vlens_array(value); + obj.mock_writer_.expect_write_fixed_record_with_vlens_array_(value); + end + + function write_record_with_fixed_arrays_(obj, value) + obj.writer_.write_record_with_fixed_arrays(value); + obj.mock_writer_.expect_write_record_with_fixed_arrays_(value); + end + + function write_named_array_(obj, value) + obj.writer_.write_named_array(value); + obj.mock_writer_.expect_write_named_array_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m b/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m new file mode 100644 index 00000000..9c8978ab --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m @@ -0,0 +1,58 @@ +classdef TestFixedVectorsWriter < test_model.FixedVectorsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestFixedVectorsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockFixedVectorsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestFixedVectorsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_fixed_int_vector_(obj, value) + obj.writer_.write_fixed_int_vector(value); + obj.mock_writer_.expect_write_fixed_int_vector_(value); + end + + function write_fixed_simple_record_vector_(obj, value) + obj.writer_.write_fixed_simple_record_vector(value); + obj.mock_writer_.expect_write_fixed_simple_record_vector_(value); + end + + function write_fixed_record_with_vlens_vector_(obj, value) + obj.writer_.write_fixed_record_with_vlens_vector(value); + obj.mock_writer_.expect_write_fixed_record_with_vlens_vector_(value); + end + + function write_record_with_fixed_vectors_(obj, value) + obj.writer_.write_record_with_fixed_vectors(value); + obj.mock_writer_.expect_write_record_with_fixed_vectors_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestFlagsWriter.m b/matlab/generated/+test_model/+testing/TestFlagsWriter.m new file mode 100644 index 00000000..0a20ca55 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestFlagsWriter.m @@ -0,0 +1,48 @@ +classdef TestFlagsWriter < test_model.FlagsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestFlagsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockFlagsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestFlagsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_days_(obj, value) + obj.writer_.write_days(value); + obj.mock_writer_.expect_write_days_(value); + end + + function write_formats_(obj, value) + obj.writer_.write_formats(value); + obj.mock_writer_.expect_write_formats_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestMapsWriter.m b/matlab/generated/+test_model/+testing/TestMapsWriter.m new file mode 100644 index 00000000..524c3466 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestMapsWriter.m @@ -0,0 +1,58 @@ +classdef TestMapsWriter < test_model.MapsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestMapsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockMapsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestMapsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_string_to_int_(obj, value) + obj.writer_.write_string_to_int(value); + obj.mock_writer_.expect_write_string_to_int_(value); + end + + function write_int_to_string_(obj, value) + obj.writer_.write_int_to_string(value); + obj.mock_writer_.expect_write_int_to_string_(value); + end + + function write_string_to_union_(obj, value) + obj.writer_.write_string_to_union(value); + obj.mock_writer_.expect_write_string_to_union_(value); + end + + function write_aliased_generic_(obj, value) + obj.writer_.write_aliased_generic(value); + obj.mock_writer_.expect_write_aliased_generic_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m b/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m new file mode 100644 index 00000000..6fd5afed --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m @@ -0,0 +1,58 @@ +classdef TestNDArraysSingleDimensionWriter < test_model.NDArraysSingleDimensionWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestNDArraysSingleDimensionWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockNDArraysSingleDimensionWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestNDArraysSingleDimensionWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_ints_(obj, value) + obj.writer_.write_ints(value); + obj.mock_writer_.expect_write_ints_(value); + end + + function write_simple_record_array_(obj, value) + obj.writer_.write_simple_record_array(value); + obj.mock_writer_.expect_write_simple_record_array_(value); + end + + function write_record_with_vlens_array_(obj, value) + obj.writer_.write_record_with_vlens_array(value); + obj.mock_writer_.expect_write_record_with_vlens_array_(value); + end + + function write_record_with_nd_arrays_(obj, value) + obj.writer_.write_record_with_nd_arrays(value); + obj.mock_writer_.expect_write_record_with_nd_arrays_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestNDArraysWriter.m b/matlab/generated/+test_model/+testing/TestNDArraysWriter.m new file mode 100644 index 00000000..76cc9a61 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestNDArraysWriter.m @@ -0,0 +1,63 @@ +classdef TestNDArraysWriter < test_model.NDArraysWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestNDArraysWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockNDArraysWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestNDArraysWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_ints_(obj, value) + obj.writer_.write_ints(value); + obj.mock_writer_.expect_write_ints_(value); + end + + function write_simple_record_array_(obj, value) + obj.writer_.write_simple_record_array(value); + obj.mock_writer_.expect_write_simple_record_array_(value); + end + + function write_record_with_vlens_array_(obj, value) + obj.writer_.write_record_with_vlens_array(value); + obj.mock_writer_.expect_write_record_with_vlens_array_(value); + end + + function write_record_with_nd_arrays_(obj, value) + obj.writer_.write_record_with_nd_arrays(value); + obj.mock_writer_.expect_write_record_with_nd_arrays_(value); + end + + function write_named_array_(obj, value) + obj.writer_.write_named_array(value); + obj.mock_writer_.expect_write_named_array_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m b/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m new file mode 100644 index 00000000..729d86f1 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m @@ -0,0 +1,43 @@ +classdef TestNestedRecordsWriter < test_model.NestedRecordsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestNestedRecordsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockNestedRecordsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestNestedRecordsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_tuple_with_records_(obj, value) + obj.writer_.write_tuple_with_records(value); + obj.mock_writer_.expect_write_tuple_with_records_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m b/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m new file mode 100644 index 00000000..3bf0fab9 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m @@ -0,0 +1,43 @@ +classdef TestOptionalVectorsWriter < test_model.OptionalVectorsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestOptionalVectorsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockOptionalVectorsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestOptionalVectorsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_record_with_optional_vector_(obj, value) + obj.writer_.write_record_with_optional_vector(value); + obj.mock_writer_.expect_write_record_with_optional_vector_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m b/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m new file mode 100644 index 00000000..0528ddf9 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m @@ -0,0 +1,43 @@ +classdef TestProtocolWithComputedFieldsWriter < test_model.ProtocolWithComputedFieldsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestProtocolWithComputedFieldsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockProtocolWithComputedFieldsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestProtocolWithComputedFieldsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_record_with_computed_fields_(obj, value) + obj.writer_.write_record_with_computed_fields(value); + obj.mock_writer_.expect_write_record_with_computed_fields_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m new file mode 100644 index 00000000..4eeec4c2 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m @@ -0,0 +1,48 @@ +classdef TestProtocolWithKeywordStepsWriter < test_model.ProtocolWithKeywordStepsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestProtocolWithKeywordStepsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockProtocolWithKeywordStepsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestProtocolWithKeywordStepsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_int_(obj, value) + obj.writer_.write_int(value); + obj.mock_writer_.expect_write_int_(value); + end + + function write_float_(obj, value) + obj.writer_.write_float(value); + obj.mock_writer_.expect_write_float_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m b/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m new file mode 100644 index 00000000..6da2c197 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m @@ -0,0 +1,58 @@ +classdef TestScalarOptionalsWriter < test_model.ScalarOptionalsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestScalarOptionalsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockScalarOptionalsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestScalarOptionalsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_optional_int_(obj, value) + obj.writer_.write_optional_int(value); + obj.mock_writer_.expect_write_optional_int_(value); + end + + function write_optional_record_(obj, value) + obj.writer_.write_optional_record(value); + obj.mock_writer_.expect_write_optional_record_(value); + end + + function write_record_with_optional_fields_(obj, value) + obj.writer_.write_record_with_optional_fields(value); + obj.mock_writer_.expect_write_record_with_optional_fields_(value); + end + + function write_optional_record_with_optional_fields_(obj, value) + obj.writer_.write_optional_record_with_optional_fields(value); + obj.mock_writer_.expect_write_optional_record_with_optional_fields_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestScalarsWriter.m b/matlab/generated/+test_model/+testing/TestScalarsWriter.m new file mode 100644 index 00000000..477a49e0 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestScalarsWriter.m @@ -0,0 +1,48 @@ +classdef TestScalarsWriter < test_model.ScalarsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestScalarsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockScalarsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestScalarsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_int32_(obj, value) + obj.writer_.write_int32(value); + obj.mock_writer_.expect_write_int32_(value); + end + + function write_record_(obj, value) + obj.writer_.write_record(value); + obj.mock_writer_.expect_write_record_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m b/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m new file mode 100644 index 00000000..fa05e668 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m @@ -0,0 +1,83 @@ +classdef TestSimpleGenericsWriter < test_model.SimpleGenericsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestSimpleGenericsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockSimpleGenericsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestSimpleGenericsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_float_image_(obj, value) + obj.writer_.write_float_image(value); + obj.mock_writer_.expect_write_float_image_(value); + end + + function write_int_image_(obj, value) + obj.writer_.write_int_image(value); + obj.mock_writer_.expect_write_int_image_(value); + end + + function write_int_image_alternate_syntax_(obj, value) + obj.writer_.write_int_image_alternate_syntax(value); + obj.mock_writer_.expect_write_int_image_alternate_syntax_(value); + end + + function write_string_image_(obj, value) + obj.writer_.write_string_image(value); + obj.mock_writer_.expect_write_string_image_(value); + end + + function write_int_float_tuple_(obj, value) + obj.writer_.write_int_float_tuple(value); + obj.mock_writer_.expect_write_int_float_tuple_(value); + end + + function write_float_float_tuple_(obj, value) + obj.writer_.write_float_float_tuple(value); + obj.mock_writer_.expect_write_float_float_tuple_(value); + end + + function write_int_float_tuple_alternate_syntax_(obj, value) + obj.writer_.write_int_float_tuple_alternate_syntax(value); + obj.mock_writer_.expect_write_int_float_tuple_alternate_syntax_(value); + end + + function write_int_string_tuple_(obj, value) + obj.writer_.write_int_string_tuple(value); + obj.mock_writer_.expect_write_int_string_tuple_(value); + end + + function write_stream_of_type_variants_(obj, value) + obj.writer_.write_stream_of_type_variants(value); + obj.mock_writer_.expect_write_stream_of_type_variants_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestStateTestWriter.m b/matlab/generated/+test_model/+testing/TestStateTestWriter.m new file mode 100644 index 00000000..082f2b74 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestStateTestWriter.m @@ -0,0 +1,53 @@ +classdef TestStateTestWriter < test_model.StateTestWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestStateTestWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockStateTestWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestStateTestWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_an_int_(obj, value) + obj.writer_.write_an_int(value); + obj.mock_writer_.expect_write_an_int_(value); + end + + function write_a_stream_(obj, value) + obj.writer_.write_a_stream(value); + obj.mock_writer_.expect_write_a_stream_(value); + end + + function write_another_int_(obj, value) + obj.writer_.write_another_int(value); + obj.mock_writer_.expect_write_another_int_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m new file mode 100644 index 00000000..2a397cff --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m @@ -0,0 +1,48 @@ +classdef TestStreamsOfAliasedUnionsWriter < test_model.StreamsOfAliasedUnionsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestStreamsOfAliasedUnionsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockStreamsOfAliasedUnionsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestStreamsOfAliasedUnionsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_int_or_simple_record_(obj, value) + obj.writer_.write_int_or_simple_record(value); + obj.mock_writer_.expect_write_int_or_simple_record_(value); + end + + function write_nullable_int_or_simple_record_(obj, value) + obj.writer_.write_nullable_int_or_simple_record(value); + obj.mock_writer_.expect_write_nullable_int_or_simple_record_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m new file mode 100644 index 00000000..183ba953 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m @@ -0,0 +1,48 @@ +classdef TestStreamsOfUnionsWriter < test_model.StreamsOfUnionsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestStreamsOfUnionsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockStreamsOfUnionsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestStreamsOfUnionsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_int_or_simple_record_(obj, value) + obj.writer_.write_int_or_simple_record(value); + obj.mock_writer_.expect_write_int_or_simple_record_(value); + end + + function write_nullable_int_or_simple_record_(obj, value) + obj.writer_.write_nullable_int_or_simple_record(value); + obj.mock_writer_.expect_write_nullable_int_or_simple_record_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestStreamsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsWriter.m new file mode 100644 index 00000000..386cb10f --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestStreamsWriter.m @@ -0,0 +1,58 @@ +classdef TestStreamsWriter < test_model.StreamsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestStreamsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockStreamsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestStreamsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_int_data_(obj, value) + obj.writer_.write_int_data(value); + obj.mock_writer_.expect_write_int_data_(value); + end + + function write_optional_int_data_(obj, value) + obj.writer_.write_optional_int_data(value); + obj.mock_writer_.expect_write_optional_int_data_(value); + end + + function write_record_with_optional_vector_data_(obj, value) + obj.writer_.write_record_with_optional_vector_data(value); + obj.mock_writer_.expect_write_record_with_optional_vector_data_(value); + end + + function write_fixed_vector_(obj, value) + obj.writer_.write_fixed_vector(value); + obj.mock_writer_.expect_write_fixed_vector_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestStringsWriter.m b/matlab/generated/+test_model/+testing/TestStringsWriter.m new file mode 100644 index 00000000..8111d7e0 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestStringsWriter.m @@ -0,0 +1,48 @@ +classdef TestStringsWriter < test_model.StringsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestStringsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockStringsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestStringsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_single_string_(obj, value) + obj.writer_.write_single_string(value); + obj.mock_writer_.expect_write_single_string_(value); + end + + function write_rec_with_string_(obj, value) + obj.writer_.write_rec_with_string(value); + obj.mock_writer_.expect_write_rec_with_string_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m b/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m new file mode 100644 index 00000000..65e669cc --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m @@ -0,0 +1,48 @@ +classdef TestSubarraysInRecordsWriter < test_model.SubarraysInRecordsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestSubarraysInRecordsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockSubarraysInRecordsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestSubarraysInRecordsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_with_fixed_subarrays_(obj, value) + obj.writer_.write_with_fixed_subarrays(value); + obj.mock_writer_.expect_write_with_fixed_subarrays_(value); + end + + function write_with_vlen_subarrays_(obj, value) + obj.writer_.write_with_vlen_subarrays(value); + obj.mock_writer_.expect_write_with_vlen_subarrays_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestSubarraysWriter.m b/matlab/generated/+test_model/+testing/TestSubarraysWriter.m new file mode 100644 index 00000000..ead973f4 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestSubarraysWriter.m @@ -0,0 +1,83 @@ +classdef TestSubarraysWriter < test_model.SubarraysWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestSubarraysWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockSubarraysWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestSubarraysWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_dynamic_with_fixed_int_subarray_(obj, value) + obj.writer_.write_dynamic_with_fixed_int_subarray(value); + obj.mock_writer_.expect_write_dynamic_with_fixed_int_subarray_(value); + end + + function write_dynamic_with_fixed_float_subarray_(obj, value) + obj.writer_.write_dynamic_with_fixed_float_subarray(value); + obj.mock_writer_.expect_write_dynamic_with_fixed_float_subarray_(value); + end + + function write_known_dim_count_with_fixed_int_subarray_(obj, value) + obj.writer_.write_known_dim_count_with_fixed_int_subarray(value); + obj.mock_writer_.expect_write_known_dim_count_with_fixed_int_subarray_(value); + end + + function write_known_dim_count_with_fixed_float_subarray_(obj, value) + obj.writer_.write_known_dim_count_with_fixed_float_subarray(value); + obj.mock_writer_.expect_write_known_dim_count_with_fixed_float_subarray_(value); + end + + function write_fixed_with_fixed_int_subarray_(obj, value) + obj.writer_.write_fixed_with_fixed_int_subarray(value); + obj.mock_writer_.expect_write_fixed_with_fixed_int_subarray_(value); + end + + function write_fixed_with_fixed_float_subarray_(obj, value) + obj.writer_.write_fixed_with_fixed_float_subarray(value); + obj.mock_writer_.expect_write_fixed_with_fixed_float_subarray_(value); + end + + function write_nested_subarray_(obj, value) + obj.writer_.write_nested_subarray(value); + obj.mock_writer_.expect_write_nested_subarray_(value); + end + + function write_dynamic_with_fixed_vector_subarray_(obj, value) + obj.writer_.write_dynamic_with_fixed_vector_subarray(value); + obj.mock_writer_.expect_write_dynamic_with_fixed_vector_subarray_(value); + end + + function write_generic_subarray_(obj, value) + obj.writer_.write_generic_subarray(value); + obj.mock_writer_.expect_write_generic_subarray_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestUnionsWriter.m b/matlab/generated/+test_model/+testing/TestUnionsWriter.m new file mode 100644 index 00000000..3b3239bc --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestUnionsWriter.m @@ -0,0 +1,58 @@ +classdef TestUnionsWriter < test_model.UnionsWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestUnionsWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockUnionsWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestUnionsWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_int_or_simple_record_(obj, value) + obj.writer_.write_int_or_simple_record(value); + obj.mock_writer_.expect_write_int_or_simple_record_(value); + end + + function write_int_or_record_with_vlens_(obj, value) + obj.writer_.write_int_or_record_with_vlens(value); + obj.mock_writer_.expect_write_int_or_record_with_vlens_(value); + end + + function write_monosotate_or_int_or_simple_record_(obj, value) + obj.writer_.write_monosotate_or_int_or_simple_record(value); + obj.mock_writer_.expect_write_monosotate_or_int_or_simple_record_(value); + end + + function write_record_with_unions_(obj, value) + obj.writer_.write_record_with_unions(value); + obj.mock_writer_.expect_write_record_with_unions_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestVlensWriter.m b/matlab/generated/+test_model/+testing/TestVlensWriter.m new file mode 100644 index 00000000..4d4bddcd --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestVlensWriter.m @@ -0,0 +1,58 @@ +classdef TestVlensWriter < test_model.VlensWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + end + + methods + function obj = TestVlensWriter(testCase, writer, create_reader) + obj.writer_ = writer; + obj.create_reader_ = create_reader; + obj.mock_writer_ = test_model.testing.MockVlensWriter(testCase); + obj.close_called_ = false; + end + + function delete(obj) + if ~obj.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestVlensWriter' to verify mocks")); + end + end + end + + methods (Access=protected) + function write_int_vector_(obj, value) + obj.writer_.write_int_vector(value); + obj.mock_writer_.expect_write_int_vector_(value); + end + + function write_complex_vector_(obj, value) + obj.writer_.write_complex_vector(value); + obj.mock_writer_.expect_write_complex_vector_(value); + end + + function write_record_with_vlens_(obj, value) + obj.writer_.write_record_with_vlens(value); + obj.mock_writer_.expect_write_record_with_vlens_(value); + end + + function write_vlen_of_record_with_vlens_(obj, value) + obj.writer_.write_vlen_of_record_with_vlens(value); + obj.mock_writer_.expect_write_vlen_of_record_with_vlens_(value); + end + + function close_(obj) + obj.close_called_ = true; + obj.writer_.close(); + reader = obj.create_reader_(); + reader.copy_to(obj.mock_writer_); + reader.close(); + obj.mock_writer_.verify(); + end + + function end_stream_(obj) + end + end +end diff --git a/matlab/generated/+test_model/AcquisitionOrImage.m b/matlab/generated/+test_model/AcquisitionOrImage.m new file mode 100644 index 00000000..df171ce2 --- /dev/null +++ b/matlab/generated/+test_model/AcquisitionOrImage.m @@ -0,0 +1,34 @@ +classdef AcquisitionOrImage < yardl.Union + methods (Static) + function res = Acquisition(value) + res = test_model.AcquisitionOrImage(1, value); + end + + function res = Image(value) + res = test_model.AcquisitionOrImage(2, value); + end + + function z = zeros(varargin) + elem = test_model.AcquisitionOrImage(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.AcquisitionOrImage') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/AdvancedGenericsReaderBase.m b/matlab/generated/+test_model/AdvancedGenericsReaderBase.m new file mode 100644 index 00000000..19568374 --- /dev/null +++ b/matlab/generated/+test_model/AdvancedGenericsReaderBase.m @@ -0,0 +1,122 @@ +classdef AdvancedGenericsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = AdvancedGenericsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 10 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_float_image_image(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_float_image_image_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_generic_record_1(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_generic_record_1_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_tuple_of_optionals(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_tuple_of_optionals_(); + obj.state_ = 6; + end + + % Ordinal 3 + function value = read_tuple_of_optionals_alternate_syntax(obj) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + value = obj.read_tuple_of_optionals_alternate_syntax_(); + obj.state_ = 8; + end + + % Ordinal 4 + function value = read_tuple_of_vectors(obj) + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); + end + + value = obj.read_tuple_of_vectors_(); + obj.state_ = 10; + end + + function copy_to(obj, writer) + writer.write_float_image_image(obj.read_float_image_image()); + writer.write_generic_record_1(obj.read_generic_record_1()); + writer.write_tuple_of_optionals(obj.read_tuple_of_optionals()); + writer.write_tuple_of_optionals_alternate_syntax(obj.read_tuple_of_optionals_alternate_syntax()); + writer.write_tuple_of_vectors(obj.read_tuple_of_vectors()); + end + end + + methods (Static) + function res = schema() + res = test_model.AdvancedGenericsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_float_image_image_(obj, value) + read_generic_record_1_(obj, value) + read_tuple_of_optionals_(obj, value) + read_tuple_of_optionals_alternate_syntax_(obj, value) + read_tuple_of_vectors_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_float_image_image'; + elseif state == 2 + name = 'read_generic_record_1'; + elseif state == 4 + name = 'read_tuple_of_optionals'; + elseif state == 6 + name = 'read_tuple_of_optionals_alternate_syntax'; + elseif state == 8 + name = 'read_tuple_of_vectors'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/AdvancedGenericsWriterBase.m b/matlab/generated/+test_model/AdvancedGenericsWriterBase.m new file mode 100644 index 00000000..7685fd06 --- /dev/null +++ b/matlab/generated/+test_model/AdvancedGenericsWriterBase.m @@ -0,0 +1,111 @@ +% Abstract writer for protocol AdvancedGenerics +classdef (Abstract) AdvancedGenericsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = AdvancedGenericsWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 10 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_float_image_image(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_float_image_image_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_generic_record_1(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_generic_record_1_(value); + obj.state_ = 4; + end + + % Ordinal 2 + function write_tuple_of_optionals(obj, value) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_tuple_of_optionals_(value); + obj.state_ = 6; + end + + % Ordinal 3 + function write_tuple_of_optionals_alternate_syntax(obj, value) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + obj.write_tuple_of_optionals_alternate_syntax_(value); + obj.state_ = 8; + end + + % Ordinal 4 + function write_tuple_of_vectors(obj, value) + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); + end + + obj.write_tuple_of_vectors_(value); + obj.state_ = 10; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"AdvancedGenerics","sequence":[{"name":"floatImageImage","type":{"name":"TestModel.Image","typeArguments":[{"name":"TestModel.Image","typeArguments":["float32"]}]}},{"name":"genericRecord1","type":{"name":"TestModel.GenericRecord","typeArguments":["int32","string"]}},{"name":"tupleOfOptionals","type":{"name":"TestModel.MyTuple","typeArguments":[[null,"int32"],[null,"string"]]}},{"name":"tupleOfOptionalsAlternateSyntax","type":{"name":"TestModel.MyTuple","typeArguments":[[null,"int32"],[null,"string"]]}},{"name":"tupleOfVectors","type":{"name":"TestModel.MyTuple","typeArguments":[{"vector":{"items":"int32"}},{"vector":{"items":"float32"}}]}}]},"types":[{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"Tuples.Tuple","typeArguments":["T1","T2"]}},{"name":"Image","typeParameters":["T"],"type":{"array":{"items":"T","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"GenericRecord","typeParameters":["T1","T2"],"fields":[{"name":"scalar1","type":"T1"},{"name":"scalar2","type":"T2"},{"name":"vector1","type":{"vector":{"items":"T1"}}},{"name":"image2","type":{"name":"TestModel.Image","typeArguments":["T2"]}}]},{"name":"Image","typeParameters":["T"],"type":{"name":"Image.Image","typeArguments":["T"]}},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"BasicTypes.MyTuple","typeArguments":["T1","T2"]}},{"name":"Tuple","typeParameters":["T1","T2"],"fields":[{"name":"v1","type":"T1"},{"name":"v2","type":"T2"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_float_image_image_(obj, value) + write_generic_record_1_(obj, value) + write_tuple_of_optionals_(obj, value) + write_tuple_of_optionals_alternate_syntax_(obj, value) + write_tuple_of_vectors_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_float_image_image'; + elseif state == 2 + name = 'write_generic_record_1'; + elseif state == 4 + name = 'write_tuple_of_optionals'; + elseif state == 6 + name = 'write_tuple_of_optionals_alternate_syntax'; + elseif state == 8 + name = 'write_tuple_of_vectors'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/AliasedClosedGeneric.m b/matlab/generated/+test_model/AliasedClosedGeneric.m new file mode 100644 index 00000000..af4ce3c6 --- /dev/null +++ b/matlab/generated/+test_model/AliasedClosedGeneric.m @@ -0,0 +1,3 @@ +function c = AliasedClosedGeneric(varargin) + c = test_model.AliasedTuple(varargin{:}); +end diff --git a/matlab/generated/+test_model/AliasedEnum.m b/matlab/generated/+test_model/AliasedEnum.m new file mode 100644 index 00000000..eddc1e37 --- /dev/null +++ b/matlab/generated/+test_model/AliasedEnum.m @@ -0,0 +1,2 @@ +classdef AliasedEnum < test_model.Fruits +end diff --git a/matlab/generated/+test_model/AliasedGenericDynamicArray.m b/matlab/generated/+test_model/AliasedGenericDynamicArray.m new file mode 100644 index 00000000..f91ac2c2 --- /dev/null +++ b/matlab/generated/+test_model/AliasedGenericDynamicArray.m @@ -0,0 +1,3 @@ +function a = AliasedGenericDynamicArray(array) + a = array; +end diff --git a/matlab/generated/+test_model/AliasedGenericFixedArray.m b/matlab/generated/+test_model/AliasedGenericFixedArray.m new file mode 100644 index 00000000..a9c65819 --- /dev/null +++ b/matlab/generated/+test_model/AliasedGenericFixedArray.m @@ -0,0 +1,3 @@ +function a = AliasedGenericFixedArray(array) + a = array; +end diff --git a/matlab/generated/+test_model/AliasedGenericFixedVector.m b/matlab/generated/+test_model/AliasedGenericFixedVector.m new file mode 100644 index 00000000..ee32e8c6 --- /dev/null +++ b/matlab/generated/+test_model/AliasedGenericFixedVector.m @@ -0,0 +1,3 @@ +function a = AliasedGenericFixedVector(array) + a = array; +end diff --git a/matlab/generated/+test_model/AliasedGenericOptional.m b/matlab/generated/+test_model/AliasedGenericOptional.m new file mode 100644 index 00000000..105e7225 --- /dev/null +++ b/matlab/generated/+test_model/AliasedGenericOptional.m @@ -0,0 +1,3 @@ +function o = AliasedGenericOptional(value) + o = yardl.Optional(value); +end diff --git a/matlab/generated/+test_model/AliasedGenericRank2Array.m b/matlab/generated/+test_model/AliasedGenericRank2Array.m new file mode 100644 index 00000000..5a189484 --- /dev/null +++ b/matlab/generated/+test_model/AliasedGenericRank2Array.m @@ -0,0 +1,3 @@ +function a = AliasedGenericRank2Array(array) + a = array; +end diff --git a/matlab/generated/+test_model/AliasedGenericUnion2.m b/matlab/generated/+test_model/AliasedGenericUnion2.m new file mode 100644 index 00000000..6c6a1d0a --- /dev/null +++ b/matlab/generated/+test_model/AliasedGenericUnion2.m @@ -0,0 +1,2 @@ +classdef AliasedGenericUnion2 < basic_types.GenericUnion2 +end diff --git a/matlab/generated/+test_model/AliasedGenericVector.m b/matlab/generated/+test_model/AliasedGenericVector.m new file mode 100644 index 00000000..29a51410 --- /dev/null +++ b/matlab/generated/+test_model/AliasedGenericVector.m @@ -0,0 +1,3 @@ +function a = AliasedGenericVector(array) + a = array; +end diff --git a/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m b/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m new file mode 100644 index 00000000..2327c56d --- /dev/null +++ b/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m @@ -0,0 +1,34 @@ +classdef AliasedIntOrSimpleRecord < yardl.Union + methods (Static) + function res = Int32(value) + res = test_model.AliasedIntOrSimpleRecord(1, value); + end + + function res = SimpleRecord(value) + res = test_model.AliasedIntOrSimpleRecord(2, value); + end + + function z = zeros(varargin) + elem = test_model.AliasedIntOrSimpleRecord(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.AliasedIntOrSimpleRecord') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/AliasedMap.m b/matlab/generated/+test_model/AliasedMap.m new file mode 100644 index 00000000..b43ebbcd --- /dev/null +++ b/matlab/generated/+test_model/AliasedMap.m @@ -0,0 +1,2 @@ +classdef AliasedMap < basic_types.AliasedMap +end diff --git a/matlab/generated/+test_model/AliasedMultiGenericOptional.m b/matlab/generated/+test_model/AliasedMultiGenericOptional.m new file mode 100644 index 00000000..0fc4c0d4 --- /dev/null +++ b/matlab/generated/+test_model/AliasedMultiGenericOptional.m @@ -0,0 +1,34 @@ +classdef AliasedMultiGenericOptional < yardl.Union + methods (Static) + function res = T(value) + res = test_model.AliasedMultiGenericOptional(1, value); + end + + function res = U(value) + res = test_model.AliasedMultiGenericOptional(2, value); + end + + function z = zeros(varargin) + elem = test_model.AliasedMultiGenericOptional(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.AliasedMultiGenericOptional') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m b/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m new file mode 100644 index 00000000..c6ab4744 --- /dev/null +++ b/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m @@ -0,0 +1,34 @@ +classdef AliasedNullableIntSimpleRecord < yardl.Union + methods (Static) + function res = Int32(value) + res = test_model.AliasedNullableIntSimpleRecord(1, value); + end + + function res = SimpleRecord(value) + res = test_model.AliasedNullableIntSimpleRecord(2, value); + end + + function z = zeros(varargin) + elem = test_model.AliasedNullableIntSimpleRecord(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.AliasedNullableIntSimpleRecord') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/AliasedOpenGeneric.m b/matlab/generated/+test_model/AliasedOpenGeneric.m new file mode 100644 index 00000000..b097107b --- /dev/null +++ b/matlab/generated/+test_model/AliasedOpenGeneric.m @@ -0,0 +1,3 @@ +function c = AliasedOpenGeneric(varargin) + c = test_model.AliasedTuple(varargin{:}); +end diff --git a/matlab/generated/+test_model/AliasedOptional.m b/matlab/generated/+test_model/AliasedOptional.m new file mode 100644 index 00000000..16300e57 --- /dev/null +++ b/matlab/generated/+test_model/AliasedOptional.m @@ -0,0 +1,4 @@ +function o = AliasedOptional(value) + assert(isa(value, 'int32')); + o = yardl.Optional(value); +end diff --git a/matlab/generated/+test_model/AliasedString.m b/matlab/generated/+test_model/AliasedString.m new file mode 100644 index 00000000..6d0543af --- /dev/null +++ b/matlab/generated/+test_model/AliasedString.m @@ -0,0 +1,2 @@ +classdef AliasedString < string +end diff --git a/matlab/generated/+test_model/AliasedTuple.m b/matlab/generated/+test_model/AliasedTuple.m new file mode 100644 index 00000000..cb12c1de --- /dev/null +++ b/matlab/generated/+test_model/AliasedTuple.m @@ -0,0 +1,3 @@ +function c = AliasedTuple(varargin) + c = test_model.MyTuple(varargin{:}); +end diff --git a/matlab/generated/+test_model/AliasedVectorOfGenericRecords.m b/matlab/generated/+test_model/AliasedVectorOfGenericRecords.m new file mode 100644 index 00000000..0468bede --- /dev/null +++ b/matlab/generated/+test_model/AliasedVectorOfGenericRecords.m @@ -0,0 +1,3 @@ +function a = AliasedVectorOfGenericRecords(array) + a = array; +end diff --git a/matlab/generated/+test_model/AliasesReaderBase.m b/matlab/generated/+test_model/AliasesReaderBase.m new file mode 100644 index 00000000..07a86314 --- /dev/null +++ b/matlab/generated/+test_model/AliasesReaderBase.m @@ -0,0 +1,192 @@ +classdef AliasesReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = AliasesReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 20 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_aliased_string(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_aliased_string_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_aliased_enum(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_aliased_enum_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_aliased_open_generic(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_aliased_open_generic_(); + obj.state_ = 6; + end + + % Ordinal 3 + function value = read_aliased_closed_generic(obj) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + value = obj.read_aliased_closed_generic_(); + obj.state_ = 8; + end + + % Ordinal 4 + function value = read_aliased_optional(obj) + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); + end + + value = obj.read_aliased_optional_(); + obj.state_ = 10; + end + + % Ordinal 5 + function value = read_aliased_generic_optional(obj) + if obj.state_ ~= 10 + obj.raise_unexpected_state_(10); + end + + value = obj.read_aliased_generic_optional_(); + obj.state_ = 12; + end + + % Ordinal 6 + function value = read_aliased_generic_union_2(obj) + if obj.state_ ~= 12 + obj.raise_unexpected_state_(12); + end + + value = obj.read_aliased_generic_union_2_(); + obj.state_ = 14; + end + + % Ordinal 7 + function value = read_aliased_generic_vector(obj) + if obj.state_ ~= 14 + obj.raise_unexpected_state_(14); + end + + value = obj.read_aliased_generic_vector_(); + obj.state_ = 16; + end + + % Ordinal 8 + function value = read_aliased_generic_fixed_vector(obj) + if obj.state_ ~= 16 + obj.raise_unexpected_state_(16); + end + + value = obj.read_aliased_generic_fixed_vector_(); + obj.state_ = 18; + end + + % Ordinal 9 + function value = read_stream_of_aliased_generic_union_2(obj) + if obj.state_ ~= 18 + obj.raise_unexpected_state_(18); + end + + value = obj.read_stream_of_aliased_generic_union_2_(); + obj.state_ = 20; + end + + function copy_to(obj, writer) + writer.write_aliased_string(obj.read_aliased_string()); + writer.write_aliased_enum(obj.read_aliased_enum()); + writer.write_aliased_open_generic(obj.read_aliased_open_generic()); + writer.write_aliased_closed_generic(obj.read_aliased_closed_generic()); + writer.write_aliased_optional(obj.read_aliased_optional()); + writer.write_aliased_generic_optional(obj.read_aliased_generic_optional()); + writer.write_aliased_generic_union_2(obj.read_aliased_generic_union_2()); + writer.write_aliased_generic_vector(obj.read_aliased_generic_vector()); + writer.write_aliased_generic_fixed_vector(obj.read_aliased_generic_fixed_vector()); + writer.write_stream_of_aliased_generic_union_2(obj.read_stream_of_aliased_generic_union_2()); + end + end + + methods (Static) + function res = schema() + res = test_model.AliasesWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_aliased_string_(obj, value) + read_aliased_enum_(obj, value) + read_aliased_open_generic_(obj, value) + read_aliased_closed_generic_(obj, value) + read_aliased_optional_(obj, value) + read_aliased_generic_optional_(obj, value) + read_aliased_generic_union_2_(obj, value) + read_aliased_generic_vector_(obj, value) + read_aliased_generic_fixed_vector_(obj, value) + read_stream_of_aliased_generic_union_2_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_aliased_string'; + elseif state == 2 + name = 'read_aliased_enum'; + elseif state == 4 + name = 'read_aliased_open_generic'; + elseif state == 6 + name = 'read_aliased_closed_generic'; + elseif state == 8 + name = 'read_aliased_optional'; + elseif state == 10 + name = 'read_aliased_generic_optional'; + elseif state == 12 + name = 'read_aliased_generic_union_2'; + elseif state == 14 + name = 'read_aliased_generic_vector'; + elseif state == 16 + name = 'read_aliased_generic_fixed_vector'; + elseif state == 18 + name = 'read_stream_of_aliased_generic_union_2'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/AliasesWriterBase.m b/matlab/generated/+test_model/AliasesWriterBase.m new file mode 100644 index 00000000..1af33872 --- /dev/null +++ b/matlab/generated/+test_model/AliasesWriterBase.m @@ -0,0 +1,181 @@ +% Abstract writer for protocol Aliases +classdef (Abstract) AliasesWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = AliasesWriterBase() + obj.state_ = 0; + end + + function close(obj) + if obj.state_ == 19 + obj.end_stream_(); + obj.close_(); + return + end + obj.close_(); + if obj.state_ ~= 20 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_aliased_string(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_aliased_string_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_aliased_enum(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_aliased_enum_(value); + obj.state_ = 4; + end + + % Ordinal 2 + function write_aliased_open_generic(obj, value) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_aliased_open_generic_(value); + obj.state_ = 6; + end + + % Ordinal 3 + function write_aliased_closed_generic(obj, value) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + obj.write_aliased_closed_generic_(value); + obj.state_ = 8; + end + + % Ordinal 4 + function write_aliased_optional(obj, value) + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); + end + + obj.write_aliased_optional_(value); + obj.state_ = 10; + end + + % Ordinal 5 + function write_aliased_generic_optional(obj, value) + if obj.state_ ~= 10 + obj.raise_unexpected_state_(10); + end + + obj.write_aliased_generic_optional_(value); + obj.state_ = 12; + end + + % Ordinal 6 + function write_aliased_generic_union_2(obj, value) + if obj.state_ ~= 12 + obj.raise_unexpected_state_(12); + end + + obj.write_aliased_generic_union_2_(value); + obj.state_ = 14; + end + + % Ordinal 7 + function write_aliased_generic_vector(obj, value) + if obj.state_ ~= 14 + obj.raise_unexpected_state_(14); + end + + obj.write_aliased_generic_vector_(value); + obj.state_ = 16; + end + + % Ordinal 8 + function write_aliased_generic_fixed_vector(obj, value) + if obj.state_ ~= 16 + obj.raise_unexpected_state_(16); + end + + obj.write_aliased_generic_fixed_vector_(value); + obj.state_ = 18; + end + + % Ordinal 9 + function write_stream_of_aliased_generic_union_2(obj, value) + if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 18 + obj.raise_unexpected_state_(18); + end + + obj.write_stream_of_aliased_generic_union_2_(value); + obj.state_ = 19; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"Aliases","sequence":[{"name":"aliasedString","type":"TestModel.AliasedString"},{"name":"aliasedEnum","type":"TestModel.AliasedEnum"},{"name":"aliasedOpenGeneric","type":{"name":"TestModel.AliasedOpenGeneric","typeArguments":["TestModel.AliasedString","TestModel.AliasedEnum"]}},{"name":"aliasedClosedGeneric","type":"TestModel.AliasedClosedGeneric"},{"name":"aliasedOptional","type":"TestModel.AliasedOptional"},{"name":"aliasedGenericOptional","type":{"name":"TestModel.AliasedGenericOptional","typeArguments":["float32"]}},{"name":"aliasedGenericUnion2","type":{"name":"TestModel.AliasedGenericUnion2","typeArguments":["TestModel.AliasedString","TestModel.AliasedEnum"]}},{"name":"aliasedGenericVector","type":{"name":"TestModel.AliasedGenericVector","typeArguments":["float32"]}},{"name":"aliasedGenericFixedVector","type":{"name":"TestModel.AliasedGenericFixedVector","typeArguments":["float32"]}},{"name":"streamOfAliasedGenericUnion2","type":{"stream":{"items":{"name":"TestModel.AliasedGenericUnion2","typeArguments":["TestModel.AliasedString","TestModel.AliasedEnum"]}}}}]},"types":[{"name":"Fruits","values":[{"symbol":"apple","value":0},{"symbol":"banana","value":1},{"symbol":"pear","value":2}]},{"name":"GenericUnion2","typeParameters":["T1","T2"],"type":[{"tag":"T1","type":"T1"},{"tag":"T2","type":"T2"}]},{"name":"GenericVector","typeParameters":["T"],"type":{"vector":{"items":"T"}}},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"Tuples.Tuple","typeArguments":["T1","T2"]}},{"name":"AliasedClosedGeneric","type":{"name":"TestModel.AliasedTuple","typeArguments":["TestModel.AliasedString","TestModel.AliasedEnum"]}},{"name":"AliasedEnum","type":"TestModel.Fruits"},{"name":"AliasedGenericFixedVector","typeParameters":["T"],"type":{"vector":{"items":"T","length":3}}},{"name":"AliasedGenericOptional","typeParameters":["T"],"type":[null,"T"]},{"name":"AliasedGenericUnion2","typeParameters":["T1","T2"],"type":{"name":"BasicTypes.GenericUnion2","typeArguments":["T1","T2"]}},{"name":"AliasedGenericVector","typeParameters":["T"],"type":{"name":"BasicTypes.GenericVector","typeArguments":["T"]}},{"name":"AliasedOpenGeneric","typeParameters":["T1","T2"],"type":{"name":"TestModel.AliasedTuple","typeArguments":["T1","T2"]}},{"name":"AliasedOptional","type":[null,"int32"]},{"name":"AliasedString","type":"string"},{"name":"AliasedTuple","typeParameters":["T1","T2"],"type":{"name":"TestModel.MyTuple","typeArguments":["T1","T2"]}},{"name":"Fruits","type":"BasicTypes.Fruits"},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"BasicTypes.MyTuple","typeArguments":["T1","T2"]}},{"name":"Tuple","typeParameters":["T1","T2"],"fields":[{"name":"v1","type":"T1"},{"name":"v2","type":"T2"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_aliased_string_(obj, value) + write_aliased_enum_(obj, value) + write_aliased_open_generic_(obj, value) + write_aliased_closed_generic_(obj, value) + write_aliased_optional_(obj, value) + write_aliased_generic_optional_(obj, value) + write_aliased_generic_union_2_(obj, value) + write_aliased_generic_vector_(obj, value) + write_aliased_generic_fixed_vector_(obj, value) + write_stream_of_aliased_generic_union_2_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_aliased_string'; + elseif state == 2 + name = 'write_aliased_enum'; + elseif state == 4 + name = 'write_aliased_open_generic'; + elseif state == 6 + name = 'write_aliased_closed_generic'; + elseif state == 8 + name = 'write_aliased_optional'; + elseif state == 10 + name = 'write_aliased_generic_optional'; + elseif state == 12 + name = 'write_aliased_generic_union_2'; + elseif state == 14 + name = 'write_aliased_generic_vector'; + elseif state == 16 + name = 'write_aliased_generic_fixed_vector'; + elseif state == 18 + name = 'write_stream_of_aliased_generic_union_2'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/ArrayOrScalar.m b/matlab/generated/+test_model/ArrayOrScalar.m new file mode 100644 index 00000000..a7846baa --- /dev/null +++ b/matlab/generated/+test_model/ArrayOrScalar.m @@ -0,0 +1,34 @@ +classdef ArrayOrScalar < yardl.Union + methods (Static) + function res = Array(value) + res = test_model.ArrayOrScalar(1, value); + end + + function res = Scalar(value) + res = test_model.ArrayOrScalar(2, value); + end + + function z = zeros(varargin) + elem = test_model.ArrayOrScalar(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.ArrayOrScalar') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m b/matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m new file mode 100644 index 00000000..150da874 --- /dev/null +++ b/matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m @@ -0,0 +1,4 @@ +function a = ArrayWithKeywordDimensionNames(array) + assert(isa(array, 'int32')); + a = array; +end diff --git a/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m b/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m new file mode 100644 index 00000000..23260744 --- /dev/null +++ b/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m @@ -0,0 +1,66 @@ +classdef BenchmarkFloat256x256ReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = BenchmarkFloat256x256ReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 2 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_float256x256(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_float256x256_(); + obj.state_ = 2; + end + + function copy_to(obj, writer) + writer.write_float256x256(obj.read_float256x256()); + end + end + + methods (Static) + function res = schema() + res = test_model.BenchmarkFloat256x256WriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_float256x256_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_float256x256'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m b/matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m new file mode 100644 index 00000000..6fa2f95c --- /dev/null +++ b/matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m @@ -0,0 +1,64 @@ +% Abstract writer for protocol BenchmarkFloat256x256 +classdef (Abstract) BenchmarkFloat256x256WriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = BenchmarkFloat256x256WriterBase() + obj.state_ = 0; + end + + function close(obj) + if obj.state_ == 1 + obj.end_stream_(); + obj.close_(); + return + end + obj.close_(); + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_float256x256(obj, value) + if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_float256x256_(value); + obj.state_ = 1; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"BenchmarkFloat256x256","sequence":[{"name":"float256x256","type":{"stream":{"items":{"array":{"items":"float32","dimensions":[{"length":256},{"length":256}]}}}}}]},"types":null}'); + end + end + + methods (Abstract, Access=protected) + write_float256x256_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_float256x256'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m b/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m new file mode 100644 index 00000000..7fdc4450 --- /dev/null +++ b/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m @@ -0,0 +1,66 @@ +classdef BenchmarkFloatVlenReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = BenchmarkFloatVlenReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 2 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_float_array(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_float_array_(); + obj.state_ = 2; + end + + function copy_to(obj, writer) + writer.write_float_array(obj.read_float_array()); + end + end + + methods (Static) + function res = schema() + res = test_model.BenchmarkFloatVlenWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_float_array_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_float_array'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m b/matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m new file mode 100644 index 00000000..54566c80 --- /dev/null +++ b/matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m @@ -0,0 +1,64 @@ +% Abstract writer for protocol BenchmarkFloatVlen +classdef (Abstract) BenchmarkFloatVlenWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = BenchmarkFloatVlenWriterBase() + obj.state_ = 0; + end + + function close(obj) + if obj.state_ == 1 + obj.end_stream_(); + obj.close_(); + return + end + obj.close_(); + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_float_array(obj, value) + if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_float_array_(value); + obj.state_ = 1; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"BenchmarkFloatVlen","sequence":[{"name":"floatArray","type":{"stream":{"items":{"array":{"items":"float32","dimensions":2}}}}}]},"types":null}'); + end + end + + methods (Abstract, Access=protected) + write_float_array_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_float_array'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m b/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m new file mode 100644 index 00000000..7757629f --- /dev/null +++ b/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m @@ -0,0 +1,66 @@ +classdef BenchmarkInt256x256ReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = BenchmarkInt256x256ReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 2 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_int256x256(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_int256x256_(); + obj.state_ = 2; + end + + function copy_to(obj, writer) + writer.write_int256x256(obj.read_int256x256()); + end + end + + methods (Static) + function res = schema() + res = test_model.BenchmarkInt256x256WriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_int256x256_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_int256x256'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m b/matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m new file mode 100644 index 00000000..3c3262e2 --- /dev/null +++ b/matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m @@ -0,0 +1,64 @@ +% Abstract writer for protocol BenchmarkInt256x256 +classdef (Abstract) BenchmarkInt256x256WriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = BenchmarkInt256x256WriterBase() + obj.state_ = 0; + end + + function close(obj) + if obj.state_ == 1 + obj.end_stream_(); + obj.close_(); + return + end + obj.close_(); + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_int256x256(obj, value) + if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_int256x256_(value); + obj.state_ = 1; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"BenchmarkInt256x256","sequence":[{"name":"int256x256","type":{"stream":{"items":{"array":{"items":"int32","dimensions":[{"length":256},{"length":256}]}}}}}]},"types":null}'); + end + end + + methods (Abstract, Access=protected) + write_int256x256_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_int256x256'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m b/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m new file mode 100644 index 00000000..05eaea61 --- /dev/null +++ b/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m @@ -0,0 +1,66 @@ +classdef BenchmarkSimpleMrdReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = BenchmarkSimpleMrdReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 2 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_data(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_data_(); + obj.state_ = 2; + end + + function copy_to(obj, writer) + writer.write_data(obj.read_data()); + end + end + + methods (Static) + function res = schema() + res = test_model.BenchmarkSimpleMrdWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_data_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_data'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m b/matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m new file mode 100644 index 00000000..0e5b6574 --- /dev/null +++ b/matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m @@ -0,0 +1,64 @@ +% Abstract writer for protocol BenchmarkSimpleMrd +classdef (Abstract) BenchmarkSimpleMrdWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = BenchmarkSimpleMrdWriterBase() + obj.state_ = 0; + end + + function close(obj) + if obj.state_ == 1 + obj.end_stream_(); + obj.close_(); + return + end + obj.close_(); + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_data(obj, value) + if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_data_(value); + obj.state_ = 1; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"BenchmarkSimpleMrd","sequence":[{"name":"data","type":{"stream":{"items":[{"tag":"acquisition","explicitTag":true,"type":"TestModel.SimpleAcquisition"},{"tag":"image","explicitTag":true,"type":{"name":"Image.Image","typeArguments":["float32"]}}]}}}]},"types":[{"name":"Image","typeParameters":["T"],"type":{"array":{"items":"T","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"SimpleAcquisition","fields":[{"name":"flags","type":"uint64"},{"name":"idx","type":"TestModel.SimpleEncodingCounters"},{"name":"data","type":{"array":{"items":"complexfloat32","dimensions":2}}},{"name":"trajectory","type":{"array":{"items":"float32","dimensions":2}}}]},{"name":"SimpleEncodingCounters","fields":[{"name":"e1","type":[null,"uint32"]},{"name":"e2","type":[null,"uint32"]},{"name":"slice","type":[null,"uint32"]},{"name":"repetition","type":[null,"uint32"]}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_data_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_data'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m new file mode 100644 index 00000000..6693b79f --- /dev/null +++ b/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m @@ -0,0 +1,66 @@ +classdef BenchmarkSmallRecordReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = BenchmarkSmallRecordReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 2 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_small_record(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_small_record_(); + obj.state_ = 2; + end + + function copy_to(obj, writer) + writer.write_small_record(obj.read_small_record()); + end + end + + methods (Static) + function res = schema() + res = test_model.BenchmarkSmallRecordWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_small_record_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_small_record'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m new file mode 100644 index 00000000..7609c90f --- /dev/null +++ b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m @@ -0,0 +1,66 @@ +classdef BenchmarkSmallRecordWithOptionalsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = BenchmarkSmallRecordWithOptionalsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 2 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_small_record(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_small_record_(); + obj.state_ = 2; + end + + function copy_to(obj, writer) + writer.write_small_record(obj.read_small_record()); + end + end + + methods (Static) + function res = schema() + res = test_model.BenchmarkSmallRecordWithOptionalsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_small_record_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_small_record'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m new file mode 100644 index 00000000..fa8da61b --- /dev/null +++ b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m @@ -0,0 +1,64 @@ +% Abstract writer for protocol BenchmarkSmallRecordWithOptionals +classdef (Abstract) BenchmarkSmallRecordWithOptionalsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = BenchmarkSmallRecordWithOptionalsWriterBase() + obj.state_ = 0; + end + + function close(obj) + if obj.state_ == 1 + obj.end_stream_(); + obj.close_(); + return + end + obj.close_(); + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_small_record(obj, value) + if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_small_record_(value); + obj.state_ = 1; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"BenchmarkSmallRecordWithOptionals","sequence":[{"name":"smallRecord","type":{"stream":{"items":"TestModel.SimpleEncodingCounters"}}}]},"types":[{"name":"SimpleEncodingCounters","fields":[{"name":"e1","type":[null,"uint32"]},{"name":"e2","type":[null,"uint32"]},{"name":"slice","type":[null,"uint32"]},{"name":"repetition","type":[null,"uint32"]}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_small_record_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_small_record'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m new file mode 100644 index 00000000..d37abe65 --- /dev/null +++ b/matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m @@ -0,0 +1,64 @@ +% Abstract writer for protocol BenchmarkSmallRecord +classdef (Abstract) BenchmarkSmallRecordWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = BenchmarkSmallRecordWriterBase() + obj.state_ = 0; + end + + function close(obj) + if obj.state_ == 1 + obj.end_stream_(); + obj.close_(); + return + end + obj.close_(); + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_small_record(obj, value) + if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_small_record_(value); + obj.state_ = 1; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"BenchmarkSmallRecord","sequence":[{"name":"smallRecord","type":{"stream":{"items":"TestModel.SmallBenchmarkRecord"}}}]},"types":[{"name":"SmallBenchmarkRecord","fields":[{"name":"a","type":"float64"},{"name":"b","type":"float32"},{"name":"c","type":"float32"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_small_record_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_small_record'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/DaysOfWeek.m b/matlab/generated/+test_model/DaysOfWeek.m new file mode 100644 index 00000000..8319dd22 --- /dev/null +++ b/matlab/generated/+test_model/DaysOfWeek.m @@ -0,0 +1,2 @@ +classdef DaysOfWeek < basic_types.DaysOfWeek +end diff --git a/matlab/generated/+test_model/DynamicNDArraysReaderBase.m b/matlab/generated/+test_model/DynamicNDArraysReaderBase.m new file mode 100644 index 00000000..08813bca --- /dev/null +++ b/matlab/generated/+test_model/DynamicNDArraysReaderBase.m @@ -0,0 +1,108 @@ +classdef DynamicNDArraysReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = DynamicNDArraysReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 8 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_ints(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_ints_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_simple_record_array(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_simple_record_array_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_record_with_vlens_array(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_record_with_vlens_array_(); + obj.state_ = 6; + end + + % Ordinal 3 + function value = read_record_with_dynamic_nd_arrays(obj) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + value = obj.read_record_with_dynamic_nd_arrays_(); + obj.state_ = 8; + end + + function copy_to(obj, writer) + writer.write_ints(obj.read_ints()); + writer.write_simple_record_array(obj.read_simple_record_array()); + writer.write_record_with_vlens_array(obj.read_record_with_vlens_array()); + writer.write_record_with_dynamic_nd_arrays(obj.read_record_with_dynamic_nd_arrays()); + end + end + + methods (Static) + function res = schema() + res = test_model.DynamicNDArraysWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_ints_(obj, value) + read_simple_record_array_(obj, value) + read_record_with_vlens_array_(obj, value) + read_record_with_dynamic_nd_arrays_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_ints'; + elseif state == 2 + name = 'read_simple_record_array'; + elseif state == 4 + name = 'read_record_with_vlens_array'; + elseif state == 6 + name = 'read_record_with_dynamic_nd_arrays'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/DynamicNDArraysWriterBase.m b/matlab/generated/+test_model/DynamicNDArraysWriterBase.m new file mode 100644 index 00000000..b6a9d582 --- /dev/null +++ b/matlab/generated/+test_model/DynamicNDArraysWriterBase.m @@ -0,0 +1,98 @@ +% Abstract writer for protocol DynamicNDArrays +classdef (Abstract) DynamicNDArraysWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = DynamicNDArraysWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 8 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_ints(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_ints_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_simple_record_array(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_simple_record_array_(value); + obj.state_ = 4; + end + + % Ordinal 2 + function write_record_with_vlens_array(obj, value) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_record_with_vlens_array_(value); + obj.state_ = 6; + end + + % Ordinal 3 + function write_record_with_dynamic_nd_arrays(obj, value) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + obj.write_record_with_dynamic_nd_arrays_(value); + obj.state_ = 8; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"DynamicNDArrays","sequence":[{"name":"ints","type":{"array":{"items":"int32"}}},{"name":"simpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord"}}},{"name":"recordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens"}}},{"name":"recordWithDynamicNDArrays","type":"TestModel.RecordWithDynamicNDArrays"}]},"types":[{"name":"IntArray","type":{"array":{"items":"int32"}}},{"name":"RecordWithDynamicNDArrays","fields":[{"name":"ints","type":"TestModel.IntArray"},{"name":"simpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord"}}},{"name":"recordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens"}}}]},{"name":"RecordWithVlens","fields":[{"name":"a","type":{"vector":{"items":"TestModel.SimpleRecord"}}},{"name":"b","type":"int32"},{"name":"c","type":"int32"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_ints_(obj, value) + write_simple_record_array_(obj, value) + write_record_with_vlens_array_(obj, value) + write_record_with_dynamic_nd_arrays_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_ints'; + elseif state == 2 + name = 'write_simple_record_array'; + elseif state == 4 + name = 'write_record_with_vlens_array'; + elseif state == 6 + name = 'write_record_with_dynamic_nd_arrays'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/EnumWithKeywordSymbols.m b/matlab/generated/+test_model/EnumWithKeywordSymbols.m new file mode 100644 index 00000000..ca97c633 --- /dev/null +++ b/matlab/generated/+test_model/EnumWithKeywordSymbols.m @@ -0,0 +1,23 @@ +classdef EnumWithKeywordSymbols < uint64 + methods (Static) + function e = TRY + e = test_model.EnumWithKeywordSymbols(2); + end + function e = CATCH + e = test_model.EnumWithKeywordSymbols(1); + end + + function z = zeros(varargin) + elem = test_model.EnumWithKeywordSymbols(0); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/EnumsReaderBase.m b/matlab/generated/+test_model/EnumsReaderBase.m new file mode 100644 index 00000000..682fda77 --- /dev/null +++ b/matlab/generated/+test_model/EnumsReaderBase.m @@ -0,0 +1,94 @@ +classdef EnumsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = EnumsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 6 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_single(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_single_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_vec(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_vec_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_size(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_size_(); + obj.state_ = 6; + end + + function copy_to(obj, writer) + writer.write_single(obj.read_single()); + writer.write_vec(obj.read_vec()); + writer.write_size(obj.read_size()); + end + end + + methods (Static) + function res = schema() + res = test_model.EnumsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_single_(obj, value) + read_vec_(obj, value) + read_size_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_single'; + elseif state == 2 + name = 'read_vec'; + elseif state == 4 + name = 'read_size'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/EnumsWriterBase.m b/matlab/generated/+test_model/EnumsWriterBase.m new file mode 100644 index 00000000..66126816 --- /dev/null +++ b/matlab/generated/+test_model/EnumsWriterBase.m @@ -0,0 +1,85 @@ +% Abstract writer for protocol Enums +classdef (Abstract) EnumsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = EnumsWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 6 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_single(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_single_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_vec(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_vec_(value); + obj.state_ = 4; + end + + % Ordinal 2 + function write_size(obj, value) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_size_(value); + obj.state_ = 6; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"Enums","sequence":[{"name":"single","type":"TestModel.Fruits"},{"name":"vec","type":{"vector":{"items":"TestModel.Fruits"}}},{"name":"size","type":"TestModel.SizeBasedEnum"}]},"types":[{"name":"Fruits","values":[{"symbol":"apple","value":0},{"symbol":"banana","value":1},{"symbol":"pear","value":2}]},{"name":"Fruits","type":"BasicTypes.Fruits"},{"name":"SizeBasedEnum","base":"size","values":[{"symbol":"a","value":0},{"symbol":"b","value":1},{"symbol":"c","value":2}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_single_(obj, value) + write_vec_(obj, value) + write_size_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_single'; + elseif state == 2 + name = 'write_vec'; + elseif state == 4 + name = 'write_size'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/FixedArraysReaderBase.m b/matlab/generated/+test_model/FixedArraysReaderBase.m new file mode 100644 index 00000000..a9520467 --- /dev/null +++ b/matlab/generated/+test_model/FixedArraysReaderBase.m @@ -0,0 +1,122 @@ +classdef FixedArraysReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = FixedArraysReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 10 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_ints(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_ints_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_fixed_simple_record_array(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_fixed_simple_record_array_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_fixed_record_with_vlens_array(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_fixed_record_with_vlens_array_(); + obj.state_ = 6; + end + + % Ordinal 3 + function value = read_record_with_fixed_arrays(obj) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + value = obj.read_record_with_fixed_arrays_(); + obj.state_ = 8; + end + + % Ordinal 4 + function value = read_named_array(obj) + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); + end + + value = obj.read_named_array_(); + obj.state_ = 10; + end + + function copy_to(obj, writer) + writer.write_ints(obj.read_ints()); + writer.write_fixed_simple_record_array(obj.read_fixed_simple_record_array()); + writer.write_fixed_record_with_vlens_array(obj.read_fixed_record_with_vlens_array()); + writer.write_record_with_fixed_arrays(obj.read_record_with_fixed_arrays()); + writer.write_named_array(obj.read_named_array()); + end + end + + methods (Static) + function res = schema() + res = test_model.FixedArraysWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_ints_(obj, value) + read_fixed_simple_record_array_(obj, value) + read_fixed_record_with_vlens_array_(obj, value) + read_record_with_fixed_arrays_(obj, value) + read_named_array_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_ints'; + elseif state == 2 + name = 'read_fixed_simple_record_array'; + elseif state == 4 + name = 'read_fixed_record_with_vlens_array'; + elseif state == 6 + name = 'read_record_with_fixed_arrays'; + elseif state == 8 + name = 'read_named_array'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/FixedArraysWriterBase.m b/matlab/generated/+test_model/FixedArraysWriterBase.m new file mode 100644 index 00000000..a1ab7258 --- /dev/null +++ b/matlab/generated/+test_model/FixedArraysWriterBase.m @@ -0,0 +1,111 @@ +% Abstract writer for protocol FixedArrays +classdef (Abstract) FixedArraysWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = FixedArraysWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 10 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_ints(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_ints_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_fixed_simple_record_array(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_fixed_simple_record_array_(value); + obj.state_ = 4; + end + + % Ordinal 2 + function write_fixed_record_with_vlens_array(obj, value) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_fixed_record_with_vlens_array_(value); + obj.state_ = 6; + end + + % Ordinal 3 + function write_record_with_fixed_arrays(obj, value) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + obj.write_record_with_fixed_arrays_(value); + obj.state_ = 8; + end + + % Ordinal 4 + function write_named_array(obj, value) + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); + end + + obj.write_named_array_(value); + obj.state_ = 10; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"FixedArrays","sequence":[{"name":"ints","type":{"array":{"items":"int32","dimensions":[{"length":2},{"length":3}]}}},{"name":"fixedSimpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord","dimensions":[{"length":3},{"length":2}]}}},{"name":"fixedRecordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens","dimensions":[{"length":2},{"length":2}]}}},{"name":"recordWithFixedArrays","type":"TestModel.RecordWithFixedArrays"},{"name":"namedArray","type":"TestModel.NamedFixedNDArray"}]},"types":[{"name":"NamedFixedNDArray","type":{"array":{"items":"int32","dimensions":[{"name":"dimA","length":2},{"name":"dimB","length":4}]}}},{"name":"RecordWithFixedArrays","fields":[{"name":"ints","type":{"array":{"items":"int32","dimensions":[{"length":2},{"length":3}]}}},{"name":"fixedSimpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord","dimensions":[{"length":3},{"length":2}]}}},{"name":"fixedRecordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens","dimensions":[{"length":2},{"length":2}]}}}]},{"name":"RecordWithVlens","fields":[{"name":"a","type":{"vector":{"items":"TestModel.SimpleRecord"}}},{"name":"b","type":"int32"},{"name":"c","type":"int32"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_ints_(obj, value) + write_fixed_simple_record_array_(obj, value) + write_fixed_record_with_vlens_array_(obj, value) + write_record_with_fixed_arrays_(obj, value) + write_named_array_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_ints'; + elseif state == 2 + name = 'write_fixed_simple_record_array'; + elseif state == 4 + name = 'write_fixed_record_with_vlens_array'; + elseif state == 6 + name = 'write_record_with_fixed_arrays'; + elseif state == 8 + name = 'write_named_array'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/FixedVectorsReaderBase.m b/matlab/generated/+test_model/FixedVectorsReaderBase.m new file mode 100644 index 00000000..4a58820d --- /dev/null +++ b/matlab/generated/+test_model/FixedVectorsReaderBase.m @@ -0,0 +1,108 @@ +classdef FixedVectorsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = FixedVectorsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 8 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_fixed_int_vector(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_fixed_int_vector_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_fixed_simple_record_vector(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_fixed_simple_record_vector_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_fixed_record_with_vlens_vector(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_fixed_record_with_vlens_vector_(); + obj.state_ = 6; + end + + % Ordinal 3 + function value = read_record_with_fixed_vectors(obj) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + value = obj.read_record_with_fixed_vectors_(); + obj.state_ = 8; + end + + function copy_to(obj, writer) + writer.write_fixed_int_vector(obj.read_fixed_int_vector()); + writer.write_fixed_simple_record_vector(obj.read_fixed_simple_record_vector()); + writer.write_fixed_record_with_vlens_vector(obj.read_fixed_record_with_vlens_vector()); + writer.write_record_with_fixed_vectors(obj.read_record_with_fixed_vectors()); + end + end + + methods (Static) + function res = schema() + res = test_model.FixedVectorsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_fixed_int_vector_(obj, value) + read_fixed_simple_record_vector_(obj, value) + read_fixed_record_with_vlens_vector_(obj, value) + read_record_with_fixed_vectors_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_fixed_int_vector'; + elseif state == 2 + name = 'read_fixed_simple_record_vector'; + elseif state == 4 + name = 'read_fixed_record_with_vlens_vector'; + elseif state == 6 + name = 'read_record_with_fixed_vectors'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/FixedVectorsWriterBase.m b/matlab/generated/+test_model/FixedVectorsWriterBase.m new file mode 100644 index 00000000..8bb116d7 --- /dev/null +++ b/matlab/generated/+test_model/FixedVectorsWriterBase.m @@ -0,0 +1,98 @@ +% Abstract writer for protocol FixedVectors +classdef (Abstract) FixedVectorsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = FixedVectorsWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 8 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_fixed_int_vector(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_fixed_int_vector_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_fixed_simple_record_vector(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_fixed_simple_record_vector_(value); + obj.state_ = 4; + end + + % Ordinal 2 + function write_fixed_record_with_vlens_vector(obj, value) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_fixed_record_with_vlens_vector_(value); + obj.state_ = 6; + end + + % Ordinal 3 + function write_record_with_fixed_vectors(obj, value) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + obj.write_record_with_fixed_vectors_(value); + obj.state_ = 8; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"FixedVectors","sequence":[{"name":"fixedIntVector","type":{"vector":{"items":"int32","length":5}}},{"name":"fixedSimpleRecordVector","type":{"vector":{"items":"TestModel.SimpleRecord","length":3}}},{"name":"fixedRecordWithVlensVector","type":{"vector":{"items":"TestModel.RecordWithVlens","length":2}}},{"name":"recordWithFixedVectors","type":"TestModel.RecordWithFixedVectors"}]},"types":[{"name":"RecordWithFixedVectors","fields":[{"name":"fixedIntVector","type":{"vector":{"items":"int32","length":5}}},{"name":"fixedSimpleRecordVector","type":{"vector":{"items":"TestModel.SimpleRecord","length":3}}},{"name":"fixedRecordWithVlensVector","type":{"vector":{"items":"TestModel.RecordWithVlens","length":2}}}]},{"name":"RecordWithVlens","fields":[{"name":"a","type":{"vector":{"items":"TestModel.SimpleRecord"}}},{"name":"b","type":"int32"},{"name":"c","type":"int32"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_fixed_int_vector_(obj, value) + write_fixed_simple_record_vector_(obj, value) + write_fixed_record_with_vlens_vector_(obj, value) + write_record_with_fixed_vectors_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_fixed_int_vector'; + elseif state == 2 + name = 'write_fixed_simple_record_vector'; + elseif state == 4 + name = 'write_fixed_record_with_vlens_vector'; + elseif state == 6 + name = 'write_record_with_fixed_vectors'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/FlagsReaderBase.m b/matlab/generated/+test_model/FlagsReaderBase.m new file mode 100644 index 00000000..f804c93c --- /dev/null +++ b/matlab/generated/+test_model/FlagsReaderBase.m @@ -0,0 +1,80 @@ +classdef FlagsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = FlagsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 4 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_days(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_days_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_formats(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_formats_(); + obj.state_ = 4; + end + + function copy_to(obj, writer) + writer.write_days(obj.read_days()); + writer.write_formats(obj.read_formats()); + end + end + + methods (Static) + function res = schema() + res = test_model.FlagsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_days_(obj, value) + read_formats_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_days'; + elseif state == 2 + name = 'read_formats'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/FlagsWriterBase.m b/matlab/generated/+test_model/FlagsWriterBase.m new file mode 100644 index 00000000..1ebac798 --- /dev/null +++ b/matlab/generated/+test_model/FlagsWriterBase.m @@ -0,0 +1,80 @@ +% Abstract writer for protocol Flags +classdef (Abstract) FlagsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = FlagsWriterBase() + obj.state_ = 0; + end + + function close(obj) + if obj.state_ == 3 + obj.end_stream_(); + obj.close_(); + return + end + obj.close_(); + if obj.state_ ~= 4 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_days(obj, value) + if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_days_(value); + obj.state_ = 1; + end + + % Ordinal 1 + function write_formats(obj, value) + if obj.state_ == 1 + obj.end_stream_(); + obj.state_ = 2; + elseif bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_formats_(value); + obj.state_ = 3; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"Flags","sequence":[{"name":"days","type":{"stream":{"items":"TestModel.DaysOfWeek"}}},{"name":"formats","type":{"stream":{"items":"TestModel.TextFormat"}}}]},"types":[{"name":"DaysOfWeek","values":[{"symbol":"monday","value":1},{"symbol":"tuesday","value":2},{"symbol":"wednesday","value":4},{"symbol":"thursday","value":8},{"symbol":"friday","value":16},{"symbol":"saturday","value":32},{"symbol":"sunday","value":64}]},{"name":"TextFormat","base":"uint64","values":[{"symbol":"regular","value":0},{"symbol":"bold","value":1},{"symbol":"italic","value":2},{"symbol":"underline","value":4},{"symbol":"strikethrough","value":8}]},{"name":"DaysOfWeek","type":"BasicTypes.DaysOfWeek"},{"name":"TextFormat","type":"BasicTypes.TextFormat"}]}'); + end + end + + methods (Abstract, Access=protected) + write_days_(obj, value) + write_formats_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_days'; + elseif state == 2 + name = 'write_formats'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/Fruits.m b/matlab/generated/+test_model/Fruits.m new file mode 100644 index 00000000..4f975d1c --- /dev/null +++ b/matlab/generated/+test_model/Fruits.m @@ -0,0 +1,2 @@ +classdef Fruits < basic_types.Fruits +end diff --git a/matlab/generated/+test_model/GenericRecord.m b/matlab/generated/+test_model/GenericRecord.m new file mode 100644 index 00000000..af8baa36 --- /dev/null +++ b/matlab/generated/+test_model/GenericRecord.m @@ -0,0 +1,31 @@ +classdef GenericRecord < handle + properties + scalar_1 + scalar_2 + vector_1 + image_2 + end + + methods + function obj = GenericRecord(scalar_1, scalar_2, vector_1, image_2) + obj.scalar_1 = scalar_1; + obj.scalar_2 = scalar_2; + obj.vector_1 = vector_1; + obj.image_2 = image_2; + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.GenericRecord') && ... + isequal(obj.scalar_1, other.scalar_1) && ... + isequal(obj.scalar_2, other.scalar_2) && ... + isequal(obj.vector_1, other.vector_1) && ... + isequal(obj.image_2, other.image_2); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + +end diff --git a/matlab/generated/+test_model/GenericUnion3.m b/matlab/generated/+test_model/GenericUnion3.m new file mode 100644 index 00000000..e666b819 --- /dev/null +++ b/matlab/generated/+test_model/GenericUnion3.m @@ -0,0 +1,38 @@ +classdef GenericUnion3 < yardl.Union + methods (Static) + function res = T(value) + res = test_model.GenericUnion3(1, value); + end + + function res = U(value) + res = test_model.GenericUnion3(2, value); + end + + function res = V(value) + res = test_model.GenericUnion3(3, value); + end + + function z = zeros(varargin) + elem = test_model.GenericUnion3(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.GenericUnion3') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/GenericUnion3Alternate.m b/matlab/generated/+test_model/GenericUnion3Alternate.m new file mode 100644 index 00000000..97dc4d55 --- /dev/null +++ b/matlab/generated/+test_model/GenericUnion3Alternate.m @@ -0,0 +1,38 @@ +classdef GenericUnion3Alternate < yardl.Union + methods (Static) + function res = U(value) + res = test_model.GenericUnion3Alternate(1, value); + end + + function res = V(value) + res = test_model.GenericUnion3Alternate(2, value); + end + + function res = W(value) + res = test_model.GenericUnion3Alternate(3, value); + end + + function z = zeros(varargin) + elem = test_model.GenericUnion3Alternate(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.GenericUnion3Alternate') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m b/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m new file mode 100644 index 00000000..e033a605 --- /dev/null +++ b/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m @@ -0,0 +1,38 @@ +classdef GenericUnionWithRepeatedTypeParameters < yardl.Union + methods (Static) + function res = T(value) + res = test_model.GenericUnionWithRepeatedTypeParameters(1, value); + end + + function res = Tv(value) + res = test_model.GenericUnionWithRepeatedTypeParameters(2, value); + end + + function res = Ta(value) + res = test_model.GenericUnionWithRepeatedTypeParameters(3, value); + end + + function z = zeros(varargin) + elem = test_model.GenericUnionWithRepeatedTypeParameters(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.GenericUnionWithRepeatedTypeParameters') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/Image.m b/matlab/generated/+test_model/Image.m new file mode 100644 index 00000000..4a551748 --- /dev/null +++ b/matlab/generated/+test_model/Image.m @@ -0,0 +1,3 @@ +function a = Image(array) + a = array; +end diff --git a/matlab/generated/+test_model/ImageFloatOrImageDouble.m b/matlab/generated/+test_model/ImageFloatOrImageDouble.m new file mode 100644 index 00000000..7b83ebc6 --- /dev/null +++ b/matlab/generated/+test_model/ImageFloatOrImageDouble.m @@ -0,0 +1,34 @@ +classdef ImageFloatOrImageDouble < yardl.Union + methods (Static) + function res = ImageFloat(value) + res = test_model.ImageFloatOrImageDouble(1, value); + end + + function res = ImageDouble(value) + res = test_model.ImageFloatOrImageDouble(2, value); + end + + function z = zeros(varargin) + elem = test_model.ImageFloatOrImageDouble(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.ImageFloatOrImageDouble') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/Int32OrFloat32.m b/matlab/generated/+test_model/Int32OrFloat32.m new file mode 100644 index 00000000..1ee13ddc --- /dev/null +++ b/matlab/generated/+test_model/Int32OrFloat32.m @@ -0,0 +1,34 @@ +classdef Int32OrFloat32 < yardl.Union + methods (Static) + function res = Int32(value) + res = test_model.Int32OrFloat32(1, value); + end + + function res = Float32(value) + res = test_model.Int32OrFloat32(2, value); + end + + function z = zeros(varargin) + elem = test_model.Int32OrFloat32(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.Int32OrFloat32') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/Int32OrRecordWithVlens.m b/matlab/generated/+test_model/Int32OrRecordWithVlens.m new file mode 100644 index 00000000..f83cf0a8 --- /dev/null +++ b/matlab/generated/+test_model/Int32OrRecordWithVlens.m @@ -0,0 +1,34 @@ +classdef Int32OrRecordWithVlens < yardl.Union + methods (Static) + function res = Int32(value) + res = test_model.Int32OrRecordWithVlens(1, value); + end + + function res = RecordWithVlens(value) + res = test_model.Int32OrRecordWithVlens(2, value); + end + + function z = zeros(varargin) + elem = test_model.Int32OrRecordWithVlens(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.Int32OrRecordWithVlens') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/Int32OrSimpleRecord.m b/matlab/generated/+test_model/Int32OrSimpleRecord.m new file mode 100644 index 00000000..ce8f50b1 --- /dev/null +++ b/matlab/generated/+test_model/Int32OrSimpleRecord.m @@ -0,0 +1,34 @@ +classdef Int32OrSimpleRecord < yardl.Union + methods (Static) + function res = Int32(value) + res = test_model.Int32OrSimpleRecord(1, value); + end + + function res = SimpleRecord(value) + res = test_model.Int32OrSimpleRecord(2, value); + end + + function z = zeros(varargin) + elem = test_model.Int32OrSimpleRecord(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.Int32OrSimpleRecord') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/Int64Enum.m b/matlab/generated/+test_model/Int64Enum.m new file mode 100644 index 00000000..f47191ee --- /dev/null +++ b/matlab/generated/+test_model/Int64Enum.m @@ -0,0 +1,20 @@ +classdef Int64Enum < int64 + methods (Static) + function e = B + e = test_model.Int64Enum(-4611686018427387904); + end + + function z = zeros(varargin) + elem = test_model.Int64Enum(0); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/IntArray.m b/matlab/generated/+test_model/IntArray.m new file mode 100644 index 00000000..e7ca7523 --- /dev/null +++ b/matlab/generated/+test_model/IntArray.m @@ -0,0 +1,4 @@ +function a = IntArray(array) + assert(isa(array, 'int32')); + a = array; +end diff --git a/matlab/generated/+test_model/IntFixedArray.m b/matlab/generated/+test_model/IntFixedArray.m new file mode 100644 index 00000000..b5f4ba89 --- /dev/null +++ b/matlab/generated/+test_model/IntFixedArray.m @@ -0,0 +1,4 @@ +function a = IntFixedArray(array) + assert(isa(array, 'int32')); + a = array; +end diff --git a/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m b/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m new file mode 100644 index 00000000..1be042e5 --- /dev/null +++ b/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m @@ -0,0 +1,34 @@ +classdef IntOrGenericRecordWithComputedFields < yardl.Union + methods (Static) + function res = Int(value) + res = test_model.IntOrGenericRecordWithComputedFields(1, value); + end + + function res = GenericRecordWithComputedFields(value) + res = test_model.IntOrGenericRecordWithComputedFields(2, value); + end + + function z = zeros(varargin) + elem = test_model.IntOrGenericRecordWithComputedFields(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.IntOrGenericRecordWithComputedFields') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/IntRank2Array.m b/matlab/generated/+test_model/IntRank2Array.m new file mode 100644 index 00000000..478edfc6 --- /dev/null +++ b/matlab/generated/+test_model/IntRank2Array.m @@ -0,0 +1,4 @@ +function a = IntRank2Array(array) + assert(isa(array, 'int32')); + a = array; +end diff --git a/matlab/generated/+test_model/MapOrScalar.m b/matlab/generated/+test_model/MapOrScalar.m new file mode 100644 index 00000000..b1b2f1bb --- /dev/null +++ b/matlab/generated/+test_model/MapOrScalar.m @@ -0,0 +1,34 @@ +classdef MapOrScalar < yardl.Union + methods (Static) + function res = Map(value) + res = test_model.MapOrScalar(1, value); + end + + function res = Scalar(value) + res = test_model.MapOrScalar(2, value); + end + + function z = zeros(varargin) + elem = test_model.MapOrScalar(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.MapOrScalar') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/MapsReaderBase.m b/matlab/generated/+test_model/MapsReaderBase.m new file mode 100644 index 00000000..45f0ff60 --- /dev/null +++ b/matlab/generated/+test_model/MapsReaderBase.m @@ -0,0 +1,108 @@ +classdef MapsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = MapsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 8 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_string_to_int(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_string_to_int_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_int_to_string(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_int_to_string_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_string_to_union(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_string_to_union_(); + obj.state_ = 6; + end + + % Ordinal 3 + function value = read_aliased_generic(obj) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + value = obj.read_aliased_generic_(); + obj.state_ = 8; + end + + function copy_to(obj, writer) + writer.write_string_to_int(obj.read_string_to_int()); + writer.write_int_to_string(obj.read_int_to_string()); + writer.write_string_to_union(obj.read_string_to_union()); + writer.write_aliased_generic(obj.read_aliased_generic()); + end + end + + methods (Static) + function res = schema() + res = test_model.MapsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_string_to_int_(obj, value) + read_int_to_string_(obj, value) + read_string_to_union_(obj, value) + read_aliased_generic_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_string_to_int'; + elseif state == 2 + name = 'read_int_to_string'; + elseif state == 4 + name = 'read_string_to_union'; + elseif state == 6 + name = 'read_aliased_generic'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/MapsWriterBase.m b/matlab/generated/+test_model/MapsWriterBase.m new file mode 100644 index 00000000..2591b4a4 --- /dev/null +++ b/matlab/generated/+test_model/MapsWriterBase.m @@ -0,0 +1,98 @@ +% Abstract writer for protocol Maps +classdef (Abstract) MapsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = MapsWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 8 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_string_to_int(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_string_to_int_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_int_to_string(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_int_to_string_(value); + obj.state_ = 4; + end + + % Ordinal 2 + function write_string_to_union(obj, value) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_string_to_union_(value); + obj.state_ = 6; + end + + % Ordinal 3 + function write_aliased_generic(obj, value) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + obj.write_aliased_generic_(value); + obj.state_ = 8; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"Maps","sequence":[{"name":"stringToInt","type":{"map":{"keys":"string","values":"int32"}}},{"name":"intToString","type":{"map":{"keys":"int32","values":"string"}}},{"name":"stringToUnion","type":{"map":{"keys":"string","values":[{"tag":"string","type":"string"},{"tag":"int32","type":"int32"}]}}},{"name":"aliasedGeneric","type":{"name":"BasicTypes.AliasedMap","typeArguments":["string","int32"]}}]},"types":[{"name":"AliasedMap","typeParameters":["K","V"],"type":{"map":{"keys":"K","values":"V"}}}]}'); + end + end + + methods (Abstract, Access=protected) + write_string_to_int_(obj, value) + write_int_to_string_(obj, value) + write_string_to_union_(obj, value) + write_aliased_generic_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_string_to_int'; + elseif state == 2 + name = 'write_int_to_string'; + elseif state == 4 + name = 'write_string_to_union'; + elseif state == 6 + name = 'write_aliased_generic'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/MyTuple.m b/matlab/generated/+test_model/MyTuple.m new file mode 100644 index 00000000..fb10e3d2 --- /dev/null +++ b/matlab/generated/+test_model/MyTuple.m @@ -0,0 +1,3 @@ +function c = MyTuple(varargin) + c = basic_types.MyTuple(varargin{:}); +end diff --git a/matlab/generated/+test_model/NDArraysReaderBase.m b/matlab/generated/+test_model/NDArraysReaderBase.m new file mode 100644 index 00000000..9ef0d452 --- /dev/null +++ b/matlab/generated/+test_model/NDArraysReaderBase.m @@ -0,0 +1,122 @@ +classdef NDArraysReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = NDArraysReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 10 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_ints(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_ints_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_simple_record_array(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_simple_record_array_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_record_with_vlens_array(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_record_with_vlens_array_(); + obj.state_ = 6; + end + + % Ordinal 3 + function value = read_record_with_nd_arrays(obj) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + value = obj.read_record_with_nd_arrays_(); + obj.state_ = 8; + end + + % Ordinal 4 + function value = read_named_array(obj) + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); + end + + value = obj.read_named_array_(); + obj.state_ = 10; + end + + function copy_to(obj, writer) + writer.write_ints(obj.read_ints()); + writer.write_simple_record_array(obj.read_simple_record_array()); + writer.write_record_with_vlens_array(obj.read_record_with_vlens_array()); + writer.write_record_with_nd_arrays(obj.read_record_with_nd_arrays()); + writer.write_named_array(obj.read_named_array()); + end + end + + methods (Static) + function res = schema() + res = test_model.NDArraysWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_ints_(obj, value) + read_simple_record_array_(obj, value) + read_record_with_vlens_array_(obj, value) + read_record_with_nd_arrays_(obj, value) + read_named_array_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_ints'; + elseif state == 2 + name = 'read_simple_record_array'; + elseif state == 4 + name = 'read_record_with_vlens_array'; + elseif state == 6 + name = 'read_record_with_nd_arrays'; + elseif state == 8 + name = 'read_named_array'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m b/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m new file mode 100644 index 00000000..0b4e0768 --- /dev/null +++ b/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m @@ -0,0 +1,108 @@ +classdef NDArraysSingleDimensionReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = NDArraysSingleDimensionReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 8 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_ints(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_ints_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_simple_record_array(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_simple_record_array_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_record_with_vlens_array(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_record_with_vlens_array_(); + obj.state_ = 6; + end + + % Ordinal 3 + function value = read_record_with_nd_arrays(obj) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + value = obj.read_record_with_nd_arrays_(); + obj.state_ = 8; + end + + function copy_to(obj, writer) + writer.write_ints(obj.read_ints()); + writer.write_simple_record_array(obj.read_simple_record_array()); + writer.write_record_with_vlens_array(obj.read_record_with_vlens_array()); + writer.write_record_with_nd_arrays(obj.read_record_with_nd_arrays()); + end + end + + methods (Static) + function res = schema() + res = test_model.NDArraysSingleDimensionWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_ints_(obj, value) + read_simple_record_array_(obj, value) + read_record_with_vlens_array_(obj, value) + read_record_with_nd_arrays_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_ints'; + elseif state == 2 + name = 'read_simple_record_array'; + elseif state == 4 + name = 'read_record_with_vlens_array'; + elseif state == 6 + name = 'read_record_with_nd_arrays'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m b/matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m new file mode 100644 index 00000000..3493a64c --- /dev/null +++ b/matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m @@ -0,0 +1,98 @@ +% Abstract writer for protocol NDArraysSingleDimension +classdef (Abstract) NDArraysSingleDimensionWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = NDArraysSingleDimensionWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 8 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_ints(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_ints_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_simple_record_array(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_simple_record_array_(value); + obj.state_ = 4; + end + + % Ordinal 2 + function write_record_with_vlens_array(obj, value) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_record_with_vlens_array_(value); + obj.state_ = 6; + end + + % Ordinal 3 + function write_record_with_nd_arrays(obj, value) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + obj.write_record_with_nd_arrays_(value); + obj.state_ = 8; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"NDArraysSingleDimension","sequence":[{"name":"ints","type":{"array":{"items":"int32","dimensions":1}}},{"name":"simpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord","dimensions":1}}},{"name":"recordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens","dimensions":1}}},{"name":"recordWithNDArrays","type":"TestModel.RecordWithNDArraysSingleDimension"}]},"types":[{"name":"RecordWithNDArraysSingleDimension","fields":[{"name":"ints","type":{"array":{"items":"int32","dimensions":1}}},{"name":"fixedSimpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord","dimensions":1}}},{"name":"fixedRecordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens","dimensions":1}}}]},{"name":"RecordWithVlens","fields":[{"name":"a","type":{"vector":{"items":"TestModel.SimpleRecord"}}},{"name":"b","type":"int32"},{"name":"c","type":"int32"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_ints_(obj, value) + write_simple_record_array_(obj, value) + write_record_with_vlens_array_(obj, value) + write_record_with_nd_arrays_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_ints'; + elseif state == 2 + name = 'write_simple_record_array'; + elseif state == 4 + name = 'write_record_with_vlens_array'; + elseif state == 6 + name = 'write_record_with_nd_arrays'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/NDArraysWriterBase.m b/matlab/generated/+test_model/NDArraysWriterBase.m new file mode 100644 index 00000000..3b787438 --- /dev/null +++ b/matlab/generated/+test_model/NDArraysWriterBase.m @@ -0,0 +1,111 @@ +% Abstract writer for protocol NDArrays +classdef (Abstract) NDArraysWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = NDArraysWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 10 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_ints(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_ints_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_simple_record_array(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_simple_record_array_(value); + obj.state_ = 4; + end + + % Ordinal 2 + function write_record_with_vlens_array(obj, value) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_record_with_vlens_array_(value); + obj.state_ = 6; + end + + % Ordinal 3 + function write_record_with_nd_arrays(obj, value) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + obj.write_record_with_nd_arrays_(value); + obj.state_ = 8; + end + + % Ordinal 4 + function write_named_array(obj, value) + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); + end + + obj.write_named_array_(value); + obj.state_ = 10; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"NDArrays","sequence":[{"name":"ints","type":{"array":{"items":"int32","dimensions":2}}},{"name":"simpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord","dimensions":2}}},{"name":"recordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens","dimensions":2}}},{"name":"recordWithNDArrays","type":"TestModel.RecordWithNDArrays"},{"name":"namedArray","type":"TestModel.NamedNDArray"}]},"types":[{"name":"NamedNDArray","type":{"array":{"items":"int32","dimensions":[{"name":"dimA"},{"name":"dimB"}]}}},{"name":"RecordWithNDArrays","fields":[{"name":"ints","type":{"array":{"items":"int32","dimensions":2}}},{"name":"fixedSimpleRecordArray","type":{"array":{"items":"TestModel.SimpleRecord","dimensions":2}}},{"name":"fixedRecordWithVlensArray","type":{"array":{"items":"TestModel.RecordWithVlens","dimensions":2}}}]},{"name":"RecordWithVlens","fields":[{"name":"a","type":{"vector":{"items":"TestModel.SimpleRecord"}}},{"name":"b","type":"int32"},{"name":"c","type":"int32"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_ints_(obj, value) + write_simple_record_array_(obj, value) + write_record_with_vlens_array_(obj, value) + write_record_with_nd_arrays_(obj, value) + write_named_array_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_ints'; + elseif state == 2 + name = 'write_simple_record_array'; + elseif state == 4 + name = 'write_record_with_vlens_array'; + elseif state == 6 + name = 'write_record_with_nd_arrays'; + elseif state == 8 + name = 'write_named_array'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/NamedFixedNDArray.m b/matlab/generated/+test_model/NamedFixedNDArray.m new file mode 100644 index 00000000..f28367d9 --- /dev/null +++ b/matlab/generated/+test_model/NamedFixedNDArray.m @@ -0,0 +1,4 @@ +function a = NamedFixedNDArray(array) + assert(isa(array, 'int32')); + a = array; +end diff --git a/matlab/generated/+test_model/NamedNDArray.m b/matlab/generated/+test_model/NamedNDArray.m new file mode 100644 index 00000000..130841da --- /dev/null +++ b/matlab/generated/+test_model/NamedNDArray.m @@ -0,0 +1,4 @@ +function a = NamedNDArray(array) + assert(isa(array, 'int32')); + a = array; +end diff --git a/matlab/generated/+test_model/NestedRecordsReaderBase.m b/matlab/generated/+test_model/NestedRecordsReaderBase.m new file mode 100644 index 00000000..b2dbb8c1 --- /dev/null +++ b/matlab/generated/+test_model/NestedRecordsReaderBase.m @@ -0,0 +1,66 @@ +classdef NestedRecordsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = NestedRecordsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 2 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_tuple_with_records(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_tuple_with_records_(); + obj.state_ = 2; + end + + function copy_to(obj, writer) + writer.write_tuple_with_records(obj.read_tuple_with_records()); + end + end + + methods (Static) + function res = schema() + res = test_model.NestedRecordsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_tuple_with_records_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_tuple_with_records'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/NestedRecordsWriterBase.m b/matlab/generated/+test_model/NestedRecordsWriterBase.m new file mode 100644 index 00000000..c5e354ac --- /dev/null +++ b/matlab/generated/+test_model/NestedRecordsWriterBase.m @@ -0,0 +1,59 @@ +% Abstract writer for protocol NestedRecords +classdef (Abstract) NestedRecordsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = NestedRecordsWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_tuple_with_records(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_tuple_with_records_(value); + obj.state_ = 2; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"NestedRecords","sequence":[{"name":"tupleWithRecords","type":"TestModel.TupleWithRecords"}]},"types":[{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]},{"name":"TupleWithRecords","fields":[{"name":"a","type":"TestModel.SimpleRecord"},{"name":"b","type":"TestModel.SimpleRecord"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_tuple_with_records_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_tuple_with_records'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/OptionalVectorsReaderBase.m b/matlab/generated/+test_model/OptionalVectorsReaderBase.m new file mode 100644 index 00000000..da037aa8 --- /dev/null +++ b/matlab/generated/+test_model/OptionalVectorsReaderBase.m @@ -0,0 +1,66 @@ +classdef OptionalVectorsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = OptionalVectorsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 2 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_record_with_optional_vector(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_record_with_optional_vector_(); + obj.state_ = 2; + end + + function copy_to(obj, writer) + writer.write_record_with_optional_vector(obj.read_record_with_optional_vector()); + end + end + + methods (Static) + function res = schema() + res = test_model.OptionalVectorsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_record_with_optional_vector_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_record_with_optional_vector'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/OptionalVectorsWriterBase.m b/matlab/generated/+test_model/OptionalVectorsWriterBase.m new file mode 100644 index 00000000..d3097346 --- /dev/null +++ b/matlab/generated/+test_model/OptionalVectorsWriterBase.m @@ -0,0 +1,59 @@ +% Abstract writer for protocol OptionalVectors +classdef (Abstract) OptionalVectorsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = OptionalVectorsWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_record_with_optional_vector(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_record_with_optional_vector_(value); + obj.state_ = 2; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"OptionalVectors","sequence":[{"name":"recordWithOptionalVector","type":"TestModel.RecordWithOptionalVector"}]},"types":[{"name":"RecordWithOptionalVector","fields":[{"name":"optionalVector","type":[null,{"vector":{"items":"int32"}}]}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_record_with_optional_vector_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_record_with_optional_vector'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m b/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m new file mode 100644 index 00000000..cf8b641e --- /dev/null +++ b/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m @@ -0,0 +1,66 @@ +classdef ProtocolWithComputedFieldsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = ProtocolWithComputedFieldsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 2 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_record_with_computed_fields(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_record_with_computed_fields_(); + obj.state_ = 2; + end + + function copy_to(obj, writer) + writer.write_record_with_computed_fields(obj.read_record_with_computed_fields()); + end + end + + methods (Static) + function res = schema() + res = test_model.ProtocolWithComputedFieldsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_record_with_computed_fields_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_record_with_computed_fields'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m b/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m new file mode 100644 index 00000000..04b64ea2 --- /dev/null +++ b/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m @@ -0,0 +1,59 @@ +% Abstract writer for protocol ProtocolWithComputedFields +classdef (Abstract) ProtocolWithComputedFieldsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = ProtocolWithComputedFieldsWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_record_with_computed_fields(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_record_with_computed_fields_(value); + obj.state_ = 2; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"ProtocolWithComputedFields","sequence":[{"name":"recordWithComputedFields","type":"TestModel.RecordWithComputedFields"}]},"types":[{"name":"GenericRecordWithComputedFields","typeParameters":["T0","T1"],"fields":[{"name":"f1","type":[{"tag":"T0","type":"T0"},{"tag":"T1","type":"T1"}]}]},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"Tuples.Tuple","typeArguments":["T1","T2"]}},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"BasicTypes.MyTuple","typeArguments":["T1","T2"]}},{"name":"NamedNDArray","type":{"array":{"items":"int32","dimensions":[{"name":"dimA"},{"name":"dimB"}]}}},{"name":"RecordWithComputedFields","fields":[{"name":"arrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"arrayFieldMapDimensions","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"dynamicArrayField","type":{"array":{"items":"int32"}}},{"name":"fixedArrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x","length":3},{"name":"y","length":4}]}}},{"name":"intField","type":"int32"},{"name":"int8Field","type":"int8"},{"name":"uint8Field","type":"uint8"},{"name":"int16Field","type":"int16"},{"name":"uint16Field","type":"uint16"},{"name":"uint32Field","type":"uint32"},{"name":"int64Field","type":"int64"},{"name":"uint64Field","type":"uint64"},{"name":"sizeField","type":"size"},{"name":"float32Field","type":"float32"},{"name":"float64Field","type":"float64"},{"name":"complexfloat32Field","type":"complexfloat32"},{"name":"complexfloat64Field","type":"complexfloat64"},{"name":"stringField","type":"string"},{"name":"tupleField","type":{"name":"TestModel.MyTuple","typeArguments":["int32","int32"]}},{"name":"vectorField","type":{"vector":{"items":"int32"}}},{"name":"vectorOfVectorsField","type":{"vector":{"items":{"vector":{"items":"int32"}}}}},{"name":"fixedVectorField","type":{"vector":{"items":"int32","length":3}}},{"name":"optionalNamedArray","type":[null,"TestModel.NamedNDArray"]},{"name":"intFloatUnion","type":[{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"nullableIntFloatUnion","type":[null,{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"unionWithNestedGenericUnion","type":[{"tag":"int","explicitTag":true,"type":"int32"},{"tag":"genericRecordWithComputedFields","explicitTag":true,"type":{"name":"BasicTypes.GenericRecordWithComputedFields","typeArguments":["string","float32"]}}]},{"name":"mapField","type":{"map":{"keys":"string","values":"string"}}}]},{"name":"Tuple","typeParameters":["T1","T2"],"fields":[{"name":"v1","type":"T1"},{"name":"v2","type":"T2"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_record_with_computed_fields_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_record_with_computed_fields'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m b/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m new file mode 100644 index 00000000..9be3cf39 --- /dev/null +++ b/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m @@ -0,0 +1,80 @@ +classdef ProtocolWithKeywordStepsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = ProtocolWithKeywordStepsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 4 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_int(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_int_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_float(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_float_(); + obj.state_ = 4; + end + + function copy_to(obj, writer) + writer.write_int(obj.read_int()); + writer.write_float(obj.read_float()); + end + end + + methods (Static) + function res = schema() + res = test_model.ProtocolWithKeywordStepsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_int_(obj, value) + read_float_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_int'; + elseif state == 2 + name = 'read_float'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m b/matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m new file mode 100644 index 00000000..c16e05a2 --- /dev/null +++ b/matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m @@ -0,0 +1,75 @@ +% Abstract writer for protocol ProtocolWithKeywordSteps +classdef (Abstract) ProtocolWithKeywordStepsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = ProtocolWithKeywordStepsWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 4 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_int(obj, value) + if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_int_(value); + obj.state_ = 1; + end + + % Ordinal 1 + function write_float(obj, value) + if obj.state_ == 1 + obj.end_stream_(); + obj.state_ = 2; + elseif obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_float_(value); + obj.state_ = 4; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"ProtocolWithKeywordSteps","sequence":[{"name":"int","type":{"stream":{"items":"TestModel.RecordWithKeywordFields"}}},{"name":"float","type":"TestModel.EnumWithKeywordSymbols"}]},"types":[{"name":"ArrayWithKeywordDimensionNames","type":{"array":{"items":"int32","dimensions":[{"name":"while"},{"name":"do"}]}}},{"name":"EnumWithKeywordSymbols","values":[{"symbol":"try","value":2},{"symbol":"catch","value":1}]},{"name":"RecordWithKeywordFields","fields":[{"name":"int","type":"string"},{"name":"sizeof","type":"TestModel.ArrayWithKeywordDimensionNames"},{"name":"if","type":"TestModel.EnumWithKeywordSymbols"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_int_(obj, value) + write_float_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_int'; + elseif state == 2 + name = 'write_float'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/RecordContainingGenericRecords.m b/matlab/generated/+test_model/RecordContainingGenericRecords.m new file mode 100644 index 00000000..0d4f971f --- /dev/null +++ b/matlab/generated/+test_model/RecordContainingGenericRecords.m @@ -0,0 +1,49 @@ +classdef RecordContainingGenericRecords < handle + properties + g1 + g1a + g2 + g2a + g3 + g3a + g4 + g5 + g6 + g7 + end + + methods + function obj = RecordContainingGenericRecords(g1, g1a, g2, g2a, g3, g3a, g4, g5, g6, g7) + obj.g1 = g1; + obj.g1a = g1a; + obj.g2 = g2; + obj.g2a = g2a; + obj.g3 = g3; + obj.g3a = g3a; + obj.g4 = g4; + obj.g5 = g5; + obj.g6 = g6; + obj.g7 = g7; + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordContainingGenericRecords') && ... + isequal(obj.g1, other.g1) && ... + isequal(obj.g1a, other.g1a) && ... + isequal(obj.g2, other.g2) && ... + isequal(obj.g2a, other.g2a) && ... + isequal(obj.g3, other.g3) && ... + isequal(obj.g3a, other.g3a) && ... + isequal(obj.g4, other.g4) && ... + isequal(obj.g5, other.g5) && ... + isequal(obj.g6, other.g6) && ... + isequal(obj.g7, other.g7); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + +end diff --git a/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m b/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m new file mode 100644 index 00000000..b0d60b92 --- /dev/null +++ b/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m @@ -0,0 +1,56 @@ +classdef RecordContainingNestedGenericRecords < handle + properties + f1 + f1a + f2 + f2a + nested + end + + methods + function obj = RecordContainingNestedGenericRecords(f1, f1a, f2, f2a, nested) + if nargin > 0 + obj.f1 = f1; + obj.f1a = f1a; + obj.f2 = f2; + obj.f2a = f2a; + obj.nested = nested; + else + obj.f1 = test_model.RecordWithOptionalGenericField(yardl.None); + obj.f1a = test_model.RecordWithAliasedOptionalGenericField(yardl.None); + obj.f2 = test_model.RecordWithOptionalGenericUnionField(yardl.None); + obj.f2a = test_model.RecordWithAliasedOptionalGenericUnionField(yardl.None); + obj.nested = test_model.RecordContainingGenericRecords(test_model.RecordWithOptionalGenericField(yardl.None), test_model.RecordWithAliasedOptionalGenericField(yardl.None), test_model.RecordWithOptionalGenericUnionField(yardl.None), test_model.RecordWithAliasedOptionalGenericUnionField(yardl.None), tuples.Tuple("", int32(0)), tuples.Tuple("", int32(0)), test_model.RecordWithGenericVectors(int32.empty(), int32.empty()), test_model.RecordWithGenericFixedVectors(repelem(int32(0), 3), repelem(int32(0), 3)), test_model.RecordWithGenericArrays(int32.empty(0, 0), repelem(int32(0), 8, 16), int32.empty(), int32.empty(0, 0), repelem(int32(0), 8, 16), int32.empty()), test_model.RecordWithGenericMaps(dictionary, dictionary)); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordContainingNestedGenericRecords') && ... + all([obj.f1] == [other.f1]) && ... + isequal(obj.f1a, other.f1a) && ... + all([obj.f2] == [other.f2]) && ... + isequal(obj.f2a, other.f2a) && ... + isequal(obj.nested, other.nested); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordContainingNestedGenericRecords(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordNotUsedInProtocol.m b/matlab/generated/+test_model/RecordNotUsedInProtocol.m new file mode 100644 index 00000000..ba84900c --- /dev/null +++ b/matlab/generated/+test_model/RecordNotUsedInProtocol.m @@ -0,0 +1,44 @@ +classdef RecordNotUsedInProtocol < handle + properties + u1 + u2 + end + + methods + function obj = RecordNotUsedInProtocol(u1, u2) + if nargin > 0 + obj.u1 = u1; + obj.u2 = u2; + else + obj.u1 = test_model.GenericUnion3.T(int32(0)); + obj.u2 = test_model.GenericUnion3Alternate.U(int32(0)); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordNotUsedInProtocol') && ... + all([obj.u1] == [other.u1]) && ... + all([obj.u2] == [other.u2]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordNotUsedInProtocol(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithAliasedGenerics.m b/matlab/generated/+test_model/RecordWithAliasedGenerics.m new file mode 100644 index 00000000..f5e1e088 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithAliasedGenerics.m @@ -0,0 +1,44 @@ +classdef RecordWithAliasedGenerics < handle + properties + my_strings + aliased_strings + end + + methods + function obj = RecordWithAliasedGenerics(my_strings, aliased_strings) + if nargin > 0 + obj.my_strings = my_strings; + obj.aliased_strings = aliased_strings; + else + obj.my_strings = tuples.Tuple("", ""); + obj.aliased_strings = tuples.Tuple("", ""); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithAliasedGenerics') && ... + isequal(obj.my_strings, other.my_strings) && ... + isequal(obj.aliased_strings, other.aliased_strings); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithAliasedGenerics(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m new file mode 100644 index 00000000..13365370 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m @@ -0,0 +1,40 @@ +classdef RecordWithAliasedOptionalGenericField < handle + properties + v + end + + methods + function obj = RecordWithAliasedOptionalGenericField(v) + if nargin > 0 + obj.v = v; + else + obj.v = yardl.None; + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithAliasedOptionalGenericField') && ... + isequal(obj.v, other.v); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithAliasedOptionalGenericField(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m new file mode 100644 index 00000000..32854f2a --- /dev/null +++ b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m @@ -0,0 +1,40 @@ +classdef RecordWithAliasedOptionalGenericUnionField < handle + properties + v + end + + methods + function obj = RecordWithAliasedOptionalGenericUnionField(v) + if nargin > 0 + obj.v = v; + else + obj.v = yardl.None; + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithAliasedOptionalGenericUnionField') && ... + isequal(obj.v, other.v); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithAliasedOptionalGenericUnionField(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithArrays.m b/matlab/generated/+test_model/RecordWithArrays.m new file mode 100644 index 00000000..bf3f1a91 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithArrays.m @@ -0,0 +1,72 @@ +classdef RecordWithArrays < handle + properties + default_array + default_array_with_empty_dimension + rank_1_array + rank_2_array + rank_2_array_with_named_dimensions + rank_2_fixed_array + rank_2_fixed_array_with_named_dimensions + dynamic_array + array_of_vectors + end + + methods + function obj = RecordWithArrays(default_array, default_array_with_empty_dimension, rank_1_array, rank_2_array, rank_2_array_with_named_dimensions, rank_2_fixed_array, rank_2_fixed_array_with_named_dimensions, dynamic_array, array_of_vectors) + if nargin > 0 + obj.default_array = default_array; + obj.default_array_with_empty_dimension = default_array_with_empty_dimension; + obj.rank_1_array = rank_1_array; + obj.rank_2_array = rank_2_array; + obj.rank_2_array_with_named_dimensions = rank_2_array_with_named_dimensions; + obj.rank_2_fixed_array = rank_2_fixed_array; + obj.rank_2_fixed_array_with_named_dimensions = rank_2_fixed_array_with_named_dimensions; + obj.dynamic_array = dynamic_array; + obj.array_of_vectors = array_of_vectors; + else + obj.default_array = int32.empty(); + obj.default_array_with_empty_dimension = int32.empty(); + obj.rank_1_array = int32.empty(0); + obj.rank_2_array = int32.empty(0, 0); + obj.rank_2_array_with_named_dimensions = int32.empty(0, 0); + obj.rank_2_fixed_array = repelem(int32(0), 4, 3); + obj.rank_2_fixed_array_with_named_dimensions = repelem(int32(0), 4, 3); + obj.dynamic_array = int32.empty(); + obj.array_of_vectors = repelem(repelem(int32(0), 4), 5, 1); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithArrays') && ... + isequal(obj.default_array, other.default_array) && ... + isequal(obj.default_array_with_empty_dimension, other.default_array_with_empty_dimension) && ... + isequal(obj.rank_1_array, other.rank_1_array) && ... + isequal(obj.rank_2_array, other.rank_2_array) && ... + isequal(obj.rank_2_array_with_named_dimensions, other.rank_2_array_with_named_dimensions) && ... + isequal(obj.rank_2_fixed_array, other.rank_2_fixed_array) && ... + isequal(obj.rank_2_fixed_array_with_named_dimensions, other.rank_2_fixed_array_with_named_dimensions) && ... + isequal(obj.dynamic_array, other.dynamic_array) && ... + isequal(obj.array_of_vectors, other.array_of_vectors); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithArrays(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m b/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m new file mode 100644 index 00000000..36ab0413 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m @@ -0,0 +1,72 @@ +classdef RecordWithArraysSimpleSyntax < handle + properties + default_array + default_array_with_empty_dimension + rank_1_array + rank_2_array + rank_2_array_with_named_dimensions + rank_2_fixed_array + rank_2_fixed_array_with_named_dimensions + dynamic_array + array_of_vectors + end + + methods + function obj = RecordWithArraysSimpleSyntax(default_array, default_array_with_empty_dimension, rank_1_array, rank_2_array, rank_2_array_with_named_dimensions, rank_2_fixed_array, rank_2_fixed_array_with_named_dimensions, dynamic_array, array_of_vectors) + if nargin > 0 + obj.default_array = default_array; + obj.default_array_with_empty_dimension = default_array_with_empty_dimension; + obj.rank_1_array = rank_1_array; + obj.rank_2_array = rank_2_array; + obj.rank_2_array_with_named_dimensions = rank_2_array_with_named_dimensions; + obj.rank_2_fixed_array = rank_2_fixed_array; + obj.rank_2_fixed_array_with_named_dimensions = rank_2_fixed_array_with_named_dimensions; + obj.dynamic_array = dynamic_array; + obj.array_of_vectors = array_of_vectors; + else + obj.default_array = int32.empty(); + obj.default_array_with_empty_dimension = int32.empty(); + obj.rank_1_array = int32.empty(0); + obj.rank_2_array = int32.empty(0, 0); + obj.rank_2_array_with_named_dimensions = int32.empty(0, 0); + obj.rank_2_fixed_array = repelem(int32(0), 4, 3); + obj.rank_2_fixed_array_with_named_dimensions = repelem(int32(0), 4, 3); + obj.dynamic_array = int32.empty(); + obj.array_of_vectors = repelem(repelem(int32(0), 4), 5, 1); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithArraysSimpleSyntax') && ... + isequal(obj.default_array, other.default_array) && ... + isequal(obj.default_array_with_empty_dimension, other.default_array_with_empty_dimension) && ... + isequal(obj.rank_1_array, other.rank_1_array) && ... + isequal(obj.rank_2_array, other.rank_2_array) && ... + isequal(obj.rank_2_array_with_named_dimensions, other.rank_2_array_with_named_dimensions) && ... + isequal(obj.rank_2_fixed_array, other.rank_2_fixed_array) && ... + isequal(obj.rank_2_fixed_array_with_named_dimensions, other.rank_2_fixed_array_with_named_dimensions) && ... + isequal(obj.dynamic_array, other.dynamic_array) && ... + isequal(obj.array_of_vectors, other.array_of_vectors); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithArraysSimpleSyntax(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithComputedFields.m b/matlab/generated/+test_model/RecordWithComputedFields.m new file mode 100644 index 00000000..64153d68 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithComputedFields.m @@ -0,0 +1,585 @@ +classdef RecordWithComputedFields < handle + properties + array_field + array_field_map_dimensions + dynamic_array_field + fixed_array_field + int_field + int8_field + uint8_field + int16_field + uint16_field + uint32_field + int64_field + uint64_field + size_field + float32_field + float64_field + complexfloat32_field + complexfloat64_field + string_field + tuple_field + vector_field + vector_of_vectors_field + fixed_vector_field + optional_named_array + int_float_union + nullable_int_float_union + union_with_nested_generic_union + map_field + end + + methods + function obj = RecordWithComputedFields(array_field, array_field_map_dimensions, dynamic_array_field, fixed_array_field, int_field, int8_field, uint8_field, int16_field, uint16_field, uint32_field, int64_field, uint64_field, size_field, float32_field, float64_field, complexfloat32_field, complexfloat64_field, string_field, tuple_field, vector_field, vector_of_vectors_field, fixed_vector_field, optional_named_array, int_float_union, nullable_int_float_union, union_with_nested_generic_union, map_field) + if nargin > 0 + obj.array_field = array_field; + obj.array_field_map_dimensions = array_field_map_dimensions; + obj.dynamic_array_field = dynamic_array_field; + obj.fixed_array_field = fixed_array_field; + obj.int_field = int_field; + obj.int8_field = int8_field; + obj.uint8_field = uint8_field; + obj.int16_field = int16_field; + obj.uint16_field = uint16_field; + obj.uint32_field = uint32_field; + obj.int64_field = int64_field; + obj.uint64_field = uint64_field; + obj.size_field = size_field; + obj.float32_field = float32_field; + obj.float64_field = float64_field; + obj.complexfloat32_field = complexfloat32_field; + obj.complexfloat64_field = complexfloat64_field; + obj.string_field = string_field; + obj.tuple_field = tuple_field; + obj.vector_field = vector_field; + obj.vector_of_vectors_field = vector_of_vectors_field; + obj.fixed_vector_field = fixed_vector_field; + obj.optional_named_array = optional_named_array; + obj.int_float_union = int_float_union; + obj.nullable_int_float_union = nullable_int_float_union; + obj.union_with_nested_generic_union = union_with_nested_generic_union; + obj.map_field = map_field; + else + obj.array_field = int32.empty(0, 0); + obj.array_field_map_dimensions = int32.empty(0, 0); + obj.dynamic_array_field = int32.empty(); + obj.fixed_array_field = repelem(int32(0), 4, 3); + obj.int_field = int32(0); + obj.int8_field = int8(0); + obj.uint8_field = uint8(0); + obj.int16_field = int16(0); + obj.uint16_field = uint16(0); + obj.uint32_field = uint32(0); + obj.int64_field = int64(0); + obj.uint64_field = uint64(0); + obj.size_field = uint64(0); + obj.float32_field = single(0); + obj.float64_field = double(0); + obj.complexfloat32_field = complex(single(0)); + obj.complexfloat64_field = complex(0); + obj.string_field = ""; + obj.tuple_field = tuples.Tuple(int32(0), int32(0)); + obj.vector_field = int32.empty(); + obj.vector_of_vectors_field = int32.empty(); + obj.fixed_vector_field = repelem(int32(0), 3); + obj.optional_named_array = yardl.None; + obj.int_float_union = test_model.Int32OrFloat32.Int32(int32(0)); + obj.nullable_int_float_union = yardl.None; + obj.union_with_nested_generic_union = test_model.IntOrGenericRecordWithComputedFields.Int(int32(0)); + obj.map_field = dictionary; + end + end + + function res = int_literal(self) + res = 42; + return + end + + function res = large_negative_int64_literal(self) + res = -4611686018427387904; + return + end + + function res = large_u_int64_literal(self) + res = 9223372036854775808; + return + end + + function res = string_literal(self) + res = "hello"; + return + end + + function res = string_literal_2(self) + res = "hello"; + return + end + + function res = string_literal_3(self) + res = "hello"; + return + end + + function res = string_literal_4(self) + res = "hello"; + return + end + + function res = access_other_computed_field(self) + res = self.int_field; + return + end + + function res = access_int_field(self) + res = self.int_field; + return + end + + function res = access_string_field(self) + res = self.string_field; + return + end + + function res = access_tuple_field(self) + res = self.tuple_field; + return + end + + function res = access_nested_tuple_field(self) + res = self.tuple_field.v2; + return + end + + function res = access_array_field(self) + res = self.array_field; + return + end + + function res = access_array_field_element(self) + res = self.array_field(1+0, 1+1); + return + end + + function res = access_array_field_element_by_name(self) + res = self.array_field(1+0, 1+1); + return + end + + function res = access_vector_field(self) + res = self.vector_field; + return + end + + function res = access_vector_field_element(self) + res = self.vector_field(1+1); + return + end + + function res = access_vector_of_vectors_field(self) + res = self.vector_of_vectors_field(1+1, 1+2); + return + end + + function res = array_size(self) + res = numel(self.array_field); + return + end + + function res = array_x_size(self) + res = size(self.array_field, 1+0); + return + end + + function res = array_y_size(self) + res = size(self.array_field, 1+1); + return + end + + function res = array_0_size(self) + res = size(self.array_field, 1+0); + return + end + + function res = array_1_size(self) + res = size(self.array_field, 1+1); + return + end + + function res = array_size_from_int_field(self) + res = size(self.array_field, 1+self.int_field); + return + end + + function res = array_size_from_string_field(self) + function dim = helper_0_(dim_name) + if dim_name == "x" + dim = 0; + elseif dim_name == "y" + dim = 1; + else + throw(yardl.KeyError("Unknown dimension name: '%s'", dim_name)); + end + + end + res = size(self.array_field, 1+1 + helper_0_(self.string_field)); + return + end + + function res = array_size_from_nested_int_field(self) + res = size(self.array_field, 1+self.tuple_field.v1); + return + end + + function res = array_field_map_dimensions_x_size(self) + res = size(self.array_field_map_dimensions, 1+0); + return + end + + function res = fixed_array_size(self) + res = 12; + return + end + + function res = fixed_array_x_size(self) + res = 3; + return + end + + function res = fixed_array_0_size(self) + res = 3; + return + end + + function res = vector_size(self) + res = length(self.vector_field); + return + end + + function res = fixed_vector_size(self) + res = 3; + return + end + + function res = array_dimension_x_index(self) + function dim = helper_0_(dim_name) + if dim_name == "x" + dim = 0; + elseif dim_name == "y" + dim = 1; + else + throw(yardl.KeyError("Unknown dimension name: '%s'", dim_name)); + end + + end + res = 1 + helper_0_("x"); + return + end + + function res = array_dimension_y_index(self) + function dim = helper_0_(dim_name) + if dim_name == "x" + dim = 0; + elseif dim_name == "y" + dim = 1; + else + throw(yardl.KeyError("Unknown dimension name: '%s'", dim_name)); + end + + end + res = 1 + helper_0_("y"); + return + end + + function res = array_dimension_index_from_string_field(self) + function dim = helper_0_(dim_name) + if dim_name == "x" + dim = 0; + elseif dim_name == "y" + dim = 1; + else + throw(yardl.KeyError("Unknown dimension name: '%s'", dim_name)); + end + + end + res = 1 + helper_0_(self.string_field); + return + end + + function res = array_dimension_count(self) + res = 2; + return + end + + function res = dynamic_array_dimension_count(self) + res = yardl.dimension_count(self.dynamic_array_field); + return + end + + function res = access_map(self) + res = self.map_field; + return + end + + function res = map_size(self) + res = numEntries(self.map_field); + return + end + + function res = access_map_entry(self) + res = self.map_field("hello"); + return + end + + function res = string_computed_field(self) + res = "hello"; + return + end + + function res = access_map_entry_with_computed_field(self) + res = self.map_field(self.string_computed_field()); + return + end + + function res = access_map_entry_with_computed_field_nested(self) + res = self.map_field(self.map_field(self.string_computed_field())); + return + end + + function res = access_missing_map_entry(self) + res = self.map_field("missing"); + return + end + + function res = optional_named_array_length(self) + var1 = self.optional_named_array; + if var1 ~= yardl.None + arr = var1; + res = numel(arr); + return + end + res = 0; + return + end + + function res = optional_named_array_length_with_discard(self) + var1 = self.optional_named_array; + if var1 ~= yardl.None + arr = var1; + res = numel(arr); + return + end + res = 0; + return + end + + function res = int_float_union_as_float(self) + var1 = self.int_float_union; + if var1.index == 1 + i_foo = var1.value; + res = single(i_foo); + return + end + if var1.index == 2 + f = var1.value; + res = f; + return + end + throw(yardl.RuntimeError("Unexpected union case")) + end + + function res = nullable_int_float_union_string(self) + var1 = self.nullable_int_float_union; + if var1 == yardl.None + res = "null"; + return + end + if var1.index == 1 + res = "int"; + return + end + res = "float"; + return + throw(yardl.RuntimeError("Unexpected union case")) + end + + function res = nested_switch(self) + var1 = self.union_with_nested_generic_union; + if var1.index == 1 + res = -1; + return + end + if var1.index == 2 + rec = var1.value; + var2 = rec.f1; + if var2.index == 2 + res = int32(20); + return + end + if var2.index == 1 + res = int32(10); + return + end + throw(yardl.RuntimeError("Unexpected union case")) + end + throw(yardl.RuntimeError("Unexpected union case")) + end + + function res = use_nested_computed_field(self) + var1 = self.union_with_nested_generic_union; + if var1.index == 1 + res = -1; + return + end + if var1.index == 2 + rec = var1.value; + res = int32(rec.type_index()); + return + end + throw(yardl.RuntimeError("Unexpected union case")) + end + + function res = switch_over_single_value(self) + var1 = self.int_field; + i = var1; + res = i; + return + end + + function res = arithmetic_1(self) + res = 1 + 2; + return + end + + function res = arithmetic_2(self) + res = 1 + 2 .* 3 + 4; + return + end + + function res = arithmetic_3(self) + res = (1 + 2) .* 3 + 4; + return + end + + function res = arithmetic_4(self) + res = self.array_size_from_int_field() + 2; + return + end + + function res = arithmetic_5(self) + res = size(self.array_field, 1+2 - 1); + return + end + + function res = arithmetic_6(self) + res = 7 ./ 2; + return + end + + function res = arithmetic_7(self) + res = double(7) ^ double(2); + return + end + + function res = arithmetic8(self) + res = self.complexfloat32_field .* complex(single(single(3))); + return + end + + function res = arithmetic_9(self) + res = 1.2 + double(1); + return + end + + function res = arithmetic_10(self) + res = 1e10 + 9e9; + return + end + + function res = arithmetic_11(self) + res = -(4.3 + double(1)); + return + end + + function res = cast_int_to_float(self) + res = single(self.int_field); + return + end + + function res = cast_float_to_int(self) + res = int32(self.float32_field); + return + end + + function res = cast_power(self) + res = int32(double(7) ^ double(2)); + return + end + + function res = cast_complex32_to_complex64(self) + res = complex(double(self.complexfloat32_field)); + return + end + + function res = cast_complex64_to_complex32(self) + res = complex(single(self.complexfloat64_field)); + return + end + + function res = cast_float_to_complex(self) + res = complex(single(66.6)); + return + end + + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithComputedFields') && ... + isequal(obj.array_field, other.array_field) && ... + isequal(obj.array_field_map_dimensions, other.array_field_map_dimensions) && ... + isequal(obj.dynamic_array_field, other.dynamic_array_field) && ... + isequal(obj.fixed_array_field, other.fixed_array_field) && ... + all([obj.int_field] == [other.int_field]) && ... + all([obj.int8_field] == [other.int8_field]) && ... + all([obj.uint8_field] == [other.uint8_field]) && ... + all([obj.int16_field] == [other.int16_field]) && ... + all([obj.uint16_field] == [other.uint16_field]) && ... + all([obj.uint32_field] == [other.uint32_field]) && ... + all([obj.int64_field] == [other.int64_field]) && ... + all([obj.uint64_field] == [other.uint64_field]) && ... + all([obj.size_field] == [other.size_field]) && ... + all([obj.float32_field] == [other.float32_field]) && ... + all([obj.float64_field] == [other.float64_field]) && ... + all([obj.complexfloat32_field] == [other.complexfloat32_field]) && ... + all([obj.complexfloat64_field] == [other.complexfloat64_field]) && ... + all([obj.string_field] == [other.string_field]) && ... + isequal(obj.tuple_field, other.tuple_field) && ... + all([obj.vector_field] == [other.vector_field]) && ... + all([obj.vector_of_vectors_field] == [other.vector_of_vectors_field]) && ... + all([obj.fixed_vector_field] == [other.fixed_vector_field]) && ... + isequal(obj.optional_named_array, other.optional_named_array) && ... + all([obj.int_float_union] == [other.int_float_union]) && ... + all([obj.nullable_int_float_union] == [other.nullable_int_float_union]) && ... + all([obj.union_with_nested_generic_union] == [other.union_with_nested_generic_union]) && ... + all([obj.map_field] == [other.map_field]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithComputedFields(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithDynamicNDArrays.m b/matlab/generated/+test_model/RecordWithDynamicNDArrays.m new file mode 100644 index 00000000..f0bafd98 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithDynamicNDArrays.m @@ -0,0 +1,48 @@ +classdef RecordWithDynamicNDArrays < handle + properties + ints + simple_record_array + record_with_vlens_array + end + + methods + function obj = RecordWithDynamicNDArrays(ints, simple_record_array, record_with_vlens_array) + if nargin > 0 + obj.ints = ints; + obj.simple_record_array = simple_record_array; + obj.record_with_vlens_array = record_with_vlens_array; + else + obj.ints = int32.empty(); + obj.simple_record_array = test_model.SimpleRecord.empty(); + obj.record_with_vlens_array = test_model.RecordWithVlens.empty(); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithDynamicNDArrays') && ... + isequal(obj.ints, other.ints) && ... + isequal(obj.simple_record_array, other.simple_record_array) && ... + isequal(obj.record_with_vlens_array, other.record_with_vlens_array); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithDynamicNDArrays(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithEnums.m b/matlab/generated/+test_model/RecordWithEnums.m new file mode 100644 index 00000000..39484dc9 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithEnums.m @@ -0,0 +1,48 @@ +classdef RecordWithEnums < handle + properties + enum + flags + flags_2 + end + + methods + function obj = RecordWithEnums(enum, flags, flags_2) + if nargin > 0 + obj.enum = enum; + obj.flags = flags; + obj.flags_2 = flags_2; + else + obj.enum = basic_types.Fruits.APPLE; + obj.flags = basic_types.DaysOfWeek(0); + obj.flags_2 = basic_types.TextFormat.REGULAR; + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithEnums') && ... + all([obj.enum] == [other.enum]) && ... + all([obj.flags] == [other.flags]) && ... + all([obj.flags_2] == [other.flags_2]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithEnums(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithFixedArrays.m b/matlab/generated/+test_model/RecordWithFixedArrays.m new file mode 100644 index 00000000..6c4323cf --- /dev/null +++ b/matlab/generated/+test_model/RecordWithFixedArrays.m @@ -0,0 +1,48 @@ +classdef RecordWithFixedArrays < handle + properties + ints + fixed_simple_record_array + fixed_record_with_vlens_array + end + + methods + function obj = RecordWithFixedArrays(ints, fixed_simple_record_array, fixed_record_with_vlens_array) + if nargin > 0 + obj.ints = ints; + obj.fixed_simple_record_array = fixed_simple_record_array; + obj.fixed_record_with_vlens_array = fixed_record_with_vlens_array; + else + obj.ints = repelem(int32(0), 3, 2); + obj.fixed_simple_record_array = repelem(test_model.SimpleRecord(), 2, 3); + obj.fixed_record_with_vlens_array = repelem(test_model.RecordWithVlens(), 2, 2); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithFixedArrays') && ... + isequal(obj.ints, other.ints) && ... + isequal(obj.fixed_simple_record_array, other.fixed_simple_record_array) && ... + isequal(obj.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithFixedArrays(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithFixedCollections.m b/matlab/generated/+test_model/RecordWithFixedCollections.m new file mode 100644 index 00000000..31a626cc --- /dev/null +++ b/matlab/generated/+test_model/RecordWithFixedCollections.m @@ -0,0 +1,44 @@ +classdef RecordWithFixedCollections < handle + properties + fixed_vector + fixed_array + end + + methods + function obj = RecordWithFixedCollections(fixed_vector, fixed_array) + if nargin > 0 + obj.fixed_vector = fixed_vector; + obj.fixed_array = fixed_array; + else + obj.fixed_vector = repelem(int32(0), 3); + obj.fixed_array = repelem(int32(0), 3, 2); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithFixedCollections') && ... + all([obj.fixed_vector] == [other.fixed_vector]) && ... + isequal(obj.fixed_array, other.fixed_array); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithFixedCollections(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithFixedVectors.m b/matlab/generated/+test_model/RecordWithFixedVectors.m new file mode 100644 index 00000000..077f7ff5 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithFixedVectors.m @@ -0,0 +1,48 @@ +classdef RecordWithFixedVectors < handle + properties + fixed_int_vector + fixed_simple_record_vector + fixed_record_with_vlens_vector + end + + methods + function obj = RecordWithFixedVectors(fixed_int_vector, fixed_simple_record_vector, fixed_record_with_vlens_vector) + if nargin > 0 + obj.fixed_int_vector = fixed_int_vector; + obj.fixed_simple_record_vector = fixed_simple_record_vector; + obj.fixed_record_with_vlens_vector = fixed_record_with_vlens_vector; + else + obj.fixed_int_vector = repelem(int32(0), 5); + obj.fixed_simple_record_vector = repelem(test_model.SimpleRecord(), 3); + obj.fixed_record_with_vlens_vector = repelem(test_model.RecordWithVlens(), 2); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithFixedVectors') && ... + all([obj.fixed_int_vector] == [other.fixed_int_vector]) && ... + all([obj.fixed_simple_record_vector] == [other.fixed_simple_record_vector]) && ... + all([obj.fixed_record_with_vlens_vector] == [other.fixed_record_with_vlens_vector]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithFixedVectors(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithGenericArrays.m b/matlab/generated/+test_model/RecordWithGenericArrays.m new file mode 100644 index 00000000..868b0685 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithGenericArrays.m @@ -0,0 +1,37 @@ +classdef RecordWithGenericArrays < handle + properties + nd + fixed_nd + dynamic_nd + aliased_nd + aliased_fixed_nd + aliased_dynamic_nd + end + + methods + function obj = RecordWithGenericArrays(nd, fixed_nd, dynamic_nd, aliased_nd, aliased_fixed_nd, aliased_dynamic_nd) + obj.nd = nd; + obj.fixed_nd = fixed_nd; + obj.dynamic_nd = dynamic_nd; + obj.aliased_nd = aliased_nd; + obj.aliased_fixed_nd = aliased_fixed_nd; + obj.aliased_dynamic_nd = aliased_dynamic_nd; + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithGenericArrays') && ... + isequal(obj.nd, other.nd) && ... + isequal(obj.fixed_nd, other.fixed_nd) && ... + isequal(obj.dynamic_nd, other.dynamic_nd) && ... + isequal(obj.aliased_nd, other.aliased_nd) && ... + isequal(obj.aliased_fixed_nd, other.aliased_fixed_nd) && ... + isequal(obj.aliased_dynamic_nd, other.aliased_dynamic_nd); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + +end diff --git a/matlab/generated/+test_model/RecordWithGenericFixedVectors.m b/matlab/generated/+test_model/RecordWithGenericFixedVectors.m new file mode 100644 index 00000000..96c7f03d --- /dev/null +++ b/matlab/generated/+test_model/RecordWithGenericFixedVectors.m @@ -0,0 +1,25 @@ +classdef RecordWithGenericFixedVectors < handle + properties + fv + afv + end + + methods + function obj = RecordWithGenericFixedVectors(fv, afv) + obj.fv = fv; + obj.afv = afv; + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithGenericFixedVectors') && ... + isequal(obj.fv, other.fv) && ... + isequal(obj.afv, other.afv); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + +end diff --git a/matlab/generated/+test_model/RecordWithGenericMaps.m b/matlab/generated/+test_model/RecordWithGenericMaps.m new file mode 100644 index 00000000..eb4f121e --- /dev/null +++ b/matlab/generated/+test_model/RecordWithGenericMaps.m @@ -0,0 +1,44 @@ +classdef RecordWithGenericMaps < handle + properties + m + am + end + + methods + function obj = RecordWithGenericMaps(m, am) + if nargin > 0 + obj.m = m; + obj.am = am; + else + obj.m = dictionary; + obj.am = dictionary; + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithGenericMaps') && ... + isequal(obj.m, other.m) && ... + isequal(obj.am, other.am); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithGenericMaps(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m b/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m new file mode 100644 index 00000000..0b3c81de --- /dev/null +++ b/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m @@ -0,0 +1,22 @@ +classdef RecordWithGenericVectorOfRecords < handle + properties + v + end + + methods + function obj = RecordWithGenericVectorOfRecords(v) + obj.v = v; + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithGenericVectorOfRecords') && ... + isequal(obj.v, other.v); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + +end diff --git a/matlab/generated/+test_model/RecordWithGenericVectors.m b/matlab/generated/+test_model/RecordWithGenericVectors.m new file mode 100644 index 00000000..69000c0d --- /dev/null +++ b/matlab/generated/+test_model/RecordWithGenericVectors.m @@ -0,0 +1,25 @@ +classdef RecordWithGenericVectors < handle + properties + v + av + end + + methods + function obj = RecordWithGenericVectors(v, av) + obj.v = v; + obj.av = av; + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithGenericVectors') && ... + isequal(obj.v, other.v) && ... + isequal(obj.av, other.av); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + +end diff --git a/matlab/generated/+test_model/RecordWithKeywordFields.m b/matlab/generated/+test_model/RecordWithKeywordFields.m new file mode 100644 index 00000000..f10d07e1 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithKeywordFields.m @@ -0,0 +1,44 @@ +classdef RecordWithKeywordFields < handle + properties + int + sizeof + if + end + + methods + function obj = RecordWithKeywordFields(int, sizeof, if) + obj.int = int; + obj.sizeof = sizeof; + obj.if = if; + end + + function res = float(self) + res = self.int; + return + end + + function res = double(self) + res = self.float(); + return + end + + function res = return(self) + res = self.sizeof(1, 2); + return + end + + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithKeywordFields') && ... + all([obj.int] == [other.int]) && ... + isequal(obj.sizeof, other.sizeof) && ... + all([obj.if] == [other.if]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + +end diff --git a/matlab/generated/+test_model/RecordWithNDArrays.m b/matlab/generated/+test_model/RecordWithNDArrays.m new file mode 100644 index 00000000..25e5e63e --- /dev/null +++ b/matlab/generated/+test_model/RecordWithNDArrays.m @@ -0,0 +1,48 @@ +classdef RecordWithNDArrays < handle + properties + ints + fixed_simple_record_array + fixed_record_with_vlens_array + end + + methods + function obj = RecordWithNDArrays(ints, fixed_simple_record_array, fixed_record_with_vlens_array) + if nargin > 0 + obj.ints = ints; + obj.fixed_simple_record_array = fixed_simple_record_array; + obj.fixed_record_with_vlens_array = fixed_record_with_vlens_array; + else + obj.ints = int32.empty(0, 0); + obj.fixed_simple_record_array = test_model.SimpleRecord.empty(0, 0); + obj.fixed_record_with_vlens_array = test_model.RecordWithVlens.empty(0, 0); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithNDArrays') && ... + isequal(obj.ints, other.ints) && ... + isequal(obj.fixed_simple_record_array, other.fixed_simple_record_array) && ... + isequal(obj.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithNDArrays(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m b/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m new file mode 100644 index 00000000..763070dd --- /dev/null +++ b/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m @@ -0,0 +1,48 @@ +classdef RecordWithNDArraysSingleDimension < handle + properties + ints + fixed_simple_record_array + fixed_record_with_vlens_array + end + + methods + function obj = RecordWithNDArraysSingleDimension(ints, fixed_simple_record_array, fixed_record_with_vlens_array) + if nargin > 0 + obj.ints = ints; + obj.fixed_simple_record_array = fixed_simple_record_array; + obj.fixed_record_with_vlens_array = fixed_record_with_vlens_array; + else + obj.ints = int32.empty(0); + obj.fixed_simple_record_array = test_model.SimpleRecord.empty(0); + obj.fixed_record_with_vlens_array = test_model.RecordWithVlens.empty(0); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithNDArraysSingleDimension') && ... + isequal(obj.ints, other.ints) && ... + isequal(obj.fixed_simple_record_array, other.fixed_simple_record_array) && ... + isequal(obj.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithNDArraysSingleDimension(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithNamedFixedArrays.m b/matlab/generated/+test_model/RecordWithNamedFixedArrays.m new file mode 100644 index 00000000..7e0ffc5f --- /dev/null +++ b/matlab/generated/+test_model/RecordWithNamedFixedArrays.m @@ -0,0 +1,48 @@ +classdef RecordWithNamedFixedArrays < handle + properties + ints + fixed_simple_record_array + fixed_record_with_vlens_array + end + + methods + function obj = RecordWithNamedFixedArrays(ints, fixed_simple_record_array, fixed_record_with_vlens_array) + if nargin > 0 + obj.ints = ints; + obj.fixed_simple_record_array = fixed_simple_record_array; + obj.fixed_record_with_vlens_array = fixed_record_with_vlens_array; + else + obj.ints = repelem(int32(0), 3, 2); + obj.fixed_simple_record_array = repelem(test_model.SimpleRecord(), 2, 3); + obj.fixed_record_with_vlens_array = repelem(test_model.RecordWithVlens(), 2, 2); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithNamedFixedArrays') && ... + isequal(obj.ints, other.ints) && ... + isequal(obj.fixed_simple_record_array, other.fixed_simple_record_array) && ... + isequal(obj.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithNamedFixedArrays(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithOptionalFields.m b/matlab/generated/+test_model/RecordWithOptionalFields.m new file mode 100644 index 00000000..55938794 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithOptionalFields.m @@ -0,0 +1,48 @@ +classdef RecordWithOptionalFields < handle + properties + optional_int + optional_int_alternate_syntax + optional_time + end + + methods + function obj = RecordWithOptionalFields(optional_int, optional_int_alternate_syntax, optional_time) + if nargin > 0 + obj.optional_int = optional_int; + obj.optional_int_alternate_syntax = optional_int_alternate_syntax; + obj.optional_time = optional_time; + else + obj.optional_int = yardl.None; + obj.optional_int_alternate_syntax = yardl.None; + obj.optional_time = yardl.None; + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithOptionalFields') && ... + all([obj.optional_int] == [other.optional_int]) && ... + all([obj.optional_int_alternate_syntax] == [other.optional_int_alternate_syntax]) && ... + all([obj.optional_time] == [other.optional_time]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithOptionalFields(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithOptionalGenericField.m b/matlab/generated/+test_model/RecordWithOptionalGenericField.m new file mode 100644 index 00000000..f6c9a443 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithOptionalGenericField.m @@ -0,0 +1,40 @@ +classdef RecordWithOptionalGenericField < handle + properties + v + end + + methods + function obj = RecordWithOptionalGenericField(v) + if nargin > 0 + obj.v = v; + else + obj.v = yardl.None; + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithOptionalGenericField') && ... + isequal(obj.v, other.v); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithOptionalGenericField(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m b/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m new file mode 100644 index 00000000..8ce030b8 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m @@ -0,0 +1,40 @@ +classdef RecordWithOptionalGenericUnionField < handle + properties + v + end + + methods + function obj = RecordWithOptionalGenericUnionField(v) + if nargin > 0 + obj.v = v; + else + obj.v = yardl.None; + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithOptionalGenericUnionField') && ... + isequal(obj.v, other.v); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithOptionalGenericUnionField(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithOptionalVector.m b/matlab/generated/+test_model/RecordWithOptionalVector.m new file mode 100644 index 00000000..aa6babfd --- /dev/null +++ b/matlab/generated/+test_model/RecordWithOptionalVector.m @@ -0,0 +1,40 @@ +classdef RecordWithOptionalVector < handle + properties + optional_vector + end + + methods + function obj = RecordWithOptionalVector(optional_vector) + if nargin > 0 + obj.optional_vector = optional_vector; + else + obj.optional_vector = yardl.None; + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithOptionalVector') && ... + all([obj.optional_vector] == [other.optional_vector]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithOptionalVector(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithPrimitiveAliases.m b/matlab/generated/+test_model/RecordWithPrimitiveAliases.m new file mode 100644 index 00000000..99194400 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithPrimitiveAliases.m @@ -0,0 +1,72 @@ +classdef RecordWithPrimitiveAliases < handle + properties + byte_field + int_field + uint_field + long_field + ulong_field + float_field + double_field + complexfloat_field + complexdouble_field + end + + methods + function obj = RecordWithPrimitiveAliases(byte_field, int_field, uint_field, long_field, ulong_field, float_field, double_field, complexfloat_field, complexdouble_field) + if nargin > 0 + obj.byte_field = byte_field; + obj.int_field = int_field; + obj.uint_field = uint_field; + obj.long_field = long_field; + obj.ulong_field = ulong_field; + obj.float_field = float_field; + obj.double_field = double_field; + obj.complexfloat_field = complexfloat_field; + obj.complexdouble_field = complexdouble_field; + else + obj.byte_field = uint8(0); + obj.int_field = int32(0); + obj.uint_field = uint32(0); + obj.long_field = int64(0); + obj.ulong_field = uint64(0); + obj.float_field = single(0); + obj.double_field = double(0); + obj.complexfloat_field = complex(single(0)); + obj.complexdouble_field = complex(0); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithPrimitiveAliases') && ... + all([obj.byte_field] == [other.byte_field]) && ... + all([obj.int_field] == [other.int_field]) && ... + all([obj.uint_field] == [other.uint_field]) && ... + all([obj.long_field] == [other.long_field]) && ... + all([obj.ulong_field] == [other.ulong_field]) && ... + all([obj.float_field] == [other.float_field]) && ... + all([obj.double_field] == [other.double_field]) && ... + all([obj.complexfloat_field] == [other.complexfloat_field]) && ... + all([obj.complexdouble_field] == [other.complexdouble_field]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithPrimitiveAliases(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithPrimitives.m b/matlab/generated/+test_model/RecordWithPrimitives.m new file mode 100644 index 00000000..31486ec8 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithPrimitives.m @@ -0,0 +1,104 @@ +classdef RecordWithPrimitives < handle + properties + bool_field + int8_field + uint8_field + int16_field + uint16_field + int32_field + uint32_field + int64_field + uint64_field + size_field + float32_field + float64_field + complexfloat32_field + complexfloat64_field + date_field + time_field + datetime_field + end + + methods + function obj = RecordWithPrimitives(bool_field, int8_field, uint8_field, int16_field, uint16_field, int32_field, uint32_field, int64_field, uint64_field, size_field, float32_field, float64_field, complexfloat32_field, complexfloat64_field, date_field, time_field, datetime_field) + if nargin > 0 + obj.bool_field = bool_field; + obj.int8_field = int8_field; + obj.uint8_field = uint8_field; + obj.int16_field = int16_field; + obj.uint16_field = uint16_field; + obj.int32_field = int32_field; + obj.uint32_field = uint32_field; + obj.int64_field = int64_field; + obj.uint64_field = uint64_field; + obj.size_field = size_field; + obj.float32_field = float32_field; + obj.float64_field = float64_field; + obj.complexfloat32_field = complexfloat32_field; + obj.complexfloat64_field = complexfloat64_field; + obj.date_field = date_field; + obj.time_field = time_field; + obj.datetime_field = datetime_field; + else + obj.bool_field = false; + obj.int8_field = int8(0); + obj.uint8_field = uint8(0); + obj.int16_field = int16(0); + obj.uint16_field = uint16(0); + obj.int32_field = int32(0); + obj.uint32_field = uint32(0); + obj.int64_field = int64(0); + obj.uint64_field = uint64(0); + obj.size_field = uint64(0); + obj.float32_field = single(0); + obj.float64_field = double(0); + obj.complexfloat32_field = complex(single(0)); + obj.complexfloat64_field = complex(0); + obj.date_field = yardl.Date(); + obj.time_field = yardl.Time(); + obj.datetime_field = yardl.DateTime(); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithPrimitives') && ... + all([obj.bool_field] == [other.bool_field]) && ... + all([obj.int8_field] == [other.int8_field]) && ... + all([obj.uint8_field] == [other.uint8_field]) && ... + all([obj.int16_field] == [other.int16_field]) && ... + all([obj.uint16_field] == [other.uint16_field]) && ... + all([obj.int32_field] == [other.int32_field]) && ... + all([obj.uint32_field] == [other.uint32_field]) && ... + all([obj.int64_field] == [other.int64_field]) && ... + all([obj.uint64_field] == [other.uint64_field]) && ... + all([obj.size_field] == [other.size_field]) && ... + all([obj.float32_field] == [other.float32_field]) && ... + all([obj.float64_field] == [other.float64_field]) && ... + all([obj.complexfloat32_field] == [other.complexfloat32_field]) && ... + all([obj.complexfloat64_field] == [other.complexfloat64_field]) && ... + all([obj.date_field] == [other.date_field]) && ... + all([obj.time_field] == [other.time_field]) && ... + all([obj.datetime_field] == [other.datetime_field]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithPrimitives(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithStrings.m b/matlab/generated/+test_model/RecordWithStrings.m new file mode 100644 index 00000000..74bcdb34 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithStrings.m @@ -0,0 +1,44 @@ +classdef RecordWithStrings < handle + properties + a + b + end + + methods + function obj = RecordWithStrings(a, b) + if nargin > 0 + obj.a = a; + obj.b = b; + else + obj.a = ""; + obj.b = ""; + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithStrings') && ... + all([obj.a] == [other.a]) && ... + all([obj.b] == [other.b]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithStrings(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithUnionsOfContainers.m b/matlab/generated/+test_model/RecordWithUnionsOfContainers.m new file mode 100644 index 00000000..63358de5 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithUnionsOfContainers.m @@ -0,0 +1,48 @@ +classdef RecordWithUnionsOfContainers < handle + properties + map_or_scalar + vector_or_scalar + array_or_scalar + end + + methods + function obj = RecordWithUnionsOfContainers(map_or_scalar, vector_or_scalar, array_or_scalar) + if nargin > 0 + obj.map_or_scalar = map_or_scalar; + obj.vector_or_scalar = vector_or_scalar; + obj.array_or_scalar = array_or_scalar; + else + obj.map_or_scalar = test_model.MapOrScalar.Map(dictionary); + obj.vector_or_scalar = test_model.VectorOrScalar.Vector(int32.empty()); + obj.array_or_scalar = test_model.ArrayOrScalar.Array(int32.empty()); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithUnionsOfContainers') && ... + all([obj.map_or_scalar] == [other.map_or_scalar]) && ... + all([obj.vector_or_scalar] == [other.vector_or_scalar]) && ... + isequal(obj.array_or_scalar, other.array_or_scalar); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithUnionsOfContainers(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithVectorOfTimes.m b/matlab/generated/+test_model/RecordWithVectorOfTimes.m new file mode 100644 index 00000000..b9a6e4a0 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithVectorOfTimes.m @@ -0,0 +1,40 @@ +classdef RecordWithVectorOfTimes < handle + properties + times + end + + methods + function obj = RecordWithVectorOfTimes(times) + if nargin > 0 + obj.times = times; + else + obj.times = yardl.Time.empty(); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithVectorOfTimes') && ... + all([obj.times] == [other.times]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithVectorOfTimes(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithVectors.m b/matlab/generated/+test_model/RecordWithVectors.m new file mode 100644 index 00000000..edcd7aab --- /dev/null +++ b/matlab/generated/+test_model/RecordWithVectors.m @@ -0,0 +1,48 @@ +classdef RecordWithVectors < handle + properties + default_vector + default_vector_fixed_length + vector_of_vectors + end + + methods + function obj = RecordWithVectors(default_vector, default_vector_fixed_length, vector_of_vectors) + if nargin > 0 + obj.default_vector = default_vector; + obj.default_vector_fixed_length = default_vector_fixed_length; + obj.vector_of_vectors = vector_of_vectors; + else + obj.default_vector = int32.empty(); + obj.default_vector_fixed_length = repelem(int32(0), 3); + obj.vector_of_vectors = int32.empty(); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithVectors') && ... + all([obj.default_vector] == [other.default_vector]) && ... + all([obj.default_vector_fixed_length] == [other.default_vector_fixed_length]) && ... + all([obj.vector_of_vectors] == [other.vector_of_vectors]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithVectors(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithVlenCollections.m b/matlab/generated/+test_model/RecordWithVlenCollections.m new file mode 100644 index 00000000..b4561706 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithVlenCollections.m @@ -0,0 +1,44 @@ +classdef RecordWithVlenCollections < handle + properties + vector + array + end + + methods + function obj = RecordWithVlenCollections(vector, array) + if nargin > 0 + obj.vector = vector; + obj.array = array; + else + obj.vector = int32.empty(); + obj.array = int32.empty(0, 0); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithVlenCollections') && ... + all([obj.vector] == [other.vector]) && ... + isequal(obj.array, other.array); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithVlenCollections(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithVlens.m b/matlab/generated/+test_model/RecordWithVlens.m new file mode 100644 index 00000000..32f50798 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithVlens.m @@ -0,0 +1,48 @@ +classdef RecordWithVlens < handle + properties + a + b + c + end + + methods + function obj = RecordWithVlens(a, b, c) + if nargin > 0 + obj.a = a; + obj.b = b; + obj.c = c; + else + obj.a = test_model.SimpleRecord.empty(); + obj.b = int32(0); + obj.c = int32(0); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.RecordWithVlens') && ... + all([obj.a] == [other.a]) && ... + all([obj.b] == [other.b]) && ... + all([obj.c] == [other.c]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.RecordWithVlens(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/RecordWithVlensFixedArray.m b/matlab/generated/+test_model/RecordWithVlensFixedArray.m new file mode 100644 index 00000000..d24b0f37 --- /dev/null +++ b/matlab/generated/+test_model/RecordWithVlensFixedArray.m @@ -0,0 +1,4 @@ +function a = RecordWithVlensFixedArray(array) + assert(isa(array, 'test_model.RecordWithVlens')); + a = array; +end diff --git a/matlab/generated/+test_model/ScalarOptionalsReaderBase.m b/matlab/generated/+test_model/ScalarOptionalsReaderBase.m new file mode 100644 index 00000000..94ef3792 --- /dev/null +++ b/matlab/generated/+test_model/ScalarOptionalsReaderBase.m @@ -0,0 +1,108 @@ +classdef ScalarOptionalsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = ScalarOptionalsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 8 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_optional_int(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_optional_int_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_optional_record(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_optional_record_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_record_with_optional_fields(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_record_with_optional_fields_(); + obj.state_ = 6; + end + + % Ordinal 3 + function value = read_optional_record_with_optional_fields(obj) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + value = obj.read_optional_record_with_optional_fields_(); + obj.state_ = 8; + end + + function copy_to(obj, writer) + writer.write_optional_int(obj.read_optional_int()); + writer.write_optional_record(obj.read_optional_record()); + writer.write_record_with_optional_fields(obj.read_record_with_optional_fields()); + writer.write_optional_record_with_optional_fields(obj.read_optional_record_with_optional_fields()); + end + end + + methods (Static) + function res = schema() + res = test_model.ScalarOptionalsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_optional_int_(obj, value) + read_optional_record_(obj, value) + read_record_with_optional_fields_(obj, value) + read_optional_record_with_optional_fields_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_optional_int'; + elseif state == 2 + name = 'read_optional_record'; + elseif state == 4 + name = 'read_record_with_optional_fields'; + elseif state == 6 + name = 'read_optional_record_with_optional_fields'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/ScalarOptionalsWriterBase.m b/matlab/generated/+test_model/ScalarOptionalsWriterBase.m new file mode 100644 index 00000000..7d86664c --- /dev/null +++ b/matlab/generated/+test_model/ScalarOptionalsWriterBase.m @@ -0,0 +1,98 @@ +% Abstract writer for protocol ScalarOptionals +classdef (Abstract) ScalarOptionalsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = ScalarOptionalsWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 8 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_optional_int(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_optional_int_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_optional_record(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_optional_record_(value); + obj.state_ = 4; + end + + % Ordinal 2 + function write_record_with_optional_fields(obj, value) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_record_with_optional_fields_(value); + obj.state_ = 6; + end + + % Ordinal 3 + function write_optional_record_with_optional_fields(obj, value) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + obj.write_optional_record_with_optional_fields_(value); + obj.state_ = 8; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"ScalarOptionals","sequence":[{"name":"optionalInt","type":[null,"int32"]},{"name":"optionalRecord","type":[null,"TestModel.SimpleRecord"]},{"name":"recordWithOptionalFields","type":"TestModel.RecordWithOptionalFields"},{"name":"optionalRecordWithOptionalFields","type":[null,"TestModel.RecordWithOptionalFields"]}]},"types":[{"name":"RecordWithOptionalFields","fields":[{"name":"optionalInt","type":[null,"int32"]},{"name":"optionalIntAlternateSyntax","type":[null,"int32"]},{"name":"optionalTime","type":[null,"time"]}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_optional_int_(obj, value) + write_optional_record_(obj, value) + write_record_with_optional_fields_(obj, value) + write_optional_record_with_optional_fields_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_optional_int'; + elseif state == 2 + name = 'write_optional_record'; + elseif state == 4 + name = 'write_record_with_optional_fields'; + elseif state == 6 + name = 'write_optional_record_with_optional_fields'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/ScalarsReaderBase.m b/matlab/generated/+test_model/ScalarsReaderBase.m new file mode 100644 index 00000000..41a92464 --- /dev/null +++ b/matlab/generated/+test_model/ScalarsReaderBase.m @@ -0,0 +1,80 @@ +classdef ScalarsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = ScalarsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 4 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_int32(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_int32_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_record(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_record_(); + obj.state_ = 4; + end + + function copy_to(obj, writer) + writer.write_int32(obj.read_int32()); + writer.write_record(obj.read_record()); + end + end + + methods (Static) + function res = schema() + res = test_model.ScalarsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_int32_(obj, value) + read_record_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_int32'; + elseif state == 2 + name = 'read_record'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/ScalarsWriterBase.m b/matlab/generated/+test_model/ScalarsWriterBase.m new file mode 100644 index 00000000..dd6ab732 --- /dev/null +++ b/matlab/generated/+test_model/ScalarsWriterBase.m @@ -0,0 +1,72 @@ +% Abstract writer for protocol Scalars +classdef (Abstract) ScalarsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = ScalarsWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 4 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_int32(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_int32_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_record(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_record_(value); + obj.state_ = 4; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"Scalars","sequence":[{"name":"int32","type":"int32"},{"name":"record","type":"TestModel.RecordWithPrimitives"}]},"types":[{"name":"RecordWithPrimitives","fields":[{"name":"boolField","type":"bool"},{"name":"int8Field","type":"int8"},{"name":"uint8Field","type":"uint8"},{"name":"int16Field","type":"int16"},{"name":"uint16Field","type":"uint16"},{"name":"int32Field","type":"int32"},{"name":"uint32Field","type":"uint32"},{"name":"int64Field","type":"int64"},{"name":"uint64Field","type":"uint64"},{"name":"sizeField","type":"size"},{"name":"float32Field","type":"float32"},{"name":"float64Field","type":"float64"},{"name":"complexfloat32Field","type":"complexfloat32"},{"name":"complexfloat64Field","type":"complexfloat64"},{"name":"dateField","type":"date"},{"name":"timeField","type":"time"},{"name":"datetimeField","type":"datetime"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_int32_(obj, value) + write_record_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_int32'; + elseif state == 2 + name = 'write_record'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/SimpleAcquisition.m b/matlab/generated/+test_model/SimpleAcquisition.m new file mode 100644 index 00000000..a0b238d8 --- /dev/null +++ b/matlab/generated/+test_model/SimpleAcquisition.m @@ -0,0 +1,52 @@ +classdef SimpleAcquisition < handle + properties + flags + idx + data + trajectory + end + + methods + function obj = SimpleAcquisition(flags, idx, data, trajectory) + if nargin > 0 + obj.flags = flags; + obj.idx = idx; + obj.data = data; + obj.trajectory = trajectory; + else + obj.flags = uint64(0); + obj.idx = test_model.SimpleEncodingCounters(); + obj.data = single.empty(0, 0); + obj.trajectory = single.empty(0, 0); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.SimpleAcquisition') && ... + all([obj.flags] == [other.flags]) && ... + all([obj.idx] == [other.idx]) && ... + isequal(obj.data, other.data) && ... + isequal(obj.trajectory, other.trajectory); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.SimpleAcquisition(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/SimpleEncodingCounters.m b/matlab/generated/+test_model/SimpleEncodingCounters.m new file mode 100644 index 00000000..8172a83e --- /dev/null +++ b/matlab/generated/+test_model/SimpleEncodingCounters.m @@ -0,0 +1,52 @@ +classdef SimpleEncodingCounters < handle + properties + e1 + e2 + slice + repetition + end + + methods + function obj = SimpleEncodingCounters(e1, e2, slice, repetition) + if nargin > 0 + obj.e1 = e1; + obj.e2 = e2; + obj.slice = slice; + obj.repetition = repetition; + else + obj.e1 = yardl.None; + obj.e2 = yardl.None; + obj.slice = yardl.None; + obj.repetition = yardl.None; + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.SimpleEncodingCounters') && ... + all([obj.e1] == [other.e1]) && ... + all([obj.e2] == [other.e2]) && ... + all([obj.slice] == [other.slice]) && ... + all([obj.repetition] == [other.repetition]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.SimpleEncodingCounters(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/SimpleGenericsReaderBase.m b/matlab/generated/+test_model/SimpleGenericsReaderBase.m new file mode 100644 index 00000000..077a49a7 --- /dev/null +++ b/matlab/generated/+test_model/SimpleGenericsReaderBase.m @@ -0,0 +1,178 @@ +classdef SimpleGenericsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = SimpleGenericsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 18 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_float_image(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_float_image_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_int_image(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_int_image_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_int_image_alternate_syntax(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_int_image_alternate_syntax_(); + obj.state_ = 6; + end + + % Ordinal 3 + function value = read_string_image(obj) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + value = obj.read_string_image_(); + obj.state_ = 8; + end + + % Ordinal 4 + function value = read_int_float_tuple(obj) + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); + end + + value = obj.read_int_float_tuple_(); + obj.state_ = 10; + end + + % Ordinal 5 + function value = read_float_float_tuple(obj) + if obj.state_ ~= 10 + obj.raise_unexpected_state_(10); + end + + value = obj.read_float_float_tuple_(); + obj.state_ = 12; + end + + % Ordinal 6 + function value = read_int_float_tuple_alternate_syntax(obj) + if obj.state_ ~= 12 + obj.raise_unexpected_state_(12); + end + + value = obj.read_int_float_tuple_alternate_syntax_(); + obj.state_ = 14; + end + + % Ordinal 7 + function value = read_int_string_tuple(obj) + if obj.state_ ~= 14 + obj.raise_unexpected_state_(14); + end + + value = obj.read_int_string_tuple_(); + obj.state_ = 16; + end + + % Ordinal 8 + function value = read_stream_of_type_variants(obj) + if obj.state_ ~= 16 + obj.raise_unexpected_state_(16); + end + + value = obj.read_stream_of_type_variants_(); + obj.state_ = 18; + end + + function copy_to(obj, writer) + writer.write_float_image(obj.read_float_image()); + writer.write_int_image(obj.read_int_image()); + writer.write_int_image_alternate_syntax(obj.read_int_image_alternate_syntax()); + writer.write_string_image(obj.read_string_image()); + writer.write_int_float_tuple(obj.read_int_float_tuple()); + writer.write_float_float_tuple(obj.read_float_float_tuple()); + writer.write_int_float_tuple_alternate_syntax(obj.read_int_float_tuple_alternate_syntax()); + writer.write_int_string_tuple(obj.read_int_string_tuple()); + writer.write_stream_of_type_variants(obj.read_stream_of_type_variants()); + end + end + + methods (Static) + function res = schema() + res = test_model.SimpleGenericsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_float_image_(obj, value) + read_int_image_(obj, value) + read_int_image_alternate_syntax_(obj, value) + read_string_image_(obj, value) + read_int_float_tuple_(obj, value) + read_float_float_tuple_(obj, value) + read_int_float_tuple_alternate_syntax_(obj, value) + read_int_string_tuple_(obj, value) + read_stream_of_type_variants_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_float_image'; + elseif state == 2 + name = 'read_int_image'; + elseif state == 4 + name = 'read_int_image_alternate_syntax'; + elseif state == 6 + name = 'read_string_image'; + elseif state == 8 + name = 'read_int_float_tuple'; + elseif state == 10 + name = 'read_float_float_tuple'; + elseif state == 12 + name = 'read_int_float_tuple_alternate_syntax'; + elseif state == 14 + name = 'read_int_string_tuple'; + elseif state == 16 + name = 'read_stream_of_type_variants'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/SimpleGenericsWriterBase.m b/matlab/generated/+test_model/SimpleGenericsWriterBase.m new file mode 100644 index 00000000..14cbb1e4 --- /dev/null +++ b/matlab/generated/+test_model/SimpleGenericsWriterBase.m @@ -0,0 +1,168 @@ +% Abstract writer for protocol SimpleGenerics +classdef (Abstract) SimpleGenericsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = SimpleGenericsWriterBase() + obj.state_ = 0; + end + + function close(obj) + if obj.state_ == 17 + obj.end_stream_(); + obj.close_(); + return + end + obj.close_(); + if obj.state_ ~= 18 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_float_image(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_float_image_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_int_image(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_int_image_(value); + obj.state_ = 4; + end + + % Ordinal 2 + function write_int_image_alternate_syntax(obj, value) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_int_image_alternate_syntax_(value); + obj.state_ = 6; + end + + % Ordinal 3 + function write_string_image(obj, value) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + obj.write_string_image_(value); + obj.state_ = 8; + end + + % Ordinal 4 + function write_int_float_tuple(obj, value) + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); + end + + obj.write_int_float_tuple_(value); + obj.state_ = 10; + end + + % Ordinal 5 + function write_float_float_tuple(obj, value) + if obj.state_ ~= 10 + obj.raise_unexpected_state_(10); + end + + obj.write_float_float_tuple_(value); + obj.state_ = 12; + end + + % Ordinal 6 + function write_int_float_tuple_alternate_syntax(obj, value) + if obj.state_ ~= 12 + obj.raise_unexpected_state_(12); + end + + obj.write_int_float_tuple_alternate_syntax_(value); + obj.state_ = 14; + end + + % Ordinal 7 + function write_int_string_tuple(obj, value) + if obj.state_ ~= 14 + obj.raise_unexpected_state_(14); + end + + obj.write_int_string_tuple_(value); + obj.state_ = 16; + end + + % Ordinal 8 + function write_stream_of_type_variants(obj, value) + if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 16 + obj.raise_unexpected_state_(16); + end + + obj.write_stream_of_type_variants_(value); + obj.state_ = 17; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"SimpleGenerics","sequence":[{"name":"floatImage","type":"Image.FloatImage"},{"name":"intImage","type":"Image.IntImage"},{"name":"intImageAlternateSyntax","type":{"name":"TestModel.Image","typeArguments":["int32"]}},{"name":"stringImage","type":{"name":"TestModel.Image","typeArguments":["string"]}},{"name":"intFloatTuple","type":{"name":"Tuples.Tuple","typeArguments":["int32","float32"]}},{"name":"floatFloatTuple","type":{"name":"Tuples.Tuple","typeArguments":["float32","float32"]}},{"name":"intFloatTupleAlternateSyntax","type":{"name":"Tuples.Tuple","typeArguments":["int32","float32"]}},{"name":"intStringTuple","type":{"name":"Tuples.Tuple","typeArguments":["int32","string"]}},{"name":"streamOfTypeVariants","type":{"stream":{"items":[{"tag":"imageFloat","explicitTag":true,"type":"Image.FloatImage"},{"tag":"imageDouble","explicitTag":true,"type":{"name":"TestModel.Image","typeArguments":["float64"]}}]}}}]},"types":[{"name":"FloatImage","type":{"name":"Image.Image","typeArguments":["float32"]}},{"name":"Image","typeParameters":["T"],"type":{"array":{"items":"T","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"IntImage","type":{"name":"Image.Image","typeArguments":["int32"]}},{"name":"Image","typeParameters":["T"],"type":{"name":"Image.Image","typeArguments":["T"]}},{"name":"Tuple","typeParameters":["T1","T2"],"fields":[{"name":"v1","type":"T1"},{"name":"v2","type":"T2"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_float_image_(obj, value) + write_int_image_(obj, value) + write_int_image_alternate_syntax_(obj, value) + write_string_image_(obj, value) + write_int_float_tuple_(obj, value) + write_float_float_tuple_(obj, value) + write_int_float_tuple_alternate_syntax_(obj, value) + write_int_string_tuple_(obj, value) + write_stream_of_type_variants_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_float_image'; + elseif state == 2 + name = 'write_int_image'; + elseif state == 4 + name = 'write_int_image_alternate_syntax'; + elseif state == 6 + name = 'write_string_image'; + elseif state == 8 + name = 'write_int_float_tuple'; + elseif state == 10 + name = 'write_float_float_tuple'; + elseif state == 12 + name = 'write_int_float_tuple_alternate_syntax'; + elseif state == 14 + name = 'write_int_string_tuple'; + elseif state == 16 + name = 'write_stream_of_type_variants'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/SimpleRecord.m b/matlab/generated/+test_model/SimpleRecord.m new file mode 100644 index 00000000..2448ba33 --- /dev/null +++ b/matlab/generated/+test_model/SimpleRecord.m @@ -0,0 +1,48 @@ +classdef SimpleRecord < handle + properties + x + y + z + end + + methods + function obj = SimpleRecord(x, y, z) + if nargin > 0 + obj.x = x; + obj.y = y; + obj.z = z; + else + obj.x = int32(0); + obj.y = int32(0); + obj.z = int32(0); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.SimpleRecord') && ... + all([obj.x] == [other.x]) && ... + all([obj.y] == [other.y]) && ... + all([obj.z] == [other.z]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.SimpleRecord(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/SimpleRecordFixedArray.m b/matlab/generated/+test_model/SimpleRecordFixedArray.m new file mode 100644 index 00000000..9afc355e --- /dev/null +++ b/matlab/generated/+test_model/SimpleRecordFixedArray.m @@ -0,0 +1,4 @@ +function a = SimpleRecordFixedArray(array) + assert(isa(array, 'test_model.SimpleRecord')); + a = array; +end diff --git a/matlab/generated/+test_model/SizeBasedEnum.m b/matlab/generated/+test_model/SizeBasedEnum.m new file mode 100644 index 00000000..518107dd --- /dev/null +++ b/matlab/generated/+test_model/SizeBasedEnum.m @@ -0,0 +1,26 @@ +classdef SizeBasedEnum < uint64 + methods (Static) + function e = A + e = test_model.SizeBasedEnum(0); + end + function e = B + e = test_model.SizeBasedEnum(1); + end + function e = C + e = test_model.SizeBasedEnum(2); + end + + function z = zeros(varargin) + elem = test_model.SizeBasedEnum(0); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/SmallBenchmarkRecord.m b/matlab/generated/+test_model/SmallBenchmarkRecord.m new file mode 100644 index 00000000..de30e923 --- /dev/null +++ b/matlab/generated/+test_model/SmallBenchmarkRecord.m @@ -0,0 +1,48 @@ +classdef SmallBenchmarkRecord < handle + properties + a + b + c + end + + methods + function obj = SmallBenchmarkRecord(a, b, c) + if nargin > 0 + obj.a = a; + obj.b = b; + obj.c = c; + else + obj.a = double(0); + obj.b = single(0); + obj.c = single(0); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.SmallBenchmarkRecord') && ... + all([obj.a] == [other.a]) && ... + all([obj.b] == [other.b]) && ... + all([obj.c] == [other.c]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.SmallBenchmarkRecord(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/StateTestReaderBase.m b/matlab/generated/+test_model/StateTestReaderBase.m new file mode 100644 index 00000000..2972f281 --- /dev/null +++ b/matlab/generated/+test_model/StateTestReaderBase.m @@ -0,0 +1,94 @@ +classdef StateTestReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = StateTestReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 6 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_an_int(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_an_int_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_a_stream(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_a_stream_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_another_int(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_another_int_(); + obj.state_ = 6; + end + + function copy_to(obj, writer) + writer.write_an_int(obj.read_an_int()); + writer.write_a_stream(obj.read_a_stream()); + writer.write_another_int(obj.read_another_int()); + end + end + + methods (Static) + function res = schema() + res = test_model.StateTestWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_an_int_(obj, value) + read_a_stream_(obj, value) + read_another_int_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_an_int'; + elseif state == 2 + name = 'read_a_stream'; + elseif state == 4 + name = 'read_another_int'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/StateTestWriterBase.m b/matlab/generated/+test_model/StateTestWriterBase.m new file mode 100644 index 00000000..144ff332 --- /dev/null +++ b/matlab/generated/+test_model/StateTestWriterBase.m @@ -0,0 +1,88 @@ +% Abstract writer for protocol StateTest +classdef (Abstract) StateTestWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = StateTestWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 6 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_an_int(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_an_int_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_a_stream(obj, value) + if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_a_stream_(value); + obj.state_ = 3; + end + + % Ordinal 2 + function write_another_int(obj, value) + if obj.state_ == 3 + obj.end_stream_(); + obj.state_ = 4; + elseif obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_another_int_(value); + obj.state_ = 6; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"StateTest","sequence":[{"name":"anInt","type":"int32"},{"name":"aStream","type":{"stream":{"items":"int32"}}},{"name":"anotherInt","type":"int32"}]},"types":null}'); + end + end + + methods (Abstract, Access=protected) + write_an_int_(obj, value) + write_a_stream_(obj, value) + write_another_int_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_an_int'; + elseif state == 2 + name = 'write_a_stream'; + elseif state == 4 + name = 'write_another_int'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m b/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m new file mode 100644 index 00000000..c24e3fc8 --- /dev/null +++ b/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m @@ -0,0 +1,80 @@ +classdef StreamsOfAliasedUnionsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = StreamsOfAliasedUnionsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 4 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_int_or_simple_record(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_int_or_simple_record_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_nullable_int_or_simple_record(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_nullable_int_or_simple_record_(); + obj.state_ = 4; + end + + function copy_to(obj, writer) + writer.write_int_or_simple_record(obj.read_int_or_simple_record()); + writer.write_nullable_int_or_simple_record(obj.read_nullable_int_or_simple_record()); + end + end + + methods (Static) + function res = schema() + res = test_model.StreamsOfAliasedUnionsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_int_or_simple_record_(obj, value) + read_nullable_int_or_simple_record_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_int_or_simple_record'; + elseif state == 2 + name = 'read_nullable_int_or_simple_record'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m b/matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m new file mode 100644 index 00000000..73524678 --- /dev/null +++ b/matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m @@ -0,0 +1,80 @@ +% Abstract writer for protocol StreamsOfAliasedUnions +classdef (Abstract) StreamsOfAliasedUnionsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = StreamsOfAliasedUnionsWriterBase() + obj.state_ = 0; + end + + function close(obj) + if obj.state_ == 3 + obj.end_stream_(); + obj.close_(); + return + end + obj.close_(); + if obj.state_ ~= 4 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_int_or_simple_record(obj, value) + if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_int_or_simple_record_(value); + obj.state_ = 1; + end + + % Ordinal 1 + function write_nullable_int_or_simple_record(obj, value) + if obj.state_ == 1 + obj.end_stream_(); + obj.state_ = 2; + elseif bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_nullable_int_or_simple_record_(value); + obj.state_ = 3; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"StreamsOfAliasedUnions","sequence":[{"name":"intOrSimpleRecord","type":{"stream":{"items":"TestModel.AliasedIntOrSimpleRecord"}}},{"name":"nullableIntOrSimpleRecord","type":{"stream":{"items":"TestModel.AliasedNullableIntSimpleRecord"}}}]},"types":[{"name":"AliasedIntOrSimpleRecord","type":[{"tag":"int32","type":"int32"},{"tag":"SimpleRecord","type":"TestModel.SimpleRecord"}]},{"name":"AliasedNullableIntSimpleRecord","type":[null,{"tag":"int32","type":"int32"},{"tag":"SimpleRecord","type":"TestModel.SimpleRecord"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_int_or_simple_record_(obj, value) + write_nullable_int_or_simple_record_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_int_or_simple_record'; + elseif state == 2 + name = 'write_nullable_int_or_simple_record'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m b/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m new file mode 100644 index 00000000..bffeb4d2 --- /dev/null +++ b/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m @@ -0,0 +1,80 @@ +classdef StreamsOfUnionsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = StreamsOfUnionsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 4 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_int_or_simple_record(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_int_or_simple_record_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_nullable_int_or_simple_record(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_nullable_int_or_simple_record_(); + obj.state_ = 4; + end + + function copy_to(obj, writer) + writer.write_int_or_simple_record(obj.read_int_or_simple_record()); + writer.write_nullable_int_or_simple_record(obj.read_nullable_int_or_simple_record()); + end + end + + methods (Static) + function res = schema() + res = test_model.StreamsOfUnionsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_int_or_simple_record_(obj, value) + read_nullable_int_or_simple_record_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_int_or_simple_record'; + elseif state == 2 + name = 'read_nullable_int_or_simple_record'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/StreamsOfUnionsWriterBase.m b/matlab/generated/+test_model/StreamsOfUnionsWriterBase.m new file mode 100644 index 00000000..fa4ff5e0 --- /dev/null +++ b/matlab/generated/+test_model/StreamsOfUnionsWriterBase.m @@ -0,0 +1,80 @@ +% Abstract writer for protocol StreamsOfUnions +classdef (Abstract) StreamsOfUnionsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = StreamsOfUnionsWriterBase() + obj.state_ = 0; + end + + function close(obj) + if obj.state_ == 3 + obj.end_stream_(); + obj.close_(); + return + end + obj.close_(); + if obj.state_ ~= 4 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_int_or_simple_record(obj, value) + if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_int_or_simple_record_(value); + obj.state_ = 1; + end + + % Ordinal 1 + function write_nullable_int_or_simple_record(obj, value) + if obj.state_ == 1 + obj.end_stream_(); + obj.state_ = 2; + elseif bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_nullable_int_or_simple_record_(value); + obj.state_ = 3; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"StreamsOfUnions","sequence":[{"name":"intOrSimpleRecord","type":{"stream":{"items":[{"tag":"int32","type":"int32"},{"tag":"SimpleRecord","type":"TestModel.SimpleRecord"}]}}},{"name":"nullableIntOrSimpleRecord","type":{"stream":{"items":[null,{"tag":"int32","type":"int32"},{"tag":"SimpleRecord","type":"TestModel.SimpleRecord"}]}}}]},"types":[{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_int_or_simple_record_(obj, value) + write_nullable_int_or_simple_record_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_int_or_simple_record'; + elseif state == 2 + name = 'write_nullable_int_or_simple_record'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/StreamsReaderBase.m b/matlab/generated/+test_model/StreamsReaderBase.m new file mode 100644 index 00000000..b95c04db --- /dev/null +++ b/matlab/generated/+test_model/StreamsReaderBase.m @@ -0,0 +1,108 @@ +classdef StreamsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = StreamsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 8 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_int_data(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_int_data_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_optional_int_data(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_optional_int_data_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_record_with_optional_vector_data(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_record_with_optional_vector_data_(); + obj.state_ = 6; + end + + % Ordinal 3 + function value = read_fixed_vector(obj) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + value = obj.read_fixed_vector_(); + obj.state_ = 8; + end + + function copy_to(obj, writer) + writer.write_int_data(obj.read_int_data()); + writer.write_optional_int_data(obj.read_optional_int_data()); + writer.write_record_with_optional_vector_data(obj.read_record_with_optional_vector_data()); + writer.write_fixed_vector(obj.read_fixed_vector()); + end + end + + methods (Static) + function res = schema() + res = test_model.StreamsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_int_data_(obj, value) + read_optional_int_data_(obj, value) + read_record_with_optional_vector_data_(obj, value) + read_fixed_vector_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_int_data'; + elseif state == 2 + name = 'read_optional_int_data'; + elseif state == 4 + name = 'read_record_with_optional_vector_data'; + elseif state == 6 + name = 'read_fixed_vector'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/StreamsWriterBase.m b/matlab/generated/+test_model/StreamsWriterBase.m new file mode 100644 index 00000000..f506db37 --- /dev/null +++ b/matlab/generated/+test_model/StreamsWriterBase.m @@ -0,0 +1,112 @@ +% Abstract writer for protocol Streams +classdef (Abstract) StreamsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = StreamsWriterBase() + obj.state_ = 0; + end + + function close(obj) + if obj.state_ == 7 + obj.end_stream_(); + obj.close_(); + return + end + obj.close_(); + if obj.state_ ~= 8 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_int_data(obj, value) + if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_int_data_(value); + obj.state_ = 1; + end + + % Ordinal 1 + function write_optional_int_data(obj, value) + if obj.state_ == 1 + obj.end_stream_(); + obj.state_ = 2; + elseif bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_optional_int_data_(value); + obj.state_ = 3; + end + + % Ordinal 2 + function write_record_with_optional_vector_data(obj, value) + if obj.state_ == 3 + obj.end_stream_(); + obj.state_ = 4; + elseif bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_record_with_optional_vector_data_(value); + obj.state_ = 5; + end + + % Ordinal 3 + function write_fixed_vector(obj, value) + if obj.state_ == 5 + obj.end_stream_(); + obj.state_ = 6; + elseif bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 6 + obj.raise_unexpected_state_(6); + end + + obj.write_fixed_vector_(value); + obj.state_ = 7; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"Streams","sequence":[{"name":"intData","type":{"stream":{"items":"int32"}}},{"name":"optionalIntData","type":{"stream":{"items":[null,"int32"]}}},{"name":"recordWithOptionalVectorData","type":{"stream":{"items":"TestModel.RecordWithOptionalVector"}}},{"name":"fixedVector","type":{"stream":{"items":{"vector":{"items":"int32","length":3}}}}}]},"types":[{"name":"RecordWithOptionalVector","fields":[{"name":"optionalVector","type":[null,{"vector":{"items":"int32"}}]}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_int_data_(obj, value) + write_optional_int_data_(obj, value) + write_record_with_optional_vector_data_(obj, value) + write_fixed_vector_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_int_data'; + elseif state == 2 + name = 'write_optional_int_data'; + elseif state == 4 + name = 'write_record_with_optional_vector_data'; + elseif state == 6 + name = 'write_fixed_vector'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/StringOrInt32.m b/matlab/generated/+test_model/StringOrInt32.m new file mode 100644 index 00000000..a90aa966 --- /dev/null +++ b/matlab/generated/+test_model/StringOrInt32.m @@ -0,0 +1,34 @@ +classdef StringOrInt32 < yardl.Union + methods (Static) + function res = String(value) + res = test_model.StringOrInt32(1, value); + end + + function res = Int32(value) + res = test_model.StringOrInt32(2, value); + end + + function z = zeros(varargin) + elem = test_model.StringOrInt32(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.StringOrInt32') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/StringsReaderBase.m b/matlab/generated/+test_model/StringsReaderBase.m new file mode 100644 index 00000000..175ea208 --- /dev/null +++ b/matlab/generated/+test_model/StringsReaderBase.m @@ -0,0 +1,80 @@ +classdef StringsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = StringsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 4 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_single_string(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_single_string_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_rec_with_string(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_rec_with_string_(); + obj.state_ = 4; + end + + function copy_to(obj, writer) + writer.write_single_string(obj.read_single_string()); + writer.write_rec_with_string(obj.read_rec_with_string()); + end + end + + methods (Static) + function res = schema() + res = test_model.StringsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_single_string_(obj, value) + read_rec_with_string_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_single_string'; + elseif state == 2 + name = 'read_rec_with_string'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/StringsWriterBase.m b/matlab/generated/+test_model/StringsWriterBase.m new file mode 100644 index 00000000..79cf638b --- /dev/null +++ b/matlab/generated/+test_model/StringsWriterBase.m @@ -0,0 +1,72 @@ +% Abstract writer for protocol Strings +classdef (Abstract) StringsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = StringsWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 4 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_single_string(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_single_string_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_rec_with_string(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_rec_with_string_(value); + obj.state_ = 4; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"Strings","sequence":[{"name":"singleString","type":"string"},{"name":"recWithString","type":"TestModel.RecordWithStrings"}]},"types":[{"name":"RecordWithStrings","fields":[{"name":"a","type":"string"},{"name":"b","type":"string"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_single_string_(obj, value) + write_rec_with_string_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_single_string'; + elseif state == 2 + name = 'write_rec_with_string'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m b/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m new file mode 100644 index 00000000..ae2deacb --- /dev/null +++ b/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m @@ -0,0 +1,80 @@ +classdef SubarraysInRecordsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = SubarraysInRecordsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 4 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_with_fixed_subarrays(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_with_fixed_subarrays_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_with_vlen_subarrays(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_with_vlen_subarrays_(); + obj.state_ = 4; + end + + function copy_to(obj, writer) + writer.write_with_fixed_subarrays(obj.read_with_fixed_subarrays()); + writer.write_with_vlen_subarrays(obj.read_with_vlen_subarrays()); + end + end + + methods (Static) + function res = schema() + res = test_model.SubarraysInRecordsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_with_fixed_subarrays_(obj, value) + read_with_vlen_subarrays_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_with_fixed_subarrays'; + elseif state == 2 + name = 'read_with_vlen_subarrays'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/SubarraysInRecordsWriterBase.m b/matlab/generated/+test_model/SubarraysInRecordsWriterBase.m new file mode 100644 index 00000000..bc87b372 --- /dev/null +++ b/matlab/generated/+test_model/SubarraysInRecordsWriterBase.m @@ -0,0 +1,72 @@ +% Abstract writer for protocol SubarraysInRecords +classdef (Abstract) SubarraysInRecordsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = SubarraysInRecordsWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 4 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_with_fixed_subarrays(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_with_fixed_subarrays_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_with_vlen_subarrays(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_with_vlen_subarrays_(value); + obj.state_ = 4; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"SubarraysInRecords","sequence":[{"name":"withFixedSubarrays","type":{"array":{"items":"TestModel.RecordWithFixedCollections"}}},{"name":"withVlenSubarrays","type":{"array":{"items":"TestModel.RecordWithVlenCollections"}}}]},"types":[{"name":"RecordWithFixedCollections","fields":[{"name":"fixedVector","type":{"vector":{"items":"int32","length":3}}},{"name":"fixedArray","type":{"array":{"items":"int32","dimensions":[{"length":2},{"length":3}]}}}]},{"name":"RecordWithVlenCollections","fields":[{"name":"vector","type":{"vector":{"items":"int32"}}},{"name":"array","type":{"array":{"items":"int32","dimensions":2}}}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_with_fixed_subarrays_(obj, value) + write_with_vlen_subarrays_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_with_fixed_subarrays'; + elseif state == 2 + name = 'write_with_vlen_subarrays'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/SubarraysReaderBase.m b/matlab/generated/+test_model/SubarraysReaderBase.m new file mode 100644 index 00000000..cfb47c0a --- /dev/null +++ b/matlab/generated/+test_model/SubarraysReaderBase.m @@ -0,0 +1,178 @@ +classdef SubarraysReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = SubarraysReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 18 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_dynamic_with_fixed_int_subarray(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_dynamic_with_fixed_int_subarray_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_dynamic_with_fixed_float_subarray(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_dynamic_with_fixed_float_subarray_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_known_dim_count_with_fixed_int_subarray(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_known_dim_count_with_fixed_int_subarray_(); + obj.state_ = 6; + end + + % Ordinal 3 + function value = read_known_dim_count_with_fixed_float_subarray(obj) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + value = obj.read_known_dim_count_with_fixed_float_subarray_(); + obj.state_ = 8; + end + + % Ordinal 4 + function value = read_fixed_with_fixed_int_subarray(obj) + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); + end + + value = obj.read_fixed_with_fixed_int_subarray_(); + obj.state_ = 10; + end + + % Ordinal 5 + function value = read_fixed_with_fixed_float_subarray(obj) + if obj.state_ ~= 10 + obj.raise_unexpected_state_(10); + end + + value = obj.read_fixed_with_fixed_float_subarray_(); + obj.state_ = 12; + end + + % Ordinal 6 + function value = read_nested_subarray(obj) + if obj.state_ ~= 12 + obj.raise_unexpected_state_(12); + end + + value = obj.read_nested_subarray_(); + obj.state_ = 14; + end + + % Ordinal 7 + function value = read_dynamic_with_fixed_vector_subarray(obj) + if obj.state_ ~= 14 + obj.raise_unexpected_state_(14); + end + + value = obj.read_dynamic_with_fixed_vector_subarray_(); + obj.state_ = 16; + end + + % Ordinal 8 + function value = read_generic_subarray(obj) + if obj.state_ ~= 16 + obj.raise_unexpected_state_(16); + end + + value = obj.read_generic_subarray_(); + obj.state_ = 18; + end + + function copy_to(obj, writer) + writer.write_dynamic_with_fixed_int_subarray(obj.read_dynamic_with_fixed_int_subarray()); + writer.write_dynamic_with_fixed_float_subarray(obj.read_dynamic_with_fixed_float_subarray()); + writer.write_known_dim_count_with_fixed_int_subarray(obj.read_known_dim_count_with_fixed_int_subarray()); + writer.write_known_dim_count_with_fixed_float_subarray(obj.read_known_dim_count_with_fixed_float_subarray()); + writer.write_fixed_with_fixed_int_subarray(obj.read_fixed_with_fixed_int_subarray()); + writer.write_fixed_with_fixed_float_subarray(obj.read_fixed_with_fixed_float_subarray()); + writer.write_nested_subarray(obj.read_nested_subarray()); + writer.write_dynamic_with_fixed_vector_subarray(obj.read_dynamic_with_fixed_vector_subarray()); + writer.write_generic_subarray(obj.read_generic_subarray()); + end + end + + methods (Static) + function res = schema() + res = test_model.SubarraysWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_dynamic_with_fixed_int_subarray_(obj, value) + read_dynamic_with_fixed_float_subarray_(obj, value) + read_known_dim_count_with_fixed_int_subarray_(obj, value) + read_known_dim_count_with_fixed_float_subarray_(obj, value) + read_fixed_with_fixed_int_subarray_(obj, value) + read_fixed_with_fixed_float_subarray_(obj, value) + read_nested_subarray_(obj, value) + read_dynamic_with_fixed_vector_subarray_(obj, value) + read_generic_subarray_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_dynamic_with_fixed_int_subarray'; + elseif state == 2 + name = 'read_dynamic_with_fixed_float_subarray'; + elseif state == 4 + name = 'read_known_dim_count_with_fixed_int_subarray'; + elseif state == 6 + name = 'read_known_dim_count_with_fixed_float_subarray'; + elseif state == 8 + name = 'read_fixed_with_fixed_int_subarray'; + elseif state == 10 + name = 'read_fixed_with_fixed_float_subarray'; + elseif state == 12 + name = 'read_nested_subarray'; + elseif state == 14 + name = 'read_dynamic_with_fixed_vector_subarray'; + elseif state == 16 + name = 'read_generic_subarray'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/SubarraysWriterBase.m b/matlab/generated/+test_model/SubarraysWriterBase.m new file mode 100644 index 00000000..b8b723d7 --- /dev/null +++ b/matlab/generated/+test_model/SubarraysWriterBase.m @@ -0,0 +1,163 @@ +% Abstract writer for protocol Subarrays +classdef (Abstract) SubarraysWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = SubarraysWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 18 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_dynamic_with_fixed_int_subarray(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_dynamic_with_fixed_int_subarray_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_dynamic_with_fixed_float_subarray(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_dynamic_with_fixed_float_subarray_(value); + obj.state_ = 4; + end + + % Ordinal 2 + function write_known_dim_count_with_fixed_int_subarray(obj, value) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_known_dim_count_with_fixed_int_subarray_(value); + obj.state_ = 6; + end + + % Ordinal 3 + function write_known_dim_count_with_fixed_float_subarray(obj, value) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + obj.write_known_dim_count_with_fixed_float_subarray_(value); + obj.state_ = 8; + end + + % Ordinal 4 + function write_fixed_with_fixed_int_subarray(obj, value) + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); + end + + obj.write_fixed_with_fixed_int_subarray_(value); + obj.state_ = 10; + end + + % Ordinal 5 + function write_fixed_with_fixed_float_subarray(obj, value) + if obj.state_ ~= 10 + obj.raise_unexpected_state_(10); + end + + obj.write_fixed_with_fixed_float_subarray_(value); + obj.state_ = 12; + end + + % Ordinal 6 + function write_nested_subarray(obj, value) + if obj.state_ ~= 12 + obj.raise_unexpected_state_(12); + end + + obj.write_nested_subarray_(value); + obj.state_ = 14; + end + + % Ordinal 7 + function write_dynamic_with_fixed_vector_subarray(obj, value) + if obj.state_ ~= 14 + obj.raise_unexpected_state_(14); + end + + obj.write_dynamic_with_fixed_vector_subarray_(value); + obj.state_ = 16; + end + + % Ordinal 8 + function write_generic_subarray(obj, value) + if obj.state_ ~= 16 + obj.raise_unexpected_state_(16); + end + + obj.write_generic_subarray_(value); + obj.state_ = 18; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"Subarrays","sequence":[{"name":"dynamicWithFixedIntSubarray","type":{"array":{"items":{"array":{"items":"int32","dimensions":[{"length":3}]}}}}},{"name":"dynamicWithFixedFloatSubarray","type":{"array":{"items":{"array":{"items":"float32","dimensions":[{"length":3}]}}}}},{"name":"knownDimCountWithFixedIntSubarray","type":{"array":{"items":{"array":{"items":"int32","dimensions":[{"length":3}]}},"dimensions":1}}},{"name":"knownDimCountWithFixedFloatSubarray","type":{"array":{"items":{"array":{"items":"float32","dimensions":[{"length":3}]}},"dimensions":1}}},{"name":"fixedWithFixedIntSubarray","type":{"array":{"items":{"array":{"items":"int32","dimensions":[{"length":3}]}},"dimensions":[{"length":2}]}}},{"name":"fixedWithFixedFloatSubarray","type":{"array":{"items":{"array":{"items":"float32","dimensions":[{"length":3}]}},"dimensions":[{"length":2}]}}},{"name":"nestedSubarray","type":{"array":{"items":{"array":{"items":{"array":{"items":"int32","dimensions":[{"length":3}]}},"dimensions":[{"length":2}]}}}}},{"name":"dynamicWithFixedVectorSubarray","type":{"array":{"items":{"vector":{"items":"int32","length":3}}}}},{"name":"genericSubarray","type":{"name":"TestModel.Image","typeArguments":[{"array":{"items":"int32","dimensions":[{"length":3}]}}]}}]},"types":[{"name":"Image","typeParameters":["T"],"type":{"array":{"items":"T","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"Image","typeParameters":["T"],"type":{"name":"Image.Image","typeArguments":["T"]}}]}'); + end + end + + methods (Abstract, Access=protected) + write_dynamic_with_fixed_int_subarray_(obj, value) + write_dynamic_with_fixed_float_subarray_(obj, value) + write_known_dim_count_with_fixed_int_subarray_(obj, value) + write_known_dim_count_with_fixed_float_subarray_(obj, value) + write_fixed_with_fixed_int_subarray_(obj, value) + write_fixed_with_fixed_float_subarray_(obj, value) + write_nested_subarray_(obj, value) + write_dynamic_with_fixed_vector_subarray_(obj, value) + write_generic_subarray_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_dynamic_with_fixed_int_subarray'; + elseif state == 2 + name = 'write_dynamic_with_fixed_float_subarray'; + elseif state == 4 + name = 'write_known_dim_count_with_fixed_int_subarray'; + elseif state == 6 + name = 'write_known_dim_count_with_fixed_float_subarray'; + elseif state == 8 + name = 'write_fixed_with_fixed_int_subarray'; + elseif state == 10 + name = 'write_fixed_with_fixed_float_subarray'; + elseif state == 12 + name = 'write_nested_subarray'; + elseif state == 14 + name = 'write_dynamic_with_fixed_vector_subarray'; + elseif state == 16 + name = 'write_generic_subarray'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/TextFormat.m b/matlab/generated/+test_model/TextFormat.m new file mode 100644 index 00000000..747cab58 --- /dev/null +++ b/matlab/generated/+test_model/TextFormat.m @@ -0,0 +1,2 @@ +classdef TextFormat < basic_types.TextFormat +end diff --git a/matlab/generated/+test_model/TupleWithRecords.m b/matlab/generated/+test_model/TupleWithRecords.m new file mode 100644 index 00000000..5c6309dc --- /dev/null +++ b/matlab/generated/+test_model/TupleWithRecords.m @@ -0,0 +1,44 @@ +classdef TupleWithRecords < handle + properties + a + b + end + + methods + function obj = TupleWithRecords(a, b) + if nargin > 0 + obj.a = a; + obj.b = b; + else + obj.a = test_model.SimpleRecord(); + obj.b = test_model.SimpleRecord(); + end + end + + function res = eq(obj, other) + res = ... + isa(other, 'test_model.TupleWithRecords') && ... + all([obj.a] == [other.a]) && ... + all([obj.b] == [other.b]); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + + methods (Static) + function z = zeros(varargin) + elem = test_model.TupleWithRecords(); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/UInt64Enum.m b/matlab/generated/+test_model/UInt64Enum.m new file mode 100644 index 00000000..7de335ff --- /dev/null +++ b/matlab/generated/+test_model/UInt64Enum.m @@ -0,0 +1,20 @@ +classdef UInt64Enum < uint64 + methods (Static) + function e = A + e = test_model.UInt64Enum(9223372036854775808); + end + + function z = zeros(varargin) + elem = test_model.UInt64Enum(0); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end +end diff --git a/matlab/generated/+test_model/UOrV.m b/matlab/generated/+test_model/UOrV.m new file mode 100644 index 00000000..f00a8e24 --- /dev/null +++ b/matlab/generated/+test_model/UOrV.m @@ -0,0 +1,34 @@ +classdef UOrV < yardl.Union + methods (Static) + function res = U(value) + res = test_model.UOrV(1, value); + end + + function res = V(value) + res = test_model.UOrV(2, value); + end + + function z = zeros(varargin) + elem = test_model.UOrV(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.UOrV') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/UnionsReaderBase.m b/matlab/generated/+test_model/UnionsReaderBase.m new file mode 100644 index 00000000..cb93a0a2 --- /dev/null +++ b/matlab/generated/+test_model/UnionsReaderBase.m @@ -0,0 +1,108 @@ +classdef UnionsReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = UnionsReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 8 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_int_or_simple_record(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_int_or_simple_record_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_int_or_record_with_vlens(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_int_or_record_with_vlens_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_monosotate_or_int_or_simple_record(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_monosotate_or_int_or_simple_record_(); + obj.state_ = 6; + end + + % Ordinal 3 + function value = read_record_with_unions(obj) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + value = obj.read_record_with_unions_(); + obj.state_ = 8; + end + + function copy_to(obj, writer) + writer.write_int_or_simple_record(obj.read_int_or_simple_record()); + writer.write_int_or_record_with_vlens(obj.read_int_or_record_with_vlens()); + writer.write_monosotate_or_int_or_simple_record(obj.read_monosotate_or_int_or_simple_record()); + writer.write_record_with_unions(obj.read_record_with_unions()); + end + end + + methods (Static) + function res = schema() + res = test_model.UnionsWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_int_or_simple_record_(obj, value) + read_int_or_record_with_vlens_(obj, value) + read_monosotate_or_int_or_simple_record_(obj, value) + read_record_with_unions_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_int_or_simple_record'; + elseif state == 2 + name = 'read_int_or_record_with_vlens'; + elseif state == 4 + name = 'read_monosotate_or_int_or_simple_record'; + elseif state == 6 + name = 'read_record_with_unions'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/UnionsWriterBase.m b/matlab/generated/+test_model/UnionsWriterBase.m new file mode 100644 index 00000000..7355cd70 --- /dev/null +++ b/matlab/generated/+test_model/UnionsWriterBase.m @@ -0,0 +1,98 @@ +% Abstract writer for protocol Unions +classdef (Abstract) UnionsWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = UnionsWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 8 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_int_or_simple_record(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_int_or_simple_record_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_int_or_record_with_vlens(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_int_or_record_with_vlens_(value); + obj.state_ = 4; + end + + % Ordinal 2 + function write_monosotate_or_int_or_simple_record(obj, value) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_monosotate_or_int_or_simple_record_(value); + obj.state_ = 6; + end + + % Ordinal 3 + function write_record_with_unions(obj, value) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + obj.write_record_with_unions_(value); + obj.state_ = 8; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"Unions","sequence":[{"name":"intOrSimpleRecord","type":[{"tag":"int32","type":"int32"},{"tag":"SimpleRecord","type":"TestModel.SimpleRecord"}]},{"name":"intOrRecordWithVlens","type":[{"tag":"int32","type":"int32"},{"tag":"RecordWithVlens","type":"TestModel.RecordWithVlens"}]},{"name":"monosotateOrIntOrSimpleRecord","type":[null,{"tag":"int32","type":"int32"},{"tag":"SimpleRecord","type":"TestModel.SimpleRecord"}]},{"name":"recordWithUnions","type":"BasicTypes.RecordWithUnions"}]},"types":[{"name":"DaysOfWeek","values":[{"symbol":"monday","value":1},{"symbol":"tuesday","value":2},{"symbol":"wednesday","value":4},{"symbol":"thursday","value":8},{"symbol":"friday","value":16},{"symbol":"saturday","value":32},{"symbol":"sunday","value":64}]},{"name":"Fruits","values":[{"symbol":"apple","value":0},{"symbol":"banana","value":1},{"symbol":"pear","value":2}]},{"name":"GenericNullableUnion2","typeParameters":["T1","T2"],"type":[null,{"tag":"T1","type":"T1"},{"tag":"T2","type":"T2"}]},{"name":"RecordWithUnions","fields":[{"name":"nullOrIntOrString","type":[null,{"tag":"int32","type":"int32"},{"tag":"string","type":"string"}]},{"name":"dateOrDatetime","type":[{"tag":"time","type":"time"},{"tag":"datetime","type":"datetime"}]},{"name":"nullOrFruitsOrDaysOfWeek","type":{"name":"BasicTypes.GenericNullableUnion2","typeArguments":["BasicTypes.Fruits","BasicTypes.DaysOfWeek"]}}]},{"name":"RecordWithVlens","fields":[{"name":"a","type":{"vector":{"items":"TestModel.SimpleRecord"}}},{"name":"b","type":"int32"},{"name":"c","type":"int32"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_int_or_simple_record_(obj, value) + write_int_or_record_with_vlens_(obj, value) + write_monosotate_or_int_or_simple_record_(obj, value) + write_record_with_unions_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_int_or_simple_record'; + elseif state == 2 + name = 'write_int_or_record_with_vlens'; + elseif state == 4 + name = 'write_monosotate_or_int_or_simple_record'; + elseif state == 6 + name = 'write_record_with_unions'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/VectorOfGenericRecords.m b/matlab/generated/+test_model/VectorOfGenericRecords.m new file mode 100644 index 00000000..0e6b0804 --- /dev/null +++ b/matlab/generated/+test_model/VectorOfGenericRecords.m @@ -0,0 +1,3 @@ +function a = VectorOfGenericRecords(array) + a = array; +end diff --git a/matlab/generated/+test_model/VectorOrScalar.m b/matlab/generated/+test_model/VectorOrScalar.m new file mode 100644 index 00000000..73ce6ded --- /dev/null +++ b/matlab/generated/+test_model/VectorOrScalar.m @@ -0,0 +1,34 @@ +classdef VectorOrScalar < yardl.Union + methods (Static) + function res = Vector(value) + res = test_model.VectorOrScalar(1, value); + end + + function res = Scalar(value) + res = test_model.VectorOrScalar(2, value); + end + + function z = zeros(varargin) + elem = test_model.VectorOrScalar(0, yardl.None); + if nargin == 0 + z = elem; + elseif nargin == 1 + n = varargin{1}; + z = reshape(repelem(elem, n*n), [n, n]); + else + sz = [varargin{:}]; + z = reshape(repelem(elem, prod(sz)), sz); + end + end + end + + methods + function eq = eq(self, other) + eq = isa(other, 'test_model.VectorOrScalar') && other.index == self.index && other.value == self.value; + end + + function ne = ne(self, other) + ne = ~self.eq(other); + end + end +end diff --git a/matlab/generated/+test_model/VlensReaderBase.m b/matlab/generated/+test_model/VlensReaderBase.m new file mode 100644 index 00000000..128b238d --- /dev/null +++ b/matlab/generated/+test_model/VlensReaderBase.m @@ -0,0 +1,108 @@ +classdef VlensReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = VlensReaderBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 8 + if mod(obj.state_, 2) == 1 + previous_method = obj.state_to_method_name_(obj.state_ - 1); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); + else + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + end + + % Ordinal 0 + function value = read_int_vector(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + value = obj.read_int_vector_(); + obj.state_ = 2; + end + + % Ordinal 1 + function value = read_complex_vector(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + value = obj.read_complex_vector_(); + obj.state_ = 4; + end + + % Ordinal 2 + function value = read_record_with_vlens(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + value = obj.read_record_with_vlens_(); + obj.state_ = 6; + end + + % Ordinal 3 + function value = read_vlen_of_record_with_vlens(obj) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + value = obj.read_vlen_of_record_with_vlens_(); + obj.state_ = 8; + end + + function copy_to(obj, writer) + writer.write_int_vector(obj.read_int_vector()); + writer.write_complex_vector(obj.read_complex_vector()); + writer.write_record_with_vlens(obj.read_record_with_vlens()); + writer.write_vlen_of_record_with_vlens(obj.read_vlen_of_record_with_vlens()); + end + end + + methods (Static) + function res = schema() + res = test_model.VlensWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + read_int_vector_(obj, value) + read_complex_vector_(obj, value) + read_record_with_vlens_(obj, value) + read_vlen_of_record_with_vlens_(obj, value) + + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + actual_method = obj.state_to_method_name_(actual); + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'read_int_vector'; + elseif state == 2 + name = 'read_complex_vector'; + elseif state == 4 + name = 'read_record_with_vlens'; + elseif state == 6 + name = 'read_vlen_of_record_with_vlens'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+test_model/VlensWriterBase.m b/matlab/generated/+test_model/VlensWriterBase.m new file mode 100644 index 00000000..4f9cbc27 --- /dev/null +++ b/matlab/generated/+test_model/VlensWriterBase.m @@ -0,0 +1,98 @@ +% Abstract writer for protocol Vlens +classdef (Abstract) VlensWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function obj = VlensWriterBase() + obj.state_ = 0; + end + + function close(obj) + obj.close_(); + if obj.state_ ~= 8 + expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_int_vector(obj, value) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.write_int_vector_(value); + obj.state_ = 2; + end + + % Ordinal 1 + function write_complex_vector(obj, value) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.write_complex_vector_(value); + obj.state_ = 4; + end + + % Ordinal 2 + function write_record_with_vlens(obj, value) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + obj.write_record_with_vlens_(value); + obj.state_ = 6; + end + + % Ordinal 3 + function write_vlen_of_record_with_vlens(obj, value) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + obj.write_vlen_of_record_with_vlens_(value); + obj.state_ = 8; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"Vlens","sequence":[{"name":"intVector","type":{"vector":{"items":"int32"}}},{"name":"complexVector","type":{"vector":{"items":"complexfloat32"}}},{"name":"recordWithVlens","type":"TestModel.RecordWithVlens"},{"name":"vlenOfRecordWithVlens","type":{"vector":{"items":"TestModel.RecordWithVlens"}}}]},"types":[{"name":"RecordWithVlens","fields":[{"name":"a","type":{"vector":{"items":"TestModel.SimpleRecord"}}},{"name":"b","type":"int32"},{"name":"c","type":"int32"}]},{"name":"SimpleRecord","fields":[{"name":"x","type":"int32"},{"name":"y","type":"int32"},{"name":"z","type":"int32"}]}]}'); + end + end + + methods (Abstract, Access=protected) + write_int_vector_(obj, value) + write_complex_vector_(obj, value) + write_record_with_vlens_(obj, value) + write_vlen_of_record_with_vlens_(obj, value) + + end_stream_(obj) + close_(obj) + end + + methods (Access=private) + function raise_unexpected_state_(obj, actual) + expected_method = obj.state_to_method_name_(obj.state_); + actual_method = obj.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(obj, state) + if state == 0 + name = 'write_int_vector'; + elseif state == 2 + name = 'write_complex_vector'; + elseif state == 4 + name = 'write_record_with_vlens'; + elseif state == 6 + name = 'write_vlen_of_record_with_vlens'; + else + name = ''; + end + end + end +end diff --git a/matlab/generated/+tuples/+binary/TupleSerializer.m b/matlab/generated/+tuples/+binary/TupleSerializer.m new file mode 100644 index 00000000..101d65b8 --- /dev/null +++ b/matlab/generated/+tuples/+binary/TupleSerializer.m @@ -0,0 +1,19 @@ +classdef TupleSerializer < yardl.binary.RecordSerializer + methods + function obj = TupleSerializer(t1_serializer, t2_serializer) + field_serializers{1} = t1_serializer; + field_serializers{2} = t2_serializer; + obj@yardl.binary.RecordSerializer('tuples.Tuple', field_serializers); + end + + function write(obj, outstream, value) + assert(isa(value, 'tuples.Tuple')); + obj.write_(outstream, value.v1, value.v2) + end + + function value = read(obj, instream) + field_values = obj.read_(instream); + value = tuples.Tuple(field_values{:}); + end + end +end diff --git a/matlab/generated/+tuples/Tuple.m b/matlab/generated/+tuples/Tuple.m new file mode 100644 index 00000000..e94a05ce --- /dev/null +++ b/matlab/generated/+tuples/Tuple.m @@ -0,0 +1,25 @@ +classdef Tuple < handle + properties + v1 + v2 + end + + methods + function obj = Tuple(v1, v2) + obj.v1 = v1; + obj.v2 = v2; + end + + function res = eq(obj, other) + res = ... + isa(other, 'tuples.Tuple') && ... + isequal(obj.v1, other.v1) && ... + isequal(obj.v2, other.v2); + end + + function res = ne(obj, other) + res = ~obj.eq(other); + end + end + +end diff --git a/matlab/generated/+yardl b/matlab/generated/+yardl new file mode 120000 index 00000000..7869ca3f --- /dev/null +++ b/matlab/generated/+yardl @@ -0,0 +1 @@ +/workspaces/yardl/tooling/internal/matlab/static_files \ No newline at end of file From f9394519cf4a07a2efd90e8644f397eccd0748aa Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Wed, 27 Mar 2024 16:08:25 +0000 Subject: [PATCH 11/32] Fixes for Matlab Stream tests. Mid-way through adapting the Vector/Array serializers to handle nested arrays/vectors. Next up are the Subarrays tests. --- ...enericRecordWithComputedFieldsSerializer.m | 2 + .../+binary/RecordWithUnionsSerializer.m | 2 + matlab/generated/+basic_types/AliasedMap.m | 2 + matlab/generated/+basic_types/DaysOfWeek.m | 14 +- matlab/generated/+basic_types/Fruits.m | 14 +- .../+basic_types/GenericNullableUnion2.m | 14 +- .../GenericRecordWithComputedFields.m | 2 + matlab/generated/+basic_types/GenericUnion2.m | 14 +- matlab/generated/+basic_types/GenericVector.m | 2 + matlab/generated/+basic_types/Int32OrString.m | 14 +- matlab/generated/+basic_types/MyTuple.m | 2 + .../generated/+basic_types/RecordWithUnions.m | 14 +- matlab/generated/+basic_types/T0OrT1.m | 14 +- matlab/generated/+basic_types/TextFormat.m | 14 +- .../generated/+basic_types/TimeOrDatetime.m | 14 +- matlab/generated/+image/FloatImage.m | 2 + matlab/generated/+image/Image.m | 2 + matlab/generated/+image/IntImage.m | 2 + .../+binary/AdvancedGenericsReader.m | 4 +- .../+binary/AdvancedGenericsWriter.m | 4 +- .../+test_model/+binary/AliasesReader.m | 4 +- .../+test_model/+binary/AliasesWriter.m | 4 +- .../+binary/BenchmarkFloat256x256Reader.m | 4 +- .../+binary/BenchmarkFloat256x256Writer.m | 4 +- .../+binary/BenchmarkFloatVlenReader.m | 4 +- .../+binary/BenchmarkFloatVlenWriter.m | 4 +- .../+binary/BenchmarkInt256x256Reader.m | 4 +- .../+binary/BenchmarkInt256x256Writer.m | 4 +- .../+binary/BenchmarkSimpleMrdReader.m | 4 +- .../+binary/BenchmarkSimpleMrdWriter.m | 4 +- .../+binary/BenchmarkSmallRecordReader.m | 4 +- .../BenchmarkSmallRecordWithOptionalsReader.m | 4 +- .../BenchmarkSmallRecordWithOptionalsWriter.m | 4 +- .../+binary/BenchmarkSmallRecordWriter.m | 4 +- .../+binary/DynamicNDArraysReader.m | 4 +- .../+binary/DynamicNDArraysWriter.m | 4 +- .../+test_model/+binary/EnumsReader.m | 4 +- .../+test_model/+binary/EnumsWriter.m | 4 +- .../+test_model/+binary/FixedArraysReader.m | 4 +- .../+test_model/+binary/FixedArraysWriter.m | 4 +- .../+test_model/+binary/FixedVectorsReader.m | 4 +- .../+test_model/+binary/FixedVectorsWriter.m | 4 +- .../+test_model/+binary/FlagsReader.m | 4 +- .../+test_model/+binary/FlagsWriter.m | 4 +- .../+binary/GenericRecordSerializer.m | 2 + .../+test_model/+binary/MapsReader.m | 4 +- .../+test_model/+binary/MapsWriter.m | 4 +- .../+test_model/+binary/NDArraysReader.m | 4 +- .../+binary/NDArraysSingleDimensionReader.m | 4 +- .../+binary/NDArraysSingleDimensionWriter.m | 4 +- .../+test_model/+binary/NDArraysWriter.m | 4 +- .../+test_model/+binary/NestedRecordsReader.m | 4 +- .../+test_model/+binary/NestedRecordsWriter.m | 4 +- .../+binary/OptionalVectorsReader.m | 4 +- .../+binary/OptionalVectorsWriter.m | 4 +- .../ProtocolWithComputedFieldsReader.m | 4 +- .../ProtocolWithComputedFieldsWriter.m | 4 +- .../+binary/ProtocolWithKeywordStepsReader.m | 4 +- .../+binary/ProtocolWithKeywordStepsWriter.m | 4 +- ...RecordContainingGenericRecordsSerializer.m | 2 + ...ContainingNestedGenericRecordsSerializer.m | 2 + .../RecordNotUsedInProtocolSerializer.m | 2 + .../RecordWithAliasedGenericsSerializer.m | 2 + ...ithAliasedOptionalGenericFieldSerializer.m | 2 + ...iasedOptionalGenericUnionFieldSerializer.m | 2 + .../+binary/RecordWithArraysSerializer.m | 2 + .../RecordWithArraysSimpleSyntaxSerializer.m | 2 + .../RecordWithComputedFieldsSerializer.m | 2 + .../RecordWithDynamicNDArraysSerializer.m | 2 + .../+binary/RecordWithEnumsSerializer.m | 2 + .../+binary/RecordWithFixedArraysSerializer.m | 2 + .../RecordWithFixedCollectionsSerializer.m | 2 + .../RecordWithFixedVectorsSerializer.m | 2 + .../RecordWithGenericArraysSerializer.m | 2 + .../RecordWithGenericFixedVectorsSerializer.m | 2 + .../+binary/RecordWithGenericMapsSerializer.m | 2 + ...cordWithGenericVectorOfRecordsSerializer.m | 2 + .../RecordWithGenericVectorsSerializer.m | 2 + .../RecordWithKeywordFieldsSerializer.m | 2 + .../+binary/RecordWithNDArraysSerializer.m | 2 + ...ordWithNDArraysSingleDimensionSerializer.m | 2 + .../RecordWithNamedFixedArraysSerializer.m | 2 + .../RecordWithOptionalFieldsSerializer.m | 2 + ...RecordWithOptionalGenericFieldSerializer.m | 2 + ...dWithOptionalGenericUnionFieldSerializer.m | 2 + .../RecordWithOptionalVectorSerializer.m | 2 + .../RecordWithPrimitiveAliasesSerializer.m | 2 + .../+binary/RecordWithPrimitivesSerializer.m | 2 + .../+binary/RecordWithStringsSerializer.m | 2 + .../RecordWithUnionsOfContainersSerializer.m | 2 + .../RecordWithVectorOfTimesSerializer.m | 2 + .../+binary/RecordWithVectorsSerializer.m | 2 + .../RecordWithVlenCollectionsSerializer.m | 2 + .../+binary/RecordWithVlensSerializer.m | 2 + .../+binary/ScalarOptionalsReader.m | 4 +- .../+binary/ScalarOptionalsWriter.m | 4 +- .../+test_model/+binary/ScalarsReader.m | 4 +- .../+test_model/+binary/ScalarsWriter.m | 4 +- .../+binary/SimpleAcquisitionSerializer.m | 2 + .../SimpleEncodingCountersSerializer.m | 2 + .../+binary/SimpleGenericsReader.m | 4 +- .../+binary/SimpleGenericsWriter.m | 4 +- .../+binary/SimpleRecordSerializer.m | 2 + .../+binary/SmallBenchmarkRecordSerializer.m | 2 + .../+test_model/+binary/StateTestReader.m | 4 +- .../+test_model/+binary/StateTestWriter.m | 4 +- .../+binary/StreamsOfAliasedUnionsReader.m | 4 +- .../+binary/StreamsOfAliasedUnionsWriter.m | 4 +- .../+binary/StreamsOfUnionsReader.m | 4 +- .../+binary/StreamsOfUnionsWriter.m | 4 +- .../+test_model/+binary/StreamsReader.m | 4 +- .../+test_model/+binary/StreamsWriter.m | 4 +- .../+test_model/+binary/StringsReader.m | 4 +- .../+test_model/+binary/StringsWriter.m | 4 +- .../+binary/SubarraysInRecordsReader.m | 4 +- .../+binary/SubarraysInRecordsWriter.m | 4 +- .../+test_model/+binary/SubarraysReader.m | 4 +- .../+test_model/+binary/SubarraysWriter.m | 4 +- .../+binary/TupleWithRecordsSerializer.m | 2 + .../+test_model/+binary/UnionsReader.m | 4 +- .../+test_model/+binary/UnionsWriter.m | 4 +- .../+test_model/+binary/VlensReader.m | 4 +- .../+test_model/+binary/VlensWriter.m | 4 +- .../+testing/MockAdvancedGenericsWriter.m | 2 + .../+test_model/+testing/MockAliasesWriter.m | 2 + .../MockBenchmarkFloat256x256Writer.m | 2 + .../+testing/MockBenchmarkFloatVlenWriter.m | 2 + .../+testing/MockBenchmarkInt256x256Writer.m | 2 + .../+testing/MockBenchmarkSimpleMrdWriter.m | 2 + ...kBenchmarkSmallRecordWithOptionalsWriter.m | 2 + .../+testing/MockBenchmarkSmallRecordWriter.m | 2 + .../+testing/MockDynamicNDArraysWriter.m | 2 + .../+test_model/+testing/MockEnumsWriter.m | 2 + .../+testing/MockFixedArraysWriter.m | 2 + .../+testing/MockFixedVectorsWriter.m | 2 + .../+test_model/+testing/MockFlagsWriter.m | 2 + .../+test_model/+testing/MockMapsWriter.m | 2 + .../MockNDArraysSingleDimensionWriter.m | 2 + .../+test_model/+testing/MockNDArraysWriter.m | 2 + .../+testing/MockNestedRecordsWriter.m | 2 + .../+testing/MockOptionalVectorsWriter.m | 2 + .../MockProtocolWithComputedFieldsWriter.m | 2 + .../MockProtocolWithKeywordStepsWriter.m | 2 + .../+testing/MockScalarOptionalsWriter.m | 2 + .../+test_model/+testing/MockScalarsWriter.m | 2 + .../+testing/MockSimpleGenericsWriter.m | 2 + .../+testing/MockStateTestWriter.m | 2 + .../MockStreamsOfAliasedUnionsWriter.m | 2 + .../+testing/MockStreamsOfUnionsWriter.m | 2 + .../+test_model/+testing/MockStreamsWriter.m | 2 + .../+test_model/+testing/MockStringsWriter.m | 2 + .../+testing/MockSubarraysInRecordsWriter.m | 2 + .../+testing/MockSubarraysWriter.m | 2 + .../+test_model/+testing/MockUnionsWriter.m | 2 + .../+test_model/+testing/MockVlensWriter.m | 2 + .../+testing/TestAdvancedGenericsWriter.m | 2 + .../+test_model/+testing/TestAliasesWriter.m | 2 + .../TestBenchmarkFloat256x256Writer.m | 2 + .../+testing/TestBenchmarkFloatVlenWriter.m | 2 + .../+testing/TestBenchmarkInt256x256Writer.m | 2 + .../+testing/TestBenchmarkSimpleMrdWriter.m | 2 + ...tBenchmarkSmallRecordWithOptionalsWriter.m | 2 + .../+testing/TestBenchmarkSmallRecordWriter.m | 2 + .../+testing/TestDynamicNDArraysWriter.m | 2 + .../+test_model/+testing/TestEnumsWriter.m | 2 + .../+testing/TestFixedArraysWriter.m | 2 + .../+testing/TestFixedVectorsWriter.m | 2 + .../+test_model/+testing/TestFlagsWriter.m | 2 + .../+test_model/+testing/TestMapsWriter.m | 2 + .../TestNDArraysSingleDimensionWriter.m | 2 + .../+test_model/+testing/TestNDArraysWriter.m | 2 + .../+testing/TestNestedRecordsWriter.m | 2 + .../+testing/TestOptionalVectorsWriter.m | 2 + .../TestProtocolWithComputedFieldsWriter.m | 2 + .../TestProtocolWithKeywordStepsWriter.m | 2 + .../+testing/TestScalarOptionalsWriter.m | 2 + .../+test_model/+testing/TestScalarsWriter.m | 2 + .../+testing/TestSimpleGenericsWriter.m | 2 + .../+testing/TestStateTestWriter.m | 2 + .../TestStreamsOfAliasedUnionsWriter.m | 2 + .../+testing/TestStreamsOfUnionsWriter.m | 2 + .../+test_model/+testing/TestStreamsWriter.m | 2 + .../+test_model/+testing/TestStringsWriter.m | 2 + .../+testing/TestSubarraysInRecordsWriter.m | 2 + .../+testing/TestSubarraysWriter.m | 2 + .../+test_model/+testing/TestUnionsWriter.m | 2 + .../+test_model/+testing/TestVlensWriter.m | 2 + .../+test_model/AcquisitionOrImage.m | 14 +- .../+test_model/AdvancedGenericsReaderBase.m | 2 + .../+test_model/AdvancedGenericsWriterBase.m | 2 + .../+test_model/AliasedClosedGeneric.m | 2 + matlab/generated/+test_model/AliasedEnum.m | 2 + .../+test_model/AliasedGenericDynamicArray.m | 2 + .../+test_model/AliasedGenericFixedArray.m | 2 + .../+test_model/AliasedGenericFixedVector.m | 2 + .../+test_model/AliasedGenericOptional.m | 2 + .../+test_model/AliasedGenericRank2Array.m | 2 + .../+test_model/AliasedGenericUnion2.m | 2 + .../+test_model/AliasedGenericVector.m | 2 + .../+test_model/AliasedIntOrSimpleRecord.m | 14 +- matlab/generated/+test_model/AliasedMap.m | 2 + .../+test_model/AliasedMultiGenericOptional.m | 14 +- .../AliasedNullableIntSimpleRecord.m | 14 +- .../+test_model/AliasedOpenGeneric.m | 2 + .../generated/+test_model/AliasedOptional.m | 2 + matlab/generated/+test_model/AliasedString.m | 2 + matlab/generated/+test_model/AliasedTuple.m | 2 + .../AliasedVectorOfGenericRecords.m | 2 + .../generated/+test_model/AliasesReaderBase.m | 2 + .../generated/+test_model/AliasesWriterBase.m | 2 + matlab/generated/+test_model/ArrayOrScalar.m | 14 +- .../ArrayWithKeywordDimensionNames.m | 2 + .../BenchmarkFloat256x256ReaderBase.m | 2 + .../BenchmarkFloat256x256WriterBase.m | 2 + .../BenchmarkFloatVlenReaderBase.m | 2 + .../BenchmarkFloatVlenWriterBase.m | 2 + .../BenchmarkInt256x256ReaderBase.m | 2 + .../BenchmarkInt256x256WriterBase.m | 2 + .../BenchmarkSimpleMrdReaderBase.m | 2 + .../BenchmarkSimpleMrdWriterBase.m | 2 + .../BenchmarkSmallRecordReaderBase.m | 2 + ...chmarkSmallRecordWithOptionalsReaderBase.m | 2 + ...chmarkSmallRecordWithOptionalsWriterBase.m | 2 + .../BenchmarkSmallRecordWriterBase.m | 2 + matlab/generated/+test_model/DaysOfWeek.m | 2 + .../+test_model/DynamicNDArraysReaderBase.m | 2 + .../+test_model/DynamicNDArraysWriterBase.m | 2 + .../+test_model/EnumWithKeywordSymbols.m | 14 +- .../generated/+test_model/EnumsReaderBase.m | 2 + .../generated/+test_model/EnumsWriterBase.m | 2 + .../+test_model/FixedArraysReaderBase.m | 2 + .../+test_model/FixedArraysWriterBase.m | 2 + .../+test_model/FixedVectorsReaderBase.m | 2 + .../+test_model/FixedVectorsWriterBase.m | 2 + .../generated/+test_model/FlagsReaderBase.m | 2 + .../generated/+test_model/FlagsWriterBase.m | 2 + matlab/generated/+test_model/Fruits.m | 2 + matlab/generated/+test_model/GenericRecord.m | 2 + matlab/generated/+test_model/GenericUnion3.m | 14 +- .../+test_model/GenericUnion3Alternate.m | 14 +- .../GenericUnionWithRepeatedTypeParameters.m | 14 +- matlab/generated/+test_model/Image.m | 2 + .../+test_model/ImageFloatOrImageDouble.m | 14 +- matlab/generated/+test_model/Int32OrFloat32.m | 14 +- .../+test_model/Int32OrRecordWithVlens.m | 14 +- .../+test_model/Int32OrSimpleRecord.m | 14 +- matlab/generated/+test_model/Int64Enum.m | 14 +- matlab/generated/+test_model/IntArray.m | 2 + matlab/generated/+test_model/IntFixedArray.m | 2 + .../IntOrGenericRecordWithComputedFields.m | 14 +- matlab/generated/+test_model/IntRank2Array.m | 2 + matlab/generated/+test_model/MapOrScalar.m | 14 +- matlab/generated/+test_model/MapsReaderBase.m | 2 + matlab/generated/+test_model/MapsWriterBase.m | 2 + matlab/generated/+test_model/MyTuple.m | 2 + .../+test_model/NDArraysReaderBase.m | 2 + .../NDArraysSingleDimensionReaderBase.m | 2 + .../NDArraysSingleDimensionWriterBase.m | 2 + .../+test_model/NDArraysWriterBase.m | 2 + .../generated/+test_model/NamedFixedNDArray.m | 2 + matlab/generated/+test_model/NamedNDArray.m | 2 + .../+test_model/NestedRecordsReaderBase.m | 2 + .../+test_model/NestedRecordsWriterBase.m | 2 + .../+test_model/OptionalVectorsReaderBase.m | 2 + .../+test_model/OptionalVectorsWriterBase.m | 2 + .../ProtocolWithComputedFieldsReaderBase.m | 2 + .../ProtocolWithComputedFieldsWriterBase.m | 2 + .../ProtocolWithKeywordStepsReaderBase.m | 2 + .../ProtocolWithKeywordStepsWriterBase.m | 2 + .../RecordContainingGenericRecords.m | 2 + .../RecordContainingNestedGenericRecords.m | 14 +- .../+test_model/RecordNotUsedInProtocol.m | 14 +- .../+test_model/RecordWithAliasedGenerics.m | 14 +- .../RecordWithAliasedOptionalGenericField.m | 14 +- ...cordWithAliasedOptionalGenericUnionField.m | 14 +- .../generated/+test_model/RecordWithArrays.m | 14 +- .../RecordWithArraysSimpleSyntax.m | 14 +- .../+test_model/RecordWithComputedFields.m | 14 +- .../+test_model/RecordWithDynamicNDArrays.m | 14 +- .../generated/+test_model/RecordWithEnums.m | 14 +- .../+test_model/RecordWithFixedArrays.m | 14 +- .../+test_model/RecordWithFixedCollections.m | 14 +- .../+test_model/RecordWithFixedVectors.m | 14 +- .../+test_model/RecordWithGenericArrays.m | 2 + .../RecordWithGenericFixedVectors.m | 2 + .../+test_model/RecordWithGenericMaps.m | 14 +- .../RecordWithGenericVectorOfRecords.m | 2 + .../+test_model/RecordWithGenericVectors.m | 2 + .../+test_model/RecordWithKeywordFields.m | 2 + .../+test_model/RecordWithNDArrays.m | 14 +- .../RecordWithNDArraysSingleDimension.m | 14 +- .../+test_model/RecordWithNamedFixedArrays.m | 14 +- .../+test_model/RecordWithOptionalFields.m | 14 +- .../RecordWithOptionalGenericField.m | 14 +- .../RecordWithOptionalGenericUnionField.m | 14 +- .../+test_model/RecordWithOptionalVector.m | 14 +- .../+test_model/RecordWithPrimitiveAliases.m | 14 +- .../+test_model/RecordWithPrimitives.m | 14 +- .../generated/+test_model/RecordWithStrings.m | 14 +- .../RecordWithUnionsOfContainers.m | 14 +- .../+test_model/RecordWithVectorOfTimes.m | 14 +- .../generated/+test_model/RecordWithVectors.m | 14 +- .../+test_model/RecordWithVlenCollections.m | 14 +- .../generated/+test_model/RecordWithVlens.m | 14 +- .../+test_model/RecordWithVlensFixedArray.m | 2 + .../+test_model/ScalarOptionalsReaderBase.m | 2 + .../+test_model/ScalarOptionalsWriterBase.m | 2 + .../generated/+test_model/ScalarsReaderBase.m | 2 + .../generated/+test_model/ScalarsWriterBase.m | 2 + .../generated/+test_model/SimpleAcquisition.m | 14 +- .../+test_model/SimpleEncodingCounters.m | 14 +- .../+test_model/SimpleGenericsReaderBase.m | 2 + .../+test_model/SimpleGenericsWriterBase.m | 2 + matlab/generated/+test_model/SimpleRecord.m | 14 +- .../+test_model/SimpleRecordFixedArray.m | 2 + matlab/generated/+test_model/SizeBasedEnum.m | 14 +- .../+test_model/SmallBenchmarkRecord.m | 14 +- .../+test_model/StateTestReaderBase.m | 2 + .../+test_model/StateTestWriterBase.m | 2 + .../StreamsOfAliasedUnionsReaderBase.m | 2 + .../StreamsOfAliasedUnionsWriterBase.m | 2 + .../+test_model/StreamsOfUnionsReaderBase.m | 2 + .../+test_model/StreamsOfUnionsWriterBase.m | 2 + .../generated/+test_model/StreamsReaderBase.m | 2 + .../generated/+test_model/StreamsWriterBase.m | 2 + matlab/generated/+test_model/StringOrInt32.m | 14 +- .../generated/+test_model/StringsReaderBase.m | 2 + .../generated/+test_model/StringsWriterBase.m | 2 + .../SubarraysInRecordsReaderBase.m | 2 + .../SubarraysInRecordsWriterBase.m | 2 + .../+test_model/SubarraysReaderBase.m | 2 + .../+test_model/SubarraysWriterBase.m | 2 + matlab/generated/+test_model/TextFormat.m | 2 + .../generated/+test_model/TupleWithRecords.m | 14 +- matlab/generated/+test_model/UInt64Enum.m | 14 +- matlab/generated/+test_model/UOrV.m | 14 +- .../generated/+test_model/UnionsReaderBase.m | 2 + .../generated/+test_model/UnionsWriterBase.m | 2 + .../+test_model/VectorOfGenericRecords.m | 2 + matlab/generated/+test_model/VectorOrScalar.m | 14 +- .../generated/+test_model/VlensReaderBase.m | 2 + .../generated/+test_model/VlensWriterBase.m | 2 + .../+tuples/+binary/TupleSerializer.m | 2 + matlab/generated/+tuples/Tuple.m | 2 + matlab/tests/GeneratedTypesTest.m | 2 + matlab/tests/RoundTripTest.m | 35 ++-- matlab/tests/SerializerShapeTest.m | 104 +++++++++++ matlab/tests/YardlTypesTest.m | 2 + matlab/tests/run.m | 2 + tooling/internal/matlab/binary/binary.go | 8 +- tooling/internal/matlab/common/common.go | 4 +- .../+binary/BinaryProtocolReader.m | 74 ++++---- .../+binary/BinaryProtocolWriter.m | 66 +++---- .../static_files/+binary/BoolSerializer.m | 36 ++-- .../+binary/CURRENT_BINARY_FORMAT_VERSION.m | 6 +- .../static_files/+binary/CodedInputStream.m | 128 ++++++------- .../static_files/+binary/CodedOutputStream.m | 148 +++++++-------- .../+binary/Complexfloat32Serializer.m | 52 +++--- .../+binary/Complexfloat64Serializer.m | 42 ++--- .../static_files/+binary/DateSerializer.m | 46 ++--- .../static_files/+binary/DatetimeSerializer.m | 46 ++--- .../+binary/DynamicNDArraySerializer.m | 4 +- .../matlab/static_files/+binary/Error.m | 15 +- .../+binary/FixedNDArraySerializer.m | 43 ++++- .../+binary/FixedVectorSerializer.m | 71 ++++++-- .../static_files/+binary/Float32Serializer.m | 42 ++--- .../static_files/+binary/Float64Serializer.m | 36 ++-- .../static_files/+binary/Int16Serializer.m | 36 ++-- .../static_files/+binary/Int32Serializer.m | 36 ++-- .../static_files/+binary/Int64Serializer.m | 36 ++-- .../static_files/+binary/Int8Serializer.m | 36 ++-- .../matlab/static_files/+binary/MAGIC_BYTES.m | 6 +- .../static_files/+binary/NDArraySerializer.m | 38 ++-- .../+binary/NDArraySerializerBase.m | 104 ++++++++--- .../static_files/+binary/NoneSerializer.m | 28 +-- .../static_files/+binary/OptionalSerializer.m | 18 +- .../static_files/+binary/RecordSerializer.m | 72 ++++---- .../static_files/+binary/SizeSerializer.m | 4 +- .../static_files/+binary/StreamSerializer.m | 85 +++++++-- .../static_files/+binary/StringSerializer.m | 44 ++--- .../static_files/+binary/TimeSerializer.m | 48 ++--- .../static_files/+binary/TypeSerializer.m | 19 +- .../static_files/+binary/Uint16Serializer.m | 36 ++-- .../static_files/+binary/Uint32Serializer.m | 36 ++-- .../static_files/+binary/Uint64Serializer.m | 36 ++-- .../static_files/+binary/Uint8Serializer.m | 36 ++-- .../static_files/+binary/UnionSerializer.m | 171 +++++++++--------- .../static_files/+binary/VectorSerializer.m | 70 ++++++- tooling/internal/matlab/static_files/Date.m | 14 ++ .../internal/matlab/static_files/DateTime.m | 14 ++ .../internal/matlab/static_files/Exception.m | 14 +- .../internal/matlab/static_files/Optional.m | 13 +- tooling/internal/matlab/static_files/Time.m | 14 ++ .../internal/matlab/static_files/allocate.m | 7 + tooling/internal/matlab/types/types.go | 79 ++------ 395 files changed, 2388 insertions(+), 1358 deletions(-) create mode 100644 matlab/tests/SerializerShapeTest.m create mode 100644 tooling/internal/matlab/static_files/allocate.m diff --git a/matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m b/matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m index c1925006..8225a1c8 100644 --- a/matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m +++ b/matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef GenericRecordWithComputedFieldsSerializer < yardl.binary.RecordSerializer methods function obj = GenericRecordWithComputedFieldsSerializer(t0_serializer, t1_serializer) diff --git a/matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m b/matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m index b636a682..3e51797c 100644 --- a/matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m +++ b/matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithUnionsSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithUnionsSerializer() diff --git a/matlab/generated/+basic_types/AliasedMap.m b/matlab/generated/+basic_types/AliasedMap.m index fe48071b..8c224bb2 100644 --- a/matlab/generated/+basic_types/AliasedMap.m +++ b/matlab/generated/+basic_types/AliasedMap.m @@ -1,2 +1,4 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef AliasedMap < dictionary end diff --git a/matlab/generated/+basic_types/DaysOfWeek.m b/matlab/generated/+basic_types/DaysOfWeek.m index 7fbc0976..32df781c 100644 --- a/matlab/generated/+basic_types/DaysOfWeek.m +++ b/matlab/generated/+basic_types/DaysOfWeek.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef DaysOfWeek < uint64 methods (Static) function e = MONDAY @@ -26,13 +28,13 @@ elem = basic_types.DaysOfWeek(0); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+basic_types/Fruits.m b/matlab/generated/+basic_types/Fruits.m index 5c80e6a5..e53ec8c7 100644 --- a/matlab/generated/+basic_types/Fruits.m +++ b/matlab/generated/+basic_types/Fruits.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef Fruits < uint64 methods (Static) function e = APPLE @@ -14,13 +16,13 @@ elem = basic_types.Fruits(0); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+basic_types/GenericNullableUnion2.m b/matlab/generated/+basic_types/GenericNullableUnion2.m index 297fd5e7..0409861e 100644 --- a/matlab/generated/+basic_types/GenericNullableUnion2.m +++ b/matlab/generated/+basic_types/GenericNullableUnion2.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef GenericNullableUnion2 < yardl.Union methods (Static) function res = T1(value) @@ -12,13 +14,13 @@ elem = basic_types.GenericNullableUnion2(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+basic_types/GenericRecordWithComputedFields.m b/matlab/generated/+basic_types/GenericRecordWithComputedFields.m index da4c0136..9e61f504 100644 --- a/matlab/generated/+basic_types/GenericRecordWithComputedFields.m +++ b/matlab/generated/+basic_types/GenericRecordWithComputedFields.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef GenericRecordWithComputedFields < handle properties f1 diff --git a/matlab/generated/+basic_types/GenericUnion2.m b/matlab/generated/+basic_types/GenericUnion2.m index 7a21a90d..830be8e5 100644 --- a/matlab/generated/+basic_types/GenericUnion2.m +++ b/matlab/generated/+basic_types/GenericUnion2.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef GenericUnion2 < yardl.Union methods (Static) function res = T1(value) @@ -12,13 +14,13 @@ elem = basic_types.GenericUnion2(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+basic_types/GenericVector.m b/matlab/generated/+basic_types/GenericVector.m index b838ba3c..7d0789dd 100644 --- a/matlab/generated/+basic_types/GenericVector.m +++ b/matlab/generated/+basic_types/GenericVector.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = GenericVector(array) a = array; end diff --git a/matlab/generated/+basic_types/Int32OrString.m b/matlab/generated/+basic_types/Int32OrString.m index 921b5b34..0a7b74d1 100644 --- a/matlab/generated/+basic_types/Int32OrString.m +++ b/matlab/generated/+basic_types/Int32OrString.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef Int32OrString < yardl.Union methods (Static) function res = Int32(value) @@ -12,13 +14,13 @@ elem = basic_types.Int32OrString(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+basic_types/MyTuple.m b/matlab/generated/+basic_types/MyTuple.m index 99abe277..a9b3a6a4 100644 --- a/matlab/generated/+basic_types/MyTuple.m +++ b/matlab/generated/+basic_types/MyTuple.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function c = MyTuple(varargin) c = tuples.Tuple(varargin{:}); end diff --git a/matlab/generated/+basic_types/RecordWithUnions.m b/matlab/generated/+basic_types/RecordWithUnions.m index e6ab9f3b..edc67bdd 100644 --- a/matlab/generated/+basic_types/RecordWithUnions.m +++ b/matlab/generated/+basic_types/RecordWithUnions.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithUnions < handle properties null_or_int_or_string @@ -36,13 +38,13 @@ elem = basic_types.RecordWithUnions(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+basic_types/T0OrT1.m b/matlab/generated/+basic_types/T0OrT1.m index 289d2064..c677eb94 100644 --- a/matlab/generated/+basic_types/T0OrT1.m +++ b/matlab/generated/+basic_types/T0OrT1.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef T0OrT1 < yardl.Union methods (Static) function res = T0(value) @@ -12,13 +14,13 @@ elem = basic_types.T0OrT1(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+basic_types/TextFormat.m b/matlab/generated/+basic_types/TextFormat.m index 187fddca..69c9010d 100644 --- a/matlab/generated/+basic_types/TextFormat.m +++ b/matlab/generated/+basic_types/TextFormat.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TextFormat < uint64 methods (Static) function e = REGULAR @@ -20,13 +22,13 @@ elem = basic_types.TextFormat(0); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+basic_types/TimeOrDatetime.m b/matlab/generated/+basic_types/TimeOrDatetime.m index 9abd79dc..f84f2d55 100644 --- a/matlab/generated/+basic_types/TimeOrDatetime.m +++ b/matlab/generated/+basic_types/TimeOrDatetime.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TimeOrDatetime < yardl.Union methods (Static) function res = Time(value) @@ -12,13 +14,13 @@ elem = basic_types.TimeOrDatetime(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+image/FloatImage.m b/matlab/generated/+image/FloatImage.m index 0d41d970..dcefa50e 100644 --- a/matlab/generated/+image/FloatImage.m +++ b/matlab/generated/+image/FloatImage.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = FloatImage(array) assert(isa(array, 'single')); a = array; diff --git a/matlab/generated/+image/Image.m b/matlab/generated/+image/Image.m index 4a551748..a31eac1f 100644 --- a/matlab/generated/+image/Image.m +++ b/matlab/generated/+image/Image.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = Image(array) a = array; end diff --git a/matlab/generated/+image/IntImage.m b/matlab/generated/+image/IntImage.m index f807307e..f419feb9 100644 --- a/matlab/generated/+image/IntImage.m +++ b/matlab/generated/+image/IntImage.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = IntImage(array) assert(isa(array, 'int32')); a = array; diff --git a/matlab/generated/+test_model/+binary/AdvancedGenericsReader.m b/matlab/generated/+test_model/+binary/AdvancedGenericsReader.m index 947fa959..8a04c248 100644 --- a/matlab/generated/+test_model/+binary/AdvancedGenericsReader.m +++ b/matlab/generated/+test_model/+binary/AdvancedGenericsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the AdvancedGenerics protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef AdvancedGenericsReader < yardl.binary.BinaryProtocolReader & test_model.AdvancedGenericsReaderBase + % Binary reader for the AdvancedGenerics protocol methods function obj = AdvancedGenericsReader(filename) obj@test_model.AdvancedGenericsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m b/matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m index 9d354ecc..1ba5e946 100644 --- a/matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m +++ b/matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the AdvancedGenerics protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef AdvancedGenericsWriter < yardl.binary.BinaryProtocolWriter & test_model.AdvancedGenericsWriterBase + % Binary writer for the AdvancedGenerics protocol methods function obj = AdvancedGenericsWriter(filename) obj@test_model.AdvancedGenericsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/AliasesReader.m b/matlab/generated/+test_model/+binary/AliasesReader.m index 3db7114c..99955a88 100644 --- a/matlab/generated/+test_model/+binary/AliasesReader.m +++ b/matlab/generated/+test_model/+binary/AliasesReader.m @@ -1,5 +1,7 @@ -% Binary reader for the Aliases protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef AliasesReader < yardl.binary.BinaryProtocolReader & test_model.AliasesReaderBase + % Binary reader for the Aliases protocol methods function obj = AliasesReader(filename) obj@test_model.AliasesReaderBase(); diff --git a/matlab/generated/+test_model/+binary/AliasesWriter.m b/matlab/generated/+test_model/+binary/AliasesWriter.m index 776701b1..39d05136 100644 --- a/matlab/generated/+test_model/+binary/AliasesWriter.m +++ b/matlab/generated/+test_model/+binary/AliasesWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the Aliases protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef AliasesWriter < yardl.binary.BinaryProtocolWriter & test_model.AliasesWriterBase + % Binary writer for the Aliases protocol methods function obj = AliasesWriter(filename) obj@test_model.AliasesWriterBase(); diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m index f6d88bdc..62d563c1 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m @@ -1,5 +1,7 @@ -% Binary reader for the BenchmarkFloat256x256 protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkFloat256x256Reader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkFloat256x256ReaderBase + % Binary reader for the BenchmarkFloat256x256 protocol methods function obj = BenchmarkFloat256x256Reader(filename) obj@test_model.BenchmarkFloat256x256ReaderBase(); diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m index 9d61aac1..6ed48fa6 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m +++ b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m @@ -1,5 +1,7 @@ -% Binary writer for the BenchmarkFloat256x256 protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkFloat256x256Writer < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkFloat256x256WriterBase + % Binary writer for the BenchmarkFloat256x256 protocol methods function obj = BenchmarkFloat256x256Writer(filename) obj@test_model.BenchmarkFloat256x256WriterBase(); diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m index a324b0be..b3731de3 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m @@ -1,5 +1,7 @@ -% Binary reader for the BenchmarkFloatVlen protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkFloatVlenReader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkFloatVlenReaderBase + % Binary reader for the BenchmarkFloatVlen protocol methods function obj = BenchmarkFloatVlenReader(filename) obj@test_model.BenchmarkFloatVlenReaderBase(); diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m index 412697b9..d249a080 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m +++ b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the BenchmarkFloatVlen protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkFloatVlenWriter < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkFloatVlenWriterBase + % Binary writer for the BenchmarkFloatVlen protocol methods function obj = BenchmarkFloatVlenWriter(filename) obj@test_model.BenchmarkFloatVlenWriterBase(); diff --git a/matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m index 7bc2cb55..cbc55f43 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m @@ -1,5 +1,7 @@ -% Binary reader for the BenchmarkInt256x256 protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkInt256x256Reader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkInt256x256ReaderBase + % Binary reader for the BenchmarkInt256x256 protocol methods function obj = BenchmarkInt256x256Reader(filename) obj@test_model.BenchmarkInt256x256ReaderBase(); diff --git a/matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m index 1e17d965..1c7a670d 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m +++ b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m @@ -1,5 +1,7 @@ -% Binary writer for the BenchmarkInt256x256 protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkInt256x256Writer < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkInt256x256WriterBase + % Binary writer for the BenchmarkInt256x256 protocol methods function obj = BenchmarkInt256x256Writer(filename) obj@test_model.BenchmarkInt256x256WriterBase(); diff --git a/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m index d2a04f0b..4f00a0f2 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m @@ -1,5 +1,7 @@ -% Binary reader for the BenchmarkSimpleMrd protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkSimpleMrdReader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkSimpleMrdReaderBase + % Binary reader for the BenchmarkSimpleMrd protocol methods function obj = BenchmarkSimpleMrdReader(filename) obj@test_model.BenchmarkSimpleMrdReaderBase(); diff --git a/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m index 43e75e6b..41e89f1d 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the BenchmarkSimpleMrd protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkSimpleMrdWriter < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkSimpleMrdWriterBase + % Binary writer for the BenchmarkSimpleMrd protocol methods function obj = BenchmarkSimpleMrdWriter(filename) obj@test_model.BenchmarkSimpleMrdWriterBase(); diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m index f811aee7..b02ebfb6 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m @@ -1,5 +1,7 @@ -% Binary reader for the BenchmarkSmallRecord protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkSmallRecordReader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkSmallRecordReaderBase + % Binary reader for the BenchmarkSmallRecord protocol methods function obj = BenchmarkSmallRecordReader(filename) obj@test_model.BenchmarkSmallRecordReaderBase(); diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m index 40df03aa..c4b31d7b 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the BenchmarkSmallRecordWithOptionals protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkSmallRecordWithOptionalsReader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkSmallRecordWithOptionalsReaderBase + % Binary reader for the BenchmarkSmallRecordWithOptionals protocol methods function obj = BenchmarkSmallRecordWithOptionalsReader(filename) obj@test_model.BenchmarkSmallRecordWithOptionalsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m index f11d54f7..14c9ea7e 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the BenchmarkSmallRecordWithOptionals protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkSmallRecordWithOptionalsWriter < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkSmallRecordWithOptionalsWriterBase + % Binary writer for the BenchmarkSmallRecordWithOptionals protocol methods function obj = BenchmarkSmallRecordWithOptionalsWriter(filename) obj@test_model.BenchmarkSmallRecordWithOptionalsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m index 30bfa239..76c06d4c 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the BenchmarkSmallRecord protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkSmallRecordWriter < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkSmallRecordWriterBase + % Binary writer for the BenchmarkSmallRecord protocol methods function obj = BenchmarkSmallRecordWriter(filename) obj@test_model.BenchmarkSmallRecordWriterBase(); diff --git a/matlab/generated/+test_model/+binary/DynamicNDArraysReader.m b/matlab/generated/+test_model/+binary/DynamicNDArraysReader.m index 534f996f..6a84d831 100644 --- a/matlab/generated/+test_model/+binary/DynamicNDArraysReader.m +++ b/matlab/generated/+test_model/+binary/DynamicNDArraysReader.m @@ -1,5 +1,7 @@ -% Binary reader for the DynamicNDArrays protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef DynamicNDArraysReader < yardl.binary.BinaryProtocolReader & test_model.DynamicNDArraysReaderBase + % Binary reader for the DynamicNDArrays protocol methods function obj = DynamicNDArraysReader(filename) obj@test_model.DynamicNDArraysReaderBase(); diff --git a/matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m b/matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m index 0dcf1cfe..a2c18b2c 100644 --- a/matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m +++ b/matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the DynamicNDArrays protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef DynamicNDArraysWriter < yardl.binary.BinaryProtocolWriter & test_model.DynamicNDArraysWriterBase + % Binary writer for the DynamicNDArrays protocol methods function obj = DynamicNDArraysWriter(filename) obj@test_model.DynamicNDArraysWriterBase(); diff --git a/matlab/generated/+test_model/+binary/EnumsReader.m b/matlab/generated/+test_model/+binary/EnumsReader.m index b3b6e085..74841ad4 100644 --- a/matlab/generated/+test_model/+binary/EnumsReader.m +++ b/matlab/generated/+test_model/+binary/EnumsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the Enums protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef EnumsReader < yardl.binary.BinaryProtocolReader & test_model.EnumsReaderBase + % Binary reader for the Enums protocol methods function obj = EnumsReader(filename) obj@test_model.EnumsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/EnumsWriter.m b/matlab/generated/+test_model/+binary/EnumsWriter.m index 47460811..252fc63b 100644 --- a/matlab/generated/+test_model/+binary/EnumsWriter.m +++ b/matlab/generated/+test_model/+binary/EnumsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the Enums protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef EnumsWriter < yardl.binary.BinaryProtocolWriter & test_model.EnumsWriterBase + % Binary writer for the Enums protocol methods function obj = EnumsWriter(filename) obj@test_model.EnumsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/FixedArraysReader.m b/matlab/generated/+test_model/+binary/FixedArraysReader.m index a0363fba..0fa10230 100644 --- a/matlab/generated/+test_model/+binary/FixedArraysReader.m +++ b/matlab/generated/+test_model/+binary/FixedArraysReader.m @@ -1,5 +1,7 @@ -% Binary reader for the FixedArrays protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef FixedArraysReader < yardl.binary.BinaryProtocolReader & test_model.FixedArraysReaderBase + % Binary reader for the FixedArrays protocol methods function obj = FixedArraysReader(filename) obj@test_model.FixedArraysReaderBase(); diff --git a/matlab/generated/+test_model/+binary/FixedArraysWriter.m b/matlab/generated/+test_model/+binary/FixedArraysWriter.m index ad2bdd80..5faf2af8 100644 --- a/matlab/generated/+test_model/+binary/FixedArraysWriter.m +++ b/matlab/generated/+test_model/+binary/FixedArraysWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the FixedArrays protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef FixedArraysWriter < yardl.binary.BinaryProtocolWriter & test_model.FixedArraysWriterBase + % Binary writer for the FixedArrays protocol methods function obj = FixedArraysWriter(filename) obj@test_model.FixedArraysWriterBase(); diff --git a/matlab/generated/+test_model/+binary/FixedVectorsReader.m b/matlab/generated/+test_model/+binary/FixedVectorsReader.m index 3c9565f0..76846984 100644 --- a/matlab/generated/+test_model/+binary/FixedVectorsReader.m +++ b/matlab/generated/+test_model/+binary/FixedVectorsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the FixedVectors protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef FixedVectorsReader < yardl.binary.BinaryProtocolReader & test_model.FixedVectorsReaderBase + % Binary reader for the FixedVectors protocol methods function obj = FixedVectorsReader(filename) obj@test_model.FixedVectorsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/FixedVectorsWriter.m b/matlab/generated/+test_model/+binary/FixedVectorsWriter.m index 7df6b24f..c60a738d 100644 --- a/matlab/generated/+test_model/+binary/FixedVectorsWriter.m +++ b/matlab/generated/+test_model/+binary/FixedVectorsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the FixedVectors protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef FixedVectorsWriter < yardl.binary.BinaryProtocolWriter & test_model.FixedVectorsWriterBase + % Binary writer for the FixedVectors protocol methods function obj = FixedVectorsWriter(filename) obj@test_model.FixedVectorsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/FlagsReader.m b/matlab/generated/+test_model/+binary/FlagsReader.m index a38e2b61..96508fdb 100644 --- a/matlab/generated/+test_model/+binary/FlagsReader.m +++ b/matlab/generated/+test_model/+binary/FlagsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the Flags protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef FlagsReader < yardl.binary.BinaryProtocolReader & test_model.FlagsReaderBase + % Binary reader for the Flags protocol methods function obj = FlagsReader(filename) obj@test_model.FlagsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/FlagsWriter.m b/matlab/generated/+test_model/+binary/FlagsWriter.m index 18479ba6..8091051f 100644 --- a/matlab/generated/+test_model/+binary/FlagsWriter.m +++ b/matlab/generated/+test_model/+binary/FlagsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the Flags protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef FlagsWriter < yardl.binary.BinaryProtocolWriter & test_model.FlagsWriterBase + % Binary writer for the Flags protocol methods function obj = FlagsWriter(filename) obj@test_model.FlagsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/GenericRecordSerializer.m b/matlab/generated/+test_model/+binary/GenericRecordSerializer.m index 74c412d5..4a52a8dd 100644 --- a/matlab/generated/+test_model/+binary/GenericRecordSerializer.m +++ b/matlab/generated/+test_model/+binary/GenericRecordSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef GenericRecordSerializer < yardl.binary.RecordSerializer methods function obj = GenericRecordSerializer(t1_serializer, t2_serializer) diff --git a/matlab/generated/+test_model/+binary/MapsReader.m b/matlab/generated/+test_model/+binary/MapsReader.m index 321ef6f4..12f025d1 100644 --- a/matlab/generated/+test_model/+binary/MapsReader.m +++ b/matlab/generated/+test_model/+binary/MapsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the Maps protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MapsReader < yardl.binary.BinaryProtocolReader & test_model.MapsReaderBase + % Binary reader for the Maps protocol methods function obj = MapsReader(filename) obj@test_model.MapsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/MapsWriter.m b/matlab/generated/+test_model/+binary/MapsWriter.m index 6d63fff6..6afabb23 100644 --- a/matlab/generated/+test_model/+binary/MapsWriter.m +++ b/matlab/generated/+test_model/+binary/MapsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the Maps protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MapsWriter < yardl.binary.BinaryProtocolWriter & test_model.MapsWriterBase + % Binary writer for the Maps protocol methods function obj = MapsWriter(filename) obj@test_model.MapsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/NDArraysReader.m b/matlab/generated/+test_model/+binary/NDArraysReader.m index 99fe28fa..15df6904 100644 --- a/matlab/generated/+test_model/+binary/NDArraysReader.m +++ b/matlab/generated/+test_model/+binary/NDArraysReader.m @@ -1,5 +1,7 @@ -% Binary reader for the NDArrays protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef NDArraysReader < yardl.binary.BinaryProtocolReader & test_model.NDArraysReaderBase + % Binary reader for the NDArrays protocol methods function obj = NDArraysReader(filename) obj@test_model.NDArraysReaderBase(); diff --git a/matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m index 9fc9b075..a0377f06 100644 --- a/matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m +++ b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m @@ -1,5 +1,7 @@ -% Binary reader for the NDArraysSingleDimension protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef NDArraysSingleDimensionReader < yardl.binary.BinaryProtocolReader & test_model.NDArraysSingleDimensionReaderBase + % Binary reader for the NDArraysSingleDimension protocol methods function obj = NDArraysSingleDimensionReader(filename) obj@test_model.NDArraysSingleDimensionReaderBase(); diff --git a/matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m index a43894db..a460257e 100644 --- a/matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m +++ b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the NDArraysSingleDimension protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef NDArraysSingleDimensionWriter < yardl.binary.BinaryProtocolWriter & test_model.NDArraysSingleDimensionWriterBase + % Binary writer for the NDArraysSingleDimension protocol methods function obj = NDArraysSingleDimensionWriter(filename) obj@test_model.NDArraysSingleDimensionWriterBase(); diff --git a/matlab/generated/+test_model/+binary/NDArraysWriter.m b/matlab/generated/+test_model/+binary/NDArraysWriter.m index d03ada99..6996cc50 100644 --- a/matlab/generated/+test_model/+binary/NDArraysWriter.m +++ b/matlab/generated/+test_model/+binary/NDArraysWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the NDArrays protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef NDArraysWriter < yardl.binary.BinaryProtocolWriter & test_model.NDArraysWriterBase + % Binary writer for the NDArrays protocol methods function obj = NDArraysWriter(filename) obj@test_model.NDArraysWriterBase(); diff --git a/matlab/generated/+test_model/+binary/NestedRecordsReader.m b/matlab/generated/+test_model/+binary/NestedRecordsReader.m index d18a6313..4be061ba 100644 --- a/matlab/generated/+test_model/+binary/NestedRecordsReader.m +++ b/matlab/generated/+test_model/+binary/NestedRecordsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the NestedRecords protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef NestedRecordsReader < yardl.binary.BinaryProtocolReader & test_model.NestedRecordsReaderBase + % Binary reader for the NestedRecords protocol methods function obj = NestedRecordsReader(filename) obj@test_model.NestedRecordsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/NestedRecordsWriter.m b/matlab/generated/+test_model/+binary/NestedRecordsWriter.m index 3405f2e5..80383b3a 100644 --- a/matlab/generated/+test_model/+binary/NestedRecordsWriter.m +++ b/matlab/generated/+test_model/+binary/NestedRecordsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the NestedRecords protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef NestedRecordsWriter < yardl.binary.BinaryProtocolWriter & test_model.NestedRecordsWriterBase + % Binary writer for the NestedRecords protocol methods function obj = NestedRecordsWriter(filename) obj@test_model.NestedRecordsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/OptionalVectorsReader.m b/matlab/generated/+test_model/+binary/OptionalVectorsReader.m index a59cec89..60b7160f 100644 --- a/matlab/generated/+test_model/+binary/OptionalVectorsReader.m +++ b/matlab/generated/+test_model/+binary/OptionalVectorsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the OptionalVectors protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef OptionalVectorsReader < yardl.binary.BinaryProtocolReader & test_model.OptionalVectorsReaderBase + % Binary reader for the OptionalVectors protocol methods function obj = OptionalVectorsReader(filename) obj@test_model.OptionalVectorsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/OptionalVectorsWriter.m b/matlab/generated/+test_model/+binary/OptionalVectorsWriter.m index 3bcd3230..640265be 100644 --- a/matlab/generated/+test_model/+binary/OptionalVectorsWriter.m +++ b/matlab/generated/+test_model/+binary/OptionalVectorsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the OptionalVectors protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef OptionalVectorsWriter < yardl.binary.BinaryProtocolWriter & test_model.OptionalVectorsWriterBase + % Binary writer for the OptionalVectors protocol methods function obj = OptionalVectorsWriter(filename) obj@test_model.OptionalVectorsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m index d838300d..45013f0c 100644 --- a/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m +++ b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the ProtocolWithComputedFields protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef ProtocolWithComputedFieldsReader < yardl.binary.BinaryProtocolReader & test_model.ProtocolWithComputedFieldsReaderBase + % Binary reader for the ProtocolWithComputedFields protocol methods function obj = ProtocolWithComputedFieldsReader(filename) obj@test_model.ProtocolWithComputedFieldsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m index 2c5acf92..c48e59f9 100644 --- a/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m +++ b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the ProtocolWithComputedFields protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef ProtocolWithComputedFieldsWriter < yardl.binary.BinaryProtocolWriter & test_model.ProtocolWithComputedFieldsWriterBase + % Binary writer for the ProtocolWithComputedFields protocol methods function obj = ProtocolWithComputedFieldsWriter(filename) obj@test_model.ProtocolWithComputedFieldsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m index 62fc290e..549ed2e0 100644 --- a/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m +++ b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the ProtocolWithKeywordSteps protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef ProtocolWithKeywordStepsReader < yardl.binary.BinaryProtocolReader & test_model.ProtocolWithKeywordStepsReaderBase + % Binary reader for the ProtocolWithKeywordSteps protocol methods function obj = ProtocolWithKeywordStepsReader(filename) obj@test_model.ProtocolWithKeywordStepsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m index 014284ca..36522619 100644 --- a/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m +++ b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the ProtocolWithKeywordSteps protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef ProtocolWithKeywordStepsWriter < yardl.binary.BinaryProtocolWriter & test_model.ProtocolWithKeywordStepsWriterBase + % Binary writer for the ProtocolWithKeywordSteps protocol methods function obj = ProtocolWithKeywordStepsWriter(filename) obj@test_model.ProtocolWithKeywordStepsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m b/matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m index 6fb98103..de878e5f 100644 --- a/matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordContainingGenericRecordsSerializer < yardl.binary.RecordSerializer methods function obj = RecordContainingGenericRecordsSerializer(a_serializer, b_serializer) diff --git a/matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m b/matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m index 391a6532..cf6844ac 100644 --- a/matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordContainingNestedGenericRecordsSerializer < yardl.binary.RecordSerializer methods function obj = RecordContainingNestedGenericRecordsSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m b/matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m index 5ebf2dfd..e2413269 100644 --- a/matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordNotUsedInProtocolSerializer < yardl.binary.RecordSerializer methods function obj = RecordNotUsedInProtocolSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m index b1cfd4f5..e050b084 100644 --- a/matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithAliasedGenericsSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithAliasedGenericsSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m index 74b92cf3..87895f56 100644 --- a/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithAliasedOptionalGenericFieldSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithAliasedOptionalGenericFieldSerializer(t_serializer) diff --git a/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m index d7bb27d3..4d9da421 100644 --- a/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithAliasedOptionalGenericUnionFieldSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithAliasedOptionalGenericUnionFieldSerializer(u_serializer, v_serializer) diff --git a/matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m index 7c6cd298..8cc58c8e 100644 --- a/matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithArraysSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithArraysSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m b/matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m index 60d0bd9f..d089a19e 100644 --- a/matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithArraysSimpleSyntaxSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithArraysSimpleSyntaxSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m index cd1c77ce..391ff580 100644 --- a/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithComputedFieldsSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithComputedFieldsSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m index aa835e28..b34a2c3d 100644 --- a/matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithDynamicNDArraysSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithDynamicNDArraysSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m index d496b28d..ddcc2310 100644 --- a/matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithEnumsSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithEnumsSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m index 1dc0f50a..0dce817c 100644 --- a/matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithFixedArraysSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithFixedArraysSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m index 39fa759f..ac3cd3cb 100644 --- a/matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithFixedCollectionsSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithFixedCollectionsSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m index ea685c88..9c2a5df3 100644 --- a/matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithFixedVectorsSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithFixedVectorsSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m index 96d273d8..06924402 100644 --- a/matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithGenericArraysSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithGenericArraysSerializer(t_serializer) diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m index 28b081d5..49b75fa9 100644 --- a/matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithGenericFixedVectorsSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithGenericFixedVectorsSerializer(t_serializer) diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m index 18070243..039d2100 100644 --- a/matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithGenericMapsSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithGenericMapsSerializer(t_serializer, u_serializer) diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m index 195a2769..bdbff197 100644 --- a/matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithGenericVectorOfRecordsSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithGenericVectorOfRecordsSerializer(t_serializer, u_serializer) diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m index 4d4f9722..1518b49f 100644 --- a/matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithGenericVectorsSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithGenericVectorsSerializer(t_serializer) diff --git a/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m index 3206f89c..ef4fb788 100644 --- a/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithKeywordFieldsSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithKeywordFieldsSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m index c7a3679a..a277561e 100644 --- a/matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithNDArraysSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithNDArraysSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m b/matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m index 9e2ed0d8..eea1ee3c 100644 --- a/matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithNDArraysSingleDimensionSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithNDArraysSingleDimensionSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m index 6050b003..3e1c4545 100644 --- a/matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithNamedFixedArraysSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithNamedFixedArraysSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m index ca0fd4f7..a9e54c59 100644 --- a/matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithOptionalFieldsSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithOptionalFieldsSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m index 443f477f..83e94bec 100644 --- a/matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithOptionalGenericFieldSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithOptionalGenericFieldSerializer(t_serializer) diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m index 6b41543a..7fe2dbd2 100644 --- a/matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithOptionalGenericUnionFieldSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithOptionalGenericUnionFieldSerializer(u_serializer, v_serializer) diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m index 45b59224..d0db2bd6 100644 --- a/matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithOptionalVectorSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithOptionalVectorSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m b/matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m index 4f499625..36bc9cd2 100644 --- a/matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithPrimitiveAliasesSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithPrimitiveAliasesSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m b/matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m index 9e52323f..3a0d1d8e 100644 --- a/matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithPrimitivesSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithPrimitivesSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m index 067ff7ff..7667d5e4 100644 --- a/matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithStringsSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithStringsSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m b/matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m index 086e03a3..a503a4a0 100644 --- a/matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithUnionsOfContainersSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithUnionsOfContainersSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m index efb313a7..d8bb776a 100644 --- a/matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithVectorOfTimesSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithVectorOfTimesSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m index aa98288b..b45cfc68 100644 --- a/matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithVectorsSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithVectorsSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m index a6f40d17..242db2f6 100644 --- a/matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithVlenCollectionsSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithVlenCollectionsSerializer() diff --git a/matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m index 18f801db..a7cb28c0 100644 --- a/matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithVlensSerializer < yardl.binary.RecordSerializer methods function obj = RecordWithVlensSerializer() diff --git a/matlab/generated/+test_model/+binary/ScalarOptionalsReader.m b/matlab/generated/+test_model/+binary/ScalarOptionalsReader.m index 56858833..f3178bd6 100644 --- a/matlab/generated/+test_model/+binary/ScalarOptionalsReader.m +++ b/matlab/generated/+test_model/+binary/ScalarOptionalsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the ScalarOptionals protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef ScalarOptionalsReader < yardl.binary.BinaryProtocolReader & test_model.ScalarOptionalsReaderBase + % Binary reader for the ScalarOptionals protocol methods function obj = ScalarOptionalsReader(filename) obj@test_model.ScalarOptionalsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m b/matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m index 8661622d..05dff021 100644 --- a/matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m +++ b/matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the ScalarOptionals protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef ScalarOptionalsWriter < yardl.binary.BinaryProtocolWriter & test_model.ScalarOptionalsWriterBase + % Binary writer for the ScalarOptionals protocol methods function obj = ScalarOptionalsWriter(filename) obj@test_model.ScalarOptionalsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/ScalarsReader.m b/matlab/generated/+test_model/+binary/ScalarsReader.m index 2cbee512..3dd3a21a 100644 --- a/matlab/generated/+test_model/+binary/ScalarsReader.m +++ b/matlab/generated/+test_model/+binary/ScalarsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the Scalars protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef ScalarsReader < yardl.binary.BinaryProtocolReader & test_model.ScalarsReaderBase + % Binary reader for the Scalars protocol methods function obj = ScalarsReader(filename) obj@test_model.ScalarsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/ScalarsWriter.m b/matlab/generated/+test_model/+binary/ScalarsWriter.m index ac9f1207..7eee90ae 100644 --- a/matlab/generated/+test_model/+binary/ScalarsWriter.m +++ b/matlab/generated/+test_model/+binary/ScalarsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the Scalars protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef ScalarsWriter < yardl.binary.BinaryProtocolWriter & test_model.ScalarsWriterBase + % Binary writer for the Scalars protocol methods function obj = ScalarsWriter(filename) obj@test_model.ScalarsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m b/matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m index f6764ae4..3de76a44 100644 --- a/matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m +++ b/matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SimpleAcquisitionSerializer < yardl.binary.RecordSerializer methods function obj = SimpleAcquisitionSerializer() diff --git a/matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m b/matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m index 5430bc91..19847e48 100644 --- a/matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m +++ b/matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SimpleEncodingCountersSerializer < yardl.binary.RecordSerializer methods function obj = SimpleEncodingCountersSerializer() diff --git a/matlab/generated/+test_model/+binary/SimpleGenericsReader.m b/matlab/generated/+test_model/+binary/SimpleGenericsReader.m index f8ba4040..404cde80 100644 --- a/matlab/generated/+test_model/+binary/SimpleGenericsReader.m +++ b/matlab/generated/+test_model/+binary/SimpleGenericsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the SimpleGenerics protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SimpleGenericsReader < yardl.binary.BinaryProtocolReader & test_model.SimpleGenericsReaderBase + % Binary reader for the SimpleGenerics protocol methods function obj = SimpleGenericsReader(filename) obj@test_model.SimpleGenericsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/SimpleGenericsWriter.m b/matlab/generated/+test_model/+binary/SimpleGenericsWriter.m index 15d49ac9..8711f243 100644 --- a/matlab/generated/+test_model/+binary/SimpleGenericsWriter.m +++ b/matlab/generated/+test_model/+binary/SimpleGenericsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the SimpleGenerics protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SimpleGenericsWriter < yardl.binary.BinaryProtocolWriter & test_model.SimpleGenericsWriterBase + % Binary writer for the SimpleGenerics protocol methods function obj = SimpleGenericsWriter(filename) obj@test_model.SimpleGenericsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/SimpleRecordSerializer.m b/matlab/generated/+test_model/+binary/SimpleRecordSerializer.m index 4431faf2..3822533d 100644 --- a/matlab/generated/+test_model/+binary/SimpleRecordSerializer.m +++ b/matlab/generated/+test_model/+binary/SimpleRecordSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SimpleRecordSerializer < yardl.binary.RecordSerializer methods function obj = SimpleRecordSerializer() diff --git a/matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m b/matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m index 2a38fb5d..5845e7be 100644 --- a/matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m +++ b/matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SmallBenchmarkRecordSerializer < yardl.binary.RecordSerializer methods function obj = SmallBenchmarkRecordSerializer() diff --git a/matlab/generated/+test_model/+binary/StateTestReader.m b/matlab/generated/+test_model/+binary/StateTestReader.m index a8079f18..74be1c7d 100644 --- a/matlab/generated/+test_model/+binary/StateTestReader.m +++ b/matlab/generated/+test_model/+binary/StateTestReader.m @@ -1,5 +1,7 @@ -% Binary reader for the StateTest protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StateTestReader < yardl.binary.BinaryProtocolReader & test_model.StateTestReaderBase + % Binary reader for the StateTest protocol methods function obj = StateTestReader(filename) obj@test_model.StateTestReaderBase(); diff --git a/matlab/generated/+test_model/+binary/StateTestWriter.m b/matlab/generated/+test_model/+binary/StateTestWriter.m index 32428cd3..1ce6f94b 100644 --- a/matlab/generated/+test_model/+binary/StateTestWriter.m +++ b/matlab/generated/+test_model/+binary/StateTestWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the StateTest protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StateTestWriter < yardl.binary.BinaryProtocolWriter & test_model.StateTestWriterBase + % Binary writer for the StateTest protocol methods function obj = StateTestWriter(filename) obj@test_model.StateTestWriterBase(); diff --git a/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m index 4275c5f6..6ad6fbdf 100644 --- a/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m +++ b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the StreamsOfAliasedUnions protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StreamsOfAliasedUnionsReader < yardl.binary.BinaryProtocolReader & test_model.StreamsOfAliasedUnionsReaderBase + % Binary reader for the StreamsOfAliasedUnions protocol methods function obj = StreamsOfAliasedUnionsReader(filename) obj@test_model.StreamsOfAliasedUnionsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m index cd7e50f6..dc8983bd 100644 --- a/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m +++ b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the StreamsOfAliasedUnions protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StreamsOfAliasedUnionsWriter < yardl.binary.BinaryProtocolWriter & test_model.StreamsOfAliasedUnionsWriterBase + % Binary writer for the StreamsOfAliasedUnions protocol methods function obj = StreamsOfAliasedUnionsWriter(filename) obj@test_model.StreamsOfAliasedUnionsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m b/matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m index d2509755..df4c06f0 100644 --- a/matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m +++ b/matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the StreamsOfUnions protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StreamsOfUnionsReader < yardl.binary.BinaryProtocolReader & test_model.StreamsOfUnionsReaderBase + % Binary reader for the StreamsOfUnions protocol methods function obj = StreamsOfUnionsReader(filename) obj@test_model.StreamsOfUnionsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m b/matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m index 22ca0318..8a62586a 100644 --- a/matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m +++ b/matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the StreamsOfUnions protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StreamsOfUnionsWriter < yardl.binary.BinaryProtocolWriter & test_model.StreamsOfUnionsWriterBase + % Binary writer for the StreamsOfUnions protocol methods function obj = StreamsOfUnionsWriter(filename) obj@test_model.StreamsOfUnionsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/StreamsReader.m b/matlab/generated/+test_model/+binary/StreamsReader.m index 29497048..32970acb 100644 --- a/matlab/generated/+test_model/+binary/StreamsReader.m +++ b/matlab/generated/+test_model/+binary/StreamsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the Streams protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StreamsReader < yardl.binary.BinaryProtocolReader & test_model.StreamsReaderBase + % Binary reader for the Streams protocol methods function obj = StreamsReader(filename) obj@test_model.StreamsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/StreamsWriter.m b/matlab/generated/+test_model/+binary/StreamsWriter.m index b73e2cf7..bee1eb4d 100644 --- a/matlab/generated/+test_model/+binary/StreamsWriter.m +++ b/matlab/generated/+test_model/+binary/StreamsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the Streams protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StreamsWriter < yardl.binary.BinaryProtocolWriter & test_model.StreamsWriterBase + % Binary writer for the Streams protocol methods function obj = StreamsWriter(filename) obj@test_model.StreamsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/StringsReader.m b/matlab/generated/+test_model/+binary/StringsReader.m index 29cceb0e..efaca4e4 100644 --- a/matlab/generated/+test_model/+binary/StringsReader.m +++ b/matlab/generated/+test_model/+binary/StringsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the Strings protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StringsReader < yardl.binary.BinaryProtocolReader & test_model.StringsReaderBase + % Binary reader for the Strings protocol methods function obj = StringsReader(filename) obj@test_model.StringsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/StringsWriter.m b/matlab/generated/+test_model/+binary/StringsWriter.m index 7807f6cd..62368b59 100644 --- a/matlab/generated/+test_model/+binary/StringsWriter.m +++ b/matlab/generated/+test_model/+binary/StringsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the Strings protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StringsWriter < yardl.binary.BinaryProtocolWriter & test_model.StringsWriterBase + % Binary writer for the Strings protocol methods function obj = StringsWriter(filename) obj@test_model.StringsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m b/matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m index 017ecf1c..6bd672eb 100644 --- a/matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m +++ b/matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the SubarraysInRecords protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SubarraysInRecordsReader < yardl.binary.BinaryProtocolReader & test_model.SubarraysInRecordsReaderBase + % Binary reader for the SubarraysInRecords protocol methods function obj = SubarraysInRecordsReader(filename) obj@test_model.SubarraysInRecordsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m b/matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m index 43e6c855..c8c2477b 100644 --- a/matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m +++ b/matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the SubarraysInRecords protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SubarraysInRecordsWriter < yardl.binary.BinaryProtocolWriter & test_model.SubarraysInRecordsWriterBase + % Binary writer for the SubarraysInRecords protocol methods function obj = SubarraysInRecordsWriter(filename) obj@test_model.SubarraysInRecordsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/SubarraysReader.m b/matlab/generated/+test_model/+binary/SubarraysReader.m index d8753e77..028cbfb0 100644 --- a/matlab/generated/+test_model/+binary/SubarraysReader.m +++ b/matlab/generated/+test_model/+binary/SubarraysReader.m @@ -1,5 +1,7 @@ -% Binary reader for the Subarrays protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SubarraysReader < yardl.binary.BinaryProtocolReader & test_model.SubarraysReaderBase + % Binary reader for the Subarrays protocol methods function obj = SubarraysReader(filename) obj@test_model.SubarraysReaderBase(); diff --git a/matlab/generated/+test_model/+binary/SubarraysWriter.m b/matlab/generated/+test_model/+binary/SubarraysWriter.m index abcc8d3c..4148b185 100644 --- a/matlab/generated/+test_model/+binary/SubarraysWriter.m +++ b/matlab/generated/+test_model/+binary/SubarraysWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the Subarrays protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SubarraysWriter < yardl.binary.BinaryProtocolWriter & test_model.SubarraysWriterBase + % Binary writer for the Subarrays protocol methods function obj = SubarraysWriter(filename) obj@test_model.SubarraysWriterBase(); diff --git a/matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m b/matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m index 97d9d107..9f9c47cd 100644 --- a/matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m +++ b/matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TupleWithRecordsSerializer < yardl.binary.RecordSerializer methods function obj = TupleWithRecordsSerializer() diff --git a/matlab/generated/+test_model/+binary/UnionsReader.m b/matlab/generated/+test_model/+binary/UnionsReader.m index a93e35a5..c456c4e8 100644 --- a/matlab/generated/+test_model/+binary/UnionsReader.m +++ b/matlab/generated/+test_model/+binary/UnionsReader.m @@ -1,5 +1,7 @@ -% Binary reader for the Unions protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef UnionsReader < yardl.binary.BinaryProtocolReader & test_model.UnionsReaderBase + % Binary reader for the Unions protocol methods function obj = UnionsReader(filename) obj@test_model.UnionsReaderBase(); diff --git a/matlab/generated/+test_model/+binary/UnionsWriter.m b/matlab/generated/+test_model/+binary/UnionsWriter.m index e04d8568..bbe28c5f 100644 --- a/matlab/generated/+test_model/+binary/UnionsWriter.m +++ b/matlab/generated/+test_model/+binary/UnionsWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the Unions protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef UnionsWriter < yardl.binary.BinaryProtocolWriter & test_model.UnionsWriterBase + % Binary writer for the Unions protocol methods function obj = UnionsWriter(filename) obj@test_model.UnionsWriterBase(); diff --git a/matlab/generated/+test_model/+binary/VlensReader.m b/matlab/generated/+test_model/+binary/VlensReader.m index 1aa8c8e2..539206aa 100644 --- a/matlab/generated/+test_model/+binary/VlensReader.m +++ b/matlab/generated/+test_model/+binary/VlensReader.m @@ -1,5 +1,7 @@ -% Binary reader for the Vlens protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef VlensReader < yardl.binary.BinaryProtocolReader & test_model.VlensReaderBase + % Binary reader for the Vlens protocol methods function obj = VlensReader(filename) obj@test_model.VlensReaderBase(); diff --git a/matlab/generated/+test_model/+binary/VlensWriter.m b/matlab/generated/+test_model/+binary/VlensWriter.m index 4596c416..5fd6d54f 100644 --- a/matlab/generated/+test_model/+binary/VlensWriter.m +++ b/matlab/generated/+test_model/+binary/VlensWriter.m @@ -1,5 +1,7 @@ -% Binary writer for the Vlens protocol +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef VlensWriter < yardl.binary.BinaryProtocolWriter & test_model.VlensWriterBase + % Binary writer for the Vlens protocol methods function obj = VlensWriter(filename) obj@test_model.VlensWriterBase(); diff --git a/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m b/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m index c471a3d1..6b6aef3e 100644 --- a/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockAdvancedGenericsWriter < test_model.AdvancedGenericsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockAliasesWriter.m b/matlab/generated/+test_model/+testing/MockAliasesWriter.m index 2c109b0f..b1794fec 100644 --- a/matlab/generated/+test_model/+testing/MockAliasesWriter.m +++ b/matlab/generated/+test_model/+testing/MockAliasesWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockAliasesWriter < test_model.AliasesWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m index 2a3f1082..1b038d1f 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockBenchmarkFloat256x256Writer < test_model.BenchmarkFloat256x256WriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m index 7608c98b..755553bb 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockBenchmarkFloatVlenWriter < test_model.BenchmarkFloatVlenWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m index 6223226c..934c6956 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockBenchmarkInt256x256Writer < test_model.BenchmarkInt256x256WriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m index 447e5e86..bb6f03d7 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockBenchmarkSimpleMrdWriter < test_model.BenchmarkSimpleMrdWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m index 6f46a935..2a627c5c 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockBenchmarkSmallRecordWithOptionalsWriter < test_model.BenchmarkSmallRecordWithOptionalsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m index de7295dd..7185c585 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockBenchmarkSmallRecordWriter < test_model.BenchmarkSmallRecordWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m b/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m index e9c24e4a..6a080ea7 100644 --- a/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockDynamicNDArraysWriter < test_model.DynamicNDArraysWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockEnumsWriter.m b/matlab/generated/+test_model/+testing/MockEnumsWriter.m index e8d677af..e5b15330 100644 --- a/matlab/generated/+test_model/+testing/MockEnumsWriter.m +++ b/matlab/generated/+test_model/+testing/MockEnumsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockEnumsWriter < test_model.EnumsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m b/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m index 459a9a53..ca92426a 100644 --- a/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockFixedArraysWriter < test_model.FixedArraysWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m b/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m index 9a40c937..c3f7db42 100644 --- a/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockFixedVectorsWriter < test_model.FixedVectorsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockFlagsWriter.m b/matlab/generated/+test_model/+testing/MockFlagsWriter.m index b9a3e5d1..806b71e3 100644 --- a/matlab/generated/+test_model/+testing/MockFlagsWriter.m +++ b/matlab/generated/+test_model/+testing/MockFlagsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockFlagsWriter < test_model.FlagsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockMapsWriter.m b/matlab/generated/+test_model/+testing/MockMapsWriter.m index 52f35124..e40436b6 100644 --- a/matlab/generated/+test_model/+testing/MockMapsWriter.m +++ b/matlab/generated/+test_model/+testing/MockMapsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockMapsWriter < test_model.MapsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m b/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m index 747dab93..09400ed0 100644 --- a/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m +++ b/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockNDArraysSingleDimensionWriter < test_model.NDArraysSingleDimensionWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockNDArraysWriter.m b/matlab/generated/+test_model/+testing/MockNDArraysWriter.m index 5dafcf71..31f4b59b 100644 --- a/matlab/generated/+test_model/+testing/MockNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockNDArraysWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockNDArraysWriter < test_model.NDArraysWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m b/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m index e7feb8b1..6de75002 100644 --- a/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockNestedRecordsWriter < test_model.NestedRecordsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m b/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m index 892e421a..5c0004d1 100644 --- a/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockOptionalVectorsWriter < test_model.OptionalVectorsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m b/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m index e48fa697..82b3908d 100644 --- a/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m +++ b/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockProtocolWithComputedFieldsWriter < test_model.ProtocolWithComputedFieldsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m index 0f90fe98..c9bff007 100644 --- a/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m +++ b/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockProtocolWithKeywordStepsWriter < test_model.ProtocolWithKeywordStepsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m b/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m index 06280141..127464f3 100644 --- a/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockScalarOptionalsWriter < test_model.ScalarOptionalsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockScalarsWriter.m b/matlab/generated/+test_model/+testing/MockScalarsWriter.m index 174440e3..0a100fc2 100644 --- a/matlab/generated/+test_model/+testing/MockScalarsWriter.m +++ b/matlab/generated/+test_model/+testing/MockScalarsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockScalarsWriter < test_model.ScalarsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m b/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m index 01f97802..c848959d 100644 --- a/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockSimpleGenericsWriter < test_model.SimpleGenericsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockStateTestWriter.m b/matlab/generated/+test_model/+testing/MockStateTestWriter.m index 334b7523..f21c8376 100644 --- a/matlab/generated/+test_model/+testing/MockStateTestWriter.m +++ b/matlab/generated/+test_model/+testing/MockStateTestWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockStateTestWriter < test_model.StateTestWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m index fa7c035f..ae538bb8 100644 --- a/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockStreamsOfAliasedUnionsWriter < test_model.StreamsOfAliasedUnionsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m index ead871c2..781c7ed2 100644 --- a/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockStreamsOfUnionsWriter < test_model.StreamsOfUnionsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockStreamsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsWriter.m index 225199e4..8beee72f 100644 --- a/matlab/generated/+test_model/+testing/MockStreamsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStreamsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockStreamsWriter < test_model.StreamsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockStringsWriter.m b/matlab/generated/+test_model/+testing/MockStringsWriter.m index 6b52554f..ed924a1e 100644 --- a/matlab/generated/+test_model/+testing/MockStringsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStringsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockStringsWriter < test_model.StringsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m b/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m index b3a3d8a1..f9427bce 100644 --- a/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockSubarraysInRecordsWriter < test_model.SubarraysInRecordsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockSubarraysWriter.m b/matlab/generated/+test_model/+testing/MockSubarraysWriter.m index f1e91901..ae052ce6 100644 --- a/matlab/generated/+test_model/+testing/MockSubarraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockSubarraysWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockSubarraysWriter < test_model.SubarraysWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockUnionsWriter.m b/matlab/generated/+test_model/+testing/MockUnionsWriter.m index bd1c2a38..ebca1771 100644 --- a/matlab/generated/+test_model/+testing/MockUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/MockUnionsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockUnionsWriter < test_model.UnionsWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/MockVlensWriter.m b/matlab/generated/+test_model/+testing/MockVlensWriter.m index a9af6253..a33017c3 100644 --- a/matlab/generated/+test_model/+testing/MockVlensWriter.m +++ b/matlab/generated/+test_model/+testing/MockVlensWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MockVlensWriter < test_model.VlensWriterBase properties testCase_ diff --git a/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m b/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m index b2011d03..a23bd2d3 100644 --- a/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestAdvancedGenericsWriter < test_model.AdvancedGenericsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestAliasesWriter.m b/matlab/generated/+test_model/+testing/TestAliasesWriter.m index 7045e138..4544cc2f 100644 --- a/matlab/generated/+test_model/+testing/TestAliasesWriter.m +++ b/matlab/generated/+test_model/+testing/TestAliasesWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestAliasesWriter < test_model.AliasesWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m index cb82f0b7..75b0b71b 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestBenchmarkFloat256x256Writer < test_model.BenchmarkFloat256x256WriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m index 20c83b4d..5ca64d39 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestBenchmarkFloatVlenWriter < test_model.BenchmarkFloatVlenWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m index 762f2e9e..5c6169b1 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestBenchmarkInt256x256Writer < test_model.BenchmarkInt256x256WriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m index f826d6fc..4a65c610 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestBenchmarkSimpleMrdWriter < test_model.BenchmarkSimpleMrdWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m index 47437359..c71c65e9 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestBenchmarkSmallRecordWithOptionalsWriter < test_model.BenchmarkSmallRecordWithOptionalsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m index 3713a2cb..fdfaa0be 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestBenchmarkSmallRecordWriter < test_model.BenchmarkSmallRecordWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m b/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m index ccd7b1d4..6a25f72b 100644 --- a/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestDynamicNDArraysWriter < test_model.DynamicNDArraysWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestEnumsWriter.m b/matlab/generated/+test_model/+testing/TestEnumsWriter.m index 96d179bc..a8f46302 100644 --- a/matlab/generated/+test_model/+testing/TestEnumsWriter.m +++ b/matlab/generated/+test_model/+testing/TestEnumsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestEnumsWriter < test_model.EnumsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m b/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m index 53708af2..5508a751 100644 --- a/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestFixedArraysWriter < test_model.FixedArraysWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m b/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m index 9c8978ab..194562bb 100644 --- a/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestFixedVectorsWriter < test_model.FixedVectorsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestFlagsWriter.m b/matlab/generated/+test_model/+testing/TestFlagsWriter.m index 0a20ca55..cd0d827c 100644 --- a/matlab/generated/+test_model/+testing/TestFlagsWriter.m +++ b/matlab/generated/+test_model/+testing/TestFlagsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestFlagsWriter < test_model.FlagsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestMapsWriter.m b/matlab/generated/+test_model/+testing/TestMapsWriter.m index 524c3466..cbf2324a 100644 --- a/matlab/generated/+test_model/+testing/TestMapsWriter.m +++ b/matlab/generated/+test_model/+testing/TestMapsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestMapsWriter < test_model.MapsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m b/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m index 6fd5afed..c74088c7 100644 --- a/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m +++ b/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestNDArraysSingleDimensionWriter < test_model.NDArraysSingleDimensionWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestNDArraysWriter.m b/matlab/generated/+test_model/+testing/TestNDArraysWriter.m index 76cc9a61..039f9a8d 100644 --- a/matlab/generated/+test_model/+testing/TestNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestNDArraysWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestNDArraysWriter < test_model.NDArraysWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m b/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m index 729d86f1..ec761e8f 100644 --- a/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestNestedRecordsWriter < test_model.NestedRecordsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m b/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m index 3bf0fab9..c485efee 100644 --- a/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestOptionalVectorsWriter < test_model.OptionalVectorsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m b/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m index 0528ddf9..0850caba 100644 --- a/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m +++ b/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestProtocolWithComputedFieldsWriter < test_model.ProtocolWithComputedFieldsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m index 4eeec4c2..43b88e2d 100644 --- a/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m +++ b/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestProtocolWithKeywordStepsWriter < test_model.ProtocolWithKeywordStepsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m b/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m index 6da2c197..23bf89b0 100644 --- a/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestScalarOptionalsWriter < test_model.ScalarOptionalsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestScalarsWriter.m b/matlab/generated/+test_model/+testing/TestScalarsWriter.m index 477a49e0..3be658ec 100644 --- a/matlab/generated/+test_model/+testing/TestScalarsWriter.m +++ b/matlab/generated/+test_model/+testing/TestScalarsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestScalarsWriter < test_model.ScalarsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m b/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m index fa05e668..e4012ad7 100644 --- a/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestSimpleGenericsWriter < test_model.SimpleGenericsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestStateTestWriter.m b/matlab/generated/+test_model/+testing/TestStateTestWriter.m index 082f2b74..858012f7 100644 --- a/matlab/generated/+test_model/+testing/TestStateTestWriter.m +++ b/matlab/generated/+test_model/+testing/TestStateTestWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestStateTestWriter < test_model.StateTestWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m index 2a397cff..9ffb9ead 100644 --- a/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestStreamsOfAliasedUnionsWriter < test_model.StreamsOfAliasedUnionsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m index 183ba953..eac82dba 100644 --- a/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestStreamsOfUnionsWriter < test_model.StreamsOfUnionsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestStreamsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsWriter.m index 386cb10f..4529417a 100644 --- a/matlab/generated/+test_model/+testing/TestStreamsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStreamsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestStreamsWriter < test_model.StreamsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestStringsWriter.m b/matlab/generated/+test_model/+testing/TestStringsWriter.m index 8111d7e0..8f83dede 100644 --- a/matlab/generated/+test_model/+testing/TestStringsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStringsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestStringsWriter < test_model.StringsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m b/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m index 65e669cc..3f7535ca 100644 --- a/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestSubarraysInRecordsWriter < test_model.SubarraysInRecordsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestSubarraysWriter.m b/matlab/generated/+test_model/+testing/TestSubarraysWriter.m index ead973f4..1b61eb72 100644 --- a/matlab/generated/+test_model/+testing/TestSubarraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestSubarraysWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestSubarraysWriter < test_model.SubarraysWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestUnionsWriter.m b/matlab/generated/+test_model/+testing/TestUnionsWriter.m index 3b3239bc..678d8c40 100644 --- a/matlab/generated/+test_model/+testing/TestUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/TestUnionsWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestUnionsWriter < test_model.UnionsWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/+testing/TestVlensWriter.m b/matlab/generated/+test_model/+testing/TestVlensWriter.m index 4d4bddcd..6e536c4e 100644 --- a/matlab/generated/+test_model/+testing/TestVlensWriter.m +++ b/matlab/generated/+test_model/+testing/TestVlensWriter.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TestVlensWriter < test_model.VlensWriterBase properties (Access = private) writer_ diff --git a/matlab/generated/+test_model/AcquisitionOrImage.m b/matlab/generated/+test_model/AcquisitionOrImage.m index df171ce2..749f6c7f 100644 --- a/matlab/generated/+test_model/AcquisitionOrImage.m +++ b/matlab/generated/+test_model/AcquisitionOrImage.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef AcquisitionOrImage < yardl.Union methods (Static) function res = Acquisition(value) @@ -12,13 +14,13 @@ elem = test_model.AcquisitionOrImage(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/AdvancedGenericsReaderBase.m b/matlab/generated/+test_model/AdvancedGenericsReaderBase.m index 19568374..6d2e1341 100644 --- a/matlab/generated/+test_model/AdvancedGenericsReaderBase.m +++ b/matlab/generated/+test_model/AdvancedGenericsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef AdvancedGenericsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/AdvancedGenericsWriterBase.m b/matlab/generated/+test_model/AdvancedGenericsWriterBase.m index 7685fd06..4aca7a6a 100644 --- a/matlab/generated/+test_model/AdvancedGenericsWriterBase.m +++ b/matlab/generated/+test_model/AdvancedGenericsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol AdvancedGenerics classdef (Abstract) AdvancedGenericsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/AliasedClosedGeneric.m b/matlab/generated/+test_model/AliasedClosedGeneric.m index af4ce3c6..677faef1 100644 --- a/matlab/generated/+test_model/AliasedClosedGeneric.m +++ b/matlab/generated/+test_model/AliasedClosedGeneric.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function c = AliasedClosedGeneric(varargin) c = test_model.AliasedTuple(varargin{:}); end diff --git a/matlab/generated/+test_model/AliasedEnum.m b/matlab/generated/+test_model/AliasedEnum.m index eddc1e37..08737fc3 100644 --- a/matlab/generated/+test_model/AliasedEnum.m +++ b/matlab/generated/+test_model/AliasedEnum.m @@ -1,2 +1,4 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef AliasedEnum < test_model.Fruits end diff --git a/matlab/generated/+test_model/AliasedGenericDynamicArray.m b/matlab/generated/+test_model/AliasedGenericDynamicArray.m index f91ac2c2..5fb27fa5 100644 --- a/matlab/generated/+test_model/AliasedGenericDynamicArray.m +++ b/matlab/generated/+test_model/AliasedGenericDynamicArray.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = AliasedGenericDynamicArray(array) a = array; end diff --git a/matlab/generated/+test_model/AliasedGenericFixedArray.m b/matlab/generated/+test_model/AliasedGenericFixedArray.m index a9c65819..f2e2aee4 100644 --- a/matlab/generated/+test_model/AliasedGenericFixedArray.m +++ b/matlab/generated/+test_model/AliasedGenericFixedArray.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = AliasedGenericFixedArray(array) a = array; end diff --git a/matlab/generated/+test_model/AliasedGenericFixedVector.m b/matlab/generated/+test_model/AliasedGenericFixedVector.m index ee32e8c6..f73f1dad 100644 --- a/matlab/generated/+test_model/AliasedGenericFixedVector.m +++ b/matlab/generated/+test_model/AliasedGenericFixedVector.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = AliasedGenericFixedVector(array) a = array; end diff --git a/matlab/generated/+test_model/AliasedGenericOptional.m b/matlab/generated/+test_model/AliasedGenericOptional.m index 105e7225..5b2a36c2 100644 --- a/matlab/generated/+test_model/AliasedGenericOptional.m +++ b/matlab/generated/+test_model/AliasedGenericOptional.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function o = AliasedGenericOptional(value) o = yardl.Optional(value); end diff --git a/matlab/generated/+test_model/AliasedGenericRank2Array.m b/matlab/generated/+test_model/AliasedGenericRank2Array.m index 5a189484..1c43a59e 100644 --- a/matlab/generated/+test_model/AliasedGenericRank2Array.m +++ b/matlab/generated/+test_model/AliasedGenericRank2Array.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = AliasedGenericRank2Array(array) a = array; end diff --git a/matlab/generated/+test_model/AliasedGenericUnion2.m b/matlab/generated/+test_model/AliasedGenericUnion2.m index 6c6a1d0a..fadecd6c 100644 --- a/matlab/generated/+test_model/AliasedGenericUnion2.m +++ b/matlab/generated/+test_model/AliasedGenericUnion2.m @@ -1,2 +1,4 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef AliasedGenericUnion2 < basic_types.GenericUnion2 end diff --git a/matlab/generated/+test_model/AliasedGenericVector.m b/matlab/generated/+test_model/AliasedGenericVector.m index 29a51410..d4a99372 100644 --- a/matlab/generated/+test_model/AliasedGenericVector.m +++ b/matlab/generated/+test_model/AliasedGenericVector.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = AliasedGenericVector(array) a = array; end diff --git a/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m b/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m index 2327c56d..a72db99d 100644 --- a/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m +++ b/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef AliasedIntOrSimpleRecord < yardl.Union methods (Static) function res = Int32(value) @@ -12,13 +14,13 @@ elem = test_model.AliasedIntOrSimpleRecord(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/AliasedMap.m b/matlab/generated/+test_model/AliasedMap.m index b43ebbcd..ab6de561 100644 --- a/matlab/generated/+test_model/AliasedMap.m +++ b/matlab/generated/+test_model/AliasedMap.m @@ -1,2 +1,4 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef AliasedMap < basic_types.AliasedMap end diff --git a/matlab/generated/+test_model/AliasedMultiGenericOptional.m b/matlab/generated/+test_model/AliasedMultiGenericOptional.m index 0fc4c0d4..7619c5d9 100644 --- a/matlab/generated/+test_model/AliasedMultiGenericOptional.m +++ b/matlab/generated/+test_model/AliasedMultiGenericOptional.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef AliasedMultiGenericOptional < yardl.Union methods (Static) function res = T(value) @@ -12,13 +14,13 @@ elem = test_model.AliasedMultiGenericOptional(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m b/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m index c6ab4744..71c24fc1 100644 --- a/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m +++ b/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef AliasedNullableIntSimpleRecord < yardl.Union methods (Static) function res = Int32(value) @@ -12,13 +14,13 @@ elem = test_model.AliasedNullableIntSimpleRecord(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/AliasedOpenGeneric.m b/matlab/generated/+test_model/AliasedOpenGeneric.m index b097107b..926723bb 100644 --- a/matlab/generated/+test_model/AliasedOpenGeneric.m +++ b/matlab/generated/+test_model/AliasedOpenGeneric.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function c = AliasedOpenGeneric(varargin) c = test_model.AliasedTuple(varargin{:}); end diff --git a/matlab/generated/+test_model/AliasedOptional.m b/matlab/generated/+test_model/AliasedOptional.m index 16300e57..fce1bd99 100644 --- a/matlab/generated/+test_model/AliasedOptional.m +++ b/matlab/generated/+test_model/AliasedOptional.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function o = AliasedOptional(value) assert(isa(value, 'int32')); o = yardl.Optional(value); diff --git a/matlab/generated/+test_model/AliasedString.m b/matlab/generated/+test_model/AliasedString.m index 6d0543af..c544744e 100644 --- a/matlab/generated/+test_model/AliasedString.m +++ b/matlab/generated/+test_model/AliasedString.m @@ -1,2 +1,4 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef AliasedString < string end diff --git a/matlab/generated/+test_model/AliasedTuple.m b/matlab/generated/+test_model/AliasedTuple.m index cb12c1de..f77c1fde 100644 --- a/matlab/generated/+test_model/AliasedTuple.m +++ b/matlab/generated/+test_model/AliasedTuple.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function c = AliasedTuple(varargin) c = test_model.MyTuple(varargin{:}); end diff --git a/matlab/generated/+test_model/AliasedVectorOfGenericRecords.m b/matlab/generated/+test_model/AliasedVectorOfGenericRecords.m index 0468bede..607013fa 100644 --- a/matlab/generated/+test_model/AliasedVectorOfGenericRecords.m +++ b/matlab/generated/+test_model/AliasedVectorOfGenericRecords.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = AliasedVectorOfGenericRecords(array) a = array; end diff --git a/matlab/generated/+test_model/AliasesReaderBase.m b/matlab/generated/+test_model/AliasesReaderBase.m index 07a86314..f6f799c5 100644 --- a/matlab/generated/+test_model/AliasesReaderBase.m +++ b/matlab/generated/+test_model/AliasesReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef AliasesReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/AliasesWriterBase.m b/matlab/generated/+test_model/AliasesWriterBase.m index 1af33872..ffb9831e 100644 --- a/matlab/generated/+test_model/AliasesWriterBase.m +++ b/matlab/generated/+test_model/AliasesWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol Aliases classdef (Abstract) AliasesWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/ArrayOrScalar.m b/matlab/generated/+test_model/ArrayOrScalar.m index a7846baa..62ac2a6d 100644 --- a/matlab/generated/+test_model/ArrayOrScalar.m +++ b/matlab/generated/+test_model/ArrayOrScalar.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef ArrayOrScalar < yardl.Union methods (Static) function res = Array(value) @@ -12,13 +14,13 @@ elem = test_model.ArrayOrScalar(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m b/matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m index 150da874..4be1c4a4 100644 --- a/matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m +++ b/matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = ArrayWithKeywordDimensionNames(array) assert(isa(array, 'int32')); a = array; diff --git a/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m b/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m index 23260744..fae4377a 100644 --- a/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkFloat256x256ReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m b/matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m index 6fa2f95c..e6c05531 100644 --- a/matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m +++ b/matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol BenchmarkFloat256x256 classdef (Abstract) BenchmarkFloat256x256WriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m b/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m index 7fdc4450..612e816b 100644 --- a/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkFloatVlenReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m b/matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m index 54566c80..288ed5fe 100644 --- a/matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m +++ b/matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol BenchmarkFloatVlen classdef (Abstract) BenchmarkFloatVlenWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m b/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m index 7757629f..9b64d136 100644 --- a/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkInt256x256ReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m b/matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m index 3c3262e2..09a0f68d 100644 --- a/matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m +++ b/matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol BenchmarkInt256x256 classdef (Abstract) BenchmarkInt256x256WriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m b/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m index 05eaea61..4dad134d 100644 --- a/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkSimpleMrdReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m b/matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m index 0e5b6574..b84e788c 100644 --- a/matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m +++ b/matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol BenchmarkSimpleMrd classdef (Abstract) BenchmarkSimpleMrdWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m index 6693b79f..ac5eeb31 100644 --- a/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkSmallRecordReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m index 7609c90f..ebfe5304 100644 --- a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef BenchmarkSmallRecordWithOptionalsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m index fa8da61b..9f076622 100644 --- a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m +++ b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol BenchmarkSmallRecordWithOptionals classdef (Abstract) BenchmarkSmallRecordWithOptionalsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m index d37abe65..c9a6cbc5 100644 --- a/matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m +++ b/matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol BenchmarkSmallRecord classdef (Abstract) BenchmarkSmallRecordWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/DaysOfWeek.m b/matlab/generated/+test_model/DaysOfWeek.m index 8319dd22..800705d6 100644 --- a/matlab/generated/+test_model/DaysOfWeek.m +++ b/matlab/generated/+test_model/DaysOfWeek.m @@ -1,2 +1,4 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef DaysOfWeek < basic_types.DaysOfWeek end diff --git a/matlab/generated/+test_model/DynamicNDArraysReaderBase.m b/matlab/generated/+test_model/DynamicNDArraysReaderBase.m index 08813bca..018f09da 100644 --- a/matlab/generated/+test_model/DynamicNDArraysReaderBase.m +++ b/matlab/generated/+test_model/DynamicNDArraysReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef DynamicNDArraysReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/DynamicNDArraysWriterBase.m b/matlab/generated/+test_model/DynamicNDArraysWriterBase.m index b6a9d582..a70096da 100644 --- a/matlab/generated/+test_model/DynamicNDArraysWriterBase.m +++ b/matlab/generated/+test_model/DynamicNDArraysWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol DynamicNDArrays classdef (Abstract) DynamicNDArraysWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/EnumWithKeywordSymbols.m b/matlab/generated/+test_model/EnumWithKeywordSymbols.m index ca97c633..e5a00901 100644 --- a/matlab/generated/+test_model/EnumWithKeywordSymbols.m +++ b/matlab/generated/+test_model/EnumWithKeywordSymbols.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef EnumWithKeywordSymbols < uint64 methods (Static) function e = TRY @@ -11,13 +13,13 @@ elem = test_model.EnumWithKeywordSymbols(0); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/EnumsReaderBase.m b/matlab/generated/+test_model/EnumsReaderBase.m index 682fda77..3e40bcb5 100644 --- a/matlab/generated/+test_model/EnumsReaderBase.m +++ b/matlab/generated/+test_model/EnumsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef EnumsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/EnumsWriterBase.m b/matlab/generated/+test_model/EnumsWriterBase.m index 66126816..f5e331a5 100644 --- a/matlab/generated/+test_model/EnumsWriterBase.m +++ b/matlab/generated/+test_model/EnumsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol Enums classdef (Abstract) EnumsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/FixedArraysReaderBase.m b/matlab/generated/+test_model/FixedArraysReaderBase.m index a9520467..cfefaf99 100644 --- a/matlab/generated/+test_model/FixedArraysReaderBase.m +++ b/matlab/generated/+test_model/FixedArraysReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef FixedArraysReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/FixedArraysWriterBase.m b/matlab/generated/+test_model/FixedArraysWriterBase.m index a1ab7258..38dca966 100644 --- a/matlab/generated/+test_model/FixedArraysWriterBase.m +++ b/matlab/generated/+test_model/FixedArraysWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol FixedArrays classdef (Abstract) FixedArraysWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/FixedVectorsReaderBase.m b/matlab/generated/+test_model/FixedVectorsReaderBase.m index 4a58820d..b1a0687d 100644 --- a/matlab/generated/+test_model/FixedVectorsReaderBase.m +++ b/matlab/generated/+test_model/FixedVectorsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef FixedVectorsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/FixedVectorsWriterBase.m b/matlab/generated/+test_model/FixedVectorsWriterBase.m index 8bb116d7..4a4ef2f2 100644 --- a/matlab/generated/+test_model/FixedVectorsWriterBase.m +++ b/matlab/generated/+test_model/FixedVectorsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol FixedVectors classdef (Abstract) FixedVectorsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/FlagsReaderBase.m b/matlab/generated/+test_model/FlagsReaderBase.m index f804c93c..62be65c2 100644 --- a/matlab/generated/+test_model/FlagsReaderBase.m +++ b/matlab/generated/+test_model/FlagsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef FlagsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/FlagsWriterBase.m b/matlab/generated/+test_model/FlagsWriterBase.m index 1ebac798..d3139421 100644 --- a/matlab/generated/+test_model/FlagsWriterBase.m +++ b/matlab/generated/+test_model/FlagsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol Flags classdef (Abstract) FlagsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/Fruits.m b/matlab/generated/+test_model/Fruits.m index 4f975d1c..e8b62e65 100644 --- a/matlab/generated/+test_model/Fruits.m +++ b/matlab/generated/+test_model/Fruits.m @@ -1,2 +1,4 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef Fruits < basic_types.Fruits end diff --git a/matlab/generated/+test_model/GenericRecord.m b/matlab/generated/+test_model/GenericRecord.m index af8baa36..9d9ebfd3 100644 --- a/matlab/generated/+test_model/GenericRecord.m +++ b/matlab/generated/+test_model/GenericRecord.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef GenericRecord < handle properties scalar_1 diff --git a/matlab/generated/+test_model/GenericUnion3.m b/matlab/generated/+test_model/GenericUnion3.m index e666b819..429be971 100644 --- a/matlab/generated/+test_model/GenericUnion3.m +++ b/matlab/generated/+test_model/GenericUnion3.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef GenericUnion3 < yardl.Union methods (Static) function res = T(value) @@ -16,13 +18,13 @@ elem = test_model.GenericUnion3(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/GenericUnion3Alternate.m b/matlab/generated/+test_model/GenericUnion3Alternate.m index 97dc4d55..6acc05e5 100644 --- a/matlab/generated/+test_model/GenericUnion3Alternate.m +++ b/matlab/generated/+test_model/GenericUnion3Alternate.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef GenericUnion3Alternate < yardl.Union methods (Static) function res = U(value) @@ -16,13 +18,13 @@ elem = test_model.GenericUnion3Alternate(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m b/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m index e033a605..c85b0ef3 100644 --- a/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m +++ b/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef GenericUnionWithRepeatedTypeParameters < yardl.Union methods (Static) function res = T(value) @@ -16,13 +18,13 @@ elem = test_model.GenericUnionWithRepeatedTypeParameters(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/Image.m b/matlab/generated/+test_model/Image.m index 4a551748..a31eac1f 100644 --- a/matlab/generated/+test_model/Image.m +++ b/matlab/generated/+test_model/Image.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = Image(array) a = array; end diff --git a/matlab/generated/+test_model/ImageFloatOrImageDouble.m b/matlab/generated/+test_model/ImageFloatOrImageDouble.m index 7b83ebc6..0e0211f5 100644 --- a/matlab/generated/+test_model/ImageFloatOrImageDouble.m +++ b/matlab/generated/+test_model/ImageFloatOrImageDouble.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef ImageFloatOrImageDouble < yardl.Union methods (Static) function res = ImageFloat(value) @@ -12,13 +14,13 @@ elem = test_model.ImageFloatOrImageDouble(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/Int32OrFloat32.m b/matlab/generated/+test_model/Int32OrFloat32.m index 1ee13ddc..431b47d3 100644 --- a/matlab/generated/+test_model/Int32OrFloat32.m +++ b/matlab/generated/+test_model/Int32OrFloat32.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef Int32OrFloat32 < yardl.Union methods (Static) function res = Int32(value) @@ -12,13 +14,13 @@ elem = test_model.Int32OrFloat32(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/Int32OrRecordWithVlens.m b/matlab/generated/+test_model/Int32OrRecordWithVlens.m index f83cf0a8..e8b94efa 100644 --- a/matlab/generated/+test_model/Int32OrRecordWithVlens.m +++ b/matlab/generated/+test_model/Int32OrRecordWithVlens.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef Int32OrRecordWithVlens < yardl.Union methods (Static) function res = Int32(value) @@ -12,13 +14,13 @@ elem = test_model.Int32OrRecordWithVlens(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/Int32OrSimpleRecord.m b/matlab/generated/+test_model/Int32OrSimpleRecord.m index ce8f50b1..12e38b94 100644 --- a/matlab/generated/+test_model/Int32OrSimpleRecord.m +++ b/matlab/generated/+test_model/Int32OrSimpleRecord.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef Int32OrSimpleRecord < yardl.Union methods (Static) function res = Int32(value) @@ -12,13 +14,13 @@ elem = test_model.Int32OrSimpleRecord(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/Int64Enum.m b/matlab/generated/+test_model/Int64Enum.m index f47191ee..231b99e7 100644 --- a/matlab/generated/+test_model/Int64Enum.m +++ b/matlab/generated/+test_model/Int64Enum.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef Int64Enum < int64 methods (Static) function e = B @@ -8,13 +10,13 @@ elem = test_model.Int64Enum(0); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/IntArray.m b/matlab/generated/+test_model/IntArray.m index e7ca7523..3d87ad7a 100644 --- a/matlab/generated/+test_model/IntArray.m +++ b/matlab/generated/+test_model/IntArray.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = IntArray(array) assert(isa(array, 'int32')); a = array; diff --git a/matlab/generated/+test_model/IntFixedArray.m b/matlab/generated/+test_model/IntFixedArray.m index b5f4ba89..11bdd16f 100644 --- a/matlab/generated/+test_model/IntFixedArray.m +++ b/matlab/generated/+test_model/IntFixedArray.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = IntFixedArray(array) assert(isa(array, 'int32')); a = array; diff --git a/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m b/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m index 1be042e5..68e2eaea 100644 --- a/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m +++ b/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef IntOrGenericRecordWithComputedFields < yardl.Union methods (Static) function res = Int(value) @@ -12,13 +14,13 @@ elem = test_model.IntOrGenericRecordWithComputedFields(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/IntRank2Array.m b/matlab/generated/+test_model/IntRank2Array.m index 478edfc6..10405a6c 100644 --- a/matlab/generated/+test_model/IntRank2Array.m +++ b/matlab/generated/+test_model/IntRank2Array.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = IntRank2Array(array) assert(isa(array, 'int32')); a = array; diff --git a/matlab/generated/+test_model/MapOrScalar.m b/matlab/generated/+test_model/MapOrScalar.m index b1b2f1bb..f5e562e5 100644 --- a/matlab/generated/+test_model/MapOrScalar.m +++ b/matlab/generated/+test_model/MapOrScalar.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MapOrScalar < yardl.Union methods (Static) function res = Map(value) @@ -12,13 +14,13 @@ elem = test_model.MapOrScalar(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/MapsReaderBase.m b/matlab/generated/+test_model/MapsReaderBase.m index 45f0ff60..ad34ca82 100644 --- a/matlab/generated/+test_model/MapsReaderBase.m +++ b/matlab/generated/+test_model/MapsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef MapsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/MapsWriterBase.m b/matlab/generated/+test_model/MapsWriterBase.m index 2591b4a4..ec72c8d6 100644 --- a/matlab/generated/+test_model/MapsWriterBase.m +++ b/matlab/generated/+test_model/MapsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol Maps classdef (Abstract) MapsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/MyTuple.m b/matlab/generated/+test_model/MyTuple.m index fb10e3d2..be3580d9 100644 --- a/matlab/generated/+test_model/MyTuple.m +++ b/matlab/generated/+test_model/MyTuple.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function c = MyTuple(varargin) c = basic_types.MyTuple(varargin{:}); end diff --git a/matlab/generated/+test_model/NDArraysReaderBase.m b/matlab/generated/+test_model/NDArraysReaderBase.m index 9ef0d452..976c6378 100644 --- a/matlab/generated/+test_model/NDArraysReaderBase.m +++ b/matlab/generated/+test_model/NDArraysReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef NDArraysReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m b/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m index 0b4e0768..7e6c206b 100644 --- a/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m +++ b/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef NDArraysSingleDimensionReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m b/matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m index 3493a64c..878c6efa 100644 --- a/matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m +++ b/matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol NDArraysSingleDimension classdef (Abstract) NDArraysSingleDimensionWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/NDArraysWriterBase.m b/matlab/generated/+test_model/NDArraysWriterBase.m index 3b787438..54248412 100644 --- a/matlab/generated/+test_model/NDArraysWriterBase.m +++ b/matlab/generated/+test_model/NDArraysWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol NDArrays classdef (Abstract) NDArraysWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/NamedFixedNDArray.m b/matlab/generated/+test_model/NamedFixedNDArray.m index f28367d9..12b7a391 100644 --- a/matlab/generated/+test_model/NamedFixedNDArray.m +++ b/matlab/generated/+test_model/NamedFixedNDArray.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = NamedFixedNDArray(array) assert(isa(array, 'int32')); a = array; diff --git a/matlab/generated/+test_model/NamedNDArray.m b/matlab/generated/+test_model/NamedNDArray.m index 130841da..8976c715 100644 --- a/matlab/generated/+test_model/NamedNDArray.m +++ b/matlab/generated/+test_model/NamedNDArray.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = NamedNDArray(array) assert(isa(array, 'int32')); a = array; diff --git a/matlab/generated/+test_model/NestedRecordsReaderBase.m b/matlab/generated/+test_model/NestedRecordsReaderBase.m index b2dbb8c1..1d0347c0 100644 --- a/matlab/generated/+test_model/NestedRecordsReaderBase.m +++ b/matlab/generated/+test_model/NestedRecordsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef NestedRecordsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/NestedRecordsWriterBase.m b/matlab/generated/+test_model/NestedRecordsWriterBase.m index c5e354ac..3deb5535 100644 --- a/matlab/generated/+test_model/NestedRecordsWriterBase.m +++ b/matlab/generated/+test_model/NestedRecordsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol NestedRecords classdef (Abstract) NestedRecordsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/OptionalVectorsReaderBase.m b/matlab/generated/+test_model/OptionalVectorsReaderBase.m index da037aa8..791a5fda 100644 --- a/matlab/generated/+test_model/OptionalVectorsReaderBase.m +++ b/matlab/generated/+test_model/OptionalVectorsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef OptionalVectorsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/OptionalVectorsWriterBase.m b/matlab/generated/+test_model/OptionalVectorsWriterBase.m index d3097346..64bc1f6d 100644 --- a/matlab/generated/+test_model/OptionalVectorsWriterBase.m +++ b/matlab/generated/+test_model/OptionalVectorsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol OptionalVectors classdef (Abstract) OptionalVectorsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m b/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m index cf8b641e..39782e90 100644 --- a/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m +++ b/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef ProtocolWithComputedFieldsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m b/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m index 04b64ea2..85b14a03 100644 --- a/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m +++ b/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol ProtocolWithComputedFields classdef (Abstract) ProtocolWithComputedFieldsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m b/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m index 9be3cf39..d93e2ab0 100644 --- a/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m +++ b/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef ProtocolWithKeywordStepsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m b/matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m index c16e05a2..df87b91f 100644 --- a/matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m +++ b/matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol ProtocolWithKeywordSteps classdef (Abstract) ProtocolWithKeywordStepsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/RecordContainingGenericRecords.m b/matlab/generated/+test_model/RecordContainingGenericRecords.m index 0d4f971f..ae916c49 100644 --- a/matlab/generated/+test_model/RecordContainingGenericRecords.m +++ b/matlab/generated/+test_model/RecordContainingGenericRecords.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordContainingGenericRecords < handle properties g1 diff --git a/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m b/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m index b0d60b92..63a2849a 100644 --- a/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m +++ b/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordContainingNestedGenericRecords < handle properties f1 @@ -44,13 +46,13 @@ elem = test_model.RecordContainingNestedGenericRecords(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordNotUsedInProtocol.m b/matlab/generated/+test_model/RecordNotUsedInProtocol.m index ba84900c..d69e7e1d 100644 --- a/matlab/generated/+test_model/RecordNotUsedInProtocol.m +++ b/matlab/generated/+test_model/RecordNotUsedInProtocol.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordNotUsedInProtocol < handle properties u1 @@ -32,13 +34,13 @@ elem = test_model.RecordNotUsedInProtocol(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithAliasedGenerics.m b/matlab/generated/+test_model/RecordWithAliasedGenerics.m index f5e1e088..8ca7aae7 100644 --- a/matlab/generated/+test_model/RecordWithAliasedGenerics.m +++ b/matlab/generated/+test_model/RecordWithAliasedGenerics.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithAliasedGenerics < handle properties my_strings @@ -32,13 +34,13 @@ elem = test_model.RecordWithAliasedGenerics(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m index 13365370..de9f82b2 100644 --- a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m +++ b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithAliasedOptionalGenericField < handle properties v @@ -28,13 +30,13 @@ elem = test_model.RecordWithAliasedOptionalGenericField(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m index 32854f2a..4c29edd0 100644 --- a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m +++ b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithAliasedOptionalGenericUnionField < handle properties v @@ -28,13 +30,13 @@ elem = test_model.RecordWithAliasedOptionalGenericUnionField(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithArrays.m b/matlab/generated/+test_model/RecordWithArrays.m index bf3f1a91..ca885162 100644 --- a/matlab/generated/+test_model/RecordWithArrays.m +++ b/matlab/generated/+test_model/RecordWithArrays.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithArrays < handle properties default_array @@ -60,13 +62,13 @@ elem = test_model.RecordWithArrays(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m b/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m index 36ab0413..77c9e830 100644 --- a/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m +++ b/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithArraysSimpleSyntax < handle properties default_array @@ -60,13 +62,13 @@ elem = test_model.RecordWithArraysSimpleSyntax(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithComputedFields.m b/matlab/generated/+test_model/RecordWithComputedFields.m index 64153d68..50bf9752 100644 --- a/matlab/generated/+test_model/RecordWithComputedFields.m +++ b/matlab/generated/+test_model/RecordWithComputedFields.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithComputedFields < handle properties array_field @@ -573,13 +575,13 @@ elem = test_model.RecordWithComputedFields(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithDynamicNDArrays.m b/matlab/generated/+test_model/RecordWithDynamicNDArrays.m index f0bafd98..af574e89 100644 --- a/matlab/generated/+test_model/RecordWithDynamicNDArrays.m +++ b/matlab/generated/+test_model/RecordWithDynamicNDArrays.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithDynamicNDArrays < handle properties ints @@ -36,13 +38,13 @@ elem = test_model.RecordWithDynamicNDArrays(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithEnums.m b/matlab/generated/+test_model/RecordWithEnums.m index 39484dc9..fd3df750 100644 --- a/matlab/generated/+test_model/RecordWithEnums.m +++ b/matlab/generated/+test_model/RecordWithEnums.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithEnums < handle properties enum @@ -36,13 +38,13 @@ elem = test_model.RecordWithEnums(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithFixedArrays.m b/matlab/generated/+test_model/RecordWithFixedArrays.m index 6c4323cf..2ba602b3 100644 --- a/matlab/generated/+test_model/RecordWithFixedArrays.m +++ b/matlab/generated/+test_model/RecordWithFixedArrays.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithFixedArrays < handle properties ints @@ -36,13 +38,13 @@ elem = test_model.RecordWithFixedArrays(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithFixedCollections.m b/matlab/generated/+test_model/RecordWithFixedCollections.m index 31a626cc..48099eb4 100644 --- a/matlab/generated/+test_model/RecordWithFixedCollections.m +++ b/matlab/generated/+test_model/RecordWithFixedCollections.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithFixedCollections < handle properties fixed_vector @@ -32,13 +34,13 @@ elem = test_model.RecordWithFixedCollections(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithFixedVectors.m b/matlab/generated/+test_model/RecordWithFixedVectors.m index 077f7ff5..08a21af1 100644 --- a/matlab/generated/+test_model/RecordWithFixedVectors.m +++ b/matlab/generated/+test_model/RecordWithFixedVectors.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithFixedVectors < handle properties fixed_int_vector @@ -36,13 +38,13 @@ elem = test_model.RecordWithFixedVectors(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithGenericArrays.m b/matlab/generated/+test_model/RecordWithGenericArrays.m index 868b0685..80c578d3 100644 --- a/matlab/generated/+test_model/RecordWithGenericArrays.m +++ b/matlab/generated/+test_model/RecordWithGenericArrays.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithGenericArrays < handle properties nd diff --git a/matlab/generated/+test_model/RecordWithGenericFixedVectors.m b/matlab/generated/+test_model/RecordWithGenericFixedVectors.m index 96c7f03d..73475e12 100644 --- a/matlab/generated/+test_model/RecordWithGenericFixedVectors.m +++ b/matlab/generated/+test_model/RecordWithGenericFixedVectors.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithGenericFixedVectors < handle properties fv diff --git a/matlab/generated/+test_model/RecordWithGenericMaps.m b/matlab/generated/+test_model/RecordWithGenericMaps.m index eb4f121e..52793233 100644 --- a/matlab/generated/+test_model/RecordWithGenericMaps.m +++ b/matlab/generated/+test_model/RecordWithGenericMaps.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithGenericMaps < handle properties m @@ -32,13 +34,13 @@ elem = test_model.RecordWithGenericMaps(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m b/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m index 0b3c81de..7ee39136 100644 --- a/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m +++ b/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithGenericVectorOfRecords < handle properties v diff --git a/matlab/generated/+test_model/RecordWithGenericVectors.m b/matlab/generated/+test_model/RecordWithGenericVectors.m index 69000c0d..99b6e21a 100644 --- a/matlab/generated/+test_model/RecordWithGenericVectors.m +++ b/matlab/generated/+test_model/RecordWithGenericVectors.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithGenericVectors < handle properties v diff --git a/matlab/generated/+test_model/RecordWithKeywordFields.m b/matlab/generated/+test_model/RecordWithKeywordFields.m index f10d07e1..a0fdf907 100644 --- a/matlab/generated/+test_model/RecordWithKeywordFields.m +++ b/matlab/generated/+test_model/RecordWithKeywordFields.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithKeywordFields < handle properties int diff --git a/matlab/generated/+test_model/RecordWithNDArrays.m b/matlab/generated/+test_model/RecordWithNDArrays.m index 25e5e63e..0ddc15f8 100644 --- a/matlab/generated/+test_model/RecordWithNDArrays.m +++ b/matlab/generated/+test_model/RecordWithNDArrays.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithNDArrays < handle properties ints @@ -36,13 +38,13 @@ elem = test_model.RecordWithNDArrays(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m b/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m index 763070dd..ab973a92 100644 --- a/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m +++ b/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithNDArraysSingleDimension < handle properties ints @@ -36,13 +38,13 @@ elem = test_model.RecordWithNDArraysSingleDimension(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithNamedFixedArrays.m b/matlab/generated/+test_model/RecordWithNamedFixedArrays.m index 7e0ffc5f..929f09ce 100644 --- a/matlab/generated/+test_model/RecordWithNamedFixedArrays.m +++ b/matlab/generated/+test_model/RecordWithNamedFixedArrays.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithNamedFixedArrays < handle properties ints @@ -36,13 +38,13 @@ elem = test_model.RecordWithNamedFixedArrays(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithOptionalFields.m b/matlab/generated/+test_model/RecordWithOptionalFields.m index 55938794..e53b3320 100644 --- a/matlab/generated/+test_model/RecordWithOptionalFields.m +++ b/matlab/generated/+test_model/RecordWithOptionalFields.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithOptionalFields < handle properties optional_int @@ -36,13 +38,13 @@ elem = test_model.RecordWithOptionalFields(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithOptionalGenericField.m b/matlab/generated/+test_model/RecordWithOptionalGenericField.m index f6c9a443..c4b897fb 100644 --- a/matlab/generated/+test_model/RecordWithOptionalGenericField.m +++ b/matlab/generated/+test_model/RecordWithOptionalGenericField.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithOptionalGenericField < handle properties v @@ -28,13 +30,13 @@ elem = test_model.RecordWithOptionalGenericField(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m b/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m index 8ce030b8..409d2183 100644 --- a/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m +++ b/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithOptionalGenericUnionField < handle properties v @@ -28,13 +30,13 @@ elem = test_model.RecordWithOptionalGenericUnionField(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithOptionalVector.m b/matlab/generated/+test_model/RecordWithOptionalVector.m index aa6babfd..c735ce2d 100644 --- a/matlab/generated/+test_model/RecordWithOptionalVector.m +++ b/matlab/generated/+test_model/RecordWithOptionalVector.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithOptionalVector < handle properties optional_vector @@ -28,13 +30,13 @@ elem = test_model.RecordWithOptionalVector(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithPrimitiveAliases.m b/matlab/generated/+test_model/RecordWithPrimitiveAliases.m index 99194400..89d6b9c5 100644 --- a/matlab/generated/+test_model/RecordWithPrimitiveAliases.m +++ b/matlab/generated/+test_model/RecordWithPrimitiveAliases.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithPrimitiveAliases < handle properties byte_field @@ -60,13 +62,13 @@ elem = test_model.RecordWithPrimitiveAliases(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithPrimitives.m b/matlab/generated/+test_model/RecordWithPrimitives.m index 31486ec8..0b450113 100644 --- a/matlab/generated/+test_model/RecordWithPrimitives.m +++ b/matlab/generated/+test_model/RecordWithPrimitives.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithPrimitives < handle properties bool_field @@ -92,13 +94,13 @@ elem = test_model.RecordWithPrimitives(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithStrings.m b/matlab/generated/+test_model/RecordWithStrings.m index 74bcdb34..b3212991 100644 --- a/matlab/generated/+test_model/RecordWithStrings.m +++ b/matlab/generated/+test_model/RecordWithStrings.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithStrings < handle properties a @@ -32,13 +34,13 @@ elem = test_model.RecordWithStrings(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithUnionsOfContainers.m b/matlab/generated/+test_model/RecordWithUnionsOfContainers.m index 63358de5..f07f452b 100644 --- a/matlab/generated/+test_model/RecordWithUnionsOfContainers.m +++ b/matlab/generated/+test_model/RecordWithUnionsOfContainers.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithUnionsOfContainers < handle properties map_or_scalar @@ -36,13 +38,13 @@ elem = test_model.RecordWithUnionsOfContainers(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithVectorOfTimes.m b/matlab/generated/+test_model/RecordWithVectorOfTimes.m index b9a6e4a0..ba8ee3e0 100644 --- a/matlab/generated/+test_model/RecordWithVectorOfTimes.m +++ b/matlab/generated/+test_model/RecordWithVectorOfTimes.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithVectorOfTimes < handle properties times @@ -28,13 +30,13 @@ elem = test_model.RecordWithVectorOfTimes(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithVectors.m b/matlab/generated/+test_model/RecordWithVectors.m index edcd7aab..d8c06d27 100644 --- a/matlab/generated/+test_model/RecordWithVectors.m +++ b/matlab/generated/+test_model/RecordWithVectors.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithVectors < handle properties default_vector @@ -36,13 +38,13 @@ elem = test_model.RecordWithVectors(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithVlenCollections.m b/matlab/generated/+test_model/RecordWithVlenCollections.m index b4561706..e346a3d7 100644 --- a/matlab/generated/+test_model/RecordWithVlenCollections.m +++ b/matlab/generated/+test_model/RecordWithVlenCollections.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithVlenCollections < handle properties vector @@ -32,13 +34,13 @@ elem = test_model.RecordWithVlenCollections(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithVlens.m b/matlab/generated/+test_model/RecordWithVlens.m index 32f50798..35c333d8 100644 --- a/matlab/generated/+test_model/RecordWithVlens.m +++ b/matlab/generated/+test_model/RecordWithVlens.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef RecordWithVlens < handle properties a @@ -36,13 +38,13 @@ elem = test_model.RecordWithVlens(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/RecordWithVlensFixedArray.m b/matlab/generated/+test_model/RecordWithVlensFixedArray.m index d24b0f37..b63350e1 100644 --- a/matlab/generated/+test_model/RecordWithVlensFixedArray.m +++ b/matlab/generated/+test_model/RecordWithVlensFixedArray.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = RecordWithVlensFixedArray(array) assert(isa(array, 'test_model.RecordWithVlens')); a = array; diff --git a/matlab/generated/+test_model/ScalarOptionalsReaderBase.m b/matlab/generated/+test_model/ScalarOptionalsReaderBase.m index 94ef3792..1747919a 100644 --- a/matlab/generated/+test_model/ScalarOptionalsReaderBase.m +++ b/matlab/generated/+test_model/ScalarOptionalsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef ScalarOptionalsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/ScalarOptionalsWriterBase.m b/matlab/generated/+test_model/ScalarOptionalsWriterBase.m index 7d86664c..d4c7b4ef 100644 --- a/matlab/generated/+test_model/ScalarOptionalsWriterBase.m +++ b/matlab/generated/+test_model/ScalarOptionalsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol ScalarOptionals classdef (Abstract) ScalarOptionalsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/ScalarsReaderBase.m b/matlab/generated/+test_model/ScalarsReaderBase.m index 41a92464..311c2c54 100644 --- a/matlab/generated/+test_model/ScalarsReaderBase.m +++ b/matlab/generated/+test_model/ScalarsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef ScalarsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/ScalarsWriterBase.m b/matlab/generated/+test_model/ScalarsWriterBase.m index dd6ab732..01145216 100644 --- a/matlab/generated/+test_model/ScalarsWriterBase.m +++ b/matlab/generated/+test_model/ScalarsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol Scalars classdef (Abstract) ScalarsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/SimpleAcquisition.m b/matlab/generated/+test_model/SimpleAcquisition.m index a0b238d8..4487a13b 100644 --- a/matlab/generated/+test_model/SimpleAcquisition.m +++ b/matlab/generated/+test_model/SimpleAcquisition.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SimpleAcquisition < handle properties flags @@ -40,13 +42,13 @@ elem = test_model.SimpleAcquisition(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/SimpleEncodingCounters.m b/matlab/generated/+test_model/SimpleEncodingCounters.m index 8172a83e..da69c5a5 100644 --- a/matlab/generated/+test_model/SimpleEncodingCounters.m +++ b/matlab/generated/+test_model/SimpleEncodingCounters.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SimpleEncodingCounters < handle properties e1 @@ -40,13 +42,13 @@ elem = test_model.SimpleEncodingCounters(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/SimpleGenericsReaderBase.m b/matlab/generated/+test_model/SimpleGenericsReaderBase.m index 077a49a7..a5a79633 100644 --- a/matlab/generated/+test_model/SimpleGenericsReaderBase.m +++ b/matlab/generated/+test_model/SimpleGenericsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SimpleGenericsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/SimpleGenericsWriterBase.m b/matlab/generated/+test_model/SimpleGenericsWriterBase.m index 14cbb1e4..aa7a8610 100644 --- a/matlab/generated/+test_model/SimpleGenericsWriterBase.m +++ b/matlab/generated/+test_model/SimpleGenericsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol SimpleGenerics classdef (Abstract) SimpleGenericsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/SimpleRecord.m b/matlab/generated/+test_model/SimpleRecord.m index 2448ba33..e70dd649 100644 --- a/matlab/generated/+test_model/SimpleRecord.m +++ b/matlab/generated/+test_model/SimpleRecord.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SimpleRecord < handle properties x @@ -36,13 +38,13 @@ elem = test_model.SimpleRecord(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/SimpleRecordFixedArray.m b/matlab/generated/+test_model/SimpleRecordFixedArray.m index 9afc355e..4ebc0649 100644 --- a/matlab/generated/+test_model/SimpleRecordFixedArray.m +++ b/matlab/generated/+test_model/SimpleRecordFixedArray.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = SimpleRecordFixedArray(array) assert(isa(array, 'test_model.SimpleRecord')); a = array; diff --git a/matlab/generated/+test_model/SizeBasedEnum.m b/matlab/generated/+test_model/SizeBasedEnum.m index 518107dd..37fd5381 100644 --- a/matlab/generated/+test_model/SizeBasedEnum.m +++ b/matlab/generated/+test_model/SizeBasedEnum.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SizeBasedEnum < uint64 methods (Static) function e = A @@ -14,13 +16,13 @@ elem = test_model.SizeBasedEnum(0); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/SmallBenchmarkRecord.m b/matlab/generated/+test_model/SmallBenchmarkRecord.m index de30e923..6a9b9566 100644 --- a/matlab/generated/+test_model/SmallBenchmarkRecord.m +++ b/matlab/generated/+test_model/SmallBenchmarkRecord.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SmallBenchmarkRecord < handle properties a @@ -36,13 +38,13 @@ elem = test_model.SmallBenchmarkRecord(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/StateTestReaderBase.m b/matlab/generated/+test_model/StateTestReaderBase.m index 2972f281..b3f53ed5 100644 --- a/matlab/generated/+test_model/StateTestReaderBase.m +++ b/matlab/generated/+test_model/StateTestReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StateTestReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/StateTestWriterBase.m b/matlab/generated/+test_model/StateTestWriterBase.m index 144ff332..d5d0f8a4 100644 --- a/matlab/generated/+test_model/StateTestWriterBase.m +++ b/matlab/generated/+test_model/StateTestWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol StateTest classdef (Abstract) StateTestWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m b/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m index c24e3fc8..b5fe99ec 100644 --- a/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m +++ b/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StreamsOfAliasedUnionsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m b/matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m index 73524678..77592477 100644 --- a/matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m +++ b/matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol StreamsOfAliasedUnions classdef (Abstract) StreamsOfAliasedUnionsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m b/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m index bffeb4d2..7b7bb4f1 100644 --- a/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m +++ b/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StreamsOfUnionsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/StreamsOfUnionsWriterBase.m b/matlab/generated/+test_model/StreamsOfUnionsWriterBase.m index fa4ff5e0..7988ed15 100644 --- a/matlab/generated/+test_model/StreamsOfUnionsWriterBase.m +++ b/matlab/generated/+test_model/StreamsOfUnionsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol StreamsOfUnions classdef (Abstract) StreamsOfUnionsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/StreamsReaderBase.m b/matlab/generated/+test_model/StreamsReaderBase.m index b95c04db..c46c778e 100644 --- a/matlab/generated/+test_model/StreamsReaderBase.m +++ b/matlab/generated/+test_model/StreamsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StreamsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/StreamsWriterBase.m b/matlab/generated/+test_model/StreamsWriterBase.m index f506db37..fdeb2f34 100644 --- a/matlab/generated/+test_model/StreamsWriterBase.m +++ b/matlab/generated/+test_model/StreamsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol Streams classdef (Abstract) StreamsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/StringOrInt32.m b/matlab/generated/+test_model/StringOrInt32.m index a90aa966..7b7d9726 100644 --- a/matlab/generated/+test_model/StringOrInt32.m +++ b/matlab/generated/+test_model/StringOrInt32.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StringOrInt32 < yardl.Union methods (Static) function res = String(value) @@ -12,13 +14,13 @@ elem = test_model.StringOrInt32(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/StringsReaderBase.m b/matlab/generated/+test_model/StringsReaderBase.m index 175ea208..fb4f16c7 100644 --- a/matlab/generated/+test_model/StringsReaderBase.m +++ b/matlab/generated/+test_model/StringsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef StringsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/StringsWriterBase.m b/matlab/generated/+test_model/StringsWriterBase.m index 79cf638b..d83c49ef 100644 --- a/matlab/generated/+test_model/StringsWriterBase.m +++ b/matlab/generated/+test_model/StringsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol Strings classdef (Abstract) StringsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m b/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m index ae2deacb..590e3825 100644 --- a/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m +++ b/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SubarraysInRecordsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/SubarraysInRecordsWriterBase.m b/matlab/generated/+test_model/SubarraysInRecordsWriterBase.m index bc87b372..08cca492 100644 --- a/matlab/generated/+test_model/SubarraysInRecordsWriterBase.m +++ b/matlab/generated/+test_model/SubarraysInRecordsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol SubarraysInRecords classdef (Abstract) SubarraysInRecordsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/SubarraysReaderBase.m b/matlab/generated/+test_model/SubarraysReaderBase.m index cfb47c0a..d0b46c64 100644 --- a/matlab/generated/+test_model/SubarraysReaderBase.m +++ b/matlab/generated/+test_model/SubarraysReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef SubarraysReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/SubarraysWriterBase.m b/matlab/generated/+test_model/SubarraysWriterBase.m index b8b723d7..2ec2cb0e 100644 --- a/matlab/generated/+test_model/SubarraysWriterBase.m +++ b/matlab/generated/+test_model/SubarraysWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol Subarrays classdef (Abstract) SubarraysWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/TextFormat.m b/matlab/generated/+test_model/TextFormat.m index 747cab58..60a46b9c 100644 --- a/matlab/generated/+test_model/TextFormat.m +++ b/matlab/generated/+test_model/TextFormat.m @@ -1,2 +1,4 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TextFormat < basic_types.TextFormat end diff --git a/matlab/generated/+test_model/TupleWithRecords.m b/matlab/generated/+test_model/TupleWithRecords.m index 5c6309dc..953d10e6 100644 --- a/matlab/generated/+test_model/TupleWithRecords.m +++ b/matlab/generated/+test_model/TupleWithRecords.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TupleWithRecords < handle properties a @@ -32,13 +34,13 @@ elem = test_model.TupleWithRecords(); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/UInt64Enum.m b/matlab/generated/+test_model/UInt64Enum.m index 7de335ff..7a002e59 100644 --- a/matlab/generated/+test_model/UInt64Enum.m +++ b/matlab/generated/+test_model/UInt64Enum.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef UInt64Enum < uint64 methods (Static) function e = A @@ -8,13 +10,13 @@ elem = test_model.UInt64Enum(0); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/matlab/generated/+test_model/UOrV.m b/matlab/generated/+test_model/UOrV.m index f00a8e24..131a6ba1 100644 --- a/matlab/generated/+test_model/UOrV.m +++ b/matlab/generated/+test_model/UOrV.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef UOrV < yardl.Union methods (Static) function res = U(value) @@ -12,13 +14,13 @@ elem = test_model.UOrV(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/UnionsReaderBase.m b/matlab/generated/+test_model/UnionsReaderBase.m index cb93a0a2..c6e1f878 100644 --- a/matlab/generated/+test_model/UnionsReaderBase.m +++ b/matlab/generated/+test_model/UnionsReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef UnionsReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/UnionsWriterBase.m b/matlab/generated/+test_model/UnionsWriterBase.m index 7355cd70..d334b128 100644 --- a/matlab/generated/+test_model/UnionsWriterBase.m +++ b/matlab/generated/+test_model/UnionsWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol Unions classdef (Abstract) UnionsWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+test_model/VectorOfGenericRecords.m b/matlab/generated/+test_model/VectorOfGenericRecords.m index 0e6b0804..d6e5265d 100644 --- a/matlab/generated/+test_model/VectorOfGenericRecords.m +++ b/matlab/generated/+test_model/VectorOfGenericRecords.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + function a = VectorOfGenericRecords(array) a = array; end diff --git a/matlab/generated/+test_model/VectorOrScalar.m b/matlab/generated/+test_model/VectorOrScalar.m index 73ce6ded..b6a5f80a 100644 --- a/matlab/generated/+test_model/VectorOrScalar.m +++ b/matlab/generated/+test_model/VectorOrScalar.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef VectorOrScalar < yardl.Union methods (Static) function res = Vector(value) @@ -12,13 +14,13 @@ elem = test_model.VectorOrScalar(0, yardl.None); if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return; + end + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end diff --git a/matlab/generated/+test_model/VlensReaderBase.m b/matlab/generated/+test_model/VlensReaderBase.m index 128b238d..19ced834 100644 --- a/matlab/generated/+test_model/VlensReaderBase.m +++ b/matlab/generated/+test_model/VlensReaderBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef VlensReaderBase < handle properties (Access=protected) state_ diff --git a/matlab/generated/+test_model/VlensWriterBase.m b/matlab/generated/+test_model/VlensWriterBase.m index 4f9cbc27..ff2ecf02 100644 --- a/matlab/generated/+test_model/VlensWriterBase.m +++ b/matlab/generated/+test_model/VlensWriterBase.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + % Abstract writer for protocol Vlens classdef (Abstract) VlensWriterBase < handle properties (Access=protected) diff --git a/matlab/generated/+tuples/+binary/TupleSerializer.m b/matlab/generated/+tuples/+binary/TupleSerializer.m index 101d65b8..229c17ee 100644 --- a/matlab/generated/+tuples/+binary/TupleSerializer.m +++ b/matlab/generated/+tuples/+binary/TupleSerializer.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef TupleSerializer < yardl.binary.RecordSerializer methods function obj = TupleSerializer(t1_serializer, t2_serializer) diff --git a/matlab/generated/+tuples/Tuple.m b/matlab/generated/+tuples/Tuple.m index e94a05ce..411ae9ec 100644 --- a/matlab/generated/+tuples/Tuple.m +++ b/matlab/generated/+tuples/Tuple.m @@ -1,3 +1,5 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + classdef Tuple < handle properties v1 diff --git a/matlab/tests/GeneratedTypesTest.m b/matlab/tests/GeneratedTypesTest.m index 5f60e621..19c0f8c0 100644 --- a/matlab/tests/GeneratedTypesTest.m +++ b/matlab/tests/GeneratedTypesTest.m @@ -1,6 +1,8 @@ classdef GeneratedTypesTest < matlab.unittest.TestCase methods (Test) + % TODO: Add test for yardl.allocate for "each" kind of type + function testDefaultRecordWithPrimitives(testCase) r = test_model.RecordWithPrimitives(); diff --git a/matlab/tests/RoundTripTest.m b/matlab/tests/RoundTripTest.m index 47663008..5caf7f6d 100644 --- a/matlab/tests/RoundTripTest.m +++ b/matlab/tests/RoundTripTest.m @@ -248,7 +248,6 @@ function testDynamicNDArrays(testCase, format) end function testMaps(testCase, format) - % d = containers.Map('KeyType', 'char', 'ValueType', 'int32'); d = dictionary(); d("a") = int32(1); d("b") = 2; @@ -257,18 +256,8 @@ function testMaps(testCase, format) w = create_validating_writer(testCase, format, 'Maps'); w.write_string_to_int(d); - % TODO: Need to use R2022b 'dictionary' to properly build the map in MapSerializer.read - % i.e. an "empty" containers.Map() has a KeyType of 'char' - % w.write_int_to_string(containers.Map(int32([1, 2, 3]), ["a", "b", "c"])); w.write_int_to_string(dictionary(int32([1, 2, 3]), ["a", "b", "c"])); - % TODO: Need to use R2022b `dictionary` to store objects as values... - % w.write_string_to_union(... - % containers.Map(... - % ["a", "b"], ... - % [test_model.StringOrInt32.Int32(1), test_model.StringOrInt32.String("2")] ... - % ) ... - % ); w.write_string_to_union(... dictionary(... ["a", "b"], ... @@ -332,9 +321,6 @@ function testFlags(testCase, format) end function testSimpleStreams(testCase, format) - % TODO: Need to fix Stream read/write of multidimensional arrays (see write_fixed_vector) - testCase.assumeFail(); - w = create_validating_writer(testCase, format, 'Streams'); % TODO: MockWriter can't yet handle multiple stream write calls (the result of read is always the full concatenated stream) @@ -349,9 +335,9 @@ function testSimpleStreams(testCase, format) test_model.RecordWithOptionalVector(int32(1:10)) ... ]); w.write_fixed_vector(... - transpose([... + transpose(int32([... [1, 2, 3]; [1, 2, 3]; [1, 2, 3]; [1, 2, 3]; - ])... + ]))... ); w.close(); @@ -418,9 +404,6 @@ function testSimpleGenerics(testCase, format) end function testAdvancedGenerics(testCase, format) - % TODO: Fix NDArraySerializers for nested NDArrays - testCase.assumeFail(); - w = create_validating_writer(testCase, format, 'AdvancedGenerics'); i1 = single([[3, 4, 5]; [6, 7, 8]]); @@ -428,11 +411,15 @@ function testAdvancedGenerics(testCase, format) i3 = single([[300, 400, 500]; [600, 700, 800]]); i4 = single([[3000, 4000, 5000]; [6000, 7000, 8000]]); - % TODO: How would I declare it with zeros first, then fill it with img_img_array[:] = ... ? e.g. (in Python) - img_img_array = i1; - img_img_array(:, :, 2) = i2; - img_img_array(:, :, 3) = i3; - img_img_array(:, :, 4) = i4; + % img_img_array = zeros([size(i1) 2 2], 'single'); + % img_img_array(:, :, 1, 1) = i1; + % img_img_array(:, :, 1, 2) = i2; + % img_img_array(:, :, 2, 1) = i3; + % img_img_array(:, :, 2, 2) = i4; + img_img_array{1, 1} = i1; + img_img_array{1, 2} = i2; + img_img_array{2, 1} = i3; + img_img_array{2, 2} = i4; w.write_float_image_image(img_img_array); diff --git a/matlab/tests/SerializerShapeTest.m b/matlab/tests/SerializerShapeTest.m new file mode 100644 index 00000000..c9433b28 --- /dev/null +++ b/matlab/tests/SerializerShapeTest.m @@ -0,0 +1,104 @@ +classdef SerializerShapeTest < matlab.unittest.TestCase + methods (Test) + + function testFixedVectorShape(testCase) + fvs = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 42); + testCase.verifyEqual(fvs.getShape(), [1, 42]); + + fvs = yardl.binary.FixedVectorSerializer(fvs, 11); + testCase.verifyEqual(fvs.getShape(), [42, 11]); + + fvs = yardl.binary.FixedVectorSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), 13); + testCase.verifyEqual(fvs.getShape(), [1, 13]); + + fvs = yardl.binary.FixedVectorSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 4]), 5); + testCase.verifyEqual(fvs.getShape(), [3, 4, 5]); + + fvs = yardl.binary.FixedVectorSerializer(yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2), 6); + testCase.verifyEqual(fvs.getShape(), [1, 6]); + + fvs = yardl.binary.FixedVectorSerializer(yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer), 7); + testCase.verifyEqual(fvs.getShape(), [1, 7]); + end + + function testVectorShape(testCase) + vs = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); + testCase.verifyEqual(vs.getShape(), []); + + vs = yardl.binary.VectorSerializer(vs); + testCase.verifyEqual(vs.getShape(), []); + + vs = yardl.binary.VectorSerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 42)); + testCase.verifyEqual(vs.getShape(), []); + + fvs = yardl.binary.VectorSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 4])); + testCase.verifyEqual(fvs.getShape(), []); + + fvs = yardl.binary.VectorSerializer(yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2)); + testCase.verifyEqual(fvs.getShape(), []); + + fvs = yardl.binary.VectorSerializer(yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer)); + testCase.verifyEqual(fvs.getShape(), []); + end + + function testFixedNDArrayShape(testCase) + fas = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 4]); + testCase.verifyEqual(fas.getShape(), [3, 4]); + + fas = yardl.binary.FixedNDArraySerializer(fas, [5, 6]); + testCase.verifyEqual(fas.getShape(), [3, 4, 5, 6]); + + fas = yardl.binary.FixedNDArraySerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), [7, 8]); + testCase.verifyEqual(fas.getShape(), [7, 8]); + + fas = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 42), [7, 8]); + testCase.verifyEqual(fas.getShape(), [42, 7, 8]); + + fas = yardl.binary.FixedNDArraySerializer(yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2), [7, 8]); + testCase.verifyEqual(fas.getShape(), [7, 8]); + + fas = yardl.binary.FixedNDArraySerializer(yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer), [7, 8]); + testCase.verifyEqual(fas.getShape(), [7, 8]); + end + + function testNDArrayShape(testCase) + nas = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + testCase.verifyEqual(nas.getShape(), []); + + nas = yardl.binary.NDArraySerializer(nas, 3); + testCase.verifyEqual(nas.getShape(), []); + + nas = yardl.binary.NDArraySerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), 2); + testCase.verifyEqual(nas.getShape(), []); + + nas = yardl.binary.NDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 42), 2); + testCase.verifyEqual(nas.getShape(), []); + + nas = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [5, 6]), 2); + testCase.verifyEqual(nas.getShape(), []); + + nas = yardl.binary.NDArraySerializer(yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer), 2); + testCase.verifyEqual(nas.getShape(), []); + end + + function testDynamicNDArrayShape(testCase) + das = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); + testCase.verifyEqual(das.getShape(), []); + + das = yardl.binary.DynamicNDArraySerializer(das); + testCase.verifyEqual(das.getShape(), []); + + das = yardl.binary.DynamicNDArraySerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer)); + testCase.verifyEqual(das.getShape(), []); + + das = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 42)); + testCase.verifyEqual(das.getShape(), []); + + das = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [5, 6])); + testCase.verifyEqual(das.getShape(), []); + + das = yardl.binary.DynamicNDArraySerializer(yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2)); + testCase.verifyEqual(das.getShape(), []); + end + end +end diff --git a/matlab/tests/YardlTypesTest.m b/matlab/tests/YardlTypesTest.m index 74661007..0f73d1e2 100644 --- a/matlab/tests/YardlTypesTest.m +++ b/matlab/tests/YardlTypesTest.m @@ -2,6 +2,8 @@ methods (Test) + % TODO: Add test for yardl.allocate for "each" kind of type + function testDateTimeFromValidDatetime(testCase) dt = yardl.DateTime.from_datetime(datetime(2020, 2, 29, 12, 22, 44, .111222)); testCase.verifyEqual(dt.value(), int64(1582978964000111222)); diff --git a/matlab/tests/run.m b/matlab/tests/run.m index 2eb4e863..1385ea99 100644 --- a/matlab/tests/run.m +++ b/matlab/tests/run.m @@ -8,4 +8,6 @@ run(EqualityTest); run(ComputedFieldsTest); +run(SerializerShapeTest); + run(RoundTripTest); diff --git a/tooling/internal/matlab/binary/binary.go b/tooling/internal/matlab/binary/binary.go index 88ad2101..1c450847 100644 --- a/tooling/internal/matlab/binary/binary.go +++ b/tooling/internal/matlab/binary/binary.go @@ -38,11 +38,11 @@ func writeProtocols(fw *common.MatlabFileWriter, ns *dsl.Namespace) error { func writeProtocolWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, ns *dsl.Namespace) error { return fw.WriteFile(BinaryWriterName(p), func(w *formatting.IndentedWriter) { - common.WriteComment(w, fmt.Sprintf("Binary writer for the %s protocol", p.Name)) - common.WriteComment(w, p.Comment) abstractWriterName := fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(p.Namespace), common.AbstractWriterName(p)) fmt.Fprintf(w, "classdef %s < yardl.binary.BinaryProtocolWriter & %s\n", BinaryWriterName(p), abstractWriterName) common.WriteBlockBody(w, func() { + common.WriteComment(w, fmt.Sprintf("Binary writer for the %s protocol", p.Name)) + common.WriteComment(w, p.Comment) w.WriteStringln("methods") common.WriteBlockBody(w, func() { @@ -73,11 +73,11 @@ func writeProtocolWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, func writeProtocolReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, ns *dsl.Namespace) error { return fw.WriteFile(BinaryReaderName(p), func(w *formatting.IndentedWriter) { - common.WriteComment(w, fmt.Sprintf("Binary reader for the %s protocol", p.Name)) - common.WriteComment(w, p.Comment) abstractReaderName := fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(p.Namespace), common.AbstractReaderName(p)) fmt.Fprintf(w, "classdef %s < yardl.binary.BinaryProtocolReader & %s\n", BinaryReaderName(p), abstractReaderName) common.WriteBlockBody(w, func() { + common.WriteComment(w, fmt.Sprintf("Binary reader for the %s protocol", p.Name)) + common.WriteComment(w, p.Comment) w.WriteStringln("methods") common.WriteBlockBody(w, func() { diff --git a/tooling/internal/matlab/common/common.go b/tooling/internal/matlab/common/common.go index 923a055e..81393e30 100644 --- a/tooling/internal/matlab/common/common.go +++ b/tooling/internal/matlab/common/common.go @@ -198,8 +198,8 @@ func ProtocolReadImplMethodName(s *dsl.ProtocolStep) string { } func WriteGeneratedFileHeader(w *formatting.IndentedWriter) { - // WriteComment(w, "This file was generated by the \"yardl\" tool. DO NOT EDIT.") - // w.WriteStringln("") + WriteComment(w, "This file was generated by the \"yardl\" tool. DO NOT EDIT.") + w.WriteStringln("") } type MatlabFileWriter struct { diff --git a/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m b/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m index 13739711..5d4837fc 100755 --- a/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m +++ b/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m @@ -1,37 +1,37 @@ -classdef BinaryProtocolReader < handle - - properties (Access=protected) - stream_ - end - - methods - function obj = BinaryProtocolReader(input, expected_schema) - obj.stream_ = yardl.binary.CodedInputStream(input); - magic_bytes = obj.stream_.read(length(yardl.binary.MAGIC_BYTES)); - if magic_bytes ~= yardl.binary.MAGIC_BYTES - throw(yardl.binary.Exception("Invalid magic bytes")); - end - - version = read_fixed_int32(obj.stream_); - if version ~= yardl.binary.CURRENT_BINARY_FORMAT_VERSION - throw(yardl.binary.Exception("Invalid binary format version")); - end - - s = yardl.binary.StringSerializer(); - schema = s.read(obj.stream_); - if ~isempty(expected_schema) & schema ~= expected_schema - throw(yardl.binary.Exception("Invalid schema")); - end - end - end - - methods (Access=protected) - function close_(obj) - obj.stream_.close(); - end - end -end - -function res = read_fixed_int32(stream) - res = typecast(stream.read(4), "int32"); -end +classdef BinaryProtocolReader < handle + + properties (Access=protected) + stream_ + end + + methods + function obj = BinaryProtocolReader(input, expected_schema) + obj.stream_ = yardl.binary.CodedInputStream(input); + magic_bytes = obj.stream_.read(length(yardl.binary.MAGIC_BYTES)); + if magic_bytes ~= yardl.binary.MAGIC_BYTES + throw(yardl.binary.Exception("Invalid magic bytes")); + end + + version = read_fixed_int32(obj.stream_); + if version ~= yardl.binary.CURRENT_BINARY_FORMAT_VERSION + throw(yardl.binary.Exception("Invalid binary format version")); + end + + s = yardl.binary.StringSerializer(); + schema = s.read(obj.stream_); + if ~isempty(expected_schema) & schema ~= expected_schema + throw(yardl.binary.Exception("Invalid schema")); + end + end + end + + methods (Access=protected) + function close_(obj) + obj.stream_.close(); + end + end +end + +function res = read_fixed_int32(stream) + res = typecast(stream.read(4), "int32"); +end diff --git a/tooling/internal/matlab/static_files/+binary/BinaryProtocolWriter.m b/tooling/internal/matlab/static_files/+binary/BinaryProtocolWriter.m index c833de3c..b584c58f 100755 --- a/tooling/internal/matlab/static_files/+binary/BinaryProtocolWriter.m +++ b/tooling/internal/matlab/static_files/+binary/BinaryProtocolWriter.m @@ -1,33 +1,33 @@ -classdef BinaryProtocolWriter < handle - - properties (Access=protected) - stream_ - end - - methods - function obj = BinaryProtocolWriter(output, schema) - obj.stream_ = yardl.binary.CodedOutputStream(output); - obj.stream_.write_bytes(yardl.binary.MAGIC_BYTES); - write_fixed_int32(obj.stream_, yardl.binary.CURRENT_BINARY_FORMAT_VERSION); - s = yardl.binary.StringSerializer(); - s.write(obj.stream_, schema); - end - end - - methods (Access=protected) - function end_stream_(obj) - obj.stream_.write_byte_no_check(0); - end - - function close_(obj) - obj.stream_.close(); - end - end -end - -function write_fixed_int32(stream, value) - assert(value >= intmin("int32")); - assert(value <= intmax("int32")); - value = int32(value); - stream.write(typecast(value, "uint8")); -end +classdef BinaryProtocolWriter < handle + + properties (Access=protected) + stream_ + end + + methods + function obj = BinaryProtocolWriter(output, schema) + obj.stream_ = yardl.binary.CodedOutputStream(output); + obj.stream_.write_bytes(yardl.binary.MAGIC_BYTES); + write_fixed_int32(obj.stream_, yardl.binary.CURRENT_BINARY_FORMAT_VERSION); + s = yardl.binary.StringSerializer(); + s.write(obj.stream_, schema); + end + end + + methods (Access=protected) + function end_stream_(obj) + obj.stream_.write_byte_no_check(0); + end + + function close_(obj) + obj.stream_.close(); + end + end +end + +function write_fixed_int32(stream, value) + assert(value >= intmin("int32")); + assert(value <= intmax("int32")); + value = int32(value); + stream.write(typecast(value, "uint8")); +end diff --git a/tooling/internal/matlab/static_files/+binary/BoolSerializer.m b/tooling/internal/matlab/static_files/+binary/BoolSerializer.m index e0f227bc..0d43a5b3 100755 --- a/tooling/internal/matlab/static_files/+binary/BoolSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/BoolSerializer.m @@ -1,18 +1,18 @@ -classdef BoolSerializer < yardl.binary.TypeSerializer - methods (Static) - function write( outstream, value) - assert(islogical(value)); - byte = cast(value, "uint8"); - outstream.write_bytes(byte); - end - - function res = read(instream) - byte = instream.read_byte(); - res = cast(byte, "logical"); - end - - function c = getClass() - c = 'logical'; - end - end -end +classdef BoolSerializer < yardl.binary.TypeSerializer + methods (Static) + function write( outstream, value) + assert(islogical(value)); + byte = cast(value, "uint8"); + outstream.write_bytes(byte); + end + + function res = read(instream) + byte = instream.read_byte(); + res = cast(byte, "logical"); + end + + function c = getClass() + c = 'logical'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/CURRENT_BINARY_FORMAT_VERSION.m b/tooling/internal/matlab/static_files/+binary/CURRENT_BINARY_FORMAT_VERSION.m index b0285967..c9286b0a 100755 --- a/tooling/internal/matlab/static_files/+binary/CURRENT_BINARY_FORMAT_VERSION.m +++ b/tooling/internal/matlab/static_files/+binary/CURRENT_BINARY_FORMAT_VERSION.m @@ -1,3 +1,3 @@ -function res = CURRENT_BINARY_FORMAT_VERSION - res = int32(1); -end \ No newline at end of file +function res = CURRENT_BINARY_FORMAT_VERSION + res = int32(1); +end diff --git a/tooling/internal/matlab/static_files/+binary/CodedInputStream.m b/tooling/internal/matlab/static_files/+binary/CodedInputStream.m index e82e9b2e..3ea1a643 100755 --- a/tooling/internal/matlab/static_files/+binary/CodedInputStream.m +++ b/tooling/internal/matlab/static_files/+binary/CodedInputStream.m @@ -1,64 +1,64 @@ -classdef CodedInputStream < handle - - properties (Access=private) - fid_ - owns_stream_ - end - - methods - function self = CodedInputStream(input) - if isa(input, "string") || isa(input, "char") - [fileId, errMsg] = fopen(input, "r"); - if fileId < 0 - throw(yardl.binary.Exception(errMsg)); - end - self.fid_ = fileId; - self.owns_stream_ = true; - else - self.fid_ = input; - self.owns_stream_ = false; - end - end - - function close(self) - if self.owns_stream_ && self.fid_ > 2 - fclose(self.fid_); - self.fid_ = -1; - end - end - - % In Python, this uses struct packing for any selfect... - function res = read(self, count) - res = fread(self.fid_, count, "*uint8"); - end - - function res = read_byte(self) - res = fread(self.fid_, 1, "*uint8"); - end - - function res = read_unsigned_varint(self) - res = uint64(0); - shift = uint8(0); - - while true - byte = self.read_byte(); - res = bitor(res, bitshift(uint64(bitand(byte, 0x7F)), shift)); - if byte < 0x80 - return - end - shift = shift + 7; - end - end - - function res = zigzag_decode(~, value) - value = uint64(value); - % res = int64(bitxor(bitshift(value, -1), -bitand(value, 1))); - res = bitxor(int64(bitshift(value, -1)), -int64(bitand(value, 1))); - end - - function res = read_signed_varint(self) - res = self.zigzag_decode(self.read_unsigned_varint()); - end - - end -end +classdef CodedInputStream < handle + + properties (Access=private) + fid_ + owns_stream_ + end + + methods + function self = CodedInputStream(input) + if isa(input, "string") || isa(input, "char") + [fileId, errMsg] = fopen(input, "r"); + if fileId < 0 + throw(yardl.binary.Exception(errMsg)); + end + self.fid_ = fileId; + self.owns_stream_ = true; + else + self.fid_ = input; + self.owns_stream_ = false; + end + end + + function close(self) + if self.owns_stream_ && self.fid_ > 2 + fclose(self.fid_); + self.fid_ = -1; + end + end + + % In Python, this uses struct packing for any selfect... + function res = read(self, count) + res = fread(self.fid_, count, "*uint8"); + end + + function res = read_byte(self) + res = fread(self.fid_, 1, "*uint8"); + end + + function res = read_unsigned_varint(self) + res = uint64(0); + shift = uint8(0); + + while true + byte = self.read_byte(); + res = bitor(res, bitshift(uint64(bitand(byte, 0x7F)), shift)); + if byte < 0x80 + return + end + shift = shift + 7; + end + end + + function res = zigzag_decode(~, value) + value = uint64(value); + % res = int64(bitxor(bitshift(value, -1), -bitand(value, 1))); + res = bitxor(int64(bitshift(value, -1)), -int64(bitand(value, 1))); + end + + function res = read_signed_varint(self) + res = self.zigzag_decode(self.read_unsigned_varint()); + end + + end +end diff --git a/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m b/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m index 9eb4625c..cbec09ca 100755 --- a/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m +++ b/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m @@ -1,74 +1,74 @@ -classdef CodedOutputStream < handle - - properties (Access=private) - fid_ - owns_stream_ - end - - methods - function self = CodedOutputStream(output) - if isa(output, "string") || isa(output, "char") - [fileId, errMsg] = fopen(output, "w"); - if fileId < 0 - throw(yardl.binary.Exception(errMsg)); - end - self.fid_ = fileId; - self.owns_stream_ = true; - else - self.fid_ = input; - self.owns_stream_ = false; - end - end - - function close(self) - if self.owns_stream_ && self.fid_ > 2 - fclose(self.fid_); - self.fid_ = -1; - end - end - - function write(self, value) - assert(isa(value, "uint8")); - fwrite(self.fid_, value, "uint8"); - end - - function write_bytes(self, bytes) - fwrite(self.fid_, bytes, "uint8"); - end - - function write_byte_no_check(self, value) - assert(isscalar(value)); - assert(all(value >= 0)); - assert(all(value <= intmax("uint8"))); - - fwrite(self.fid_, value, "uint8"); - end - - function write_unsigned_varint(self, value) - assert(isscalar(value)); - - int_val = uint64(value); - while true - if int_val < 0x80 - self.write_byte_no_check(int_val); - return - end - - self.write_byte_no_check(bitor(bitand(int_val, uint64(0x7F)), uint64(0x80))); - int_val = bitshift(int_val, -7); - end - end - - function res = zigzag_encode(~, value) - int_val = int64(value); - res = bitxor(bitshift(int_val, 1), bitshift(int_val, -63)); - end - - function write_signed_varint(self, value) - assert(isscalar(value)); - - self.write_unsigned_varint(self.zigzag_encode(value)); - end - - end -end +classdef CodedOutputStream < handle + + properties (Access=private) + fid_ + owns_stream_ + end + + methods + function self = CodedOutputStream(output) + if isa(output, "string") || isa(output, "char") + [fileId, errMsg] = fopen(output, "w"); + if fileId < 0 + throw(yardl.binary.Exception(errMsg)); + end + self.fid_ = fileId; + self.owns_stream_ = true; + else + self.fid_ = input; + self.owns_stream_ = false; + end + end + + function close(self) + if self.owns_stream_ && self.fid_ > 2 + fclose(self.fid_); + self.fid_ = -1; + end + end + + function write(self, value) + assert(isa(value, "uint8")); + fwrite(self.fid_, value, "uint8"); + end + + function write_bytes(self, bytes) + fwrite(self.fid_, bytes, "uint8"); + end + + function write_byte_no_check(self, value) + assert(isscalar(value)); + assert(all(value >= 0)); + assert(all(value <= intmax("uint8"))); + + fwrite(self.fid_, value, "uint8"); + end + + function write_unsigned_varint(self, value) + assert(isscalar(value)); + + int_val = uint64(value); + while true + if int_val < 0x80 + self.write_byte_no_check(int_val); + return + end + + self.write_byte_no_check(bitor(bitand(int_val, uint64(0x7F)), uint64(0x80))); + int_val = bitshift(int_val, -7); + end + end + + function res = zigzag_encode(~, value) + int_val = int64(value); + res = bitxor(bitshift(int_val, 1), bitshift(int_val, -63)); + end + + function write_signed_varint(self, value) + assert(isscalar(value)); + + self.write_unsigned_varint(self.zigzag_encode(value)); + end + + end +end diff --git a/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m b/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m index 1a3f0775..8caadfb6 100755 --- a/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m @@ -1,26 +1,26 @@ -classdef Complexfloat32Serializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - % assert(class(value) == "single"); - assert(real(value) <= realmax('single')); - assert(imag(value) <= realmax('single')); - assert(real(value) >= -realmax('single')); - assert(imag(value) >= -realmax('single')); - - real_bytes = typecast(single(real(value)), "uint8"); - imag_bytes = typecast(single(imag(value)), "uint8"); - outstream.write_bytes(real_bytes); - outstream.write_bytes(imag_bytes); - end - - function res = read(instream) - real_bytes = instream.read(4); - imag_bytes = instream.read(4); - res = complex(typecast(real_bytes, "single"), typecast(imag_bytes, "single")); - end - - function c = getClass() - c = 'single'; - end - end -end +classdef Complexfloat32Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + % assert(class(value) == "single"); + assert(real(value) <= realmax('single')); + assert(imag(value) <= realmax('single')); + assert(real(value) >= -realmax('single')); + assert(imag(value) >= -realmax('single')); + + real_bytes = typecast(single(real(value)), "uint8"); + imag_bytes = typecast(single(imag(value)), "uint8"); + outstream.write_bytes(real_bytes); + outstream.write_bytes(imag_bytes); + end + + function res = read(instream) + real_bytes = instream.read(4); + imag_bytes = instream.read(4); + res = complex(typecast(real_bytes, "single"), typecast(imag_bytes, "single")); + end + + function c = getClass() + c = 'single'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m b/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m index 5aeeb0db..2b7e6a52 100755 --- a/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m @@ -1,21 +1,21 @@ -classdef Complexfloat64Serializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - assert(class(value) == "double"); - real_bytes = typecast(double(real(value)), "uint8"); - imag_bytes = typecast(double(imag(value)), "uint8"); - outstream.write_bytes(real_bytes); - outstream.write_bytes(imag_bytes); - end - - function res = read(instream) - real_bytes = instream.read(8); - imag_bytes = instream.read(8); - res = complex(typecast(real_bytes, "double"), typecast(imag_bytes, "double")); - end - - function c = getClass() - c = 'double'; - end - end -end +classdef Complexfloat64Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(class(value) == "double"); + real_bytes = typecast(double(real(value)), "uint8"); + imag_bytes = typecast(double(imag(value)), "uint8"); + outstream.write_bytes(real_bytes); + outstream.write_bytes(imag_bytes); + end + + function res = read(instream) + real_bytes = instream.read(8); + imag_bytes = instream.read(8); + res = complex(typecast(real_bytes, "double"), typecast(imag_bytes, "double")); + end + + function c = getClass() + c = 'double'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/DateSerializer.m b/tooling/internal/matlab/static_files/+binary/DateSerializer.m index 3a55f7a0..bcb066d6 100755 --- a/tooling/internal/matlab/static_files/+binary/DateSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/DateSerializer.m @@ -1,23 +1,23 @@ -classdef DateSerializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - if isa(value, 'datetime') - value = yardl.Date.from_datetime(value).value; - elseif isa(value, 'yardl.Date') - value = value.value; - else - throw(yardl.TypeError("Expected datetime or yardl.Date, got %s", class(value))); - end - outstream.write_signed_varint(value); - end - - function res = read(instream) - value = instream.read_signed_varint(); - res = yardl.Date(value); - end - - function c = getClass() - c = 'yardl.Date'; - end - end -end +classdef DateSerializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + if isa(value, 'datetime') + value = yardl.Date.from_datetime(value).value; + elseif isa(value, 'yardl.Date') + value = value.value; + else + throw(yardl.TypeError("Expected datetime or yardl.Date, got %s", class(value))); + end + outstream.write_signed_varint(value); + end + + function res = read(instream) + value = instream.read_signed_varint(); + res = yardl.Date(value); + end + + function c = getClass() + c = 'yardl.Date'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/DatetimeSerializer.m b/tooling/internal/matlab/static_files/+binary/DatetimeSerializer.m index 44875874..eb82c840 100755 --- a/tooling/internal/matlab/static_files/+binary/DatetimeSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/DatetimeSerializer.m @@ -1,23 +1,23 @@ -classdef DatetimeSerializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - if isa(value, 'datetime') - value = yardl.DateTime.from_datetime(value).value; - elseif isa(value, 'yardl.DateTime') - value = value.value; - else - throw(yardl.TypeError("Expected datetime or yardl.DateTime, got %s", class(value))); - end - outstream.write_signed_varint(value); - end - - function res = read(instream) - value = instream.read_signed_varint(); - res = yardl.DateTime(value); - end - - function c = getClass() - c = 'yardl.DateTime'; - end - end -end +classdef DatetimeSerializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + if isa(value, 'datetime') + value = yardl.DateTime.from_datetime(value).value; + elseif isa(value, 'yardl.DateTime') + value = value.value; + else + throw(yardl.TypeError("Expected datetime or yardl.DateTime, got %s", class(value))); + end + outstream.write_signed_varint(value); + end + + function res = read(instream) + value = instream.read_signed_varint(); + res = yardl.DateTime(value); + end + + function c = getClass() + c = 'yardl.DateTime'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m index 4042deb9..769973b2 100644 --- a/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m @@ -1,8 +1,8 @@ classdef DynamicNDArraySerializer < yardl.binary.NDArraySerializerBase methods - function self = DynamicNDArraySerializer(element_serializer) - self@yardl.binary.NDArraySerializerBase(element_serializer); + function self = DynamicNDArraySerializer(item_serializer) + self@yardl.binary.NDArraySerializerBase(item_serializer); end function write(self, outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/Error.m b/tooling/internal/matlab/static_files/+binary/Error.m index ba166127..60872510 100755 --- a/tooling/internal/matlab/static_files/+binary/Error.m +++ b/tooling/internal/matlab/static_files/+binary/Error.m @@ -1,12 +1,3 @@ -% function err = Exception(msg, A) -% identifier = "yardl:binary:error"; -% if nargin < 2 -% err = MException(identifier, msg); -% else -% err = MException(identifier, msg, A); -% end -% end - -function err = Error(varargin) - err = yardl.Exception("yardl:binary:Error", varargin{:}); -end +function err = Error(varargin) + err = yardl.Exception("yardl:binary:Error", varargin{:}); +end diff --git a/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m index a92d7260..aa1abb1a 100644 --- a/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m @@ -4,25 +4,54 @@ shape_ end - methods - function self = FixedNDArraySerializer(element_serializer, shape) - self@yardl.binary.NDArraySerializerBase(element_serializer); + function self = FixedNDArraySerializer(item_serializer, shape) + self@yardl.binary.NDArraySerializerBase(item_serializer); self.shape_ = shape; end - function write(self, outstream, value) - if size(value) ~= self.shape_ + function write(self, outstream, values) + sz = size(values); + + if sz == self.shape_ + % This is an NDArray of scalars + self.write_data_(outstream, values(:)); + return; + end + + if length(sz) < length(self.shape_) + expected = sprintf("%d ", self.shape_); + actual = sprintf("%d ", sz); + throw(yardl.ValueError("Expected shape [%s], got [%s]", expected, actual)); + end + + fixedSize = sz(end-length(self.shape_)+1:end); + if fixedSize ~= self.shape_ expected = sprintf("%d ", self.shape_); - actual = sprintf("%d ", size(value)); + actual = sprintf("%d ", fixedSize); throw(yardl.ValueError("Expected shape [%s], got [%s]", expected, actual)); end - self.write_data_(outstream, value); + inner_shape = sz(1:end-length(self.shape_)); + values = reshape(values, [inner_shape prod(self.shape_)]); + + self.write_data_(outstream, values); end function value = read(self, instream) value = self.read_data_(instream, self.shape_); end + + function s = getShape(obj) + item_shape = obj.item_serializer_.getShape(); + if isempty(item_shape) + s = obj.shape_; + elseif isscalar(item_shape) + s = obj.shape_; + else + s = [item_shape obj.shape_]; + s = s(s>1); + end + end end end diff --git a/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m b/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m index 5e4732fd..6d7823c9 100644 --- a/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m @@ -1,33 +1,82 @@ classdef FixedVectorSerializer < yardl.binary.TypeSerializer properties - element_serializer_; + item_serializer_; length_; end methods - function obj = FixedVectorSerializer(element_serializer, length) - obj.element_serializer_ = element_serializer; + function obj = FixedVectorSerializer(item_serializer, length) + obj.item_serializer_ = item_serializer; obj.length_ = length; end - function write(obj, outstream, value) - if length(value) ~= obj.length_ - throw(yardl.ValueError("Expected an array of length %d, got %d", obj.length_, length(value))); + function write(obj, outstream, values) + s = size(values); + count = s(end); + + if count ~= obj.length_ + throw(yardl.ValueError("Expected an array of length %d, got %d", obj.length_, count)); end - for i = 1:obj.length_ - obj.element_serializer_.write(outstream, value(i)); + if iscell(values) + assert(s(1) == 1); + for i = 1:count + obj.item_serializer_.write(outstream, values{i}); + end + else + if ndims(values) > 2 + r = reshape(values, [], count); + for i = 1:count + val = reshape(r(:, i), s(1:end-1)); + obj.item_serializer_.write(outstream, val); + end + else + for i = 1:count + % obj.item_serializer_.write(outstream, values(:, i)); + obj.item_serializer_.write(outstream, transpose(values(:, i))); + end + end end end function res = read(obj, instream) - for i = 1:obj.length_ - res(i) = obj.element_serializer_.read(instream); + item_shape = obj.item_serializer_.getShape(); + if isempty(item_shape) + res = cell(1, obj.length_); + for i = 1:obj.length_ + res{i} = obj.item_serializer_.read(instream); + end + elseif isscalar(item_shape) + % res = zeros(obj.getShape(), obj.getClass()); + res = yardl.allocate(obj.getClass(), obj.getShape()); + for i = 1:obj.length_ + res(i) = obj.item_serializer_.read(instream); + end + else + % res = zeros([prod(item_shape), obj.length_], obj.getClass()); + res = yardl.allocate(obj.getClass(), [prod(item_shape), obj.length_]); + for i = 1:obj.length_ + item = obj.item_serializer_.read(instream); + res(:, i) = item(:); + end + res = squeeze(reshape(res, [item_shape, obj.length_])); end end function c = getClass(obj) - c = obj.element_serializer_.getClass(); + c = obj.item_serializer_.getClass(); + end + + function s = getShape(obj) + item_shape = obj.item_serializer_.getShape(); + if isempty(item_shape) + s = [1, obj.length_]; + elseif isscalar(item_shape) + s = [item_shape obj.length_]; + else + s = [item_shape obj.length_]; + s = s(s>1); + end end end end diff --git a/tooling/internal/matlab/static_files/+binary/Float32Serializer.m b/tooling/internal/matlab/static_files/+binary/Float32Serializer.m index 5f97e6d2..d3498cda 100755 --- a/tooling/internal/matlab/static_files/+binary/Float32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Float32Serializer.m @@ -1,21 +1,21 @@ -classdef Float32Serializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - % assert(class(value) == "single"); - assert(value <= realmax('single')); - assert(value >= -realmax('single')); - - bytes = typecast(single(value), "uint8"); - outstream.write_bytes(bytes); - end - - function res = read(instream) - bytes = instream.read(4); - res = typecast(bytes, "single"); - end - - function c = getClass() - c = 'single'; - end - end -end +classdef Float32Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + % assert(class(value) == "single"); + assert(value <= realmax('single')); + assert(value >= -realmax('single')); + + bytes = typecast(single(value), "uint8"); + outstream.write_bytes(bytes); + end + + function res = read(instream) + bytes = instream.read(4); + res = typecast(bytes, "single"); + end + + function c = getClass() + c = 'single'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/Float64Serializer.m b/tooling/internal/matlab/static_files/+binary/Float64Serializer.m index 625f5d60..b50c476c 100755 --- a/tooling/internal/matlab/static_files/+binary/Float64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Float64Serializer.m @@ -1,18 +1,18 @@ -classdef Float64Serializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - assert(class(value) == "double"); - bytes = typecast(double(value), "uint8"); - outstream.write_bytes(bytes); - end - - function res = read(instream) - bytes = instream.read(8); - res = typecast(bytes, "double"); - end - - function c = getClass() - c = 'double'; - end - end -end +classdef Float64Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(class(value) == "double"); + bytes = typecast(double(value), "uint8"); + outstream.write_bytes(bytes); + end + + function res = read(instream) + bytes = instream.read(8); + res = typecast(bytes, "double"); + end + + function c = getClass() + c = 'double'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/Int16Serializer.m b/tooling/internal/matlab/static_files/+binary/Int16Serializer.m index 5fc57b25..4d82b6ba 100755 --- a/tooling/internal/matlab/static_files/+binary/Int16Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int16Serializer.m @@ -1,18 +1,18 @@ -classdef Int16Serializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - assert(value <= intmax("int16")); - assert(value >= intmin("int16")); - value = int16(value); - outstream.write_signed_varint(value); - end - - function res = read(instream) - res = int16(instream.read_signed_varint()); - end - - function c = getClass() - c = 'int16'; - end - end -end +classdef Int16Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("int16")); + assert(value >= intmin("int16")); + value = int16(value); + outstream.write_signed_varint(value); + end + + function res = read(instream) + res = int16(instream.read_signed_varint()); + end + + function c = getClass() + c = 'int16'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/Int32Serializer.m b/tooling/internal/matlab/static_files/+binary/Int32Serializer.m index 6de34c40..32f1c655 100755 --- a/tooling/internal/matlab/static_files/+binary/Int32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int32Serializer.m @@ -1,18 +1,18 @@ -classdef Int32Serializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - assert(value <= intmax("int32")); - assert(value >= intmin("int32")); - value = int32(value); - outstream.write_signed_varint(value); - end - - function res = read(instream) - res = int32(instream.read_signed_varint()); - end - - function c = getClass() - c = 'int32'; - end - end -end +classdef Int32Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("int32")); + assert(value >= intmin("int32")); + value = int32(value); + outstream.write_signed_varint(value); + end + + function res = read(instream) + res = int32(instream.read_signed_varint()); + end + + function c = getClass() + c = 'int32'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/Int64Serializer.m b/tooling/internal/matlab/static_files/+binary/Int64Serializer.m index f8903963..34fe4225 100755 --- a/tooling/internal/matlab/static_files/+binary/Int64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int64Serializer.m @@ -1,18 +1,18 @@ -classdef Int64Serializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - assert(value <= intmax("int64")); - assert(value >= intmin("int64")); - value = int64(value); - outstream.write_signed_varint(value); - end - - function res = read(instream) - res = int64(instream.read_signed_varint()); - end - - function c = getClass() - c = 'int64'; - end - end -end +classdef Int64Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("int64")); + assert(value >= intmin("int64")); + value = int64(value); + outstream.write_signed_varint(value); + end + + function res = read(instream) + res = int64(instream.read_signed_varint()); + end + + function c = getClass() + c = 'int64'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/Int8Serializer.m b/tooling/internal/matlab/static_files/+binary/Int8Serializer.m index 6d382ce5..1187843e 100755 --- a/tooling/internal/matlab/static_files/+binary/Int8Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int8Serializer.m @@ -1,18 +1,18 @@ -classdef Int8Serializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - assert(value <= intmax("int8")); - assert(value >= intmin("int8")); - bytes = typecast(int8(value), "uint8"); - outstream.write_bytes(bytes); - end - - function res = read(instream) - res = typecast(instream.read_byte(), "int8"); - end - - function c = getClass() - c = 'int8'; - end - end -end +classdef Int8Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("int8")); + assert(value >= intmin("int8")); + bytes = typecast(int8(value), "uint8"); + outstream.write_bytes(bytes); + end + + function res = read(instream) + res = typecast(instream.read_byte(), "int8"); + end + + function c = getClass() + c = 'int8'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/MAGIC_BYTES.m b/tooling/internal/matlab/static_files/+binary/MAGIC_BYTES.m index cd086b1c..a7a6e67c 100755 --- a/tooling/internal/matlab/static_files/+binary/MAGIC_BYTES.m +++ b/tooling/internal/matlab/static_files/+binary/MAGIC_BYTES.m @@ -1,3 +1,3 @@ -function res = MAGIC_BYTES - res = unicode2native('yardl'); -end +function res = MAGIC_BYTES + res = unicode2native('yardl'); +end diff --git a/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m index 6da46c59..52de2fec 100644 --- a/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m @@ -5,30 +5,46 @@ end methods - function self = NDArraySerializer(element_serializer, ndims) - self@yardl.binary.NDArraySerializerBase(element_serializer); + function self = NDArraySerializer(item_serializer, ndims) + self@yardl.binary.NDArraySerializerBase(item_serializer); self.ndims_ = ndims; end - function write(self, outstream, value) - if ndims(value) ~= max(2, self.ndims_) - throw(yardl.ValueError("Expected %d dimensions, got %d", self.ndims_, ndims(value))); + function write(self, outstream, values) + if ndims(values) < self.ndims_ + throw(yardl.ValueError("Expected %d dimensions, got %d", self.ndims_, ndims(values))); end - for dim = self.ndims_: -1: 1 - len = size(value, dim); + sz = size(values); + + flipped_shape = flip(sz); + for dim = 1: self.ndims_ + len = flipped_shape(dim); outstream.write_unsigned_varint(len); end - self.write_data_(outstream, value); + if ndims(values) == self.ndims_ + % This is an NDArray of scalars + self.write_data_(outstream, values(:)); + return + end + + % This is an NDArray of vectors/arrays + inner_shape = sz(1:end-self.ndims_); + outer_shape = sz(end-self.ndims_+1:end); + values = reshape(values, [inner_shape prod(outer_shape)]); + + self.write_data_(outstream, values); end function value = read(self, instream) - shape = zeros(1, self.ndims_); + flipped_shape = zeros(1, self.ndims_); for dim = 1:self.ndims_ - shape(dim) = instream.read_unsigned_varint(); + flipped_shape(dim) = instream.read_unsigned_varint(); end - value = self.read_data_(instream, flip(shape)); + shape = flip(flipped_shape); + + value = self.read_data_(instream, shape); end end end diff --git a/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m b/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m index 0df2088e..407f6563 100644 --- a/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m +++ b/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m @@ -1,48 +1,98 @@ -classdef NDArraySerializerBase < handle +classdef NDArraySerializerBase < yardl.binary.TypeSerializer properties - element_serializer_ + item_serializer_ end methods (Abstract) - write(self, outstream, value) + write(self, outstream, values) read(self, instream) end - methods - function c = getClass(obj) - c = obj.element_serializer_.getClass(); - end - end - methods (Access=protected) - function self = NDArraySerializerBase(element_serializer) - if isa(element_serializer, 'yardl.binary.FixedNDArraySerializer') || ... - isa(element_serializer, 'yardl.binary.FixedVectorSerializer') - self.element_serializer_ = element_serializer.element_serializer_; - else - self.element_serializer_ = element_serializer; - end + function self = NDArraySerializerBase(item_serializer) + % if isa(item_serializer, 'yardl.binary.FixedNDArraySerializer') || ... + % isa(item_serializer, 'yardl.binary.FixedVectorSerializer') + % self.item_serializer_ = item_serializer.item_serializer_; + % else + % self.item_serializer_ = item_serializer; + % end + self.item_serializer_ = item_serializer; end - function write_data_(self, outstream, value) - flat_value = value(:); - for i = 1:length(flat_value) - self.element_serializer_.write(outstream, flat_value(i)); + function write_data_(self, outstream, values) + % values is an array of shape [A, B, ..., N], where + % N is the "flattened" dimension of the NDArray, and + % A, B, ... are the dimensions of the inner items. + + sz = size(values); + + if ndims(values) > 2 + count = sz(end); + inner_shape = sz(1:end-1); + r = reshape(values, [], count); + for i = 1:count + val = reshape(r(:, i), inner_shape); + self.item_serializer_.write(outstream, val); + end + else + count = prod(sz); + if iscell(values) + for i = 1:count + self.item_serializer_.write(outstream, values{i}); + end + else + for i = 1:count + self.item_serializer_.write(outstream, values(i)); + end + end end end - function value = read_data_(self, instream, shape) + function res = read_data_(self, instream, shape) flat_length = prod(shape); - % if self.element_serializer_.is_trivially_serializable()... - for i = 1:flat_length - value(i) = self.element_serializer_.read(instream); - end + item_shape = self.item_serializer_.getShape(); - if length(shape) > 1 - value = reshape(value, shape); + if isempty(item_shape) + res = cell(shape); + for i = 1:flat_length + res{i} = self.item_serializer_.read(instream); + end + elseif isscalar(item_shape) + % res = zeros(shape, self.getClass()); + res = yardl.allocate(self.getClass(), shape); + for i = 1:flat_length + res(i) = self.item_serializer_.read(instream); + end + res = squeeze(res); + else + % res = zeros([prod(item_shape), flat_length], self.getClass()); + res = yardl.allocate(self.getClass(), [prod(item_shape), flat_length]); + for i = 1:flat_length + item = self.item_serializer_.read(instream); + res(:, i) = item(:); + end + res = squeeze(reshape(res, [item_shape shape])); end + + % for i = 1:flat_length + % value(i) = self.item_serializer_.read(instream); + % end + + % if length(shape) > 1 + % value = reshape(value, shape); + % end + end + end + + methods + function c = getClass(self) + c = self.item_serializer_.getClass(); + end + + function s = getShape(~) + s = []; end end end diff --git a/tooling/internal/matlab/static_files/+binary/NoneSerializer.m b/tooling/internal/matlab/static_files/+binary/NoneSerializer.m index b6241ede..5cd0147e 100755 --- a/tooling/internal/matlab/static_files/+binary/NoneSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/NoneSerializer.m @@ -1,14 +1,14 @@ -classdef NoneSerializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - end - - function res = read(instream) - res = yardl.None; - end - - function c = getClass() - c = 'yardl.Optional'; - end - end -end +classdef NoneSerializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + end + + function res = read(instream) + res = yardl.None; + end + + function c = getClass() + c = 'yardl.Optional'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m b/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m index b9929da5..9ad9bf6a 100644 --- a/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m @@ -1,11 +1,11 @@ classdef OptionalSerializer < yardl.binary.TypeSerializer properties - element_serializer_; + item_serializer_; end methods - function obj = OptionalSerializer(element_serializer) - obj.element_serializer_ = element_serializer; + function obj = OptionalSerializer(item_serializer) + obj.item_serializer_ = item_serializer; end function write(obj, outstream, value) @@ -14,19 +14,19 @@ function write(obj, outstream, value) % return % end % outstream.write_byte_no_check(1); - % obj.element_serializer_.write(outstream, value); + % obj.item_serializer_.write(outstream, value); if isa(value, 'yardl.Optional') if value.has_value() outstream.write_byte_no_check(1); - obj.element_serializer_.write(outstream, value.value()); + obj.item_serializer_.write(outstream, value.value()); else outstream.write_byte_no_check(0); return end else outstream.write_byte_no_check(1); - obj.element_serializer_.write(outstream, value); + obj.item_serializer_.write(outstream, value); end end @@ -35,15 +35,15 @@ function write(obj, outstream, value) if has_value == 0 res = yardl.None; else - res = obj.element_serializer_.read(instream); + res = obj.item_serializer_.read(instream); - % value = obj.element_serializer_.read(instream); + % value = obj.item_serializer_.read(instream); % res = yardl.Optional(value); end end function c = getClass(obj) - % c = obj.element_serializer_.getClass(); + % c = obj.item_serializer_.getClass(); c = 'yardl.Optional'; end end diff --git a/tooling/internal/matlab/static_files/+binary/RecordSerializer.m b/tooling/internal/matlab/static_files/+binary/RecordSerializer.m index 79ec35dd..d59a5097 100755 --- a/tooling/internal/matlab/static_files/+binary/RecordSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/RecordSerializer.m @@ -1,36 +1,36 @@ -classdef RecordSerializer < handle - - properties - field_serializers - classname - end - - methods - function obj = RecordSerializer(classname, field_serializers) - obj.classname = classname; - obj.field_serializers = field_serializers; - end - - function c = getClass(obj) - c = obj.classname; - end - end - - methods (Access=protected) - function write_(obj, outstream, varargin) - for i = 1:nargin-2 - fs = obj.field_serializers{i}; - field_value = varargin{i}; - fs.write(outstream, field_value); - end - end - - function res = read_(obj, instream) - res = cell(size(obj.field_serializers)); - for i = 1:length(obj.field_serializers) - fs = obj.field_serializers{i}; - res{i} = fs.read(instream); - end - end - end -end +classdef RecordSerializer < yardl.binary.TypeSerializer + + properties + field_serializers + classname + end + + methods + function obj = RecordSerializer(classname, field_serializers) + obj.classname = classname; + obj.field_serializers = field_serializers; + end + + function c = getClass(obj) + c = obj.classname; + end + end + + methods (Access=protected) + function write_(obj, outstream, varargin) + for i = 1:nargin-2 + fs = obj.field_serializers{i}; + field_value = varargin{i}; + fs.write(outstream, field_value); + end + end + + function res = read_(obj, instream) + res = cell(size(obj.field_serializers)); + for i = 1:length(obj.field_serializers) + fs = obj.field_serializers{i}; + res{i} = fs.read(instream); + end + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/SizeSerializer.m b/tooling/internal/matlab/static_files/+binary/SizeSerializer.m index fcc7fe74..53f51e4d 100755 --- a/tooling/internal/matlab/static_files/+binary/SizeSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/SizeSerializer.m @@ -1,2 +1,2 @@ -classdef SizeSerializer < yardl.binary.Uint64Serializer -end +classdef SizeSerializer < yardl.binary.Uint64Serializer +end diff --git a/tooling/internal/matlab/static_files/+binary/StreamSerializer.m b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m index 9d307416..979a726c 100644 --- a/tooling/internal/matlab/static_files/+binary/StreamSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m @@ -1,18 +1,37 @@ classdef StreamSerializer < yardl.binary.TypeSerializer properties - element_serializer_; + item_serializer_; end methods - function obj = StreamSerializer(element_serializer) - obj.element_serializer_ = element_serializer; + function obj = StreamSerializer(item_serializer) + obj.item_serializer_ = item_serializer; end - function write(obj, outstream, value) - len = size(value, 2); - outstream.write_unsigned_varint(len); - for i = 1:len - obj.element_serializer_.write(outstream, value(:, i)); + function write(obj, outstream, values) + s = size(values); + count = s(end); + outstream.write_unsigned_varint(count); + + if iscell(values) + assert(s(1) == 1); + for i = 1:count + obj.item_serializer_.write(outstream, values{i}); + end + else + if ndims(values) > 2 + r = reshape(values, [], count); + inner_shape = s(1:end-1); + for i = 1:count + val = reshape(r(:, i), inner_shape); + obj.item_serializer_.write(outstream, val); + end + else + for i = 1:count + % obj.item_serializer_.write(outstream, values(:, i)); + obj.item_serializer_.write(outstream, transpose(values(:, i))); + end + end end end @@ -23,20 +42,52 @@ function write(obj, outstream, value) return; end - % Preallocate the result vector (THIS DOESN'T WORK if the element is a vector or array) - res = zeros(1, count, obj.getClass); - idx = 1; - while count > 0 - for c = 1:count - res(:, idx) = obj.element_serializer_.read(instream); - idx = idx + 1; + item_shape = obj.item_serializer_.getShape(); + if isempty(item_shape) + res = cell(1, count); + idx = 1; + while count > 0 + for c = 1:count + res{idx} = obj.item_serializer_.read(instream); + idx = idx + 1; + end + count = instream.read_unsigned_varint(); + end + elseif isscalar(item_shape) + % res = zeros([item_shape, count], obj.getClass()); + res = yardl.allocate(obj.getClass(), [item_shape, count]); + idx = 1; + while count > 0 + for c = 1:count + res(idx) = obj.item_serializer_.read(instream); + idx = idx + 1; + end + count = instream.read_unsigned_varint(); + end + else + % res = zeros([prod(item_shape), count], obj.getClass()); + res = yardl.allocate(obj.getClass(), [prod(item_shape), count]); + total_count = 0; + while count > 0 + for c = 1:count + idx = total_count + c; + item = obj.item_serializer_.read(instream); + res(:, idx) = item(:); + end + + total_count = total_count + count; + count = instream.read_unsigned_varint(); end - count = instream.read_unsigned_varint(); + res = squeeze(reshape(res, [item_shape, total_count])); end end function c = getClass(obj) - c = obj.element_serializer_.getClass(); + c = obj.item_serializer_.getClass(); + end + + function s = getShape(~) + s = []; end end end diff --git a/tooling/internal/matlab/static_files/+binary/StringSerializer.m b/tooling/internal/matlab/static_files/+binary/StringSerializer.m index 3beb9e97..3844acdf 100755 --- a/tooling/internal/matlab/static_files/+binary/StringSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/StringSerializer.m @@ -1,22 +1,22 @@ -classdef StringSerializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - % if ischar(value) - % value = convertCharsToStrings(value); - % end - bytes = unicode2native(value, "utf-8"); - outstream.write_unsigned_varint(length(bytes)); - outstream.write_bytes(bytes); - end - - function res = read(instream) - len = instream.read_unsigned_varint(); - bytes = instream.read(len); - res = convertCharsToStrings(native2unicode(bytes, "utf-8")); - end - - function c = getClass() - c = 'string'; - end - end -end +classdef StringSerializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + % if ischar(value) + % value = convertCharsToStrings(value); + % end + bytes = unicode2native(value, "utf-8"); + outstream.write_unsigned_varint(length(bytes)); + outstream.write_bytes(bytes); + end + + function res = read(instream) + len = instream.read_unsigned_varint(); + bytes = instream.read(len); + res = convertCharsToStrings(native2unicode(bytes, "utf-8")); + end + + function c = getClass() + c = 'string'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/TimeSerializer.m b/tooling/internal/matlab/static_files/+binary/TimeSerializer.m index ae7362f8..2e14c985 100755 --- a/tooling/internal/matlab/static_files/+binary/TimeSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/TimeSerializer.m @@ -1,24 +1,24 @@ -classdef TimeSerializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - if isa(value, 'datetime') - value = yardl.Time.from_datetime(value).value; - elseif isa(value, 'yardl.Time') - value = value.value; - else - throw(yardl.TypeError("Expected datetime or yardl.Time, got %s", class(value))); - end - - outstream.write_signed_varint(value); - end - - function res = read(instream) - value = instream.read_signed_varint(); - res = yardl.Time(value); - end - - function c = getClass() - c = 'yardl.Time'; - end - end -end +classdef TimeSerializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + if isa(value, 'datetime') + value = yardl.Time.from_datetime(value).value; + elseif isa(value, 'yardl.Time') + value = value.value; + else + throw(yardl.TypeError("Expected datetime or yardl.Time, got %s", class(value))); + end + + outstream.write_signed_varint(value); + end + + function res = read(instream) + value = instream.read_signed_varint(); + res = yardl.Time(value); + end + + function c = getClass() + c = 'yardl.Time'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/TypeSerializer.m b/tooling/internal/matlab/static_files/+binary/TypeSerializer.m index da8cd343..91e855b0 100755 --- a/tooling/internal/matlab/static_files/+binary/TypeSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/TypeSerializer.m @@ -1,6 +1,13 @@ -classdef TypeSerializer < handle - methods (Static, Abstract) - write(obj, stream, value) - res = read(obj, stream) - end -end +classdef TypeSerializer < handle + methods (Static, Abstract) + write(obj, stream, value) + res = read(obj, stream) + c = getClass(obj) + end + + methods (Static) + function s = getShape() + s = 1; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/Uint16Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint16Serializer.m index c8605176..05712b64 100755 --- a/tooling/internal/matlab/static_files/+binary/Uint16Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint16Serializer.m @@ -1,18 +1,18 @@ -classdef Uint16Serializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - assert(value <= intmax("uint16")); - assert(value >= intmin("uint16")); - value = uint16(value); - outstream.write_unsigned_varint(value); - end - - function res = read(instream) - res = uint16(instream.read_unsigned_varint()); - end - - function c = getClass() - c = 'uint16'; - end - end -end +classdef Uint16Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("uint16")); + assert(value >= intmin("uint16")); + value = uint16(value); + outstream.write_unsigned_varint(value); + end + + function res = read(instream) + res = uint16(instream.read_unsigned_varint()); + end + + function c = getClass() + c = 'uint16'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/Uint32Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint32Serializer.m index e82d4fc2..c2fa58b7 100755 --- a/tooling/internal/matlab/static_files/+binary/Uint32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint32Serializer.m @@ -1,18 +1,18 @@ -classdef Uint32Serializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - assert(value <= intmax("uint32")); - assert(value >= intmin("uint32")); - value = uint32(value); - outstream.write_unsigned_varint(value); - end - - function res = read(instream) - res = uint32(instream.read_unsigned_varint()); - end - - function c = getClass() - c = 'uint32'; - end - end -end +classdef Uint32Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("uint32")); + assert(value >= intmin("uint32")); + value = uint32(value); + outstream.write_unsigned_varint(value); + end + + function res = read(instream) + res = uint32(instream.read_unsigned_varint()); + end + + function c = getClass() + c = 'uint32'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/Uint64Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint64Serializer.m index ecd59892..3bff28ec 100755 --- a/tooling/internal/matlab/static_files/+binary/Uint64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint64Serializer.m @@ -1,18 +1,18 @@ -classdef Uint64Serializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - assert(value <= intmax("uint64")); - assert(value >= intmin("uint64")); - value = uint64(value); - outstream.write_unsigned_varint(value); - end - - function res = read(instream) - res = uint64(instream.read_unsigned_varint()); - end - - function c = getClass() - c = 'uint64'; - end - end -end +classdef Uint64Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("uint64")); + assert(value >= intmin("uint64")); + value = uint64(value); + outstream.write_unsigned_varint(value); + end + + function res = read(instream) + res = uint64(instream.read_unsigned_varint()); + end + + function c = getClass() + c = 'uint64'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m index 5300ac5b..88dbba27 100755 --- a/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m @@ -1,18 +1,18 @@ -classdef Uint8Serializer < yardl.binary.TypeSerializer - methods (Static) - function write(outstream, value) - assert(value <= intmax("uint8")); - assert(value >= intmin("uint8")); - % bytes = typecast(uint8(value), "uint8"); - outstream.write_bytes(uint8(value)); - end - - function res = read(instream) - res = instream.read_byte(); - end - - function c = getClass() - c = 'uint8'; - end - end -end +classdef Uint8Serializer < yardl.binary.TypeSerializer + methods (Static) + function write(outstream, value) + assert(value <= intmax("uint8")); + assert(value >= intmin("uint8")); + % bytes = typecast(uint8(value), "uint8"); + outstream.write_bytes(uint8(value)); + end + + function res = read(instream) + res = instream.read_byte(); + end + + function c = getClass() + c = 'uint8'; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/UnionSerializer.m b/tooling/internal/matlab/static_files/+binary/UnionSerializer.m index 4fc5a65e..73b61dc3 100755 --- a/tooling/internal/matlab/static_files/+binary/UnionSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/UnionSerializer.m @@ -1,82 +1,89 @@ -classdef UnionSerializer < handle - - properties (Access=protected) - classname_ - case_serializers_ - case_factories_ - offset_ - end - - methods - - function obj = UnionSerializer(union_class, case_serializers, case_factories) - obj.classname_ = union_class; - obj.case_serializers_ = case_serializers; - obj.case_factories_ = case_factories; - - if isa(case_serializers{1}, 'yardl.binary.NoneSerializer') - obj.offset_ = 1; - else - obj.offset_ = 0; - end - end - - function write(obj, outstream, value) - - if isa(value, 'yardl.Optional') - if ~isa(obj.case_serializers_{1}, 'yardl.binary.NoneSerializer') - throw(yardl.TypeError("Optional is not valid for this union type")) - end - - if value.has_value() - value = value.value; - else - outstream.write_byte_no_check(0); - return; - end - end - - % if isa(value, 'yardl.Optional') && ~value.has_value() - % if isa(obj.case_serializers_{1}, 'yardl.binary.NoneSerializer') - % outstream.write_byte_no_check(0); - % return; - % else - % throw(yardl.TypeError("None is not valid for this union type")) - % end - % end - - if ~isa(value, obj.classname_) - throw(yardl.TypeError("Expected union value of type %s, got %s", obj.classname_, class(value))) - end - - tag_index = uint8(value.index + obj.offset_); - outstream.write_byte_no_check(tag_index-1); - - serializer = obj.case_serializers_{tag_index}; - serializer.write(outstream, value.value); - end - - function res = read(obj, instream) - case_index = instream.read_byte() + 1; - - if case_index == 1 && obj.offset_ == 1 - res = yardl.None; - return - end - - serializer = obj.case_serializers_{case_index}; - value = serializer.read(instream); - - factory = obj.case_factories_{case_index}; - res = factory(value); - end - - function c = getClass(obj) - if isa(obj.case_serializers_{1}, 'yardl.binary.NoneSerializer') - c = 'yardl.Optional'; - else - c = obj.classname_; - end - end - end -end +classdef UnionSerializer < handle + + properties (Access=protected) + classname_ + case_serializers_ + case_factories_ + offset_ + end + + methods + + function obj = UnionSerializer(union_class, case_serializers, case_factories) + obj.classname_ = union_class; + obj.case_serializers_ = case_serializers; + obj.case_factories_ = case_factories; + + if isa(case_serializers{1}, 'yardl.binary.NoneSerializer') + obj.offset_ = 1; + else + obj.offset_ = 0; + end + end + + function write(obj, outstream, value) + + if isa(value, 'yardl.Optional') + if ~isa(obj.case_serializers_{1}, 'yardl.binary.NoneSerializer') + throw(yardl.TypeError("Optional is not valid for this union type")) + end + + if value.has_value() + value = value.value; + else + outstream.write_byte_no_check(0); + return; + end + end + + % if isa(value, 'yardl.Optional') && ~value.has_value() + % if isa(obj.case_serializers_{1}, 'yardl.binary.NoneSerializer') + % outstream.write_byte_no_check(0); + % return; + % else + % throw(yardl.TypeError("None is not valid for this union type")) + % end + % end + + if ~isa(value, obj.classname_) + throw(yardl.TypeError("Expected union value of type %s, got %s", obj.classname_, class(value))) + end + + tag_index = uint8(value.index + obj.offset_); + outstream.write_byte_no_check(tag_index-1); + + serializer = obj.case_serializers_{tag_index}; + serializer.write(outstream, value.value); + end + + function res = read(obj, instream) + case_index = instream.read_byte() + 1; + + if case_index == 1 && obj.offset_ == 1 + res = yardl.None; + return + end + + serializer = obj.case_serializers_{case_index}; + value = serializer.read(instream); + + factory = obj.case_factories_{case_index}; + res = factory(value); + end + + function c = getClass(obj) + if isa(obj.case_serializers_{1}, 'yardl.binary.NoneSerializer') + c = 'yardl.Optional'; + else + c = obj.classname_; + end + end + + end + + methods (Static) + function s = getShape() + s = 1; + end + end +end diff --git a/tooling/internal/matlab/static_files/+binary/VectorSerializer.m b/tooling/internal/matlab/static_files/+binary/VectorSerializer.m index 1b10edbe..10079fe7 100644 --- a/tooling/internal/matlab/static_files/+binary/VectorSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/VectorSerializer.m @@ -1,29 +1,79 @@ classdef VectorSerializer < yardl.binary.TypeSerializer properties - element_serializer_; + item_serializer_; end methods - function obj = VectorSerializer(element_serializer) - obj.element_serializer_ = element_serializer; + function obj = VectorSerializer(item_serializer) + obj.item_serializer_ = item_serializer; end - function write(obj, outstream, value) - outstream.write_unsigned_varint(length(value)); - for i = 1:length(value) - obj.element_serializer_.write(outstream, value(i)); + function write(obj, outstream, values) + s = size(values); + count = s(end); + outstream.write_unsigned_varint(count); + + if iscell(values) + % values is a cell array, so must be a vector of shape [1, COUNT] + assert(s(1) == 1); + for i = 1:count + obj.item_serializer_.write(obj, values{i}); + end + else + % values is an array, so must have shape [A, B, ..., COUNT] + if ndims(values) > 2 + r = reshape(values, [], count); + for i = 1:count + val = reshape(r(:, i), s(1:end-1)); + obj.item_serializer_.write(outstream, val); + end + else + for i = 1:count + % obj.item_serializer_.write(outstream, values(:, i)); + obj.item_serializer_.write(outstream, transpose(values(:, i))); + end + end end end function res = read(obj, instream) count = instream.read_unsigned_varint(); - for i = 1:count - res(i) = obj.element_serializer_.read(instream); + if count == 0 + % res = zeros(0, obj.getClass()); + res = yardl.allocate(obj.getClass(), 0); + return; + end + + item_shape = obj.item_serializer_.getShape(); + if isempty(item_shape) + res = cell(1, count); + for i = 1:count + res{i} = obj.item_serializer_.read(instream); + end + elseif isscalar(item_shape) + % res = zeros([1 count], obj.getClass()); + res = yardl.allocate(obj.getClass(), [1 count]); + for i = 1:count + res(i) = obj.item_serializer_.read(instream); + end + res = squeeze(res); + else + % res = zeros([prod(item_shape), count], obj.getClass()); + res = yardl.allocate(obj.getClass(), [prod(item_shape), count]); + for i = 1:count + item = obj.item_serializer_.read(instream); + res(:, i) = item(:); + end + res = squeeze(reshape(res, [item_shape, total_count])); end end function c = getClass(obj) - c = obj.element_serializer_.getClass; + c = obj.item_serializer_.getClass; + end + + function s = getShape(~) + s = []; end end end diff --git a/tooling/internal/matlab/static_files/Date.m b/tooling/internal/matlab/static_files/Date.m index 1dcc8548..6ba484ec 100644 --- a/tooling/internal/matlab/static_files/Date.m +++ b/tooling/internal/matlab/static_files/Date.m @@ -44,6 +44,20 @@ function d = from_components(y, m, d) d = yardl.Date.from_datetime(datetime(y, m, d)); end + + function z = zeros(varargin) + elem = yardl.Date(0); + if nargin == 0 + z = elem; + return + end + + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; + end + z = reshape(repelem(elem, prod(sz)), sz); + end end end diff --git a/tooling/internal/matlab/static_files/DateTime.m b/tooling/internal/matlab/static_files/DateTime.m index 25526abf..ba44fd4b 100644 --- a/tooling/internal/matlab/static_files/DateTime.m +++ b/tooling/internal/matlab/static_files/DateTime.m @@ -51,6 +51,20 @@ seconds_since_epoch = convertTo(mdt, 'epochtime'); dt = yardl.DateTime(seconds_since_epoch * 1e9 + nanosecond); end + + function z = zeros(varargin) + elem = yardl.DateTime(0); + if nargin == 0 + z = elem; + return + end + + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; + end + z = reshape(repelem(elem, prod(sz)), sz); + end end end diff --git a/tooling/internal/matlab/static_files/Exception.m b/tooling/internal/matlab/static_files/Exception.m index c2dddb57..fc8c6ad7 100755 --- a/tooling/internal/matlab/static_files/Exception.m +++ b/tooling/internal/matlab/static_files/Exception.m @@ -1,11 +1,3 @@ -% function err = Exception(id, msg, A) -% if nargin < 3 -% err = MException(id, msg); -% else -% err = MException(id, msg, A); -% end -% end - -function err = Exception(id, varargin) - err = MException(id, varargin{:}); -end +function err = Exception(id, varargin) + err = MException(id, varargin{:}); +end diff --git a/tooling/internal/matlab/static_files/Optional.m b/tooling/internal/matlab/static_files/Optional.m index 57e5ab4d..71b74c61 100644 --- a/tooling/internal/matlab/static_files/Optional.m +++ b/tooling/internal/matlab/static_files/Optional.m @@ -83,13 +83,14 @@ elem = yardl.None; if nargin == 0 z = elem; - elseif nargin == 1 - n = varargin{1}; - z = reshape(repelem(elem, n*n), [n, n]); - else - sz = [varargin{:}]; - z = reshape(repelem(elem, prod(sz)), sz); + return + end + + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; end + z = reshape(repelem(elem, prod(sz)), sz); end end end diff --git a/tooling/internal/matlab/static_files/Time.m b/tooling/internal/matlab/static_files/Time.m index bf19e670..690e02d3 100644 --- a/tooling/internal/matlab/static_files/Time.m +++ b/tooling/internal/matlab/static_files/Time.m @@ -64,6 +64,20 @@ t = yardl.Time(hour * 60*60*1e9 + minute * 60*1e9 + second * 1e9 + nanosecond); end + + function z = zeros(varargin) + elem = yardl.Time(0); + if nargin == 0 + z = elem; + return + end + + sz = [varargin{:}]; + if isscalar(sz) + sz = [sz, sz]; + end + z = reshape(repelem(elem, prod(sz)), sz); + end end end diff --git a/tooling/internal/matlab/static_files/allocate.m b/tooling/internal/matlab/static_files/allocate.m new file mode 100644 index 00000000..1d2267af --- /dev/null +++ b/tooling/internal/matlab/static_files/allocate.m @@ -0,0 +1,7 @@ +function res = allocate(classname, varargin) + if classname == "string" + res = strings(varargin{:}); + else + res = zeros(varargin{:}, classname); + end +end diff --git a/tooling/internal/matlab/types/types.go b/tooling/internal/matlab/types/types.go index ff4d0612..3e61dca4 100644 --- a/tooling/internal/matlab/types/types.go +++ b/tooling/internal/matlab/types/types.go @@ -123,14 +123,13 @@ func writeUnionClass(w *formatting.IndentedWriter, className string, generalized func writeNamedType(fw *common.MatlabFileWriter, td *dsl.NamedType) error { return fw.WriteFile(common.TypeIdentifierName(td.Name), func(w *formatting.IndentedWriter) { - common.WriteComment(w, td.Comment) - ut := dsl.GetUnderlyingType(td.Type) // If the underlying type is a RecordDefinition or Optional, we will generate a "function" alias if st, ok := ut.(*dsl.SimpleType); ok { if _, ok := st.ResolvedDefinition.(*dsl.RecordDefinition); ok { fmt.Fprintf(w, "function c = %s(varargin) \n", common.TypeIdentifierName(td.Name)) common.WriteBlockBody(w, func() { + common.WriteComment(w, td.Comment) fmt.Fprintf(w, "c = %s(varargin{:});\n", common.TypeSyntax(td.Type, td.Namespace)) }) return @@ -140,6 +139,7 @@ func writeNamedType(fw *common.MatlabFileWriter, td *dsl.NamedType) error { innerType := gt.Cases[1].Type fmt.Fprintf(w, "function o = %s(value) \n", common.TypeIdentifierName(td.Name)) common.WriteBlockBody(w, func() { + common.WriteComment(w, td.Comment) if !dsl.TypeContainsGenericTypeParameter(innerType) { fmt.Fprintf(w, "assert(isa(value, '%s'));\n", common.TypeSyntax(innerType, td.Namespace)) } @@ -153,10 +153,10 @@ func writeNamedType(fw *common.MatlabFileWriter, td *dsl.NamedType) error { scalar := gt.ToScalar() fmt.Fprintf(w, "function a = %s(array) \n", common.TypeIdentifierName(td.Name)) common.WriteBlockBody(w, func() { + common.WriteComment(w, td.Comment) if !dsl.TypeContainsGenericTypeParameter(scalar) { fmt.Fprintf(w, "assert(isa(array, '%s'));\n", common.TypeSyntax(scalar, td.Namespace)) } - // fmt.Fprintf(w, "a = array;\n", common.TypeSyntax(td.Type, td.Namespace)) w.WriteStringln("a = array;") }) return @@ -165,54 +165,10 @@ func writeNamedType(fw *common.MatlabFileWriter, td *dsl.NamedType) error { // Otherwise, it's a subclass of the underlying type fmt.Fprintf(w, "classdef %s < %s\n", common.TypeIdentifierName(td.Name), common.TypeSyntax(td.Type, td.Namespace)) - w.WriteStringln("end") + common.WriteBlockBody(w, func() { + common.WriteComment(w, td.Comment) + }) }) - - // writeClassdefAlias := func() error { - // return fw.WriteFile(common.TypeIdentifierName(td.Name), func(w *formatting.IndentedWriter) { - // common.WriteComment(w, td.Comment) - // fmt.Fprintf(w, "classdef %s < %s\n", common.TypeIdentifierName(td.Name), common.TypeSyntax(td.Type, td.Namespace)) - // w.WriteStringln("end") - // }) - // } - - // writeFunctionAlias := func(t dsl.Type) error { - // return fw.WriteFile(common.TypeIdentifierName(td.Name), func(w *formatting.IndentedWriter) { - // common.WriteComment(w, td.Comment) - // fmt.Fprintf(w, "function c = %s(varargin) \n", common.TypeIdentifierName(td.Name)) - // common.WriteBlockBody(w, func() { - // if t == nil { - // w.WriteStringln("c = varargin{:};") - // } else { - // fmt.Fprintf(w, "c = %s(varargin{:});\n", common.TypeSyntax(t, td.Namespace)) - // } - // }) - // }) - // } - - // ut := dsl.GetUnderlyingType(td.Type) - // // If the underlying type is a RecordDefinition or Optional, we will generate a "function" alias - // if st, ok := ut.(*dsl.SimpleType); ok { - // if _, ok := st.ResolvedDefinition.(*dsl.RecordDefinition); ok { - // return writeFunctionAlias(td.Type) - // } - // } else if gt, ok := ut.(*dsl.GeneralizedType); ok { - // if gt.Cases.IsOptional() { - // return writeFunctionAlias(td.Type) - // } - - // switch gt.Dimensionality.(type) { - // case *dsl.Vector, *dsl.Array: - // // scalar := gt.ToScalar() - // // if dsl.TypeContainsGenericTypeParameter(scalar) { - // // return writeFunctionAlias(nil) - // // } - // // return writeFunctionAlias(scalar) - // return writeFunctionAlias(nil) - // } - // } - - // return writeClassdefAlias() } func writeEnum(fw *common.MatlabFileWriter, enum *dsl.EnumDefinition, namedType *dsl.NamedType) error { @@ -228,9 +184,9 @@ func writeEnum(fw *common.MatlabFileWriter, enum *dsl.EnumDefinition, namedType base = common.TypeSyntax(enum.BaseType, enum.Namespace) } - common.WriteComment(w, enum.Comment) fmt.Fprintf(w, "classdef %s < %s\n", enumName, base) common.WriteBlockBody(w, func() { + common.WriteComment(w, enum.Comment) w.WriteStringln("methods (Static)") common.WriteBlockBody(w, func() { for _, value := range enum.Values { @@ -250,10 +206,9 @@ func writeEnum(fw *common.MatlabFileWriter, enum *dsl.EnumDefinition, namedType func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl.SymbolTable) error { recordName := common.TypeIdentifierName(rec.Name) return fw.WriteFile(recordName, func(w *formatting.IndentedWriter) { - common.WriteComment(w, rec.Comment) - fmt.Fprintf(w, "classdef %s < handle\n", recordName) common.WriteBlockBody(w, func() { + common.WriteComment(w, rec.Comment) w.WriteStringln("properties") var fieldNames []string @@ -313,9 +268,9 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. for _, computedField := range rec.ComputedFields { fieldName := common.ComputedFieldIdentifierName(computedField.Name) - common.WriteComment(w, computedField.Comment) fmt.Fprintf(w, "function res = %s(self)\n", fieldName) common.WriteBlockBody(w, func() { + common.WriteComment(w, computedField.Comment) writeComputedFieldExpression(w, computedField.Expression, rec.Namespace) }) w.WriteStringln("") @@ -363,19 +318,17 @@ func writeZerosStaticMethod(w *formatting.IndentedWriter, typeSyntax string, def common.WriteBlockBody(w, func() { fmt.Fprintf(w, "elem = %s(%s);\n", typeSyntax, strings.Join(defaultArgs, ", ")) w.WriteStringln("if nargin == 0") - w.Indented(func() { + common.WriteBlockBody(w, func() { w.WriteStringln("z = elem;") + w.WriteStringln("return;") }) - w.WriteStringln("elseif nargin == 1") - w.Indented(func() { - w.WriteStringln("n = varargin{1};") - w.WriteStringln("z = reshape(repelem(elem, n*n), [n, n]);") - }) - w.WriteStringln("else") + + w.WriteStringln("sz = [varargin{:}];") + w.WriteStringln("if isscalar(sz)") common.WriteBlockBody(w, func() { - w.WriteStringln("sz = [varargin{:}];") - w.WriteStringln("z = reshape(repelem(elem, prod(sz)), sz);") + w.WriteStringln("sz = [sz, sz];") }) + w.WriteStringln("z = reshape(repelem(elem, prod(sz)), sz);") }) } From 67776b6a113e14785fbb5594d965acbf7150ddfc Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Wed, 27 Mar 2024 22:43:26 +0000 Subject: [PATCH 12/32] Finish implementing all C++/Python tests in Matlab All passing. Next: - Clean up the Vector/Array serializers - Add C++ translator to RoundTripTest - Finish fixing computed fields and ComputedFieldsTest - Documentation --- matlab/tests/RoundTripTest.m | 41 ++++++++++++------- .../+binary/DynamicNDArraySerializer.m | 39 ++++++++++++++---- .../+binary/FixedNDArraySerializer.m | 12 ++++-- .../+binary/FixedVectorSerializer.m | 6 ++- .../+binary/NDArraySerializerBase.m | 24 ++++------- .../static_files/+binary/StreamSerializer.m | 2 - .../static_files/+binary/VectorSerializer.m | 3 -- 7 files changed, 76 insertions(+), 51 deletions(-) diff --git a/matlab/tests/RoundTripTest.m b/matlab/tests/RoundTripTest.m index 5caf7f6d..95e3f0a7 100644 --- a/matlab/tests/RoundTripTest.m +++ b/matlab/tests/RoundTripTest.m @@ -145,8 +145,7 @@ function testFixedArrays(testCase, format) end function testSubarrays(testCase, format) - % TODO: Gotta figure out the (Python) subarray logic (in Matlab) - testCase.assumeFail(); + % TODO: Add checks for input validation errors (e.g. unexpected array shape). See Python tests. w = create_validating_writer(testCase, format, 'Subarrays'); @@ -168,28 +167,40 @@ function testSubarrays(testCase, format) floats = transpose(single([[1, 2, 3]; [4, 5, 6]])); w.write_fixed_with_fixed_float_subarray(floats); - ints = transpose(int32([... - [[1, 2, 3]; [4, 5, 6]]; ... - [[10, 20, 30]; [40, 50, 60]]; ... - [[100, 200, 300]; [400, 500, 600]] ... - ])); - w.write_nested_subarray(ints); + nested(:, :, 1) = int32([[1; 2; 3], [4; 5; 6]]); + nested(:, :, 2) = [[10; 20; 30], [40; 50; 60]]; + nested(:, :, 3) = [[100; 200; 300], [400; 500; 600]]; + w.write_nested_subarray(nested); ints = transpose(int32([[1, 2, 3]; [4, 5, 6]])); w.write_dynamic_with_fixed_vector_subarray(ints); - images = transpose(int32([... - [[1, 2, 3]; [4, 5, 6]]; ... - [[10, 11, 12]; [13, 14, 15]]; ... - ])); - w.write_generic_subarray(images); + image(:, 1, 1) = int32([1; 2; 3]); + image(:, 1, 2) = [4; 5; 6]; + image(:, 2, 1) = [10; 11; 12]; + image(:, 2, 2) = [13; 14; 15]; + w.write_generic_subarray(image); w.close(); end function testSubarraysInRecords(testCase, format) - % TODO: Gotta figure out the (Python) subarray logic (in Matlab) - testCase.assumeFail(); + RF = @test_model.RecordWithFixedCollections; + records_with_fixed = [... + RF(int32([1, 2, 3]), int32([[11; 12; 13], [14; 15; 16]])), ... + RF(int32([101, 102, 103]), int32([[1011; 1012; 1013], [1014; 1015; 1016]])), ... + ]; + + RV = @test_model.RecordWithVlenCollections; + records_with_vlens = [... + RV(int32([1, 2, 3]), int32([[11, 12, 13]; [14, 15, 16]])), ...]) + RV(int32([101, 102, 103]), int32([[1011, 1012, 1013]; [1014, 1015, 1016]])), ... + ]; + + w = create_validating_writer(testCase, format, 'SubarraysInRecords'); + w.write_with_fixed_subarrays(records_with_fixed); + w.write_with_vlen_subarrays(records_with_vlens); + w.close(); end function testNDArrays(testCase, format) diff --git a/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m index 769973b2..baa52ec1 100644 --- a/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m @@ -5,23 +5,44 @@ self@yardl.binary.NDArraySerializerBase(item_serializer); end - function write(self, outstream, value) - outstream.write_unsigned_varint(ndims(value)); - for dim = ndims(value): -1: 1 - len = size(value, dim); - outstream.write_unsigned_varint(len); + function write(self, outstream, values) + + item_shape = self.item_serializer_.getShape(); + + shape = size(values); + if isempty(item_shape) + % values is an array of variable-length vectors or arrays + values = values(:); + + elseif isscalar(item_shape) + % values is an array of scalars + values = values(:); + + else + % values is an array of fixed-length vectors or arrays + item_shape = item_shape(item_shape > 1); + outer_shape = shape(length(item_shape) + 1:end); + values = reshape(values, [item_shape prod(outer_shape)]); + shape = outer_shape; + end + + outstream.write_unsigned_varint(length(shape)); + flipped_shape = flip(shape); + for dim = 1:length(flipped_shape) + outstream.write_unsigned_varint(flipped_shape(dim)); end - self.write_data_(outstream, value); + self.write_data_(outstream, values); end function value = read(self, instream) ndims = instream.read_unsigned_varint(); - shape = zeros(1, ndims); + flipped_shape = zeros(1, ndims); for dim = 1:ndims - shape(dim) = instream.read_unsigned_varint(); + flipped_shape(dim) = instream.read_unsigned_varint(); end - value = self.read_data_(instream, flip(shape)); + shape = flip(flipped_shape); + value = self.read_data_(instream, shape); end end end diff --git a/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m index aa1abb1a..71612628 100644 --- a/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m @@ -13,7 +13,7 @@ function write(self, outstream, values) sz = size(values); - if sz == self.shape_ + if numel(values) == prod(self.shape_) % This is an NDArray of scalars self.write_data_(outstream, values(:)); return; @@ -39,7 +39,13 @@ function write(self, outstream, values) end function value = read(self, instream) - value = self.read_data_(instream, self.shape_); + % TODO: Better way of doing this? Possibly needed elsewhere to? + % self.shape_ should really be non-scalar... + if isscalar(self.shape_) + value = self.read_data_(instream, [1 self.shape_]); + else + value = self.read_data_(instream, self.shape_); + end end function s = getShape(obj) @@ -47,7 +53,7 @@ function write(self, outstream, values) if isempty(item_shape) s = obj.shape_; elseif isscalar(item_shape) - s = obj.shape_; + s = [item_shape obj.shape_ ]; else s = [item_shape obj.shape_]; s = s(s>1); diff --git a/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m b/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m index 6d7823c9..20128be5 100644 --- a/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m @@ -11,6 +11,10 @@ end function write(obj, outstream, values) + if iscolumn(values) + values = transpose(values); + end + s = size(values); count = s(end); @@ -47,13 +51,11 @@ function write(obj, outstream, values) res{i} = obj.item_serializer_.read(instream); end elseif isscalar(item_shape) - % res = zeros(obj.getShape(), obj.getClass()); res = yardl.allocate(obj.getClass(), obj.getShape()); for i = 1:obj.length_ res(i) = obj.item_serializer_.read(instream); end else - % res = zeros([prod(item_shape), obj.length_], obj.getClass()); res = yardl.allocate(obj.getClass(), [prod(item_shape), obj.length_]); for i = 1:obj.length_ item = obj.item_serializer_.read(instream); diff --git a/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m b/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m index 407f6563..f00baaf2 100644 --- a/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m +++ b/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m @@ -11,12 +11,6 @@ methods (Access=protected) function self = NDArraySerializerBase(item_serializer) - % if isa(item_serializer, 'yardl.binary.FixedNDArraySerializer') || ... - % isa(item_serializer, 'yardl.binary.FixedVectorSerializer') - % self.item_serializer_ = item_serializer.item_serializer_; - % else - % self.item_serializer_ = item_serializer; - % end self.item_serializer_ = item_serializer; end @@ -35,7 +29,7 @@ function write_data_(self, outstream, values) val = reshape(r(:, i), inner_shape); self.item_serializer_.write(outstream, val); end - else + elseif isrow(values) || iscolumn(values) count = prod(sz); if iscell(values) for i = 1:count @@ -46,6 +40,12 @@ function write_data_(self, outstream, values) self.item_serializer_.write(outstream, values(i)); end end + else + assert(ismatrix(values)); + count = sz(end); + for i = 1:count + self.item_serializer_.write(outstream, values(:, i)); + end end end @@ -60,14 +60,12 @@ function write_data_(self, outstream, values) res{i} = self.item_serializer_.read(instream); end elseif isscalar(item_shape) - % res = zeros(shape, self.getClass()); res = yardl.allocate(self.getClass(), shape); for i = 1:flat_length res(i) = self.item_serializer_.read(instream); end res = squeeze(res); else - % res = zeros([prod(item_shape), flat_length], self.getClass()); res = yardl.allocate(self.getClass(), [prod(item_shape), flat_length]); for i = 1:flat_length item = self.item_serializer_.read(instream); @@ -75,14 +73,6 @@ function write_data_(self, outstream, values) end res = squeeze(reshape(res, [item_shape shape])); end - - % for i = 1:flat_length - % value(i) = self.item_serializer_.read(instream); - % end - - % if length(shape) > 1 - % value = reshape(value, shape); - % end end end diff --git a/tooling/internal/matlab/static_files/+binary/StreamSerializer.m b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m index 979a726c..282db4bd 100644 --- a/tooling/internal/matlab/static_files/+binary/StreamSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m @@ -54,7 +54,6 @@ function write(obj, outstream, values) count = instream.read_unsigned_varint(); end elseif isscalar(item_shape) - % res = zeros([item_shape, count], obj.getClass()); res = yardl.allocate(obj.getClass(), [item_shape, count]); idx = 1; while count > 0 @@ -65,7 +64,6 @@ function write(obj, outstream, values) count = instream.read_unsigned_varint(); end else - % res = zeros([prod(item_shape), count], obj.getClass()); res = yardl.allocate(obj.getClass(), [prod(item_shape), count]); total_count = 0; while count > 0 diff --git a/tooling/internal/matlab/static_files/+binary/VectorSerializer.m b/tooling/internal/matlab/static_files/+binary/VectorSerializer.m index 10079fe7..8d1563c9 100644 --- a/tooling/internal/matlab/static_files/+binary/VectorSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/VectorSerializer.m @@ -39,7 +39,6 @@ function write(obj, outstream, values) function res = read(obj, instream) count = instream.read_unsigned_varint(); if count == 0 - % res = zeros(0, obj.getClass()); res = yardl.allocate(obj.getClass(), 0); return; end @@ -51,14 +50,12 @@ function write(obj, outstream, values) res{i} = obj.item_serializer_.read(instream); end elseif isscalar(item_shape) - % res = zeros([1 count], obj.getClass()); res = yardl.allocate(obj.getClass(), [1 count]); for i = 1:count res(i) = obj.item_serializer_.read(instream); end res = squeeze(res); else - % res = zeros([prod(item_shape), count], obj.getClass()); res = yardl.allocate(obj.getClass(), [prod(item_shape), count]); for i = 1:count item = obj.item_serializer_.read(instream); From d8c573e55e10036493edcaa0e2ce0df8b106e0c3 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Fri, 29 Mar 2024 14:05:18 +0000 Subject: [PATCH 13/32] Add translator to/from C++ to Matlab RoundTripTest --- .../+testing/MockAdvancedGenericsWriter.m | 47 +++++++--- .../+test_model/+testing/MockAliasesWriter.m | 92 ++++++++++++++----- .../MockBenchmarkFloat256x256Writer.m | 11 ++- .../+testing/MockBenchmarkFloatVlenWriter.m | 11 ++- .../+testing/MockBenchmarkInt256x256Writer.m | 11 ++- .../+testing/MockBenchmarkSimpleMrdWriter.m | 11 ++- ...kBenchmarkSmallRecordWithOptionalsWriter.m | 11 ++- .../+testing/MockBenchmarkSmallRecordWriter.m | 11 ++- .../+testing/MockDynamicNDArraysWriter.m | 38 ++++++-- .../+test_model/+testing/MockEnumsWriter.m | 29 ++++-- .../+testing/MockFixedArraysWriter.m | 47 +++++++--- .../+testing/MockFixedVectorsWriter.m | 38 ++++++-- .../+test_model/+testing/MockFlagsWriter.m | 20 +++- .../+test_model/+testing/MockMapsWriter.m | 38 ++++++-- .../MockNDArraysSingleDimensionWriter.m | 38 ++++++-- .../+test_model/+testing/MockNDArraysWriter.m | 47 +++++++--- .../+testing/MockNestedRecordsWriter.m | 11 ++- .../+testing/MockOptionalVectorsWriter.m | 11 ++- .../MockProtocolWithComputedFieldsWriter.m | 11 ++- .../MockProtocolWithKeywordStepsWriter.m | 20 +++- .../+testing/MockScalarOptionalsWriter.m | 38 ++++++-- .../+test_model/+testing/MockScalarsWriter.m | 20 +++- .../+testing/MockSimpleGenericsWriter.m | 83 +++++++++++++---- .../+testing/MockStateTestWriter.m | 29 ++++-- .../MockStreamsOfAliasedUnionsWriter.m | 20 +++- .../+testing/MockStreamsOfUnionsWriter.m | 20 +++- .../+test_model/+testing/MockStreamsWriter.m | 38 ++++++-- .../+test_model/+testing/MockStringsWriter.m | 20 +++- .../+testing/MockSubarraysInRecordsWriter.m | 20 +++- .../+testing/MockSubarraysWriter.m | 83 +++++++++++++---- .../+test_model/+testing/MockUnionsWriter.m | 38 ++++++-- .../+test_model/+testing/MockVlensWriter.m | 38 ++++++-- .../+testing/TestAdvancedGenericsWriter.m | 22 ++++- .../+test_model/+testing/TestAliasesWriter.m | 22 ++++- .../TestBenchmarkFloat256x256Writer.m | 22 ++++- .../+testing/TestBenchmarkFloatVlenWriter.m | 22 ++++- .../+testing/TestBenchmarkInt256x256Writer.m | 22 ++++- .../+testing/TestBenchmarkSimpleMrdWriter.m | 22 ++++- ...tBenchmarkSmallRecordWithOptionalsWriter.m | 22 ++++- .../+testing/TestBenchmarkSmallRecordWriter.m | 22 ++++- .../+testing/TestDynamicNDArraysWriter.m | 22 ++++- .../+test_model/+testing/TestEnumsWriter.m | 22 ++++- .../+testing/TestFixedArraysWriter.m | 22 ++++- .../+testing/TestFixedVectorsWriter.m | 22 ++++- .../+test_model/+testing/TestFlagsWriter.m | 22 ++++- .../+test_model/+testing/TestMapsWriter.m | 22 ++++- .../TestNDArraysSingleDimensionWriter.m | 22 ++++- .../+test_model/+testing/TestNDArraysWriter.m | 22 ++++- .../+testing/TestNestedRecordsWriter.m | 22 ++++- .../+testing/TestOptionalVectorsWriter.m | 22 ++++- .../TestProtocolWithComputedFieldsWriter.m | 22 ++++- .../TestProtocolWithKeywordStepsWriter.m | 22 ++++- .../+testing/TestScalarOptionalsWriter.m | 22 ++++- .../+test_model/+testing/TestScalarsWriter.m | 22 ++++- .../+testing/TestSimpleGenericsWriter.m | 22 ++++- .../+testing/TestStateTestWriter.m | 22 ++++- .../TestStreamsOfAliasedUnionsWriter.m | 22 ++++- .../+testing/TestStreamsOfUnionsWriter.m | 22 ++++- .../+test_model/+testing/TestStreamsWriter.m | 22 ++++- .../+test_model/+testing/TestStringsWriter.m | 22 ++++- .../+testing/TestSubarraysInRecordsWriter.m | 22 ++++- .../+testing/TestSubarraysWriter.m | 22 ++++- .../+test_model/+testing/TestUnionsWriter.m | 22 ++++- .../+test_model/+testing/TestVlensWriter.m | 22 ++++- matlab/tests/RoundTripTest.m | 24 +++-- matlab/tests/invoke_translator.m | 15 +++ tooling/internal/matlab/mocks/mocks.go | 60 +++++++----- .../+binary/FixedNDArraySerializer.m | 3 + .../static_files/+binary/StreamSerializer.m | 4 + 69 files changed, 1441 insertions(+), 369 deletions(-) create mode 100644 matlab/tests/invoke_translator.m diff --git a/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m b/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m index 6b6aef3e..0bfdedde 100644 --- a/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockAdvancedGenericsWriter < test_model.AdvancedGenericsWriterBase +classdef MockAdvancedGenericsWriter < matlab.mixin.Copyable & test_model.AdvancedGenericsWriterBase properties testCase_ write_float_image_image_written @@ -21,23 +21,48 @@ end function expect_write_float_image_image_(obj, value) - obj.write_float_image_image_written(end+1) = Node(value); + if isempty(obj.write_float_image_image_written) + obj.write_float_image_image_written = Node(value); + else + last_dim = ndims(value); + obj.write_float_image_image_written = Node(cat(last_dim, obj.write_float_image_image_written(1).value, value)); + end end function expect_write_generic_record_1_(obj, value) - obj.write_generic_record_1_written(end+1) = Node(value); + if isempty(obj.write_generic_record_1_written) + obj.write_generic_record_1_written = Node(value); + else + last_dim = ndims(value); + obj.write_generic_record_1_written = Node(cat(last_dim, obj.write_generic_record_1_written(1).value, value)); + end end function expect_write_tuple_of_optionals_(obj, value) - obj.write_tuple_of_optionals_written(end+1) = Node(value); + if isempty(obj.write_tuple_of_optionals_written) + obj.write_tuple_of_optionals_written = Node(value); + else + last_dim = ndims(value); + obj.write_tuple_of_optionals_written = Node(cat(last_dim, obj.write_tuple_of_optionals_written(1).value, value)); + end end function expect_write_tuple_of_optionals_alternate_syntax_(obj, value) - obj.write_tuple_of_optionals_alternate_syntax_written(end+1) = Node(value); + if isempty(obj.write_tuple_of_optionals_alternate_syntax_written) + obj.write_tuple_of_optionals_alternate_syntax_written = Node(value); + else + last_dim = ndims(value); + obj.write_tuple_of_optionals_alternate_syntax_written = Node(cat(last_dim, obj.write_tuple_of_optionals_alternate_syntax_written(1).value, value)); + end end function expect_write_tuple_of_vectors_(obj, value) - obj.write_tuple_of_vectors_written(end+1) = Node(value); + if isempty(obj.write_tuple_of_vectors_written) + obj.write_tuple_of_vectors_written = Node(value); + else + last_dim = ndims(value); + obj.write_tuple_of_vectors_written = Node(cat(last_dim, obj.write_tuple_of_vectors_written(1).value, value)); + end end function verify(obj) @@ -54,35 +79,35 @@ function write_float_image_image_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_float_image_image_written), "Unexpected call to write_float_image_image_"); expected = obj.write_float_image_image_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_image_image_"); - obj.write_float_image_image_written = obj.write_float_image_image_written(2:end); + obj.write_float_image_image_written = Node.empty(); end function write_generic_record_1_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_generic_record_1_written), "Unexpected call to write_generic_record_1_"); expected = obj.write_generic_record_1_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_generic_record_1_"); - obj.write_generic_record_1_written = obj.write_generic_record_1_written(2:end); + obj.write_generic_record_1_written = Node.empty(); end function write_tuple_of_optionals_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_tuple_of_optionals_written), "Unexpected call to write_tuple_of_optionals_"); expected = obj.write_tuple_of_optionals_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_of_optionals_"); - obj.write_tuple_of_optionals_written = obj.write_tuple_of_optionals_written(2:end); + obj.write_tuple_of_optionals_written = Node.empty(); end function write_tuple_of_optionals_alternate_syntax_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_tuple_of_optionals_alternate_syntax_written), "Unexpected call to write_tuple_of_optionals_alternate_syntax_"); expected = obj.write_tuple_of_optionals_alternate_syntax_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_of_optionals_alternate_syntax_"); - obj.write_tuple_of_optionals_alternate_syntax_written = obj.write_tuple_of_optionals_alternate_syntax_written(2:end); + obj.write_tuple_of_optionals_alternate_syntax_written = Node.empty(); end function write_tuple_of_vectors_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_tuple_of_vectors_written), "Unexpected call to write_tuple_of_vectors_"); expected = obj.write_tuple_of_vectors_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_of_vectors_"); - obj.write_tuple_of_vectors_written = obj.write_tuple_of_vectors_written(2:end); + obj.write_tuple_of_vectors_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockAliasesWriter.m b/matlab/generated/+test_model/+testing/MockAliasesWriter.m index b1794fec..e1025cd4 100644 --- a/matlab/generated/+test_model/+testing/MockAliasesWriter.m +++ b/matlab/generated/+test_model/+testing/MockAliasesWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockAliasesWriter < test_model.AliasesWriterBase +classdef MockAliasesWriter < matlab.mixin.Copyable & test_model.AliasesWriterBase properties testCase_ write_aliased_string_written @@ -31,43 +31,93 @@ end function expect_write_aliased_string_(obj, value) - obj.write_aliased_string_written(end+1) = Node(value); + if isempty(obj.write_aliased_string_written) + obj.write_aliased_string_written = Node(value); + else + last_dim = ndims(value); + obj.write_aliased_string_written = Node(cat(last_dim, obj.write_aliased_string_written(1).value, value)); + end end function expect_write_aliased_enum_(obj, value) - obj.write_aliased_enum_written(end+1) = Node(value); + if isempty(obj.write_aliased_enum_written) + obj.write_aliased_enum_written = Node(value); + else + last_dim = ndims(value); + obj.write_aliased_enum_written = Node(cat(last_dim, obj.write_aliased_enum_written(1).value, value)); + end end function expect_write_aliased_open_generic_(obj, value) - obj.write_aliased_open_generic_written(end+1) = Node(value); + if isempty(obj.write_aliased_open_generic_written) + obj.write_aliased_open_generic_written = Node(value); + else + last_dim = ndims(value); + obj.write_aliased_open_generic_written = Node(cat(last_dim, obj.write_aliased_open_generic_written(1).value, value)); + end end function expect_write_aliased_closed_generic_(obj, value) - obj.write_aliased_closed_generic_written(end+1) = Node(value); + if isempty(obj.write_aliased_closed_generic_written) + obj.write_aliased_closed_generic_written = Node(value); + else + last_dim = ndims(value); + obj.write_aliased_closed_generic_written = Node(cat(last_dim, obj.write_aliased_closed_generic_written(1).value, value)); + end end function expect_write_aliased_optional_(obj, value) - obj.write_aliased_optional_written(end+1) = Node(value); + if isempty(obj.write_aliased_optional_written) + obj.write_aliased_optional_written = Node(value); + else + last_dim = ndims(value); + obj.write_aliased_optional_written = Node(cat(last_dim, obj.write_aliased_optional_written(1).value, value)); + end end function expect_write_aliased_generic_optional_(obj, value) - obj.write_aliased_generic_optional_written(end+1) = Node(value); + if isempty(obj.write_aliased_generic_optional_written) + obj.write_aliased_generic_optional_written = Node(value); + else + last_dim = ndims(value); + obj.write_aliased_generic_optional_written = Node(cat(last_dim, obj.write_aliased_generic_optional_written(1).value, value)); + end end function expect_write_aliased_generic_union_2_(obj, value) - obj.write_aliased_generic_union_2_written(end+1) = Node(value); + if isempty(obj.write_aliased_generic_union_2_written) + obj.write_aliased_generic_union_2_written = Node(value); + else + last_dim = ndims(value); + obj.write_aliased_generic_union_2_written = Node(cat(last_dim, obj.write_aliased_generic_union_2_written(1).value, value)); + end end function expect_write_aliased_generic_vector_(obj, value) - obj.write_aliased_generic_vector_written(end+1) = Node(value); + if isempty(obj.write_aliased_generic_vector_written) + obj.write_aliased_generic_vector_written = Node(value); + else + last_dim = ndims(value); + obj.write_aliased_generic_vector_written = Node(cat(last_dim, obj.write_aliased_generic_vector_written(1).value, value)); + end end function expect_write_aliased_generic_fixed_vector_(obj, value) - obj.write_aliased_generic_fixed_vector_written(end+1) = Node(value); + if isempty(obj.write_aliased_generic_fixed_vector_written) + obj.write_aliased_generic_fixed_vector_written = Node(value); + else + last_dim = ndims(value); + obj.write_aliased_generic_fixed_vector_written = Node(cat(last_dim, obj.write_aliased_generic_fixed_vector_written(1).value, value)); + end end function expect_write_stream_of_aliased_generic_union_2_(obj, value) - obj.write_stream_of_aliased_generic_union_2_written(end+1) = Node(value); + if isempty(obj.write_stream_of_aliased_generic_union_2_written) + obj.write_stream_of_aliased_generic_union_2_written = Node(value); + else + last_dim = ndims(value); + obj.write_stream_of_aliased_generic_union_2_written = Node(cat(last_dim, obj.write_stream_of_aliased_generic_union_2_written(1).value, value)); + end end function verify(obj) @@ -89,70 +139,70 @@ function write_aliased_string_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_aliased_string_written), "Unexpected call to write_aliased_string_"); expected = obj.write_aliased_string_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_string_"); - obj.write_aliased_string_written = obj.write_aliased_string_written(2:end); + obj.write_aliased_string_written = Node.empty(); end function write_aliased_enum_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_aliased_enum_written), "Unexpected call to write_aliased_enum_"); expected = obj.write_aliased_enum_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_enum_"); - obj.write_aliased_enum_written = obj.write_aliased_enum_written(2:end); + obj.write_aliased_enum_written = Node.empty(); end function write_aliased_open_generic_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_aliased_open_generic_written), "Unexpected call to write_aliased_open_generic_"); expected = obj.write_aliased_open_generic_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_open_generic_"); - obj.write_aliased_open_generic_written = obj.write_aliased_open_generic_written(2:end); + obj.write_aliased_open_generic_written = Node.empty(); end function write_aliased_closed_generic_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_aliased_closed_generic_written), "Unexpected call to write_aliased_closed_generic_"); expected = obj.write_aliased_closed_generic_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_closed_generic_"); - obj.write_aliased_closed_generic_written = obj.write_aliased_closed_generic_written(2:end); + obj.write_aliased_closed_generic_written = Node.empty(); end function write_aliased_optional_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_aliased_optional_written), "Unexpected call to write_aliased_optional_"); expected = obj.write_aliased_optional_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_optional_"); - obj.write_aliased_optional_written = obj.write_aliased_optional_written(2:end); + obj.write_aliased_optional_written = Node.empty(); end function write_aliased_generic_optional_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_aliased_generic_optional_written), "Unexpected call to write_aliased_generic_optional_"); expected = obj.write_aliased_generic_optional_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_optional_"); - obj.write_aliased_generic_optional_written = obj.write_aliased_generic_optional_written(2:end); + obj.write_aliased_generic_optional_written = Node.empty(); end function write_aliased_generic_union_2_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_aliased_generic_union_2_written), "Unexpected call to write_aliased_generic_union_2_"); expected = obj.write_aliased_generic_union_2_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_union_2_"); - obj.write_aliased_generic_union_2_written = obj.write_aliased_generic_union_2_written(2:end); + obj.write_aliased_generic_union_2_written = Node.empty(); end function write_aliased_generic_vector_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_aliased_generic_vector_written), "Unexpected call to write_aliased_generic_vector_"); expected = obj.write_aliased_generic_vector_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_vector_"); - obj.write_aliased_generic_vector_written = obj.write_aliased_generic_vector_written(2:end); + obj.write_aliased_generic_vector_written = Node.empty(); end function write_aliased_generic_fixed_vector_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_aliased_generic_fixed_vector_written), "Unexpected call to write_aliased_generic_fixed_vector_"); expected = obj.write_aliased_generic_fixed_vector_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_fixed_vector_"); - obj.write_aliased_generic_fixed_vector_written = obj.write_aliased_generic_fixed_vector_written(2:end); + obj.write_aliased_generic_fixed_vector_written = Node.empty(); end function write_stream_of_aliased_generic_union_2_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_stream_of_aliased_generic_union_2_written), "Unexpected call to write_stream_of_aliased_generic_union_2_"); expected = obj.write_stream_of_aliased_generic_union_2_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_stream_of_aliased_generic_union_2_"); - obj.write_stream_of_aliased_generic_union_2_written = obj.write_stream_of_aliased_generic_union_2_written(2:end); + obj.write_stream_of_aliased_generic_union_2_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m index 1b038d1f..321eba25 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockBenchmarkFloat256x256Writer < test_model.BenchmarkFloat256x256WriterBase +classdef MockBenchmarkFloat256x256Writer < matlab.mixin.Copyable & test_model.BenchmarkFloat256x256WriterBase properties testCase_ write_float256x256_written @@ -13,7 +13,12 @@ end function expect_write_float256x256_(obj, value) - obj.write_float256x256_written(end+1) = Node(value); + if isempty(obj.write_float256x256_written) + obj.write_float256x256_written = Node(value); + else + last_dim = ndims(value); + obj.write_float256x256_written = Node(cat(last_dim, obj.write_float256x256_written(1).value, value)); + end end function verify(obj) @@ -26,7 +31,7 @@ function write_float256x256_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_float256x256_written), "Unexpected call to write_float256x256_"); expected = obj.write_float256x256_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float256x256_"); - obj.write_float256x256_written = obj.write_float256x256_written(2:end); + obj.write_float256x256_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m index 755553bb..aa92a6ac 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockBenchmarkFloatVlenWriter < test_model.BenchmarkFloatVlenWriterBase +classdef MockBenchmarkFloatVlenWriter < matlab.mixin.Copyable & test_model.BenchmarkFloatVlenWriterBase properties testCase_ write_float_array_written @@ -13,7 +13,12 @@ end function expect_write_float_array_(obj, value) - obj.write_float_array_written(end+1) = Node(value); + if isempty(obj.write_float_array_written) + obj.write_float_array_written = Node(value); + else + last_dim = ndims(value); + obj.write_float_array_written = Node(cat(last_dim, obj.write_float_array_written(1).value, value)); + end end function verify(obj) @@ -26,7 +31,7 @@ function write_float_array_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_float_array_written), "Unexpected call to write_float_array_"); expected = obj.write_float_array_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_array_"); - obj.write_float_array_written = obj.write_float_array_written(2:end); + obj.write_float_array_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m index 934c6956..8c5b2ceb 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockBenchmarkInt256x256Writer < test_model.BenchmarkInt256x256WriterBase +classdef MockBenchmarkInt256x256Writer < matlab.mixin.Copyable & test_model.BenchmarkInt256x256WriterBase properties testCase_ write_int256x256_written @@ -13,7 +13,12 @@ end function expect_write_int256x256_(obj, value) - obj.write_int256x256_written(end+1) = Node(value); + if isempty(obj.write_int256x256_written) + obj.write_int256x256_written = Node(value); + else + last_dim = ndims(value); + obj.write_int256x256_written = Node(cat(last_dim, obj.write_int256x256_written(1).value, value)); + end end function verify(obj) @@ -26,7 +31,7 @@ function write_int256x256_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_int256x256_written), "Unexpected call to write_int256x256_"); expected = obj.write_int256x256_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int256x256_"); - obj.write_int256x256_written = obj.write_int256x256_written(2:end); + obj.write_int256x256_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m index bb6f03d7..9649bf9d 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockBenchmarkSimpleMrdWriter < test_model.BenchmarkSimpleMrdWriterBase +classdef MockBenchmarkSimpleMrdWriter < matlab.mixin.Copyable & test_model.BenchmarkSimpleMrdWriterBase properties testCase_ write_data_written @@ -13,7 +13,12 @@ end function expect_write_data_(obj, value) - obj.write_data_written(end+1) = Node(value); + if isempty(obj.write_data_written) + obj.write_data_written = Node(value); + else + last_dim = ndims(value); + obj.write_data_written = Node(cat(last_dim, obj.write_data_written(1).value, value)); + end end function verify(obj) @@ -26,7 +31,7 @@ function write_data_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_data_written), "Unexpected call to write_data_"); expected = obj.write_data_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_data_"); - obj.write_data_written = obj.write_data_written(2:end); + obj.write_data_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m index 2a627c5c..8040507d 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockBenchmarkSmallRecordWithOptionalsWriter < test_model.BenchmarkSmallRecordWithOptionalsWriterBase +classdef MockBenchmarkSmallRecordWithOptionalsWriter < matlab.mixin.Copyable & test_model.BenchmarkSmallRecordWithOptionalsWriterBase properties testCase_ write_small_record_written @@ -13,7 +13,12 @@ end function expect_write_small_record_(obj, value) - obj.write_small_record_written(end+1) = Node(value); + if isempty(obj.write_small_record_written) + obj.write_small_record_written = Node(value); + else + last_dim = ndims(value); + obj.write_small_record_written = Node(cat(last_dim, obj.write_small_record_written(1).value, value)); + end end function verify(obj) @@ -26,7 +31,7 @@ function write_small_record_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_small_record_written), "Unexpected call to write_small_record_"); expected = obj.write_small_record_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_small_record_"); - obj.write_small_record_written = obj.write_small_record_written(2:end); + obj.write_small_record_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m index 7185c585..6ec0d87a 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockBenchmarkSmallRecordWriter < test_model.BenchmarkSmallRecordWriterBase +classdef MockBenchmarkSmallRecordWriter < matlab.mixin.Copyable & test_model.BenchmarkSmallRecordWriterBase properties testCase_ write_small_record_written @@ -13,7 +13,12 @@ end function expect_write_small_record_(obj, value) - obj.write_small_record_written(end+1) = Node(value); + if isempty(obj.write_small_record_written) + obj.write_small_record_written = Node(value); + else + last_dim = ndims(value); + obj.write_small_record_written = Node(cat(last_dim, obj.write_small_record_written(1).value, value)); + end end function verify(obj) @@ -26,7 +31,7 @@ function write_small_record_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_small_record_written), "Unexpected call to write_small_record_"); expected = obj.write_small_record_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_small_record_"); - obj.write_small_record_written = obj.write_small_record_written(2:end); + obj.write_small_record_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m b/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m index 6a080ea7..5be1ddf0 100644 --- a/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockDynamicNDArraysWriter < test_model.DynamicNDArraysWriterBase +classdef MockDynamicNDArraysWriter < matlab.mixin.Copyable & test_model.DynamicNDArraysWriterBase properties testCase_ write_ints_written @@ -19,19 +19,39 @@ end function expect_write_ints_(obj, value) - obj.write_ints_written(end+1) = Node(value); + if isempty(obj.write_ints_written) + obj.write_ints_written = Node(value); + else + last_dim = ndims(value); + obj.write_ints_written = Node(cat(last_dim, obj.write_ints_written(1).value, value)); + end end function expect_write_simple_record_array_(obj, value) - obj.write_simple_record_array_written(end+1) = Node(value); + if isempty(obj.write_simple_record_array_written) + obj.write_simple_record_array_written = Node(value); + else + last_dim = ndims(value); + obj.write_simple_record_array_written = Node(cat(last_dim, obj.write_simple_record_array_written(1).value, value)); + end end function expect_write_record_with_vlens_array_(obj, value) - obj.write_record_with_vlens_array_written(end+1) = Node(value); + if isempty(obj.write_record_with_vlens_array_written) + obj.write_record_with_vlens_array_written = Node(value); + else + last_dim = ndims(value); + obj.write_record_with_vlens_array_written = Node(cat(last_dim, obj.write_record_with_vlens_array_written(1).value, value)); + end end function expect_write_record_with_dynamic_nd_arrays_(obj, value) - obj.write_record_with_dynamic_nd_arrays_written(end+1) = Node(value); + if isempty(obj.write_record_with_dynamic_nd_arrays_written) + obj.write_record_with_dynamic_nd_arrays_written = Node(value); + else + last_dim = ndims(value); + obj.write_record_with_dynamic_nd_arrays_written = Node(cat(last_dim, obj.write_record_with_dynamic_nd_arrays_written(1).value, value)); + end end function verify(obj) @@ -47,28 +67,28 @@ function write_ints_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_ints_written), "Unexpected call to write_ints_"); expected = obj.write_ints_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); - obj.write_ints_written = obj.write_ints_written(2:end); + obj.write_ints_written = Node.empty(); end function write_simple_record_array_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_simple_record_array_written), "Unexpected call to write_simple_record_array_"); expected = obj.write_simple_record_array_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_simple_record_array_"); - obj.write_simple_record_array_written = obj.write_simple_record_array_written(2:end); + obj.write_simple_record_array_written = Node.empty(); end function write_record_with_vlens_array_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_record_with_vlens_array_written), "Unexpected call to write_record_with_vlens_array_"); expected = obj.write_record_with_vlens_array_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_array_"); - obj.write_record_with_vlens_array_written = obj.write_record_with_vlens_array_written(2:end); + obj.write_record_with_vlens_array_written = Node.empty(); end function write_record_with_dynamic_nd_arrays_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_record_with_dynamic_nd_arrays_written), "Unexpected call to write_record_with_dynamic_nd_arrays_"); expected = obj.write_record_with_dynamic_nd_arrays_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_dynamic_nd_arrays_"); - obj.write_record_with_dynamic_nd_arrays_written = obj.write_record_with_dynamic_nd_arrays_written(2:end); + obj.write_record_with_dynamic_nd_arrays_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockEnumsWriter.m b/matlab/generated/+test_model/+testing/MockEnumsWriter.m index e5b15330..bb4394b7 100644 --- a/matlab/generated/+test_model/+testing/MockEnumsWriter.m +++ b/matlab/generated/+test_model/+testing/MockEnumsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockEnumsWriter < test_model.EnumsWriterBase +classdef MockEnumsWriter < matlab.mixin.Copyable & test_model.EnumsWriterBase properties testCase_ write_single_written @@ -17,15 +17,30 @@ end function expect_write_single_(obj, value) - obj.write_single_written(end+1) = Node(value); + if isempty(obj.write_single_written) + obj.write_single_written = Node(value); + else + last_dim = ndims(value); + obj.write_single_written = Node(cat(last_dim, obj.write_single_written(1).value, value)); + end end function expect_write_vec_(obj, value) - obj.write_vec_written(end+1) = Node(value); + if isempty(obj.write_vec_written) + obj.write_vec_written = Node(value); + else + last_dim = ndims(value); + obj.write_vec_written = Node(cat(last_dim, obj.write_vec_written(1).value, value)); + end end function expect_write_size_(obj, value) - obj.write_size_written(end+1) = Node(value); + if isempty(obj.write_size_written) + obj.write_size_written = Node(value); + else + last_dim = ndims(value); + obj.write_size_written = Node(cat(last_dim, obj.write_size_written(1).value, value)); + end end function verify(obj) @@ -40,21 +55,21 @@ function write_single_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_single_written), "Unexpected call to write_single_"); expected = obj.write_single_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_single_"); - obj.write_single_written = obj.write_single_written(2:end); + obj.write_single_written = Node.empty(); end function write_vec_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_vec_written), "Unexpected call to write_vec_"); expected = obj.write_vec_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_vec_"); - obj.write_vec_written = obj.write_vec_written(2:end); + obj.write_vec_written = Node.empty(); end function write_size_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_size_written), "Unexpected call to write_size_"); expected = obj.write_size_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_size_"); - obj.write_size_written = obj.write_size_written(2:end); + obj.write_size_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m b/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m index ca92426a..06f824e9 100644 --- a/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockFixedArraysWriter < test_model.FixedArraysWriterBase +classdef MockFixedArraysWriter < matlab.mixin.Copyable & test_model.FixedArraysWriterBase properties testCase_ write_ints_written @@ -21,23 +21,48 @@ end function expect_write_ints_(obj, value) - obj.write_ints_written(end+1) = Node(value); + if isempty(obj.write_ints_written) + obj.write_ints_written = Node(value); + else + last_dim = ndims(value); + obj.write_ints_written = Node(cat(last_dim, obj.write_ints_written(1).value, value)); + end end function expect_write_fixed_simple_record_array_(obj, value) - obj.write_fixed_simple_record_array_written(end+1) = Node(value); + if isempty(obj.write_fixed_simple_record_array_written) + obj.write_fixed_simple_record_array_written = Node(value); + else + last_dim = ndims(value); + obj.write_fixed_simple_record_array_written = Node(cat(last_dim, obj.write_fixed_simple_record_array_written(1).value, value)); + end end function expect_write_fixed_record_with_vlens_array_(obj, value) - obj.write_fixed_record_with_vlens_array_written(end+1) = Node(value); + if isempty(obj.write_fixed_record_with_vlens_array_written) + obj.write_fixed_record_with_vlens_array_written = Node(value); + else + last_dim = ndims(value); + obj.write_fixed_record_with_vlens_array_written = Node(cat(last_dim, obj.write_fixed_record_with_vlens_array_written(1).value, value)); + end end function expect_write_record_with_fixed_arrays_(obj, value) - obj.write_record_with_fixed_arrays_written(end+1) = Node(value); + if isempty(obj.write_record_with_fixed_arrays_written) + obj.write_record_with_fixed_arrays_written = Node(value); + else + last_dim = ndims(value); + obj.write_record_with_fixed_arrays_written = Node(cat(last_dim, obj.write_record_with_fixed_arrays_written(1).value, value)); + end end function expect_write_named_array_(obj, value) - obj.write_named_array_written(end+1) = Node(value); + if isempty(obj.write_named_array_written) + obj.write_named_array_written = Node(value); + else + last_dim = ndims(value); + obj.write_named_array_written = Node(cat(last_dim, obj.write_named_array_written(1).value, value)); + end end function verify(obj) @@ -54,35 +79,35 @@ function write_ints_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_ints_written), "Unexpected call to write_ints_"); expected = obj.write_ints_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); - obj.write_ints_written = obj.write_ints_written(2:end); + obj.write_ints_written = Node.empty(); end function write_fixed_simple_record_array_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_fixed_simple_record_array_written), "Unexpected call to write_fixed_simple_record_array_"); expected = obj.write_fixed_simple_record_array_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_simple_record_array_"); - obj.write_fixed_simple_record_array_written = obj.write_fixed_simple_record_array_written(2:end); + obj.write_fixed_simple_record_array_written = Node.empty(); end function write_fixed_record_with_vlens_array_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_fixed_record_with_vlens_array_written), "Unexpected call to write_fixed_record_with_vlens_array_"); expected = obj.write_fixed_record_with_vlens_array_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_record_with_vlens_array_"); - obj.write_fixed_record_with_vlens_array_written = obj.write_fixed_record_with_vlens_array_written(2:end); + obj.write_fixed_record_with_vlens_array_written = Node.empty(); end function write_record_with_fixed_arrays_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_record_with_fixed_arrays_written), "Unexpected call to write_record_with_fixed_arrays_"); expected = obj.write_record_with_fixed_arrays_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_fixed_arrays_"); - obj.write_record_with_fixed_arrays_written = obj.write_record_with_fixed_arrays_written(2:end); + obj.write_record_with_fixed_arrays_written = Node.empty(); end function write_named_array_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_named_array_written), "Unexpected call to write_named_array_"); expected = obj.write_named_array_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_named_array_"); - obj.write_named_array_written = obj.write_named_array_written(2:end); + obj.write_named_array_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m b/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m index c3f7db42..b6bcbf09 100644 --- a/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockFixedVectorsWriter < test_model.FixedVectorsWriterBase +classdef MockFixedVectorsWriter < matlab.mixin.Copyable & test_model.FixedVectorsWriterBase properties testCase_ write_fixed_int_vector_written @@ -19,19 +19,39 @@ end function expect_write_fixed_int_vector_(obj, value) - obj.write_fixed_int_vector_written(end+1) = Node(value); + if isempty(obj.write_fixed_int_vector_written) + obj.write_fixed_int_vector_written = Node(value); + else + last_dim = ndims(value); + obj.write_fixed_int_vector_written = Node(cat(last_dim, obj.write_fixed_int_vector_written(1).value, value)); + end end function expect_write_fixed_simple_record_vector_(obj, value) - obj.write_fixed_simple_record_vector_written(end+1) = Node(value); + if isempty(obj.write_fixed_simple_record_vector_written) + obj.write_fixed_simple_record_vector_written = Node(value); + else + last_dim = ndims(value); + obj.write_fixed_simple_record_vector_written = Node(cat(last_dim, obj.write_fixed_simple_record_vector_written(1).value, value)); + end end function expect_write_fixed_record_with_vlens_vector_(obj, value) - obj.write_fixed_record_with_vlens_vector_written(end+1) = Node(value); + if isempty(obj.write_fixed_record_with_vlens_vector_written) + obj.write_fixed_record_with_vlens_vector_written = Node(value); + else + last_dim = ndims(value); + obj.write_fixed_record_with_vlens_vector_written = Node(cat(last_dim, obj.write_fixed_record_with_vlens_vector_written(1).value, value)); + end end function expect_write_record_with_fixed_vectors_(obj, value) - obj.write_record_with_fixed_vectors_written(end+1) = Node(value); + if isempty(obj.write_record_with_fixed_vectors_written) + obj.write_record_with_fixed_vectors_written = Node(value); + else + last_dim = ndims(value); + obj.write_record_with_fixed_vectors_written = Node(cat(last_dim, obj.write_record_with_fixed_vectors_written(1).value, value)); + end end function verify(obj) @@ -47,28 +67,28 @@ function write_fixed_int_vector_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_fixed_int_vector_written), "Unexpected call to write_fixed_int_vector_"); expected = obj.write_fixed_int_vector_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_int_vector_"); - obj.write_fixed_int_vector_written = obj.write_fixed_int_vector_written(2:end); + obj.write_fixed_int_vector_written = Node.empty(); end function write_fixed_simple_record_vector_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_fixed_simple_record_vector_written), "Unexpected call to write_fixed_simple_record_vector_"); expected = obj.write_fixed_simple_record_vector_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_simple_record_vector_"); - obj.write_fixed_simple_record_vector_written = obj.write_fixed_simple_record_vector_written(2:end); + obj.write_fixed_simple_record_vector_written = Node.empty(); end function write_fixed_record_with_vlens_vector_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_fixed_record_with_vlens_vector_written), "Unexpected call to write_fixed_record_with_vlens_vector_"); expected = obj.write_fixed_record_with_vlens_vector_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_record_with_vlens_vector_"); - obj.write_fixed_record_with_vlens_vector_written = obj.write_fixed_record_with_vlens_vector_written(2:end); + obj.write_fixed_record_with_vlens_vector_written = Node.empty(); end function write_record_with_fixed_vectors_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_record_with_fixed_vectors_written), "Unexpected call to write_record_with_fixed_vectors_"); expected = obj.write_record_with_fixed_vectors_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_fixed_vectors_"); - obj.write_record_with_fixed_vectors_written = obj.write_record_with_fixed_vectors_written(2:end); + obj.write_record_with_fixed_vectors_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockFlagsWriter.m b/matlab/generated/+test_model/+testing/MockFlagsWriter.m index 806b71e3..4833ee2d 100644 --- a/matlab/generated/+test_model/+testing/MockFlagsWriter.m +++ b/matlab/generated/+test_model/+testing/MockFlagsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockFlagsWriter < test_model.FlagsWriterBase +classdef MockFlagsWriter < matlab.mixin.Copyable & test_model.FlagsWriterBase properties testCase_ write_days_written @@ -15,11 +15,21 @@ end function expect_write_days_(obj, value) - obj.write_days_written(end+1) = Node(value); + if isempty(obj.write_days_written) + obj.write_days_written = Node(value); + else + last_dim = ndims(value); + obj.write_days_written = Node(cat(last_dim, obj.write_days_written(1).value, value)); + end end function expect_write_formats_(obj, value) - obj.write_formats_written(end+1) = Node(value); + if isempty(obj.write_formats_written) + obj.write_formats_written = Node(value); + else + last_dim = ndims(value); + obj.write_formats_written = Node(cat(last_dim, obj.write_formats_written(1).value, value)); + end end function verify(obj) @@ -33,14 +43,14 @@ function write_days_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_days_written), "Unexpected call to write_days_"); expected = obj.write_days_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_days_"); - obj.write_days_written = obj.write_days_written(2:end); + obj.write_days_written = Node.empty(); end function write_formats_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_formats_written), "Unexpected call to write_formats_"); expected = obj.write_formats_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_formats_"); - obj.write_formats_written = obj.write_formats_written(2:end); + obj.write_formats_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockMapsWriter.m b/matlab/generated/+test_model/+testing/MockMapsWriter.m index e40436b6..6a524c6c 100644 --- a/matlab/generated/+test_model/+testing/MockMapsWriter.m +++ b/matlab/generated/+test_model/+testing/MockMapsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockMapsWriter < test_model.MapsWriterBase +classdef MockMapsWriter < matlab.mixin.Copyable & test_model.MapsWriterBase properties testCase_ write_string_to_int_written @@ -19,19 +19,39 @@ end function expect_write_string_to_int_(obj, value) - obj.write_string_to_int_written(end+1) = Node(value); + if isempty(obj.write_string_to_int_written) + obj.write_string_to_int_written = Node(value); + else + last_dim = ndims(value); + obj.write_string_to_int_written = Node(cat(last_dim, obj.write_string_to_int_written(1).value, value)); + end end function expect_write_int_to_string_(obj, value) - obj.write_int_to_string_written(end+1) = Node(value); + if isempty(obj.write_int_to_string_written) + obj.write_int_to_string_written = Node(value); + else + last_dim = ndims(value); + obj.write_int_to_string_written = Node(cat(last_dim, obj.write_int_to_string_written(1).value, value)); + end end function expect_write_string_to_union_(obj, value) - obj.write_string_to_union_written(end+1) = Node(value); + if isempty(obj.write_string_to_union_written) + obj.write_string_to_union_written = Node(value); + else + last_dim = ndims(value); + obj.write_string_to_union_written = Node(cat(last_dim, obj.write_string_to_union_written(1).value, value)); + end end function expect_write_aliased_generic_(obj, value) - obj.write_aliased_generic_written(end+1) = Node(value); + if isempty(obj.write_aliased_generic_written) + obj.write_aliased_generic_written = Node(value); + else + last_dim = ndims(value); + obj.write_aliased_generic_written = Node(cat(last_dim, obj.write_aliased_generic_written(1).value, value)); + end end function verify(obj) @@ -47,28 +67,28 @@ function write_string_to_int_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_string_to_int_written), "Unexpected call to write_string_to_int_"); expected = obj.write_string_to_int_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_string_to_int_"); - obj.write_string_to_int_written = obj.write_string_to_int_written(2:end); + obj.write_string_to_int_written = Node.empty(); end function write_int_to_string_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_int_to_string_written), "Unexpected call to write_int_to_string_"); expected = obj.write_int_to_string_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_to_string_"); - obj.write_int_to_string_written = obj.write_int_to_string_written(2:end); + obj.write_int_to_string_written = Node.empty(); end function write_string_to_union_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_string_to_union_written), "Unexpected call to write_string_to_union_"); expected = obj.write_string_to_union_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_string_to_union_"); - obj.write_string_to_union_written = obj.write_string_to_union_written(2:end); + obj.write_string_to_union_written = Node.empty(); end function write_aliased_generic_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_aliased_generic_written), "Unexpected call to write_aliased_generic_"); expected = obj.write_aliased_generic_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_"); - obj.write_aliased_generic_written = obj.write_aliased_generic_written(2:end); + obj.write_aliased_generic_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m b/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m index 09400ed0..02474d4b 100644 --- a/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m +++ b/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockNDArraysSingleDimensionWriter < test_model.NDArraysSingleDimensionWriterBase +classdef MockNDArraysSingleDimensionWriter < matlab.mixin.Copyable & test_model.NDArraysSingleDimensionWriterBase properties testCase_ write_ints_written @@ -19,19 +19,39 @@ end function expect_write_ints_(obj, value) - obj.write_ints_written(end+1) = Node(value); + if isempty(obj.write_ints_written) + obj.write_ints_written = Node(value); + else + last_dim = ndims(value); + obj.write_ints_written = Node(cat(last_dim, obj.write_ints_written(1).value, value)); + end end function expect_write_simple_record_array_(obj, value) - obj.write_simple_record_array_written(end+1) = Node(value); + if isempty(obj.write_simple_record_array_written) + obj.write_simple_record_array_written = Node(value); + else + last_dim = ndims(value); + obj.write_simple_record_array_written = Node(cat(last_dim, obj.write_simple_record_array_written(1).value, value)); + end end function expect_write_record_with_vlens_array_(obj, value) - obj.write_record_with_vlens_array_written(end+1) = Node(value); + if isempty(obj.write_record_with_vlens_array_written) + obj.write_record_with_vlens_array_written = Node(value); + else + last_dim = ndims(value); + obj.write_record_with_vlens_array_written = Node(cat(last_dim, obj.write_record_with_vlens_array_written(1).value, value)); + end end function expect_write_record_with_nd_arrays_(obj, value) - obj.write_record_with_nd_arrays_written(end+1) = Node(value); + if isempty(obj.write_record_with_nd_arrays_written) + obj.write_record_with_nd_arrays_written = Node(value); + else + last_dim = ndims(value); + obj.write_record_with_nd_arrays_written = Node(cat(last_dim, obj.write_record_with_nd_arrays_written(1).value, value)); + end end function verify(obj) @@ -47,28 +67,28 @@ function write_ints_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_ints_written), "Unexpected call to write_ints_"); expected = obj.write_ints_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); - obj.write_ints_written = obj.write_ints_written(2:end); + obj.write_ints_written = Node.empty(); end function write_simple_record_array_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_simple_record_array_written), "Unexpected call to write_simple_record_array_"); expected = obj.write_simple_record_array_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_simple_record_array_"); - obj.write_simple_record_array_written = obj.write_simple_record_array_written(2:end); + obj.write_simple_record_array_written = Node.empty(); end function write_record_with_vlens_array_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_record_with_vlens_array_written), "Unexpected call to write_record_with_vlens_array_"); expected = obj.write_record_with_vlens_array_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_array_"); - obj.write_record_with_vlens_array_written = obj.write_record_with_vlens_array_written(2:end); + obj.write_record_with_vlens_array_written = Node.empty(); end function write_record_with_nd_arrays_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_record_with_nd_arrays_written), "Unexpected call to write_record_with_nd_arrays_"); expected = obj.write_record_with_nd_arrays_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_nd_arrays_"); - obj.write_record_with_nd_arrays_written = obj.write_record_with_nd_arrays_written(2:end); + obj.write_record_with_nd_arrays_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockNDArraysWriter.m b/matlab/generated/+test_model/+testing/MockNDArraysWriter.m index 31f4b59b..89340084 100644 --- a/matlab/generated/+test_model/+testing/MockNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockNDArraysWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockNDArraysWriter < test_model.NDArraysWriterBase +classdef MockNDArraysWriter < matlab.mixin.Copyable & test_model.NDArraysWriterBase properties testCase_ write_ints_written @@ -21,23 +21,48 @@ end function expect_write_ints_(obj, value) - obj.write_ints_written(end+1) = Node(value); + if isempty(obj.write_ints_written) + obj.write_ints_written = Node(value); + else + last_dim = ndims(value); + obj.write_ints_written = Node(cat(last_dim, obj.write_ints_written(1).value, value)); + end end function expect_write_simple_record_array_(obj, value) - obj.write_simple_record_array_written(end+1) = Node(value); + if isempty(obj.write_simple_record_array_written) + obj.write_simple_record_array_written = Node(value); + else + last_dim = ndims(value); + obj.write_simple_record_array_written = Node(cat(last_dim, obj.write_simple_record_array_written(1).value, value)); + end end function expect_write_record_with_vlens_array_(obj, value) - obj.write_record_with_vlens_array_written(end+1) = Node(value); + if isempty(obj.write_record_with_vlens_array_written) + obj.write_record_with_vlens_array_written = Node(value); + else + last_dim = ndims(value); + obj.write_record_with_vlens_array_written = Node(cat(last_dim, obj.write_record_with_vlens_array_written(1).value, value)); + end end function expect_write_record_with_nd_arrays_(obj, value) - obj.write_record_with_nd_arrays_written(end+1) = Node(value); + if isempty(obj.write_record_with_nd_arrays_written) + obj.write_record_with_nd_arrays_written = Node(value); + else + last_dim = ndims(value); + obj.write_record_with_nd_arrays_written = Node(cat(last_dim, obj.write_record_with_nd_arrays_written(1).value, value)); + end end function expect_write_named_array_(obj, value) - obj.write_named_array_written(end+1) = Node(value); + if isempty(obj.write_named_array_written) + obj.write_named_array_written = Node(value); + else + last_dim = ndims(value); + obj.write_named_array_written = Node(cat(last_dim, obj.write_named_array_written(1).value, value)); + end end function verify(obj) @@ -54,35 +79,35 @@ function write_ints_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_ints_written), "Unexpected call to write_ints_"); expected = obj.write_ints_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); - obj.write_ints_written = obj.write_ints_written(2:end); + obj.write_ints_written = Node.empty(); end function write_simple_record_array_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_simple_record_array_written), "Unexpected call to write_simple_record_array_"); expected = obj.write_simple_record_array_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_simple_record_array_"); - obj.write_simple_record_array_written = obj.write_simple_record_array_written(2:end); + obj.write_simple_record_array_written = Node.empty(); end function write_record_with_vlens_array_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_record_with_vlens_array_written), "Unexpected call to write_record_with_vlens_array_"); expected = obj.write_record_with_vlens_array_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_array_"); - obj.write_record_with_vlens_array_written = obj.write_record_with_vlens_array_written(2:end); + obj.write_record_with_vlens_array_written = Node.empty(); end function write_record_with_nd_arrays_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_record_with_nd_arrays_written), "Unexpected call to write_record_with_nd_arrays_"); expected = obj.write_record_with_nd_arrays_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_nd_arrays_"); - obj.write_record_with_nd_arrays_written = obj.write_record_with_nd_arrays_written(2:end); + obj.write_record_with_nd_arrays_written = Node.empty(); end function write_named_array_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_named_array_written), "Unexpected call to write_named_array_"); expected = obj.write_named_array_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_named_array_"); - obj.write_named_array_written = obj.write_named_array_written(2:end); + obj.write_named_array_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m b/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m index 6de75002..842cc2b2 100644 --- a/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockNestedRecordsWriter < test_model.NestedRecordsWriterBase +classdef MockNestedRecordsWriter < matlab.mixin.Copyable & test_model.NestedRecordsWriterBase properties testCase_ write_tuple_with_records_written @@ -13,7 +13,12 @@ end function expect_write_tuple_with_records_(obj, value) - obj.write_tuple_with_records_written(end+1) = Node(value); + if isempty(obj.write_tuple_with_records_written) + obj.write_tuple_with_records_written = Node(value); + else + last_dim = ndims(value); + obj.write_tuple_with_records_written = Node(cat(last_dim, obj.write_tuple_with_records_written(1).value, value)); + end end function verify(obj) @@ -26,7 +31,7 @@ function write_tuple_with_records_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_tuple_with_records_written), "Unexpected call to write_tuple_with_records_"); expected = obj.write_tuple_with_records_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_with_records_"); - obj.write_tuple_with_records_written = obj.write_tuple_with_records_written(2:end); + obj.write_tuple_with_records_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m b/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m index 5c0004d1..85ee3401 100644 --- a/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockOptionalVectorsWriter < test_model.OptionalVectorsWriterBase +classdef MockOptionalVectorsWriter < matlab.mixin.Copyable & test_model.OptionalVectorsWriterBase properties testCase_ write_record_with_optional_vector_written @@ -13,7 +13,12 @@ end function expect_write_record_with_optional_vector_(obj, value) - obj.write_record_with_optional_vector_written(end+1) = Node(value); + if isempty(obj.write_record_with_optional_vector_written) + obj.write_record_with_optional_vector_written = Node(value); + else + last_dim = ndims(value); + obj.write_record_with_optional_vector_written = Node(cat(last_dim, obj.write_record_with_optional_vector_written(1).value, value)); + end end function verify(obj) @@ -26,7 +31,7 @@ function write_record_with_optional_vector_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_record_with_optional_vector_written), "Unexpected call to write_record_with_optional_vector_"); expected = obj.write_record_with_optional_vector_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_optional_vector_"); - obj.write_record_with_optional_vector_written = obj.write_record_with_optional_vector_written(2:end); + obj.write_record_with_optional_vector_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m b/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m index 82b3908d..533645a9 100644 --- a/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m +++ b/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockProtocolWithComputedFieldsWriter < test_model.ProtocolWithComputedFieldsWriterBase +classdef MockProtocolWithComputedFieldsWriter < matlab.mixin.Copyable & test_model.ProtocolWithComputedFieldsWriterBase properties testCase_ write_record_with_computed_fields_written @@ -13,7 +13,12 @@ end function expect_write_record_with_computed_fields_(obj, value) - obj.write_record_with_computed_fields_written(end+1) = Node(value); + if isempty(obj.write_record_with_computed_fields_written) + obj.write_record_with_computed_fields_written = Node(value); + else + last_dim = ndims(value); + obj.write_record_with_computed_fields_written = Node(cat(last_dim, obj.write_record_with_computed_fields_written(1).value, value)); + end end function verify(obj) @@ -26,7 +31,7 @@ function write_record_with_computed_fields_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_record_with_computed_fields_written), "Unexpected call to write_record_with_computed_fields_"); expected = obj.write_record_with_computed_fields_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_computed_fields_"); - obj.write_record_with_computed_fields_written = obj.write_record_with_computed_fields_written(2:end); + obj.write_record_with_computed_fields_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m index c9bff007..4cfbfbab 100644 --- a/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m +++ b/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockProtocolWithKeywordStepsWriter < test_model.ProtocolWithKeywordStepsWriterBase +classdef MockProtocolWithKeywordStepsWriter < matlab.mixin.Copyable & test_model.ProtocolWithKeywordStepsWriterBase properties testCase_ write_int_written @@ -15,11 +15,21 @@ end function expect_write_int_(obj, value) - obj.write_int_written(end+1) = Node(value); + if isempty(obj.write_int_written) + obj.write_int_written = Node(value); + else + last_dim = ndims(value); + obj.write_int_written = Node(cat(last_dim, obj.write_int_written(1).value, value)); + end end function expect_write_float_(obj, value) - obj.write_float_written(end+1) = Node(value); + if isempty(obj.write_float_written) + obj.write_float_written = Node(value); + else + last_dim = ndims(value); + obj.write_float_written = Node(cat(last_dim, obj.write_float_written(1).value, value)); + end end function verify(obj) @@ -33,14 +43,14 @@ function write_int_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_int_written), "Unexpected call to write_int_"); expected = obj.write_int_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_"); - obj.write_int_written = obj.write_int_written(2:end); + obj.write_int_written = Node.empty(); end function write_float_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_float_written), "Unexpected call to write_float_"); expected = obj.write_float_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_"); - obj.write_float_written = obj.write_float_written(2:end); + obj.write_float_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m b/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m index 127464f3..0a797a41 100644 --- a/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockScalarOptionalsWriter < test_model.ScalarOptionalsWriterBase +classdef MockScalarOptionalsWriter < matlab.mixin.Copyable & test_model.ScalarOptionalsWriterBase properties testCase_ write_optional_int_written @@ -19,19 +19,39 @@ end function expect_write_optional_int_(obj, value) - obj.write_optional_int_written(end+1) = Node(value); + if isempty(obj.write_optional_int_written) + obj.write_optional_int_written = Node(value); + else + last_dim = ndims(value); + obj.write_optional_int_written = Node(cat(last_dim, obj.write_optional_int_written(1).value, value)); + end end function expect_write_optional_record_(obj, value) - obj.write_optional_record_written(end+1) = Node(value); + if isempty(obj.write_optional_record_written) + obj.write_optional_record_written = Node(value); + else + last_dim = ndims(value); + obj.write_optional_record_written = Node(cat(last_dim, obj.write_optional_record_written(1).value, value)); + end end function expect_write_record_with_optional_fields_(obj, value) - obj.write_record_with_optional_fields_written(end+1) = Node(value); + if isempty(obj.write_record_with_optional_fields_written) + obj.write_record_with_optional_fields_written = Node(value); + else + last_dim = ndims(value); + obj.write_record_with_optional_fields_written = Node(cat(last_dim, obj.write_record_with_optional_fields_written(1).value, value)); + end end function expect_write_optional_record_with_optional_fields_(obj, value) - obj.write_optional_record_with_optional_fields_written(end+1) = Node(value); + if isempty(obj.write_optional_record_with_optional_fields_written) + obj.write_optional_record_with_optional_fields_written = Node(value); + else + last_dim = ndims(value); + obj.write_optional_record_with_optional_fields_written = Node(cat(last_dim, obj.write_optional_record_with_optional_fields_written(1).value, value)); + end end function verify(obj) @@ -47,28 +67,28 @@ function write_optional_int_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_optional_int_written), "Unexpected call to write_optional_int_"); expected = obj.write_optional_int_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_int_"); - obj.write_optional_int_written = obj.write_optional_int_written(2:end); + obj.write_optional_int_written = Node.empty(); end function write_optional_record_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_optional_record_written), "Unexpected call to write_optional_record_"); expected = obj.write_optional_record_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_record_"); - obj.write_optional_record_written = obj.write_optional_record_written(2:end); + obj.write_optional_record_written = Node.empty(); end function write_record_with_optional_fields_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_record_with_optional_fields_written), "Unexpected call to write_record_with_optional_fields_"); expected = obj.write_record_with_optional_fields_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_optional_fields_"); - obj.write_record_with_optional_fields_written = obj.write_record_with_optional_fields_written(2:end); + obj.write_record_with_optional_fields_written = Node.empty(); end function write_optional_record_with_optional_fields_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_optional_record_with_optional_fields_written), "Unexpected call to write_optional_record_with_optional_fields_"); expected = obj.write_optional_record_with_optional_fields_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_record_with_optional_fields_"); - obj.write_optional_record_with_optional_fields_written = obj.write_optional_record_with_optional_fields_written(2:end); + obj.write_optional_record_with_optional_fields_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockScalarsWriter.m b/matlab/generated/+test_model/+testing/MockScalarsWriter.m index 0a100fc2..ffafe9c1 100644 --- a/matlab/generated/+test_model/+testing/MockScalarsWriter.m +++ b/matlab/generated/+test_model/+testing/MockScalarsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockScalarsWriter < test_model.ScalarsWriterBase +classdef MockScalarsWriter < matlab.mixin.Copyable & test_model.ScalarsWriterBase properties testCase_ write_int32_written @@ -15,11 +15,21 @@ end function expect_write_int32_(obj, value) - obj.write_int32_written(end+1) = Node(value); + if isempty(obj.write_int32_written) + obj.write_int32_written = Node(value); + else + last_dim = ndims(value); + obj.write_int32_written = Node(cat(last_dim, obj.write_int32_written(1).value, value)); + end end function expect_write_record_(obj, value) - obj.write_record_written(end+1) = Node(value); + if isempty(obj.write_record_written) + obj.write_record_written = Node(value); + else + last_dim = ndims(value); + obj.write_record_written = Node(cat(last_dim, obj.write_record_written(1).value, value)); + end end function verify(obj) @@ -33,14 +43,14 @@ function write_int32_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_int32_written), "Unexpected call to write_int32_"); expected = obj.write_int32_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int32_"); - obj.write_int32_written = obj.write_int32_written(2:end); + obj.write_int32_written = Node.empty(); end function write_record_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_record_written), "Unexpected call to write_record_"); expected = obj.write_record_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_"); - obj.write_record_written = obj.write_record_written(2:end); + obj.write_record_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m b/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m index c848959d..20c45a97 100644 --- a/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockSimpleGenericsWriter < test_model.SimpleGenericsWriterBase +classdef MockSimpleGenericsWriter < matlab.mixin.Copyable & test_model.SimpleGenericsWriterBase properties testCase_ write_float_image_written @@ -29,39 +29,84 @@ end function expect_write_float_image_(obj, value) - obj.write_float_image_written(end+1) = Node(value); + if isempty(obj.write_float_image_written) + obj.write_float_image_written = Node(value); + else + last_dim = ndims(value); + obj.write_float_image_written = Node(cat(last_dim, obj.write_float_image_written(1).value, value)); + end end function expect_write_int_image_(obj, value) - obj.write_int_image_written(end+1) = Node(value); + if isempty(obj.write_int_image_written) + obj.write_int_image_written = Node(value); + else + last_dim = ndims(value); + obj.write_int_image_written = Node(cat(last_dim, obj.write_int_image_written(1).value, value)); + end end function expect_write_int_image_alternate_syntax_(obj, value) - obj.write_int_image_alternate_syntax_written(end+1) = Node(value); + if isempty(obj.write_int_image_alternate_syntax_written) + obj.write_int_image_alternate_syntax_written = Node(value); + else + last_dim = ndims(value); + obj.write_int_image_alternate_syntax_written = Node(cat(last_dim, obj.write_int_image_alternate_syntax_written(1).value, value)); + end end function expect_write_string_image_(obj, value) - obj.write_string_image_written(end+1) = Node(value); + if isempty(obj.write_string_image_written) + obj.write_string_image_written = Node(value); + else + last_dim = ndims(value); + obj.write_string_image_written = Node(cat(last_dim, obj.write_string_image_written(1).value, value)); + end end function expect_write_int_float_tuple_(obj, value) - obj.write_int_float_tuple_written(end+1) = Node(value); + if isempty(obj.write_int_float_tuple_written) + obj.write_int_float_tuple_written = Node(value); + else + last_dim = ndims(value); + obj.write_int_float_tuple_written = Node(cat(last_dim, obj.write_int_float_tuple_written(1).value, value)); + end end function expect_write_float_float_tuple_(obj, value) - obj.write_float_float_tuple_written(end+1) = Node(value); + if isempty(obj.write_float_float_tuple_written) + obj.write_float_float_tuple_written = Node(value); + else + last_dim = ndims(value); + obj.write_float_float_tuple_written = Node(cat(last_dim, obj.write_float_float_tuple_written(1).value, value)); + end end function expect_write_int_float_tuple_alternate_syntax_(obj, value) - obj.write_int_float_tuple_alternate_syntax_written(end+1) = Node(value); + if isempty(obj.write_int_float_tuple_alternate_syntax_written) + obj.write_int_float_tuple_alternate_syntax_written = Node(value); + else + last_dim = ndims(value); + obj.write_int_float_tuple_alternate_syntax_written = Node(cat(last_dim, obj.write_int_float_tuple_alternate_syntax_written(1).value, value)); + end end function expect_write_int_string_tuple_(obj, value) - obj.write_int_string_tuple_written(end+1) = Node(value); + if isempty(obj.write_int_string_tuple_written) + obj.write_int_string_tuple_written = Node(value); + else + last_dim = ndims(value); + obj.write_int_string_tuple_written = Node(cat(last_dim, obj.write_int_string_tuple_written(1).value, value)); + end end function expect_write_stream_of_type_variants_(obj, value) - obj.write_stream_of_type_variants_written(end+1) = Node(value); + if isempty(obj.write_stream_of_type_variants_written) + obj.write_stream_of_type_variants_written = Node(value); + else + last_dim = ndims(value); + obj.write_stream_of_type_variants_written = Node(cat(last_dim, obj.write_stream_of_type_variants_written(1).value, value)); + end end function verify(obj) @@ -82,63 +127,63 @@ function write_float_image_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_float_image_written), "Unexpected call to write_float_image_"); expected = obj.write_float_image_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_image_"); - obj.write_float_image_written = obj.write_float_image_written(2:end); + obj.write_float_image_written = Node.empty(); end function write_int_image_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_int_image_written), "Unexpected call to write_int_image_"); expected = obj.write_int_image_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_image_"); - obj.write_int_image_written = obj.write_int_image_written(2:end); + obj.write_int_image_written = Node.empty(); end function write_int_image_alternate_syntax_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_int_image_alternate_syntax_written), "Unexpected call to write_int_image_alternate_syntax_"); expected = obj.write_int_image_alternate_syntax_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_image_alternate_syntax_"); - obj.write_int_image_alternate_syntax_written = obj.write_int_image_alternate_syntax_written(2:end); + obj.write_int_image_alternate_syntax_written = Node.empty(); end function write_string_image_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_string_image_written), "Unexpected call to write_string_image_"); expected = obj.write_string_image_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_string_image_"); - obj.write_string_image_written = obj.write_string_image_written(2:end); + obj.write_string_image_written = Node.empty(); end function write_int_float_tuple_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_int_float_tuple_written), "Unexpected call to write_int_float_tuple_"); expected = obj.write_int_float_tuple_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_float_tuple_"); - obj.write_int_float_tuple_written = obj.write_int_float_tuple_written(2:end); + obj.write_int_float_tuple_written = Node.empty(); end function write_float_float_tuple_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_float_float_tuple_written), "Unexpected call to write_float_float_tuple_"); expected = obj.write_float_float_tuple_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_float_tuple_"); - obj.write_float_float_tuple_written = obj.write_float_float_tuple_written(2:end); + obj.write_float_float_tuple_written = Node.empty(); end function write_int_float_tuple_alternate_syntax_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_int_float_tuple_alternate_syntax_written), "Unexpected call to write_int_float_tuple_alternate_syntax_"); expected = obj.write_int_float_tuple_alternate_syntax_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_float_tuple_alternate_syntax_"); - obj.write_int_float_tuple_alternate_syntax_written = obj.write_int_float_tuple_alternate_syntax_written(2:end); + obj.write_int_float_tuple_alternate_syntax_written = Node.empty(); end function write_int_string_tuple_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_int_string_tuple_written), "Unexpected call to write_int_string_tuple_"); expected = obj.write_int_string_tuple_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_string_tuple_"); - obj.write_int_string_tuple_written = obj.write_int_string_tuple_written(2:end); + obj.write_int_string_tuple_written = Node.empty(); end function write_stream_of_type_variants_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_stream_of_type_variants_written), "Unexpected call to write_stream_of_type_variants_"); expected = obj.write_stream_of_type_variants_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_stream_of_type_variants_"); - obj.write_stream_of_type_variants_written = obj.write_stream_of_type_variants_written(2:end); + obj.write_stream_of_type_variants_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockStateTestWriter.m b/matlab/generated/+test_model/+testing/MockStateTestWriter.m index f21c8376..1d48c013 100644 --- a/matlab/generated/+test_model/+testing/MockStateTestWriter.m +++ b/matlab/generated/+test_model/+testing/MockStateTestWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockStateTestWriter < test_model.StateTestWriterBase +classdef MockStateTestWriter < matlab.mixin.Copyable & test_model.StateTestWriterBase properties testCase_ write_an_int_written @@ -17,15 +17,30 @@ end function expect_write_an_int_(obj, value) - obj.write_an_int_written(end+1) = Node(value); + if isempty(obj.write_an_int_written) + obj.write_an_int_written = Node(value); + else + last_dim = ndims(value); + obj.write_an_int_written = Node(cat(last_dim, obj.write_an_int_written(1).value, value)); + end end function expect_write_a_stream_(obj, value) - obj.write_a_stream_written(end+1) = Node(value); + if isempty(obj.write_a_stream_written) + obj.write_a_stream_written = Node(value); + else + last_dim = ndims(value); + obj.write_a_stream_written = Node(cat(last_dim, obj.write_a_stream_written(1).value, value)); + end end function expect_write_another_int_(obj, value) - obj.write_another_int_written(end+1) = Node(value); + if isempty(obj.write_another_int_written) + obj.write_another_int_written = Node(value); + else + last_dim = ndims(value); + obj.write_another_int_written = Node(cat(last_dim, obj.write_another_int_written(1).value, value)); + end end function verify(obj) @@ -40,21 +55,21 @@ function write_an_int_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_an_int_written), "Unexpected call to write_an_int_"); expected = obj.write_an_int_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_an_int_"); - obj.write_an_int_written = obj.write_an_int_written(2:end); + obj.write_an_int_written = Node.empty(); end function write_a_stream_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_a_stream_written), "Unexpected call to write_a_stream_"); expected = obj.write_a_stream_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_a_stream_"); - obj.write_a_stream_written = obj.write_a_stream_written(2:end); + obj.write_a_stream_written = Node.empty(); end function write_another_int_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_another_int_written), "Unexpected call to write_another_int_"); expected = obj.write_another_int_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_another_int_"); - obj.write_another_int_written = obj.write_another_int_written(2:end); + obj.write_another_int_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m index ae538bb8..a6354446 100644 --- a/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockStreamsOfAliasedUnionsWriter < test_model.StreamsOfAliasedUnionsWriterBase +classdef MockStreamsOfAliasedUnionsWriter < matlab.mixin.Copyable & test_model.StreamsOfAliasedUnionsWriterBase properties testCase_ write_int_or_simple_record_written @@ -15,11 +15,21 @@ end function expect_write_int_or_simple_record_(obj, value) - obj.write_int_or_simple_record_written(end+1) = Node(value); + if isempty(obj.write_int_or_simple_record_written) + obj.write_int_or_simple_record_written = Node(value); + else + last_dim = ndims(value); + obj.write_int_or_simple_record_written = Node(cat(last_dim, obj.write_int_or_simple_record_written(1).value, value)); + end end function expect_write_nullable_int_or_simple_record_(obj, value) - obj.write_nullable_int_or_simple_record_written(end+1) = Node(value); + if isempty(obj.write_nullable_int_or_simple_record_written) + obj.write_nullable_int_or_simple_record_written = Node(value); + else + last_dim = ndims(value); + obj.write_nullable_int_or_simple_record_written = Node(cat(last_dim, obj.write_nullable_int_or_simple_record_written(1).value, value)); + end end function verify(obj) @@ -33,14 +43,14 @@ function write_int_or_simple_record_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_int_or_simple_record_written), "Unexpected call to write_int_or_simple_record_"); expected = obj.write_int_or_simple_record_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_simple_record_"); - obj.write_int_or_simple_record_written = obj.write_int_or_simple_record_written(2:end); + obj.write_int_or_simple_record_written = Node.empty(); end function write_nullable_int_or_simple_record_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_nullable_int_or_simple_record_written), "Unexpected call to write_nullable_int_or_simple_record_"); expected = obj.write_nullable_int_or_simple_record_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_nullable_int_or_simple_record_"); - obj.write_nullable_int_or_simple_record_written = obj.write_nullable_int_or_simple_record_written(2:end); + obj.write_nullable_int_or_simple_record_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m index 781c7ed2..76ec34b5 100644 --- a/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockStreamsOfUnionsWriter < test_model.StreamsOfUnionsWriterBase +classdef MockStreamsOfUnionsWriter < matlab.mixin.Copyable & test_model.StreamsOfUnionsWriterBase properties testCase_ write_int_or_simple_record_written @@ -15,11 +15,21 @@ end function expect_write_int_or_simple_record_(obj, value) - obj.write_int_or_simple_record_written(end+1) = Node(value); + if isempty(obj.write_int_or_simple_record_written) + obj.write_int_or_simple_record_written = Node(value); + else + last_dim = ndims(value); + obj.write_int_or_simple_record_written = Node(cat(last_dim, obj.write_int_or_simple_record_written(1).value, value)); + end end function expect_write_nullable_int_or_simple_record_(obj, value) - obj.write_nullable_int_or_simple_record_written(end+1) = Node(value); + if isempty(obj.write_nullable_int_or_simple_record_written) + obj.write_nullable_int_or_simple_record_written = Node(value); + else + last_dim = ndims(value); + obj.write_nullable_int_or_simple_record_written = Node(cat(last_dim, obj.write_nullable_int_or_simple_record_written(1).value, value)); + end end function verify(obj) @@ -33,14 +43,14 @@ function write_int_or_simple_record_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_int_or_simple_record_written), "Unexpected call to write_int_or_simple_record_"); expected = obj.write_int_or_simple_record_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_simple_record_"); - obj.write_int_or_simple_record_written = obj.write_int_or_simple_record_written(2:end); + obj.write_int_or_simple_record_written = Node.empty(); end function write_nullable_int_or_simple_record_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_nullable_int_or_simple_record_written), "Unexpected call to write_nullable_int_or_simple_record_"); expected = obj.write_nullable_int_or_simple_record_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_nullable_int_or_simple_record_"); - obj.write_nullable_int_or_simple_record_written = obj.write_nullable_int_or_simple_record_written(2:end); + obj.write_nullable_int_or_simple_record_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockStreamsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsWriter.m index 8beee72f..1f6313ac 100644 --- a/matlab/generated/+test_model/+testing/MockStreamsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStreamsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockStreamsWriter < test_model.StreamsWriterBase +classdef MockStreamsWriter < matlab.mixin.Copyable & test_model.StreamsWriterBase properties testCase_ write_int_data_written @@ -19,19 +19,39 @@ end function expect_write_int_data_(obj, value) - obj.write_int_data_written(end+1) = Node(value); + if isempty(obj.write_int_data_written) + obj.write_int_data_written = Node(value); + else + last_dim = ndims(value); + obj.write_int_data_written = Node(cat(last_dim, obj.write_int_data_written(1).value, value)); + end end function expect_write_optional_int_data_(obj, value) - obj.write_optional_int_data_written(end+1) = Node(value); + if isempty(obj.write_optional_int_data_written) + obj.write_optional_int_data_written = Node(value); + else + last_dim = ndims(value); + obj.write_optional_int_data_written = Node(cat(last_dim, obj.write_optional_int_data_written(1).value, value)); + end end function expect_write_record_with_optional_vector_data_(obj, value) - obj.write_record_with_optional_vector_data_written(end+1) = Node(value); + if isempty(obj.write_record_with_optional_vector_data_written) + obj.write_record_with_optional_vector_data_written = Node(value); + else + last_dim = ndims(value); + obj.write_record_with_optional_vector_data_written = Node(cat(last_dim, obj.write_record_with_optional_vector_data_written(1).value, value)); + end end function expect_write_fixed_vector_(obj, value) - obj.write_fixed_vector_written(end+1) = Node(value); + if isempty(obj.write_fixed_vector_written) + obj.write_fixed_vector_written = Node(value); + else + last_dim = ndims(value); + obj.write_fixed_vector_written = Node(cat(last_dim, obj.write_fixed_vector_written(1).value, value)); + end end function verify(obj) @@ -47,28 +67,28 @@ function write_int_data_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_int_data_written), "Unexpected call to write_int_data_"); expected = obj.write_int_data_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_data_"); - obj.write_int_data_written = obj.write_int_data_written(2:end); + obj.write_int_data_written = Node.empty(); end function write_optional_int_data_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_optional_int_data_written), "Unexpected call to write_optional_int_data_"); expected = obj.write_optional_int_data_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_int_data_"); - obj.write_optional_int_data_written = obj.write_optional_int_data_written(2:end); + obj.write_optional_int_data_written = Node.empty(); end function write_record_with_optional_vector_data_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_record_with_optional_vector_data_written), "Unexpected call to write_record_with_optional_vector_data_"); expected = obj.write_record_with_optional_vector_data_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_optional_vector_data_"); - obj.write_record_with_optional_vector_data_written = obj.write_record_with_optional_vector_data_written(2:end); + obj.write_record_with_optional_vector_data_written = Node.empty(); end function write_fixed_vector_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_fixed_vector_written), "Unexpected call to write_fixed_vector_"); expected = obj.write_fixed_vector_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_vector_"); - obj.write_fixed_vector_written = obj.write_fixed_vector_written(2:end); + obj.write_fixed_vector_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockStringsWriter.m b/matlab/generated/+test_model/+testing/MockStringsWriter.m index ed924a1e..d2ac995f 100644 --- a/matlab/generated/+test_model/+testing/MockStringsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStringsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockStringsWriter < test_model.StringsWriterBase +classdef MockStringsWriter < matlab.mixin.Copyable & test_model.StringsWriterBase properties testCase_ write_single_string_written @@ -15,11 +15,21 @@ end function expect_write_single_string_(obj, value) - obj.write_single_string_written(end+1) = Node(value); + if isempty(obj.write_single_string_written) + obj.write_single_string_written = Node(value); + else + last_dim = ndims(value); + obj.write_single_string_written = Node(cat(last_dim, obj.write_single_string_written(1).value, value)); + end end function expect_write_rec_with_string_(obj, value) - obj.write_rec_with_string_written(end+1) = Node(value); + if isempty(obj.write_rec_with_string_written) + obj.write_rec_with_string_written = Node(value); + else + last_dim = ndims(value); + obj.write_rec_with_string_written = Node(cat(last_dim, obj.write_rec_with_string_written(1).value, value)); + end end function verify(obj) @@ -33,14 +43,14 @@ function write_single_string_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_single_string_written), "Unexpected call to write_single_string_"); expected = obj.write_single_string_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_single_string_"); - obj.write_single_string_written = obj.write_single_string_written(2:end); + obj.write_single_string_written = Node.empty(); end function write_rec_with_string_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_rec_with_string_written), "Unexpected call to write_rec_with_string_"); expected = obj.write_rec_with_string_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_rec_with_string_"); - obj.write_rec_with_string_written = obj.write_rec_with_string_written(2:end); + obj.write_rec_with_string_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m b/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m index f9427bce..d10f651e 100644 --- a/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockSubarraysInRecordsWriter < test_model.SubarraysInRecordsWriterBase +classdef MockSubarraysInRecordsWriter < matlab.mixin.Copyable & test_model.SubarraysInRecordsWriterBase properties testCase_ write_with_fixed_subarrays_written @@ -15,11 +15,21 @@ end function expect_write_with_fixed_subarrays_(obj, value) - obj.write_with_fixed_subarrays_written(end+1) = Node(value); + if isempty(obj.write_with_fixed_subarrays_written) + obj.write_with_fixed_subarrays_written = Node(value); + else + last_dim = ndims(value); + obj.write_with_fixed_subarrays_written = Node(cat(last_dim, obj.write_with_fixed_subarrays_written(1).value, value)); + end end function expect_write_with_vlen_subarrays_(obj, value) - obj.write_with_vlen_subarrays_written(end+1) = Node(value); + if isempty(obj.write_with_vlen_subarrays_written) + obj.write_with_vlen_subarrays_written = Node(value); + else + last_dim = ndims(value); + obj.write_with_vlen_subarrays_written = Node(cat(last_dim, obj.write_with_vlen_subarrays_written(1).value, value)); + end end function verify(obj) @@ -33,14 +43,14 @@ function write_with_fixed_subarrays_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_with_fixed_subarrays_written), "Unexpected call to write_with_fixed_subarrays_"); expected = obj.write_with_fixed_subarrays_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_with_fixed_subarrays_"); - obj.write_with_fixed_subarrays_written = obj.write_with_fixed_subarrays_written(2:end); + obj.write_with_fixed_subarrays_written = Node.empty(); end function write_with_vlen_subarrays_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_with_vlen_subarrays_written), "Unexpected call to write_with_vlen_subarrays_"); expected = obj.write_with_vlen_subarrays_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_with_vlen_subarrays_"); - obj.write_with_vlen_subarrays_written = obj.write_with_vlen_subarrays_written(2:end); + obj.write_with_vlen_subarrays_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockSubarraysWriter.m b/matlab/generated/+test_model/+testing/MockSubarraysWriter.m index ae052ce6..7e965bf0 100644 --- a/matlab/generated/+test_model/+testing/MockSubarraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockSubarraysWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockSubarraysWriter < test_model.SubarraysWriterBase +classdef MockSubarraysWriter < matlab.mixin.Copyable & test_model.SubarraysWriterBase properties testCase_ write_dynamic_with_fixed_int_subarray_written @@ -29,39 +29,84 @@ end function expect_write_dynamic_with_fixed_int_subarray_(obj, value) - obj.write_dynamic_with_fixed_int_subarray_written(end+1) = Node(value); + if isempty(obj.write_dynamic_with_fixed_int_subarray_written) + obj.write_dynamic_with_fixed_int_subarray_written = Node(value); + else + last_dim = ndims(value); + obj.write_dynamic_with_fixed_int_subarray_written = Node(cat(last_dim, obj.write_dynamic_with_fixed_int_subarray_written(1).value, value)); + end end function expect_write_dynamic_with_fixed_float_subarray_(obj, value) - obj.write_dynamic_with_fixed_float_subarray_written(end+1) = Node(value); + if isempty(obj.write_dynamic_with_fixed_float_subarray_written) + obj.write_dynamic_with_fixed_float_subarray_written = Node(value); + else + last_dim = ndims(value); + obj.write_dynamic_with_fixed_float_subarray_written = Node(cat(last_dim, obj.write_dynamic_with_fixed_float_subarray_written(1).value, value)); + end end function expect_write_known_dim_count_with_fixed_int_subarray_(obj, value) - obj.write_known_dim_count_with_fixed_int_subarray_written(end+1) = Node(value); + if isempty(obj.write_known_dim_count_with_fixed_int_subarray_written) + obj.write_known_dim_count_with_fixed_int_subarray_written = Node(value); + else + last_dim = ndims(value); + obj.write_known_dim_count_with_fixed_int_subarray_written = Node(cat(last_dim, obj.write_known_dim_count_with_fixed_int_subarray_written(1).value, value)); + end end function expect_write_known_dim_count_with_fixed_float_subarray_(obj, value) - obj.write_known_dim_count_with_fixed_float_subarray_written(end+1) = Node(value); + if isempty(obj.write_known_dim_count_with_fixed_float_subarray_written) + obj.write_known_dim_count_with_fixed_float_subarray_written = Node(value); + else + last_dim = ndims(value); + obj.write_known_dim_count_with_fixed_float_subarray_written = Node(cat(last_dim, obj.write_known_dim_count_with_fixed_float_subarray_written(1).value, value)); + end end function expect_write_fixed_with_fixed_int_subarray_(obj, value) - obj.write_fixed_with_fixed_int_subarray_written(end+1) = Node(value); + if isempty(obj.write_fixed_with_fixed_int_subarray_written) + obj.write_fixed_with_fixed_int_subarray_written = Node(value); + else + last_dim = ndims(value); + obj.write_fixed_with_fixed_int_subarray_written = Node(cat(last_dim, obj.write_fixed_with_fixed_int_subarray_written(1).value, value)); + end end function expect_write_fixed_with_fixed_float_subarray_(obj, value) - obj.write_fixed_with_fixed_float_subarray_written(end+1) = Node(value); + if isempty(obj.write_fixed_with_fixed_float_subarray_written) + obj.write_fixed_with_fixed_float_subarray_written = Node(value); + else + last_dim = ndims(value); + obj.write_fixed_with_fixed_float_subarray_written = Node(cat(last_dim, obj.write_fixed_with_fixed_float_subarray_written(1).value, value)); + end end function expect_write_nested_subarray_(obj, value) - obj.write_nested_subarray_written(end+1) = Node(value); + if isempty(obj.write_nested_subarray_written) + obj.write_nested_subarray_written = Node(value); + else + last_dim = ndims(value); + obj.write_nested_subarray_written = Node(cat(last_dim, obj.write_nested_subarray_written(1).value, value)); + end end function expect_write_dynamic_with_fixed_vector_subarray_(obj, value) - obj.write_dynamic_with_fixed_vector_subarray_written(end+1) = Node(value); + if isempty(obj.write_dynamic_with_fixed_vector_subarray_written) + obj.write_dynamic_with_fixed_vector_subarray_written = Node(value); + else + last_dim = ndims(value); + obj.write_dynamic_with_fixed_vector_subarray_written = Node(cat(last_dim, obj.write_dynamic_with_fixed_vector_subarray_written(1).value, value)); + end end function expect_write_generic_subarray_(obj, value) - obj.write_generic_subarray_written(end+1) = Node(value); + if isempty(obj.write_generic_subarray_written) + obj.write_generic_subarray_written = Node(value); + else + last_dim = ndims(value); + obj.write_generic_subarray_written = Node(cat(last_dim, obj.write_generic_subarray_written(1).value, value)); + end end function verify(obj) @@ -82,63 +127,63 @@ function write_dynamic_with_fixed_int_subarray_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_dynamic_with_fixed_int_subarray_written), "Unexpected call to write_dynamic_with_fixed_int_subarray_"); expected = obj.write_dynamic_with_fixed_int_subarray_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_dynamic_with_fixed_int_subarray_"); - obj.write_dynamic_with_fixed_int_subarray_written = obj.write_dynamic_with_fixed_int_subarray_written(2:end); + obj.write_dynamic_with_fixed_int_subarray_written = Node.empty(); end function write_dynamic_with_fixed_float_subarray_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_dynamic_with_fixed_float_subarray_written), "Unexpected call to write_dynamic_with_fixed_float_subarray_"); expected = obj.write_dynamic_with_fixed_float_subarray_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_dynamic_with_fixed_float_subarray_"); - obj.write_dynamic_with_fixed_float_subarray_written = obj.write_dynamic_with_fixed_float_subarray_written(2:end); + obj.write_dynamic_with_fixed_float_subarray_written = Node.empty(); end function write_known_dim_count_with_fixed_int_subarray_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_known_dim_count_with_fixed_int_subarray_written), "Unexpected call to write_known_dim_count_with_fixed_int_subarray_"); expected = obj.write_known_dim_count_with_fixed_int_subarray_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_known_dim_count_with_fixed_int_subarray_"); - obj.write_known_dim_count_with_fixed_int_subarray_written = obj.write_known_dim_count_with_fixed_int_subarray_written(2:end); + obj.write_known_dim_count_with_fixed_int_subarray_written = Node.empty(); end function write_known_dim_count_with_fixed_float_subarray_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_known_dim_count_with_fixed_float_subarray_written), "Unexpected call to write_known_dim_count_with_fixed_float_subarray_"); expected = obj.write_known_dim_count_with_fixed_float_subarray_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_known_dim_count_with_fixed_float_subarray_"); - obj.write_known_dim_count_with_fixed_float_subarray_written = obj.write_known_dim_count_with_fixed_float_subarray_written(2:end); + obj.write_known_dim_count_with_fixed_float_subarray_written = Node.empty(); end function write_fixed_with_fixed_int_subarray_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_fixed_with_fixed_int_subarray_written), "Unexpected call to write_fixed_with_fixed_int_subarray_"); expected = obj.write_fixed_with_fixed_int_subarray_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_with_fixed_int_subarray_"); - obj.write_fixed_with_fixed_int_subarray_written = obj.write_fixed_with_fixed_int_subarray_written(2:end); + obj.write_fixed_with_fixed_int_subarray_written = Node.empty(); end function write_fixed_with_fixed_float_subarray_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_fixed_with_fixed_float_subarray_written), "Unexpected call to write_fixed_with_fixed_float_subarray_"); expected = obj.write_fixed_with_fixed_float_subarray_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_with_fixed_float_subarray_"); - obj.write_fixed_with_fixed_float_subarray_written = obj.write_fixed_with_fixed_float_subarray_written(2:end); + obj.write_fixed_with_fixed_float_subarray_written = Node.empty(); end function write_nested_subarray_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_nested_subarray_written), "Unexpected call to write_nested_subarray_"); expected = obj.write_nested_subarray_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_nested_subarray_"); - obj.write_nested_subarray_written = obj.write_nested_subarray_written(2:end); + obj.write_nested_subarray_written = Node.empty(); end function write_dynamic_with_fixed_vector_subarray_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_dynamic_with_fixed_vector_subarray_written), "Unexpected call to write_dynamic_with_fixed_vector_subarray_"); expected = obj.write_dynamic_with_fixed_vector_subarray_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_dynamic_with_fixed_vector_subarray_"); - obj.write_dynamic_with_fixed_vector_subarray_written = obj.write_dynamic_with_fixed_vector_subarray_written(2:end); + obj.write_dynamic_with_fixed_vector_subarray_written = Node.empty(); end function write_generic_subarray_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_generic_subarray_written), "Unexpected call to write_generic_subarray_"); expected = obj.write_generic_subarray_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_generic_subarray_"); - obj.write_generic_subarray_written = obj.write_generic_subarray_written(2:end); + obj.write_generic_subarray_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockUnionsWriter.m b/matlab/generated/+test_model/+testing/MockUnionsWriter.m index ebca1771..ae2baf9f 100644 --- a/matlab/generated/+test_model/+testing/MockUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/MockUnionsWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockUnionsWriter < test_model.UnionsWriterBase +classdef MockUnionsWriter < matlab.mixin.Copyable & test_model.UnionsWriterBase properties testCase_ write_int_or_simple_record_written @@ -19,19 +19,39 @@ end function expect_write_int_or_simple_record_(obj, value) - obj.write_int_or_simple_record_written(end+1) = Node(value); + if isempty(obj.write_int_or_simple_record_written) + obj.write_int_or_simple_record_written = Node(value); + else + last_dim = ndims(value); + obj.write_int_or_simple_record_written = Node(cat(last_dim, obj.write_int_or_simple_record_written(1).value, value)); + end end function expect_write_int_or_record_with_vlens_(obj, value) - obj.write_int_or_record_with_vlens_written(end+1) = Node(value); + if isempty(obj.write_int_or_record_with_vlens_written) + obj.write_int_or_record_with_vlens_written = Node(value); + else + last_dim = ndims(value); + obj.write_int_or_record_with_vlens_written = Node(cat(last_dim, obj.write_int_or_record_with_vlens_written(1).value, value)); + end end function expect_write_monosotate_or_int_or_simple_record_(obj, value) - obj.write_monosotate_or_int_or_simple_record_written(end+1) = Node(value); + if isempty(obj.write_monosotate_or_int_or_simple_record_written) + obj.write_monosotate_or_int_or_simple_record_written = Node(value); + else + last_dim = ndims(value); + obj.write_monosotate_or_int_or_simple_record_written = Node(cat(last_dim, obj.write_monosotate_or_int_or_simple_record_written(1).value, value)); + end end function expect_write_record_with_unions_(obj, value) - obj.write_record_with_unions_written(end+1) = Node(value); + if isempty(obj.write_record_with_unions_written) + obj.write_record_with_unions_written = Node(value); + else + last_dim = ndims(value); + obj.write_record_with_unions_written = Node(cat(last_dim, obj.write_record_with_unions_written(1).value, value)); + end end function verify(obj) @@ -47,28 +67,28 @@ function write_int_or_simple_record_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_int_or_simple_record_written), "Unexpected call to write_int_or_simple_record_"); expected = obj.write_int_or_simple_record_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_simple_record_"); - obj.write_int_or_simple_record_written = obj.write_int_or_simple_record_written(2:end); + obj.write_int_or_simple_record_written = Node.empty(); end function write_int_or_record_with_vlens_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_int_or_record_with_vlens_written), "Unexpected call to write_int_or_record_with_vlens_"); expected = obj.write_int_or_record_with_vlens_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_record_with_vlens_"); - obj.write_int_or_record_with_vlens_written = obj.write_int_or_record_with_vlens_written(2:end); + obj.write_int_or_record_with_vlens_written = Node.empty(); end function write_monosotate_or_int_or_simple_record_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_monosotate_or_int_or_simple_record_written), "Unexpected call to write_monosotate_or_int_or_simple_record_"); expected = obj.write_monosotate_or_int_or_simple_record_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_monosotate_or_int_or_simple_record_"); - obj.write_monosotate_or_int_or_simple_record_written = obj.write_monosotate_or_int_or_simple_record_written(2:end); + obj.write_monosotate_or_int_or_simple_record_written = Node.empty(); end function write_record_with_unions_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_record_with_unions_written), "Unexpected call to write_record_with_unions_"); expected = obj.write_record_with_unions_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_unions_"); - obj.write_record_with_unions_written = obj.write_record_with_unions_written(2:end); + obj.write_record_with_unions_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockVlensWriter.m b/matlab/generated/+test_model/+testing/MockVlensWriter.m index a33017c3..0b64ae03 100644 --- a/matlab/generated/+test_model/+testing/MockVlensWriter.m +++ b/matlab/generated/+test_model/+testing/MockVlensWriter.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef MockVlensWriter < test_model.VlensWriterBase +classdef MockVlensWriter < matlab.mixin.Copyable & test_model.VlensWriterBase properties testCase_ write_int_vector_written @@ -19,19 +19,39 @@ end function expect_write_int_vector_(obj, value) - obj.write_int_vector_written(end+1) = Node(value); + if isempty(obj.write_int_vector_written) + obj.write_int_vector_written = Node(value); + else + last_dim = ndims(value); + obj.write_int_vector_written = Node(cat(last_dim, obj.write_int_vector_written(1).value, value)); + end end function expect_write_complex_vector_(obj, value) - obj.write_complex_vector_written(end+1) = Node(value); + if isempty(obj.write_complex_vector_written) + obj.write_complex_vector_written = Node(value); + else + last_dim = ndims(value); + obj.write_complex_vector_written = Node(cat(last_dim, obj.write_complex_vector_written(1).value, value)); + end end function expect_write_record_with_vlens_(obj, value) - obj.write_record_with_vlens_written(end+1) = Node(value); + if isempty(obj.write_record_with_vlens_written) + obj.write_record_with_vlens_written = Node(value); + else + last_dim = ndims(value); + obj.write_record_with_vlens_written = Node(cat(last_dim, obj.write_record_with_vlens_written(1).value, value)); + end end function expect_write_vlen_of_record_with_vlens_(obj, value) - obj.write_vlen_of_record_with_vlens_written(end+1) = Node(value); + if isempty(obj.write_vlen_of_record_with_vlens_written) + obj.write_vlen_of_record_with_vlens_written = Node(value); + else + last_dim = ndims(value); + obj.write_vlen_of_record_with_vlens_written = Node(cat(last_dim, obj.write_vlen_of_record_with_vlens_written(1).value, value)); + end end function verify(obj) @@ -47,28 +67,28 @@ function write_int_vector_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_int_vector_written), "Unexpected call to write_int_vector_"); expected = obj.write_int_vector_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_vector_"); - obj.write_int_vector_written = obj.write_int_vector_written(2:end); + obj.write_int_vector_written = Node.empty(); end function write_complex_vector_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_complex_vector_written), "Unexpected call to write_complex_vector_"); expected = obj.write_complex_vector_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_complex_vector_"); - obj.write_complex_vector_written = obj.write_complex_vector_written(2:end); + obj.write_complex_vector_written = Node.empty(); end function write_record_with_vlens_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_record_with_vlens_written), "Unexpected call to write_record_with_vlens_"); expected = obj.write_record_with_vlens_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_"); - obj.write_record_with_vlens_written = obj.write_record_with_vlens_written(2:end); + obj.write_record_with_vlens_written = Node.empty(); end function write_vlen_of_record_with_vlens_(obj, value) obj.testCase_.verifyTrue(~isempty(obj.write_vlen_of_record_with_vlens_written), "Unexpected call to write_vlen_of_record_with_vlens_"); expected = obj.write_vlen_of_record_with_vlens_written(1).value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_vlen_of_record_with_vlens_"); - obj.write_vlen_of_record_with_vlens_written = obj.write_vlen_of_record_with_vlens_written(2:end); + obj.write_vlen_of_record_with_vlens_written = Node.empty(); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m b/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m index a23bd2d3..02156af8 100644 --- a/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestAdvancedGenericsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestAdvancedGenericsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockAdvancedGenericsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestAdvancedGenericsWriter' to verify mocks")); @@ -53,10 +58,21 @@ function write_tuple_of_vectors_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestAliasesWriter.m b/matlab/generated/+test_model/+testing/TestAliasesWriter.m index 4544cc2f..e9053022 100644 --- a/matlab/generated/+test_model/+testing/TestAliasesWriter.m +++ b/matlab/generated/+test_model/+testing/TestAliasesWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestAliasesWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestAliasesWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockAliasesWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestAliasesWriter' to verify mocks")); @@ -78,10 +83,21 @@ function write_stream_of_aliased_generic_union_2_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m index 75b0b71b..cfbfcf67 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestBenchmarkFloat256x256Writer(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestBenchmarkFloat256x256Writer(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockBenchmarkFloat256x256Writer(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkFloat256x256Writer' to verify mocks")); @@ -33,10 +38,21 @@ function write_float256x256_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m index 5ca64d39..25460c1a 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestBenchmarkFloatVlenWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestBenchmarkFloatVlenWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockBenchmarkFloatVlenWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkFloatVlenWriter' to verify mocks")); @@ -33,10 +38,21 @@ function write_float_array_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m index 5c6169b1..c4d5bb14 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestBenchmarkInt256x256Writer(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestBenchmarkInt256x256Writer(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockBenchmarkInt256x256Writer(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkInt256x256Writer' to verify mocks")); @@ -33,10 +38,21 @@ function write_int256x256_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m index 4a65c610..44907283 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestBenchmarkSimpleMrdWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestBenchmarkSimpleMrdWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockBenchmarkSimpleMrdWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkSimpleMrdWriter' to verify mocks")); @@ -33,10 +38,21 @@ function write_data_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m index c71c65e9..d3a01189 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestBenchmarkSmallRecordWithOptionalsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestBenchmarkSmallRecordWithOptionalsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockBenchmarkSmallRecordWithOptionalsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkSmallRecordWithOptionalsWriter' to verify mocks")); @@ -33,10 +38,21 @@ function write_small_record_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m index fdfaa0be..8a33ec97 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestBenchmarkSmallRecordWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestBenchmarkSmallRecordWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockBenchmarkSmallRecordWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkSmallRecordWriter' to verify mocks")); @@ -33,10 +38,21 @@ function write_small_record_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m b/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m index 6a25f72b..739674e5 100644 --- a/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestDynamicNDArraysWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestDynamicNDArraysWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockDynamicNDArraysWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestDynamicNDArraysWriter' to verify mocks")); @@ -48,10 +53,21 @@ function write_record_with_dynamic_nd_arrays_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestEnumsWriter.m b/matlab/generated/+test_model/+testing/TestEnumsWriter.m index a8f46302..f5347b03 100644 --- a/matlab/generated/+test_model/+testing/TestEnumsWriter.m +++ b/matlab/generated/+test_model/+testing/TestEnumsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestEnumsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestEnumsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockEnumsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestEnumsWriter' to verify mocks")); @@ -43,10 +48,21 @@ function write_size_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m b/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m index 5508a751..0edfd48c 100644 --- a/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestFixedArraysWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestFixedArraysWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockFixedArraysWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestFixedArraysWriter' to verify mocks")); @@ -53,10 +58,21 @@ function write_named_array_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m b/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m index 194562bb..1a8ceb70 100644 --- a/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestFixedVectorsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestFixedVectorsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockFixedVectorsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestFixedVectorsWriter' to verify mocks")); @@ -48,10 +53,21 @@ function write_record_with_fixed_vectors_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestFlagsWriter.m b/matlab/generated/+test_model/+testing/TestFlagsWriter.m index cd0d827c..45dda4de 100644 --- a/matlab/generated/+test_model/+testing/TestFlagsWriter.m +++ b/matlab/generated/+test_model/+testing/TestFlagsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestFlagsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestFlagsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockFlagsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestFlagsWriter' to verify mocks")); @@ -38,10 +43,21 @@ function write_formats_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestMapsWriter.m b/matlab/generated/+test_model/+testing/TestMapsWriter.m index cbf2324a..bf33b865 100644 --- a/matlab/generated/+test_model/+testing/TestMapsWriter.m +++ b/matlab/generated/+test_model/+testing/TestMapsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestMapsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestMapsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockMapsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestMapsWriter' to verify mocks")); @@ -48,10 +53,21 @@ function write_aliased_generic_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m b/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m index c74088c7..f88bc9de 100644 --- a/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m +++ b/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestNDArraysSingleDimensionWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestNDArraysSingleDimensionWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockNDArraysSingleDimensionWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestNDArraysSingleDimensionWriter' to verify mocks")); @@ -48,10 +53,21 @@ function write_record_with_nd_arrays_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestNDArraysWriter.m b/matlab/generated/+test_model/+testing/TestNDArraysWriter.m index 039f9a8d..cbead3e9 100644 --- a/matlab/generated/+test_model/+testing/TestNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestNDArraysWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestNDArraysWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestNDArraysWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockNDArraysWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestNDArraysWriter' to verify mocks")); @@ -53,10 +58,21 @@ function write_named_array_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m b/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m index ec761e8f..c298e402 100644 --- a/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestNestedRecordsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestNestedRecordsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockNestedRecordsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestNestedRecordsWriter' to verify mocks")); @@ -33,10 +38,21 @@ function write_tuple_with_records_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m b/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m index c485efee..a489df7a 100644 --- a/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestOptionalVectorsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestOptionalVectorsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockOptionalVectorsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestOptionalVectorsWriter' to verify mocks")); @@ -33,10 +38,21 @@ function write_record_with_optional_vector_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m b/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m index 0850caba..5ce8e409 100644 --- a/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m +++ b/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestProtocolWithComputedFieldsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestProtocolWithComputedFieldsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockProtocolWithComputedFieldsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestProtocolWithComputedFieldsWriter' to verify mocks")); @@ -33,10 +38,21 @@ function write_record_with_computed_fields_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m index 43b88e2d..ef40690f 100644 --- a/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m +++ b/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestProtocolWithKeywordStepsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestProtocolWithKeywordStepsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockProtocolWithKeywordStepsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestProtocolWithKeywordStepsWriter' to verify mocks")); @@ -38,10 +43,21 @@ function write_float_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m b/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m index 23bf89b0..c7438c65 100644 --- a/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestScalarOptionalsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestScalarOptionalsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockScalarOptionalsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestScalarOptionalsWriter' to verify mocks")); @@ -48,10 +53,21 @@ function write_optional_record_with_optional_fields_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestScalarsWriter.m b/matlab/generated/+test_model/+testing/TestScalarsWriter.m index 3be658ec..2c3bfa64 100644 --- a/matlab/generated/+test_model/+testing/TestScalarsWriter.m +++ b/matlab/generated/+test_model/+testing/TestScalarsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestScalarsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestScalarsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockScalarsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestScalarsWriter' to verify mocks")); @@ -38,10 +43,21 @@ function write_record_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m b/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m index e4012ad7..5b377580 100644 --- a/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestSimpleGenericsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestSimpleGenericsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockSimpleGenericsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestSimpleGenericsWriter' to verify mocks")); @@ -73,10 +78,21 @@ function write_stream_of_type_variants_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestStateTestWriter.m b/matlab/generated/+test_model/+testing/TestStateTestWriter.m index 858012f7..2bafbfef 100644 --- a/matlab/generated/+test_model/+testing/TestStateTestWriter.m +++ b/matlab/generated/+test_model/+testing/TestStateTestWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestStateTestWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestStateTestWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockStateTestWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestStateTestWriter' to verify mocks")); @@ -43,10 +48,21 @@ function write_another_int_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m index 9ffb9ead..01cad8e2 100644 --- a/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestStreamsOfAliasedUnionsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestStreamsOfAliasedUnionsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockStreamsOfAliasedUnionsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestStreamsOfAliasedUnionsWriter' to verify mocks")); @@ -38,10 +43,21 @@ function write_nullable_int_or_simple_record_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m index eac82dba..790189d5 100644 --- a/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestStreamsOfUnionsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestStreamsOfUnionsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockStreamsOfUnionsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestStreamsOfUnionsWriter' to verify mocks")); @@ -38,10 +43,21 @@ function write_nullable_int_or_simple_record_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestStreamsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsWriter.m index 4529417a..9b6ddda8 100644 --- a/matlab/generated/+test_model/+testing/TestStreamsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStreamsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestStreamsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestStreamsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockStreamsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestStreamsWriter' to verify mocks")); @@ -48,10 +53,21 @@ function write_fixed_vector_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestStringsWriter.m b/matlab/generated/+test_model/+testing/TestStringsWriter.m index 8f83dede..4889b4fc 100644 --- a/matlab/generated/+test_model/+testing/TestStringsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStringsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestStringsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestStringsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockStringsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestStringsWriter' to verify mocks")); @@ -38,10 +43,21 @@ function write_rec_with_string_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m b/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m index 3f7535ca..5e74c33f 100644 --- a/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestSubarraysInRecordsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestSubarraysInRecordsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockSubarraysInRecordsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestSubarraysInRecordsWriter' to verify mocks")); @@ -38,10 +43,21 @@ function write_with_vlen_subarrays_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestSubarraysWriter.m b/matlab/generated/+test_model/+testing/TestSubarraysWriter.m index 1b61eb72..7417c09e 100644 --- a/matlab/generated/+test_model/+testing/TestSubarraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestSubarraysWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestSubarraysWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestSubarraysWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockSubarraysWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestSubarraysWriter' to verify mocks")); @@ -73,10 +78,21 @@ function write_generic_subarray_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestUnionsWriter.m b/matlab/generated/+test_model/+testing/TestUnionsWriter.m index 678d8c40..0a68bc32 100644 --- a/matlab/generated/+test_model/+testing/TestUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/TestUnionsWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestUnionsWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestUnionsWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockUnionsWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestUnionsWriter' to verify mocks")); @@ -48,10 +53,21 @@ function write_record_with_unions_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestVlensWriter.m b/matlab/generated/+test_model/+testing/TestVlensWriter.m index 6e536c4e..e4e8ddd9 100644 --- a/matlab/generated/+test_model/+testing/TestVlensWriter.m +++ b/matlab/generated/+test_model/+testing/TestVlensWriter.m @@ -6,17 +6,22 @@ create_reader_ mock_writer_ close_called_ + filename_ + format_ end methods - function obj = TestVlensWriter(testCase, writer, create_reader) - obj.writer_ = writer; + function obj = TestVlensWriter(testCase, format, create_writer, create_reader) + obj.filename_ = tempname(); + obj.format_ = format; + obj.writer_ = create_writer(obj.filename_); obj.create_reader_ = create_reader; obj.mock_writer_ = test_model.testing.MockVlensWriter(testCase); obj.close_called_ = false; end function delete(obj) + % delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestVlensWriter' to verify mocks")); @@ -48,10 +53,21 @@ function write_vlen_of_record_with_vlens_(obj, value) function close_(obj) obj.close_called_ = true; obj.writer_.close(); - reader = obj.create_reader_(); + mock_copy = copy(obj.mock_writer_); + + reader = obj.create_reader_(obj.filename_); reader.copy_to(obj.mock_writer_); reader.close(); obj.mock_writer_.verify(); + obj.mock_writer_.close(); + + translated = invoke_translator(obj.filename_, obj.format_, obj.format_); + reader = obj.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + % delete(translated); end function end_stream_(obj) diff --git a/matlab/tests/RoundTripTest.m b/matlab/tests/RoundTripTest.m index 95e3f0a7..7aa01d3d 100644 --- a/matlab/tests/RoundTripTest.m +++ b/matlab/tests/RoundTripTest.m @@ -334,11 +334,10 @@ function testFlags(testCase, format) function testSimpleStreams(testCase, format) w = create_validating_writer(testCase, format, 'Streams'); - % TODO: MockWriter can't yet handle multiple stream write calls (the result of read is always the full concatenated stream) - % w.write_int_data(int32(1:10)); - % w.write_int_data(int32(1:20)); - w.write_int_data(int32(1:30)); - + % Non-empty streams + w.write_int_data(int32(1:10)); + w.write_int_data(42); + w.write_int_data(int32(1:20)); w.write_optional_int_data([1, 2, yardl.None, 4, 5, yardl.None, 7, 8, 9, 10]); w.write_record_with_optional_vector_data([... test_model.RecordWithOptionalVector(), ... @@ -352,6 +351,17 @@ function testSimpleStreams(testCase, format) ); w.close(); + % Mixed empty/non-empty streams + w = create_validating_writer(testCase, format, 'Streams'); + w.write_int_data(int32(1:10)) + w.write_int_data([]); + w.write_optional_int_data([]); + w.write_optional_int_data([1, 2, yardl.None, 4, 5, yardl.None, 7, 8, 9, 10]); + w.write_record_with_optional_vector_data([]); + w.write_fixed_vector(int32(repmat([1;2;3], 1,4))); + w.close(); + + % All empty streams w = create_validating_writer(testCase, format, 'Streams'); w.write_int_data([]); w.write_optional_int_data([]); @@ -477,7 +487,5 @@ function testAliases(testCase, format) create_reader = str2func(reader_name); create_test_writer = str2func(test_writer_name); - testfile = tempname; - writer = create_writer(testfile); - w = create_test_writer(testCase, writer, @() create_reader(testfile)); + w = create_test_writer(testCase, format, @(f) create_writer(f), @(f) create_reader(f)); end diff --git a/matlab/tests/invoke_translator.m b/matlab/tests/invoke_translator.m new file mode 100644 index 00000000..03bd2611 --- /dev/null +++ b/matlab/tests/invoke_translator.m @@ -0,0 +1,15 @@ +function output_filename = invoke_translator(input_filename, input_format, output_format) + translator_path = "../../cpp/build/translator"; + % output_filename = tempname(); + output_filename = sprintf("%s.translated", input_filename); + dump = "cat"; + if ispc + dump = "type"; + end + cmd = sprintf("%s %s | %s %s %s > %s", dump, input_filename, translator_path, input_format, output_format, output_filename); + + [status, cmdout] = system(cmd); + if status ~= 0 + error("Failed to invoke translator: %s", cmdout); + end +end diff --git a/tooling/internal/matlab/mocks/mocks.go b/tooling/internal/matlab/mocks/mocks.go index 9e4cf093..f257aa38 100644 --- a/tooling/internal/matlab/mocks/mocks.go +++ b/tooling/internal/matlab/mocks/mocks.go @@ -20,14 +20,13 @@ func WriteMocks(fw *common.MatlabFileWriter, ns *dsl.Namespace) error { return err } } - return nil } func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) error { return fw.WriteFile(mockWriterName(p), func(w *formatting.IndentedWriter) { abstractWriterName := fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(p.Namespace), common.AbstractWriterName(p)) - fmt.Fprintf(w, "classdef %s < %s\n", mockWriterName(p), abstractWriterName) + fmt.Fprintf(w, "classdef %s < matlab.mixin.Copyable & %s\n", mockWriterName(p), abstractWriterName) common.WriteBlockBody(w, func() { w.WriteStringln("properties") common.WriteBlockBody(w, func() { @@ -52,7 +51,15 @@ func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) e for _, step := range p.Sequence { fmt.Fprintf(w, "function expect_%s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.%swritten(end+1) = Node(value);\n", common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "if isempty(obj.%swritten)\n", common.ProtocolWriteImplMethodName(step)) + w.Indented(func() { + fmt.Fprintf(w, "obj.%swritten = Node(value);\n", common.ProtocolWriteImplMethodName(step)) + }) + w.WriteStringln("else") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "last_dim = ndims(value);\n") + fmt.Fprintf(w, "obj.%swritten = Node(cat(last_dim, obj.%swritten(1).value, value));\n", common.ProtocolWriteImplMethodName(step), common.ProtocolWriteImplMethodName(step)) + }) }) w.WriteStringln("") } @@ -60,10 +67,6 @@ func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) e w.WriteStringln("function verify(obj)") common.WriteBlockBody(w, func() { for _, step := range p.Sequence { - // fmt.Fprintf(w, "if ~isempty(obj.%swritten)\n", common.ProtocolWriteImplMethodName(step)) - // common.WriteBlockBody(w, func() { - // fmt.Fprintf(w, "throw(yardl.RuntimeError(\"Expected call to %s was not received\"));\n", common.ProtocolWriteImplMethodName(step)) - // }) diagnostic := fmt.Sprintf("Expected call to %s was not received", common.ProtocolWriteImplMethodName(step)) fmt.Fprintf(w, "obj.testCase_.verifyTrue(isempty(obj.%swritten), \"%s\");\n", common.ProtocolWriteImplMethodName(step), diagnostic) } @@ -76,20 +79,10 @@ func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) e for _, step := range p.Sequence { fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) common.WriteBlockBody(w, func() { - // fmt.Fprintf(w, "if isempty(obj.%swritten)\n", common.ProtocolWriteImplMethodName(step)) - // common.WriteBlockBody(w, func() { - // fmt.Fprintf(w, "throw(yardl.RuntimeError(\"Unexpected call to %s\"));\n", common.ProtocolWriteImplMethodName(step)) - // }) fmt.Fprintf(w, "obj.testCase_.verifyTrue(~isempty(obj.%swritten), \"Unexpected call to %s\");\n", common.ProtocolWriteImplMethodName(step), common.ProtocolWriteImplMethodName(step)) - - // fmt.Fprintf(w, "if value ~= obj.%swritten(1)\n", common.ProtocolWriteImplMethodName(step)) - // common.WriteBlockBody(w, func() { - // fmt.Fprintf(w, "throw(yardl.RuntimeError(\"Unexpected argument value for call to %s\"));\n", common.ProtocolWriteImplMethodName(step)) - // }) fmt.Fprintf(w, "expected = obj.%swritten(1).value;\n", common.ProtocolWriteImplMethodName(step)) fmt.Fprintf(w, "obj.testCase_.verifyEqual(value, expected, \"Unexpected argument value for call to %s\");\n", common.ProtocolWriteImplMethodName(step)) - - fmt.Fprintf(w, "obj.%swritten = obj.%swritten(2:end);\n", common.ProtocolWriteImplMethodName(step), common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "obj.%swritten = Node.empty();\n", common.ProtocolWriteImplMethodName(step)) }) w.WriteStringln("") } @@ -115,14 +108,19 @@ func writeProtocolTestWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinit w.WriteStringln("create_reader_") w.WriteStringln("mock_writer_") w.WriteStringln("close_called_") + w.WriteStringln("filename_") + w.WriteStringln("format_") }) w.WriteStringln("") w.WriteStringln("methods") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "function obj = %s(testCase, writer, create_reader)\n", testWriterName(p)) + fmt.Fprintf(w, "function obj = %s(testCase, format, create_writer, create_reader)\n", testWriterName(p)) common.WriteBlockBody(w, func() { - w.WriteStringln("obj.writer_ = writer;") + w.WriteStringln("obj.filename_ = tempname();") + // w.WriteStringln("obj.filename_ = sprintf(\"%s" + formatting.ToPascalCase(p.Name) + ".bin\", tempdir());") + w.WriteStringln("obj.format_ = format;") + w.WriteStringln("obj.writer_ = create_writer(obj.filename_);") w.WriteStringln("obj.create_reader_ = create_reader;") mockWriterName := fmt.Sprintf("%s.testing.%s", common.NamespaceIdentifierName(p.Namespace), mockWriterName(p)) fmt.Fprintf(w, "obj.mock_writer_ = %s(testCase);\n", mockWriterName) @@ -132,6 +130,7 @@ func writeProtocolTestWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinit w.WriteStringln("function delete(obj)") common.WriteBlockBody(w, func() { + w.WriteStringln("% delete(obj.filename_);") w.WriteStringln("if ~obj.close_called_") common.WriteBlockBody(w, func() { common.WriteComment(w, "ADD_FAILURE() << ...;") @@ -156,26 +155,37 @@ func writeProtocolTestWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinit common.WriteBlockBody(w, func() { w.WriteStringln("obj.close_called_ = true;") w.WriteStringln("obj.writer_.close();") - w.WriteStringln("reader = obj.create_reader_();") + w.WriteStringln("mock_copy = copy(obj.mock_writer_);") + + w.WriteStringln("") + w.WriteStringln("reader = obj.create_reader_(obj.filename_);") w.WriteStringln("reader.copy_to(obj.mock_writer_);") w.WriteStringln("reader.close();") w.WriteStringln("obj.mock_writer_.verify();") + w.WriteStringln("obj.mock_writer_.close();") + + w.WriteStringln("") + w.WriteStringln("translated = invoke_translator(obj.filename_, obj.format_, obj.format_);") + w.WriteStringln("reader = obj.create_reader_(translated);") + w.WriteStringln("reader.copy_to(mock_copy);") + w.WriteStringln("reader.close();") + w.WriteStringln("mock_copy.verify();") + w.WriteStringln("mock_copy.close();") + w.WriteStringln("% delete(translated);") }) w.WriteStringln("") w.WriteStringln("function end_stream_(obj)") common.WriteBlockBody(w, func() {}) }) - }) - }) } func mockWriterName(p *dsl.ProtocolDefinition) string { - return fmt.Sprintf("Mock%sWriter", p.Name) + return fmt.Sprintf("Mock%sWriter", formatting.ToPascalCase(p.Name)) } func testWriterName(p *dsl.ProtocolDefinition) string { - return fmt.Sprintf("Test%sWriter", p.Name) + return fmt.Sprintf("Test%sWriter", formatting.ToPascalCase(p.Name)) } diff --git a/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m index 71612628..86f05d5d 100644 --- a/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m @@ -56,6 +56,9 @@ function write(self, outstream, values) s = [item_shape obj.shape_ ]; else s = [item_shape obj.shape_]; + end + + if length(s) > 2 s = s(s>1); end end diff --git a/tooling/internal/matlab/static_files/+binary/StreamSerializer.m b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m index 282db4bd..a82e6680 100644 --- a/tooling/internal/matlab/static_files/+binary/StreamSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m @@ -9,6 +9,10 @@ end function write(obj, outstream, values) + if isempty(values) + return; + end + s = size(values); count = s(end); outstream.write_unsigned_varint(count); From 788df0dd833218f9960ac69f2a20730cd1f3717c Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Fri, 5 Apr 2024 18:54:15 +0000 Subject: [PATCH 14/32] Finish Matlab tests --- cpp/test/generated/binary/protocols.cc | 7 +- cpp/test/generated/hdf5/protocols.cc | 4 + cpp/test/generated/model.json | 51 +++++ cpp/test/generated/ndjson/protocols.cc | 6 + cpp/test/generated/protocols.cc | 2 +- cpp/test/generated/types.h | 14 ++ .../RecordWithComputedFieldsSerializer.m | 13 +- .../RecordWithKeywordFieldsSerializer.m | 2 +- .../+testing/MockAdvancedGenericsWriter.m | 90 ++++----- .../+test_model/+testing/MockAliasesWriter.m | 180 +++++++++--------- .../MockBenchmarkFloat256x256Writer.m | 18 +- .../+testing/MockBenchmarkFloatVlenWriter.m | 18 +- .../+testing/MockBenchmarkInt256x256Writer.m | 18 +- .../+testing/MockBenchmarkSimpleMrdWriter.m | 18 +- ...kBenchmarkSmallRecordWithOptionalsWriter.m | 18 +- .../+testing/MockBenchmarkSmallRecordWriter.m | 18 +- .../+testing/MockDynamicNDArraysWriter.m | 72 +++---- .../+test_model/+testing/MockEnumsWriter.m | 54 +++--- .../+testing/MockFixedArraysWriter.m | 90 ++++----- .../+testing/MockFixedVectorsWriter.m | 72 +++---- .../+test_model/+testing/MockFlagsWriter.m | 36 ++-- .../+test_model/+testing/MockMapsWriter.m | 72 +++---- .../MockNDArraysSingleDimensionWriter.m | 72 +++---- .../+test_model/+testing/MockNDArraysWriter.m | 90 ++++----- .../+testing/MockNestedRecordsWriter.m | 18 +- .../+testing/MockOptionalVectorsWriter.m | 18 +- .../MockProtocolWithComputedFieldsWriter.m | 18 +- .../MockProtocolWithKeywordStepsWriter.m | 36 ++-- .../+testing/MockScalarOptionalsWriter.m | 72 +++---- .../+test_model/+testing/MockScalarsWriter.m | 36 ++-- .../+testing/MockSimpleGenericsWriter.m | 162 ++++++++-------- .../+testing/MockStateTestWriter.m | 54 +++--- .../MockStreamsOfAliasedUnionsWriter.m | 36 ++-- .../+testing/MockStreamsOfUnionsWriter.m | 36 ++-- .../+test_model/+testing/MockStreamsWriter.m | 72 +++---- .../+test_model/+testing/MockStringsWriter.m | 36 ++-- .../+testing/MockSubarraysInRecordsWriter.m | 36 ++-- .../+testing/MockSubarraysWriter.m | 162 ++++++++-------- .../+test_model/+testing/MockUnionsWriter.m | 72 +++---- .../+test_model/+testing/MockVlensWriter.m | 72 +++---- .../+testing/TestAdvancedGenericsWriter.m | 4 +- .../+test_model/+testing/TestAliasesWriter.m | 4 +- .../TestBenchmarkFloat256x256Writer.m | 4 +- .../+testing/TestBenchmarkFloatVlenWriter.m | 4 +- .../+testing/TestBenchmarkInt256x256Writer.m | 4 +- .../+testing/TestBenchmarkSimpleMrdWriter.m | 4 +- ...tBenchmarkSmallRecordWithOptionalsWriter.m | 4 +- .../+testing/TestBenchmarkSmallRecordWriter.m | 4 +- .../+testing/TestDynamicNDArraysWriter.m | 4 +- .../+test_model/+testing/TestEnumsWriter.m | 4 +- .../+testing/TestFixedArraysWriter.m | 4 +- .../+testing/TestFixedVectorsWriter.m | 4 +- .../+test_model/+testing/TestFlagsWriter.m | 4 +- .../+test_model/+testing/TestMapsWriter.m | 4 +- .../TestNDArraysSingleDimensionWriter.m | 4 +- .../+test_model/+testing/TestNDArraysWriter.m | 4 +- .../+testing/TestNestedRecordsWriter.m | 4 +- .../+testing/TestOptionalVectorsWriter.m | 4 +- .../TestProtocolWithComputedFieldsWriter.m | 4 +- .../TestProtocolWithKeywordStepsWriter.m | 4 +- .../+testing/TestScalarOptionalsWriter.m | 4 +- .../+test_model/+testing/TestScalarsWriter.m | 4 +- .../+testing/TestSimpleGenericsWriter.m | 4 +- .../+testing/TestStateTestWriter.m | 4 +- .../TestStreamsOfAliasedUnionsWriter.m | 4 +- .../+testing/TestStreamsOfUnionsWriter.m | 4 +- .../+test_model/+testing/TestStreamsWriter.m | 4 +- .../+test_model/+testing/TestStringsWriter.m | 4 +- .../+testing/TestSubarraysInRecordsWriter.m | 4 +- .../+testing/TestSubarraysWriter.m | 4 +- .../+test_model/+testing/TestUnionsWriter.m | 4 +- .../+test_model/+testing/TestVlensWriter.m | 4 +- .../ProtocolWithComputedFieldsWriterBase.m | 2 +- .../+test_model/RecordWithComputedFields.m | 67 +++---- .../+test_model/RecordWithKeywordFields.m | 12 +- matlab/tests/ComputedFieldsTest.m | 72 ++++--- matlab/tests/EqualityTest.m | 41 +++- matlab/tests/GeneratedTypesTest.m | 45 ++++- matlab/tests/Node.m | 10 - matlab/tests/RoundTripTest.m | 10 - matlab/tests/YardlTypesTest.m | 2 - matlab/tests/run.m | 13 +- models/test/unittests.yml | 3 + python/test_model/binary.py | 8 +- python/test_model/ndjson.py | 6 + python/test_model/protocols.py | 2 +- python/test_model/types.py | 16 +- tooling/internal/matlab/binary/binary.go | 7 - tooling/internal/matlab/common/common.go | 30 ++- tooling/internal/matlab/mocks/mocks.go | 23 ++- .../+binary/BinaryProtocolReader.m | 3 + .../+binary/BinaryProtocolWriter.m | 3 + .../static_files/+binary/BoolSerializer.m | 3 + .../+binary/CURRENT_BINARY_FORMAT_VERSION.m | 3 + .../static_files/+binary/CodedInputStream.m | 3 + .../static_files/+binary/CodedOutputStream.m | 3 + .../+binary/Complexfloat32Serializer.m | 3 + .../+binary/Complexfloat64Serializer.m | 3 + .../static_files/+binary/DateSerializer.m | 3 + .../static_files/+binary/DatetimeSerializer.m | 3 + .../+binary/DynamicNDArraySerializer.m | 3 + .../static_files/+binary/EnumSerializer.m | 3 + .../matlab/static_files/+binary/Error.m | 3 + .../+binary/FixedNDArraySerializer.m | 3 + .../+binary/FixedVectorSerializer.m | 3 + .../static_files/+binary/Float32Serializer.m | 3 + .../static_files/+binary/Float64Serializer.m | 3 + .../static_files/+binary/Int16Serializer.m | 3 + .../static_files/+binary/Int32Serializer.m | 3 + .../static_files/+binary/Int64Serializer.m | 3 + .../static_files/+binary/Int8Serializer.m | 3 + .../matlab/static_files/+binary/MAGIC_BYTES.m | 3 + .../static_files/+binary/MapSerializer.m | 15 +- .../static_files/+binary/NDArraySerializer.m | 3 + .../+binary/NDArraySerializerBase.m | 3 + .../static_files/+binary/NoneSerializer.m | 3 + .../static_files/+binary/OptionalSerializer.m | 14 +- .../static_files/+binary/RecordSerializer.m | 3 + .../static_files/+binary/SizeSerializer.m | 3 + .../static_files/+binary/StreamSerializer.m | 3 + .../static_files/+binary/StringSerializer.m | 6 +- .../static_files/+binary/TimeSerializer.m | 3 + .../static_files/+binary/TypeSerializer.m | 3 + .../static_files/+binary/Uint16Serializer.m | 3 + .../static_files/+binary/Uint32Serializer.m | 3 + .../static_files/+binary/Uint64Serializer.m | 3 + .../static_files/+binary/Uint8Serializer.m | 4 +- .../static_files/+binary/UnionSerializer.m | 12 +- .../static_files/+binary/VectorSerializer.m | 3 + tooling/internal/matlab/static_files/Date.m | 3 + .../internal/matlab/static_files/DateTime.m | 5 +- .../internal/matlab/static_files/Exception.m | 3 + .../internal/matlab/static_files/KeyError.m | 3 + tooling/internal/matlab/static_files/None.m | 30 +-- .../internal/matlab/static_files/Optional.m | 23 +-- .../matlab/static_files/ProtocolError.m | 3 + .../matlab/static_files/RuntimeError.m | 3 + tooling/internal/matlab/static_files/Time.m | 7 +- .../internal/matlab/static_files/TypeError.m | 3 + tooling/internal/matlab/static_files/Union.m | 3 + .../internal/matlab/static_files/ValueError.m | 3 + .../internal/matlab/static_files/allocate.m | 4 + .../matlab/static_files/dimension_count.m | 7 +- tooling/internal/matlab/types/types.go | 45 ++--- 144 files changed, 1479 insertions(+), 1287 deletions(-) delete mode 100644 matlab/tests/Node.m diff --git a/cpp/test/generated/binary/protocols.cc b/cpp/test/generated/binary/protocols.cc index 55163ae6..52603b1b 100644 --- a/cpp/test/generated/binary/protocols.cc +++ b/cpp/test/generated/binary/protocols.cc @@ -547,13 +547,14 @@ struct IsTriviallySerializable { IsTriviallySerializable::value && IsTriviallySerializable::value && IsTriviallySerializable::value && + IsTriviallySerializable::value && IsTriviallySerializable::value && IsTriviallySerializable::value && IsTriviallySerializable::value && IsTriviallySerializable::value && IsTriviallySerializable::value && - (sizeof(__T__) == (sizeof(__T__::array_field) + sizeof(__T__::array_field_map_dimensions) + sizeof(__T__::dynamic_array_field) + sizeof(__T__::fixed_array_field) + sizeof(__T__::int_field) + sizeof(__T__::int8_field) + sizeof(__T__::uint8_field) + sizeof(__T__::int16_field) + sizeof(__T__::uint16_field) + sizeof(__T__::uint32_field) + sizeof(__T__::int64_field) + sizeof(__T__::uint64_field) + sizeof(__T__::size_field) + sizeof(__T__::float32_field) + sizeof(__T__::float64_field) + sizeof(__T__::complexfloat32_field) + sizeof(__T__::complexfloat64_field) + sizeof(__T__::string_field) + sizeof(__T__::tuple_field) + sizeof(__T__::vector_field) + sizeof(__T__::vector_of_vectors_field) + sizeof(__T__::fixed_vector_field) + sizeof(__T__::optional_named_array) + sizeof(__T__::int_float_union) + sizeof(__T__::nullable_int_float_union) + sizeof(__T__::union_with_nested_generic_union) + sizeof(__T__::map_field))) && - offsetof(__T__, array_field) < offsetof(__T__, array_field_map_dimensions) && offsetof(__T__, array_field_map_dimensions) < offsetof(__T__, dynamic_array_field) && offsetof(__T__, dynamic_array_field) < offsetof(__T__, fixed_array_field) && offsetof(__T__, fixed_array_field) < offsetof(__T__, int_field) && offsetof(__T__, int_field) < offsetof(__T__, int8_field) && offsetof(__T__, int8_field) < offsetof(__T__, uint8_field) && offsetof(__T__, uint8_field) < offsetof(__T__, int16_field) && offsetof(__T__, int16_field) < offsetof(__T__, uint16_field) && offsetof(__T__, uint16_field) < offsetof(__T__, uint32_field) && offsetof(__T__, uint32_field) < offsetof(__T__, int64_field) && offsetof(__T__, int64_field) < offsetof(__T__, uint64_field) && offsetof(__T__, uint64_field) < offsetof(__T__, size_field) && offsetof(__T__, size_field) < offsetof(__T__, float32_field) && offsetof(__T__, float32_field) < offsetof(__T__, float64_field) && offsetof(__T__, float64_field) < offsetof(__T__, complexfloat32_field) && offsetof(__T__, complexfloat32_field) < offsetof(__T__, complexfloat64_field) && offsetof(__T__, complexfloat64_field) < offsetof(__T__, string_field) && offsetof(__T__, string_field) < offsetof(__T__, tuple_field) && offsetof(__T__, tuple_field) < offsetof(__T__, vector_field) && offsetof(__T__, vector_field) < offsetof(__T__, vector_of_vectors_field) && offsetof(__T__, vector_of_vectors_field) < offsetof(__T__, fixed_vector_field) && offsetof(__T__, fixed_vector_field) < offsetof(__T__, optional_named_array) && offsetof(__T__, optional_named_array) < offsetof(__T__, int_float_union) && offsetof(__T__, int_float_union) < offsetof(__T__, nullable_int_float_union) && offsetof(__T__, nullable_int_float_union) < offsetof(__T__, union_with_nested_generic_union) && offsetof(__T__, union_with_nested_generic_union) < offsetof(__T__, map_field); + (sizeof(__T__) == (sizeof(__T__::array_field) + sizeof(__T__::array_field_map_dimensions) + sizeof(__T__::dynamic_array_field) + sizeof(__T__::fixed_array_field) + sizeof(__T__::int_field) + sizeof(__T__::int8_field) + sizeof(__T__::uint8_field) + sizeof(__T__::int16_field) + sizeof(__T__::uint16_field) + sizeof(__T__::uint32_field) + sizeof(__T__::int64_field) + sizeof(__T__::uint64_field) + sizeof(__T__::size_field) + sizeof(__T__::float32_field) + sizeof(__T__::float64_field) + sizeof(__T__::complexfloat32_field) + sizeof(__T__::complexfloat64_field) + sizeof(__T__::string_field) + sizeof(__T__::tuple_field) + sizeof(__T__::vector_field) + sizeof(__T__::vector_of_vectors_field) + sizeof(__T__::fixed_vector_field) + sizeof(__T__::fixed_vector_of_vectors_field) + sizeof(__T__::optional_named_array) + sizeof(__T__::int_float_union) + sizeof(__T__::nullable_int_float_union) + sizeof(__T__::union_with_nested_generic_union) + sizeof(__T__::map_field))) && + offsetof(__T__, array_field) < offsetof(__T__, array_field_map_dimensions) && offsetof(__T__, array_field_map_dimensions) < offsetof(__T__, dynamic_array_field) && offsetof(__T__, dynamic_array_field) < offsetof(__T__, fixed_array_field) && offsetof(__T__, fixed_array_field) < offsetof(__T__, int_field) && offsetof(__T__, int_field) < offsetof(__T__, int8_field) && offsetof(__T__, int8_field) < offsetof(__T__, uint8_field) && offsetof(__T__, uint8_field) < offsetof(__T__, int16_field) && offsetof(__T__, int16_field) < offsetof(__T__, uint16_field) && offsetof(__T__, uint16_field) < offsetof(__T__, uint32_field) && offsetof(__T__, uint32_field) < offsetof(__T__, int64_field) && offsetof(__T__, int64_field) < offsetof(__T__, uint64_field) && offsetof(__T__, uint64_field) < offsetof(__T__, size_field) && offsetof(__T__, size_field) < offsetof(__T__, float32_field) && offsetof(__T__, float32_field) < offsetof(__T__, float64_field) && offsetof(__T__, float64_field) < offsetof(__T__, complexfloat32_field) && offsetof(__T__, complexfloat32_field) < offsetof(__T__, complexfloat64_field) && offsetof(__T__, complexfloat64_field) < offsetof(__T__, string_field) && offsetof(__T__, string_field) < offsetof(__T__, tuple_field) && offsetof(__T__, tuple_field) < offsetof(__T__, vector_field) && offsetof(__T__, vector_field) < offsetof(__T__, vector_of_vectors_field) && offsetof(__T__, vector_of_vectors_field) < offsetof(__T__, fixed_vector_field) && offsetof(__T__, fixed_vector_field) < offsetof(__T__, fixed_vector_of_vectors_field) && offsetof(__T__, fixed_vector_of_vectors_field) < offsetof(__T__, optional_named_array) && offsetof(__T__, optional_named_array) < offsetof(__T__, int_float_union) && offsetof(__T__, int_float_union) < offsetof(__T__, nullable_int_float_union) && offsetof(__T__, nullable_int_float_union) < offsetof(__T__, union_with_nested_generic_union) && offsetof(__T__, union_with_nested_generic_union) < offsetof(__T__, map_field); }; template <> @@ -2439,6 +2440,7 @@ template ReadA, typename B, yardl::binary:: yardl::binary::WriteVector(stream, value.vector_field); yardl::binary::WriteVector, yardl::binary::WriteVector>(stream, value.vector_of_vectors_field); yardl::binary::WriteArray(stream, value.fixed_vector_field); + yardl::binary::WriteArray, yardl::binary::WriteArray, 2>(stream, value.fixed_vector_of_vectors_field); yardl::binary::WriteOptional(stream, value.optional_named_array); WriteUnion(stream, value.int_float_union); WriteUnion(stream, value.nullable_int_float_union); @@ -2474,6 +2476,7 @@ template ReadA, typename B, yardl::binary:: yardl::binary::ReadVector(stream, value.vector_field); yardl::binary::ReadVector, yardl::binary::ReadVector>(stream, value.vector_of_vectors_field); yardl::binary::ReadArray(stream, value.fixed_vector_field); + yardl::binary::ReadArray, yardl::binary::ReadArray, 2>(stream, value.fixed_vector_of_vectors_field); yardl::binary::ReadOptional(stream, value.optional_named_array); ReadUnion(stream, value.int_float_union); ReadUnion(stream, value.nullable_int_float_union); diff --git a/cpp/test/generated/hdf5/protocols.cc b/cpp/test/generated/hdf5/protocols.cc index 5efaead7..3fbc74b8 100644 --- a/cpp/test/generated/hdf5/protocols.cc +++ b/cpp/test/generated/hdf5/protocols.cc @@ -1010,6 +1010,7 @@ struct _Inner_RecordWithComputedFields { vector_field(o.vector_field), vector_of_vectors_field(o.vector_of_vectors_field), fixed_vector_field(o.fixed_vector_field), + fixed_vector_of_vectors_field(o.fixed_vector_of_vectors_field), optional_named_array(o.optional_named_array), int_float_union(o.int_float_union), nullable_int_float_union(o.nullable_int_float_union), @@ -1040,6 +1041,7 @@ struct _Inner_RecordWithComputedFields { yardl::hdf5::ToOuter(vector_field, o.vector_field); yardl::hdf5::ToOuter(vector_of_vectors_field, o.vector_of_vectors_field); yardl::hdf5::ToOuter(fixed_vector_field, o.fixed_vector_field); + yardl::hdf5::ToOuter(fixed_vector_of_vectors_field, o.fixed_vector_of_vectors_field); yardl::hdf5::ToOuter(optional_named_array, o.optional_named_array); yardl::hdf5::ToOuter(int_float_union, o.int_float_union); yardl::hdf5::ToOuter(nullable_int_float_union, o.nullable_int_float_union); @@ -1069,6 +1071,7 @@ struct _Inner_RecordWithComputedFields { yardl::hdf5::InnerVlen vector_field; yardl::hdf5::InnerVlen, std::vector> vector_of_vectors_field; std::array fixed_vector_field; + std::array, 2> fixed_vector_of_vectors_field; yardl::hdf5::InnerOptional, test_model::NamedNDArray> optional_named_array; ::InnerUnion2 int_float_union; ::InnerUnion2 nullable_int_float_union; @@ -1514,6 +1517,7 @@ template t.insertMember("vectorField", HOFFSET(RecordType, vector_field), yardl::hdf5::InnerVlenDdl(H5::PredType::NATIVE_INT32)); t.insertMember("vectorOfVectorsField", HOFFSET(RecordType, vector_of_vectors_field), yardl::hdf5::InnerVlenDdl(yardl::hdf5::InnerVlenDdl(H5::PredType::NATIVE_INT32))); t.insertMember("fixedVectorField", HOFFSET(RecordType, fixed_vector_field), yardl::hdf5::FixedVectorDdl(H5::PredType::NATIVE_INT32, 3)); + t.insertMember("fixedVectorOfVectorsField", HOFFSET(RecordType, fixed_vector_of_vectors_field), yardl::hdf5::FixedVectorDdl(yardl::hdf5::FixedVectorDdl(H5::PredType::NATIVE_INT32, 3), 2)); t.insertMember("optionalNamedArray", HOFFSET(RecordType, optional_named_array), yardl::hdf5::OptionalTypeDdl, test_model::NamedNDArray>(yardl::hdf5::NDArrayDdl(H5::PredType::NATIVE_INT32))); t.insertMember("intFloatUnion", HOFFSET(RecordType, int_float_union), ::InnerUnion2Ddl(false, H5::PredType::NATIVE_INT32, "int32", H5::PredType::NATIVE_FLOAT, "float32")); t.insertMember("nullableIntFloatUnion", HOFFSET(RecordType, nullable_int_float_union), ::InnerUnion2Ddl(true, H5::PredType::NATIVE_INT32, "int32", H5::PredType::NATIVE_FLOAT, "float32")); diff --git a/cpp/test/generated/model.json b/cpp/test/generated/model.json index 6a33f89f..bd5df2a0 100644 --- a/cpp/test/generated/model.json +++ b/cpp/test/generated/model.json @@ -2444,6 +2444,20 @@ } } }, + { + "name": "fixedVectorOfVectorsField", + "type": { + "vector": { + "items": { + "vector": { + "items": "int32", + "length": 3 + } + }, + "length": 2 + } + } + }, { "name": "optionalNamedArray", "type": [ @@ -2716,6 +2730,37 @@ } } }, + { + "name": "accessFixedVectorOfVectorsField", + "expression": { + "subscript": { + "target": { + "subscript": { + "target": { + "memberAccess": { + "member": "fixedVectorOfVectorsField", + "kind": "field" + } + }, + "arguments": [ + { + "expression": { + "integer": 1 + } + } + ] + } + }, + "arguments": [ + { + "expression": { + "integer": 2 + } + } + ] + } + } + }, { "name": "arraySize", "expression": { @@ -2952,6 +2997,12 @@ "integer": 3 } }, + { + "name": "fixedVectorOfVectorsSize", + "expression": { + "integer": 2 + } + }, { "name": "arrayDimensionXIndex", "expression": { diff --git a/cpp/test/generated/ndjson/protocols.cc b/cpp/test/generated/ndjson/protocols.cc index 170632a4..9e6c84dc 100644 --- a/cpp/test/generated/ndjson/protocols.cc +++ b/cpp/test/generated/ndjson/protocols.cc @@ -2378,6 +2378,9 @@ void to_json(ordered_json& j, test_model::RecordWithComputedFields const& value) if (yardl::ndjson::ShouldSerializeFieldValue(value.fixed_vector_field)) { j.push_back({"fixedVectorField", value.fixed_vector_field}); } + if (yardl::ndjson::ShouldSerializeFieldValue(value.fixed_vector_of_vectors_field)) { + j.push_back({"fixedVectorOfVectorsField", value.fixed_vector_of_vectors_field}); + } if (yardl::ndjson::ShouldSerializeFieldValue(value.optional_named_array)) { j.push_back({"optionalNamedArray", value.optional_named_array}); } @@ -2462,6 +2465,9 @@ void from_json(ordered_json const& j, test_model::RecordWithComputedFields& valu if (auto it = j.find("fixedVectorField"); it != j.end()) { it->get_to(value.fixed_vector_field); } + if (auto it = j.find("fixedVectorOfVectorsField"); it != j.end()) { + it->get_to(value.fixed_vector_of_vectors_field); + } if (auto it = j.find("optionalNamedArray"); it != j.end()) { it->get_to(value.optional_named_array); } diff --git a/cpp/test/generated/protocols.cc b/cpp/test/generated/protocols.cc index b85c321b..b4e6f4a0 100644 --- a/cpp/test/generated/protocols.cc +++ b/cpp/test/generated/protocols.cc @@ -6145,7 +6145,7 @@ void ProtocolWithComputedFieldsReaderBaseInvalidState(uint8_t attempted, uint8_t } // namespace -std::string ProtocolWithComputedFieldsWriterBase::schema_ = R"({"protocol":{"name":"ProtocolWithComputedFields","sequence":[{"name":"recordWithComputedFields","type":"TestModel.RecordWithComputedFields"}]},"types":[{"name":"GenericRecordWithComputedFields","typeParameters":["T0","T1"],"fields":[{"name":"f1","type":[{"tag":"T0","type":"T0"},{"tag":"T1","type":"T1"}]}]},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"Tuples.Tuple","typeArguments":["T1","T2"]}},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"BasicTypes.MyTuple","typeArguments":["T1","T2"]}},{"name":"NamedNDArray","type":{"array":{"items":"int32","dimensions":[{"name":"dimA"},{"name":"dimB"}]}}},{"name":"RecordWithComputedFields","fields":[{"name":"arrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"arrayFieldMapDimensions","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"dynamicArrayField","type":{"array":{"items":"int32"}}},{"name":"fixedArrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x","length":3},{"name":"y","length":4}]}}},{"name":"intField","type":"int32"},{"name":"int8Field","type":"int8"},{"name":"uint8Field","type":"uint8"},{"name":"int16Field","type":"int16"},{"name":"uint16Field","type":"uint16"},{"name":"uint32Field","type":"uint32"},{"name":"int64Field","type":"int64"},{"name":"uint64Field","type":"uint64"},{"name":"sizeField","type":"size"},{"name":"float32Field","type":"float32"},{"name":"float64Field","type":"float64"},{"name":"complexfloat32Field","type":"complexfloat32"},{"name":"complexfloat64Field","type":"complexfloat64"},{"name":"stringField","type":"string"},{"name":"tupleField","type":{"name":"TestModel.MyTuple","typeArguments":["int32","int32"]}},{"name":"vectorField","type":{"vector":{"items":"int32"}}},{"name":"vectorOfVectorsField","type":{"vector":{"items":{"vector":{"items":"int32"}}}}},{"name":"fixedVectorField","type":{"vector":{"items":"int32","length":3}}},{"name":"optionalNamedArray","type":[null,"TestModel.NamedNDArray"]},{"name":"intFloatUnion","type":[{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"nullableIntFloatUnion","type":[null,{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"unionWithNestedGenericUnion","type":[{"tag":"int","explicitTag":true,"type":"int32"},{"tag":"genericRecordWithComputedFields","explicitTag":true,"type":{"name":"BasicTypes.GenericRecordWithComputedFields","typeArguments":["string","float32"]}}]},{"name":"mapField","type":{"map":{"keys":"string","values":"string"}}}]},{"name":"Tuple","typeParameters":["T1","T2"],"fields":[{"name":"v1","type":"T1"},{"name":"v2","type":"T2"}]}]})"; +std::string ProtocolWithComputedFieldsWriterBase::schema_ = R"({"protocol":{"name":"ProtocolWithComputedFields","sequence":[{"name":"recordWithComputedFields","type":"TestModel.RecordWithComputedFields"}]},"types":[{"name":"GenericRecordWithComputedFields","typeParameters":["T0","T1"],"fields":[{"name":"f1","type":[{"tag":"T0","type":"T0"},{"tag":"T1","type":"T1"}]}]},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"Tuples.Tuple","typeArguments":["T1","T2"]}},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"BasicTypes.MyTuple","typeArguments":["T1","T2"]}},{"name":"NamedNDArray","type":{"array":{"items":"int32","dimensions":[{"name":"dimA"},{"name":"dimB"}]}}},{"name":"RecordWithComputedFields","fields":[{"name":"arrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"arrayFieldMapDimensions","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"dynamicArrayField","type":{"array":{"items":"int32"}}},{"name":"fixedArrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x","length":3},{"name":"y","length":4}]}}},{"name":"intField","type":"int32"},{"name":"int8Field","type":"int8"},{"name":"uint8Field","type":"uint8"},{"name":"int16Field","type":"int16"},{"name":"uint16Field","type":"uint16"},{"name":"uint32Field","type":"uint32"},{"name":"int64Field","type":"int64"},{"name":"uint64Field","type":"uint64"},{"name":"sizeField","type":"size"},{"name":"float32Field","type":"float32"},{"name":"float64Field","type":"float64"},{"name":"complexfloat32Field","type":"complexfloat32"},{"name":"complexfloat64Field","type":"complexfloat64"},{"name":"stringField","type":"string"},{"name":"tupleField","type":{"name":"TestModel.MyTuple","typeArguments":["int32","int32"]}},{"name":"vectorField","type":{"vector":{"items":"int32"}}},{"name":"vectorOfVectorsField","type":{"vector":{"items":{"vector":{"items":"int32"}}}}},{"name":"fixedVectorField","type":{"vector":{"items":"int32","length":3}}},{"name":"fixedVectorOfVectorsField","type":{"vector":{"items":{"vector":{"items":"int32","length":3}},"length":2}}},{"name":"optionalNamedArray","type":[null,"TestModel.NamedNDArray"]},{"name":"intFloatUnion","type":[{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"nullableIntFloatUnion","type":[null,{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"unionWithNestedGenericUnion","type":[{"tag":"int","explicitTag":true,"type":"int32"},{"tag":"genericRecordWithComputedFields","explicitTag":true,"type":{"name":"BasicTypes.GenericRecordWithComputedFields","typeArguments":["string","float32"]}}]},{"name":"mapField","type":{"map":{"keys":"string","values":"string"}}}]},{"name":"Tuple","typeParameters":["T1","T2"],"fields":[{"name":"v1","type":"T1"},{"name":"v2","type":"T2"}]}]})"; std::vector ProtocolWithComputedFieldsWriterBase::previous_schemas_ = { }; diff --git a/cpp/test/generated/types.h b/cpp/test/generated/types.h index 109b55c3..e51f96d1 100644 --- a/cpp/test/generated/types.h +++ b/cpp/test/generated/types.h @@ -908,6 +908,7 @@ struct RecordWithComputedFields { std::vector vector_field{}; std::vector> vector_of_vectors_field{}; std::array fixed_vector_field{}; + std::array, 2> fixed_vector_of_vectors_field{}; std::optional optional_named_array{}; std::variant int_float_union{}; std::variant nullable_int_float_union{}; @@ -1030,6 +1031,14 @@ struct RecordWithComputedFields { return const_cast(std::as_const(*this).AccessVectorOfVectorsField()); } + int32_t const& AccessFixedVectorOfVectorsField() const { + return fixed_vector_of_vectors_field.at(1).at(2); + } + + int32_t& AccessFixedVectorOfVectorsField() { + return const_cast(std::as_const(*this).AccessFixedVectorOfVectorsField()); + } + yardl::Size ArraySize() const { return array_field.size(); } @@ -1090,6 +1099,10 @@ struct RecordWithComputedFields { return 3ULL; } + yardl::Size FixedVectorOfVectorsSize() const { + return 2ULL; + } + yardl::Size ArrayDimensionXIndex() const { return 0ULL; } @@ -1345,6 +1358,7 @@ struct RecordWithComputedFields { vector_field == other.vector_field && vector_of_vectors_field == other.vector_of_vectors_field && fixed_vector_field == other.fixed_vector_field && + fixed_vector_of_vectors_field == other.fixed_vector_of_vectors_field && optional_named_array == other.optional_named_array && int_float_union == other.int_float_union && nullable_int_float_union == other.nullable_int_float_union && diff --git a/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m index 391ff580..b7a91bb1 100644 --- a/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m @@ -25,17 +25,18 @@ field_serializers{20} = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); field_serializers{21} = yardl.binary.VectorSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer)); field_serializers{22} = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3); - field_serializers{23} = yardl.binary.OptionalSerializer(yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2)); - field_serializers{24} = yardl.binary.UnionSerializer('test_model.Int32OrFloat32', {yardl.binary.Int32Serializer, yardl.binary.Float32Serializer}, {@test_model.Int32OrFloat32.Int32, @test_model.Int32OrFloat32.Float32}); - field_serializers{25} = yardl.binary.UnionSerializer('test_model.Int32OrFloat32', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, yardl.binary.Float32Serializer}, {yardl.None, @test_model.Int32OrFloat32.Int32, @test_model.Int32OrFloat32.Float32}); - field_serializers{26} = yardl.binary.UnionSerializer('test_model.IntOrGenericRecordWithComputedFields', {yardl.binary.Int32Serializer, basic_types.binary.GenericRecordWithComputedFieldsSerializer(yardl.binary.StringSerializer, yardl.binary.Float32Serializer)}, {@test_model.IntOrGenericRecordWithComputedFields.Int, @test_model.IntOrGenericRecordWithComputedFields.GenericRecordWithComputedFields}); - field_serializers{27} = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.StringSerializer); + field_serializers{23} = yardl.binary.FixedVectorSerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3), 2); + field_serializers{24} = yardl.binary.OptionalSerializer(yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2)); + field_serializers{25} = yardl.binary.UnionSerializer('test_model.Int32OrFloat32', {yardl.binary.Int32Serializer, yardl.binary.Float32Serializer}, {@test_model.Int32OrFloat32.Int32, @test_model.Int32OrFloat32.Float32}); + field_serializers{26} = yardl.binary.UnionSerializer('test_model.Int32OrFloat32', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, yardl.binary.Float32Serializer}, {yardl.None, @test_model.Int32OrFloat32.Int32, @test_model.Int32OrFloat32.Float32}); + field_serializers{27} = yardl.binary.UnionSerializer('test_model.IntOrGenericRecordWithComputedFields', {yardl.binary.Int32Serializer, basic_types.binary.GenericRecordWithComputedFieldsSerializer(yardl.binary.StringSerializer, yardl.binary.Float32Serializer)}, {@test_model.IntOrGenericRecordWithComputedFields.Int, @test_model.IntOrGenericRecordWithComputedFields.GenericRecordWithComputedFields}); + field_serializers{28} = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.StringSerializer); obj@yardl.binary.RecordSerializer('test_model.RecordWithComputedFields', field_serializers); end function write(obj, outstream, value) assert(isa(value, 'test_model.RecordWithComputedFields')); - obj.write_(outstream, value.array_field, value.array_field_map_dimensions, value.dynamic_array_field, value.fixed_array_field, value.int_field, value.int8_field, value.uint8_field, value.int16_field, value.uint16_field, value.uint32_field, value.int64_field, value.uint64_field, value.size_field, value.float32_field, value.float64_field, value.complexfloat32_field, value.complexfloat64_field, value.string_field, value.tuple_field, value.vector_field, value.vector_of_vectors_field, value.fixed_vector_field, value.optional_named_array, value.int_float_union, value.nullable_int_float_union, value.union_with_nested_generic_union, value.map_field) + obj.write_(outstream, value.array_field, value.array_field_map_dimensions, value.dynamic_array_field, value.fixed_array_field, value.int_field, value.int8_field, value.uint8_field, value.int16_field, value.uint16_field, value.uint32_field, value.int64_field, value.uint64_field, value.size_field, value.float32_field, value.float64_field, value.complexfloat32_field, value.complexfloat64_field, value.string_field, value.tuple_field, value.vector_field, value.vector_of_vectors_field, value.fixed_vector_field, value.fixed_vector_of_vectors_field, value.optional_named_array, value.int_float_union, value.nullable_int_float_union, value.union_with_nested_generic_union, value.map_field) end function value = read(obj, instream) diff --git a/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m index ef4fb788..263820e1 100644 --- a/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m @@ -11,7 +11,7 @@ function write(obj, outstream, value) assert(isa(value, 'test_model.RecordWithKeywordFields')); - obj.write_(outstream, value.int, value.sizeof, value.if) + obj.write_(outstream, value.int, value.sizeof, value.if_) end function value = read(obj, instream) diff --git a/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m b/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m index 0bfdedde..45e1fde2 100644 --- a/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m @@ -13,101 +13,101 @@ methods function obj = MockAdvancedGenericsWriter(testCase) obj.testCase_ = testCase; - obj.write_float_image_image_written = Node.empty(); - obj.write_generic_record_1_written = Node.empty(); - obj.write_tuple_of_optionals_written = Node.empty(); - obj.write_tuple_of_optionals_alternate_syntax_written = Node.empty(); - obj.write_tuple_of_vectors_written = Node.empty(); + obj.write_float_image_image_written = yardl.None; + obj.write_generic_record_1_written = yardl.None; + obj.write_tuple_of_optionals_written = yardl.None; + obj.write_tuple_of_optionals_alternate_syntax_written = yardl.None; + obj.write_tuple_of_vectors_written = yardl.None; end function expect_write_float_image_image_(obj, value) - if isempty(obj.write_float_image_image_written) - obj.write_float_image_image_written = Node(value); - else + if obj.write_float_image_image_written.has_value() last_dim = ndims(value); - obj.write_float_image_image_written = Node(cat(last_dim, obj.write_float_image_image_written(1).value, value)); + obj.write_float_image_image_written = yardl.Optional(cat(last_dim, obj.write_float_image_image_written.value, value)); + else + obj.write_float_image_image_written = yardl.Optional(value); end end function expect_write_generic_record_1_(obj, value) - if isempty(obj.write_generic_record_1_written) - obj.write_generic_record_1_written = Node(value); - else + if obj.write_generic_record_1_written.has_value() last_dim = ndims(value); - obj.write_generic_record_1_written = Node(cat(last_dim, obj.write_generic_record_1_written(1).value, value)); + obj.write_generic_record_1_written = yardl.Optional(cat(last_dim, obj.write_generic_record_1_written.value, value)); + else + obj.write_generic_record_1_written = yardl.Optional(value); end end function expect_write_tuple_of_optionals_(obj, value) - if isempty(obj.write_tuple_of_optionals_written) - obj.write_tuple_of_optionals_written = Node(value); - else + if obj.write_tuple_of_optionals_written.has_value() last_dim = ndims(value); - obj.write_tuple_of_optionals_written = Node(cat(last_dim, obj.write_tuple_of_optionals_written(1).value, value)); + obj.write_tuple_of_optionals_written = yardl.Optional(cat(last_dim, obj.write_tuple_of_optionals_written.value, value)); + else + obj.write_tuple_of_optionals_written = yardl.Optional(value); end end function expect_write_tuple_of_optionals_alternate_syntax_(obj, value) - if isempty(obj.write_tuple_of_optionals_alternate_syntax_written) - obj.write_tuple_of_optionals_alternate_syntax_written = Node(value); - else + if obj.write_tuple_of_optionals_alternate_syntax_written.has_value() last_dim = ndims(value); - obj.write_tuple_of_optionals_alternate_syntax_written = Node(cat(last_dim, obj.write_tuple_of_optionals_alternate_syntax_written(1).value, value)); + obj.write_tuple_of_optionals_alternate_syntax_written = yardl.Optional(cat(last_dim, obj.write_tuple_of_optionals_alternate_syntax_written.value, value)); + else + obj.write_tuple_of_optionals_alternate_syntax_written = yardl.Optional(value); end end function expect_write_tuple_of_vectors_(obj, value) - if isempty(obj.write_tuple_of_vectors_written) - obj.write_tuple_of_vectors_written = Node(value); - else + if obj.write_tuple_of_vectors_written.has_value() last_dim = ndims(value); - obj.write_tuple_of_vectors_written = Node(cat(last_dim, obj.write_tuple_of_vectors_written(1).value, value)); + obj.write_tuple_of_vectors_written = yardl.Optional(cat(last_dim, obj.write_tuple_of_vectors_written.value, value)); + else + obj.write_tuple_of_vectors_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_float_image_image_written), "Expected call to write_float_image_image_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_generic_record_1_written), "Expected call to write_generic_record_1_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_tuple_of_optionals_written), "Expected call to write_tuple_of_optionals_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_tuple_of_optionals_alternate_syntax_written), "Expected call to write_tuple_of_optionals_alternate_syntax_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_tuple_of_vectors_written), "Expected call to write_tuple_of_vectors_ was not received"); + obj.testCase_.verifyEqual(obj.write_float_image_image_written, yardl.None, "Expected call to write_float_image_image_ was not received"); + obj.testCase_.verifyEqual(obj.write_generic_record_1_written, yardl.None, "Expected call to write_generic_record_1_ was not received"); + obj.testCase_.verifyEqual(obj.write_tuple_of_optionals_written, yardl.None, "Expected call to write_tuple_of_optionals_ was not received"); + obj.testCase_.verifyEqual(obj.write_tuple_of_optionals_alternate_syntax_written, yardl.None, "Expected call to write_tuple_of_optionals_alternate_syntax_ was not received"); + obj.testCase_.verifyEqual(obj.write_tuple_of_vectors_written, yardl.None, "Expected call to write_tuple_of_vectors_ was not received"); end end methods (Access=protected) function write_float_image_image_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_float_image_image_written), "Unexpected call to write_float_image_image_"); - expected = obj.write_float_image_image_written(1).value; + obj.testCase_.verifyTrue(obj.write_float_image_image_written.has_value(), "Unexpected call to write_float_image_image_"); + expected = obj.write_float_image_image_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_image_image_"); - obj.write_float_image_image_written = Node.empty(); + obj.write_float_image_image_written = yardl.None; end function write_generic_record_1_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_generic_record_1_written), "Unexpected call to write_generic_record_1_"); - expected = obj.write_generic_record_1_written(1).value; + obj.testCase_.verifyTrue(obj.write_generic_record_1_written.has_value(), "Unexpected call to write_generic_record_1_"); + expected = obj.write_generic_record_1_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_generic_record_1_"); - obj.write_generic_record_1_written = Node.empty(); + obj.write_generic_record_1_written = yardl.None; end function write_tuple_of_optionals_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_tuple_of_optionals_written), "Unexpected call to write_tuple_of_optionals_"); - expected = obj.write_tuple_of_optionals_written(1).value; + obj.testCase_.verifyTrue(obj.write_tuple_of_optionals_written.has_value(), "Unexpected call to write_tuple_of_optionals_"); + expected = obj.write_tuple_of_optionals_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_of_optionals_"); - obj.write_tuple_of_optionals_written = Node.empty(); + obj.write_tuple_of_optionals_written = yardl.None; end function write_tuple_of_optionals_alternate_syntax_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_tuple_of_optionals_alternate_syntax_written), "Unexpected call to write_tuple_of_optionals_alternate_syntax_"); - expected = obj.write_tuple_of_optionals_alternate_syntax_written(1).value; + obj.testCase_.verifyTrue(obj.write_tuple_of_optionals_alternate_syntax_written.has_value(), "Unexpected call to write_tuple_of_optionals_alternate_syntax_"); + expected = obj.write_tuple_of_optionals_alternate_syntax_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_of_optionals_alternate_syntax_"); - obj.write_tuple_of_optionals_alternate_syntax_written = Node.empty(); + obj.write_tuple_of_optionals_alternate_syntax_written = yardl.None; end function write_tuple_of_vectors_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_tuple_of_vectors_written), "Unexpected call to write_tuple_of_vectors_"); - expected = obj.write_tuple_of_vectors_written(1).value; + obj.testCase_.verifyTrue(obj.write_tuple_of_vectors_written.has_value(), "Unexpected call to write_tuple_of_vectors_"); + expected = obj.write_tuple_of_vectors_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_of_vectors_"); - obj.write_tuple_of_vectors_written = Node.empty(); + obj.write_tuple_of_vectors_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockAliasesWriter.m b/matlab/generated/+test_model/+testing/MockAliasesWriter.m index e1025cd4..eed855bb 100644 --- a/matlab/generated/+test_model/+testing/MockAliasesWriter.m +++ b/matlab/generated/+test_model/+testing/MockAliasesWriter.m @@ -18,191 +18,191 @@ methods function obj = MockAliasesWriter(testCase) obj.testCase_ = testCase; - obj.write_aliased_string_written = Node.empty(); - obj.write_aliased_enum_written = Node.empty(); - obj.write_aliased_open_generic_written = Node.empty(); - obj.write_aliased_closed_generic_written = Node.empty(); - obj.write_aliased_optional_written = Node.empty(); - obj.write_aliased_generic_optional_written = Node.empty(); - obj.write_aliased_generic_union_2_written = Node.empty(); - obj.write_aliased_generic_vector_written = Node.empty(); - obj.write_aliased_generic_fixed_vector_written = Node.empty(); - obj.write_stream_of_aliased_generic_union_2_written = Node.empty(); + obj.write_aliased_string_written = yardl.None; + obj.write_aliased_enum_written = yardl.None; + obj.write_aliased_open_generic_written = yardl.None; + obj.write_aliased_closed_generic_written = yardl.None; + obj.write_aliased_optional_written = yardl.None; + obj.write_aliased_generic_optional_written = yardl.None; + obj.write_aliased_generic_union_2_written = yardl.None; + obj.write_aliased_generic_vector_written = yardl.None; + obj.write_aliased_generic_fixed_vector_written = yardl.None; + obj.write_stream_of_aliased_generic_union_2_written = yardl.None; end function expect_write_aliased_string_(obj, value) - if isempty(obj.write_aliased_string_written) - obj.write_aliased_string_written = Node(value); - else + if obj.write_aliased_string_written.has_value() last_dim = ndims(value); - obj.write_aliased_string_written = Node(cat(last_dim, obj.write_aliased_string_written(1).value, value)); + obj.write_aliased_string_written = yardl.Optional(cat(last_dim, obj.write_aliased_string_written.value, value)); + else + obj.write_aliased_string_written = yardl.Optional(value); end end function expect_write_aliased_enum_(obj, value) - if isempty(obj.write_aliased_enum_written) - obj.write_aliased_enum_written = Node(value); - else + if obj.write_aliased_enum_written.has_value() last_dim = ndims(value); - obj.write_aliased_enum_written = Node(cat(last_dim, obj.write_aliased_enum_written(1).value, value)); + obj.write_aliased_enum_written = yardl.Optional(cat(last_dim, obj.write_aliased_enum_written.value, value)); + else + obj.write_aliased_enum_written = yardl.Optional(value); end end function expect_write_aliased_open_generic_(obj, value) - if isempty(obj.write_aliased_open_generic_written) - obj.write_aliased_open_generic_written = Node(value); - else + if obj.write_aliased_open_generic_written.has_value() last_dim = ndims(value); - obj.write_aliased_open_generic_written = Node(cat(last_dim, obj.write_aliased_open_generic_written(1).value, value)); + obj.write_aliased_open_generic_written = yardl.Optional(cat(last_dim, obj.write_aliased_open_generic_written.value, value)); + else + obj.write_aliased_open_generic_written = yardl.Optional(value); end end function expect_write_aliased_closed_generic_(obj, value) - if isempty(obj.write_aliased_closed_generic_written) - obj.write_aliased_closed_generic_written = Node(value); - else + if obj.write_aliased_closed_generic_written.has_value() last_dim = ndims(value); - obj.write_aliased_closed_generic_written = Node(cat(last_dim, obj.write_aliased_closed_generic_written(1).value, value)); + obj.write_aliased_closed_generic_written = yardl.Optional(cat(last_dim, obj.write_aliased_closed_generic_written.value, value)); + else + obj.write_aliased_closed_generic_written = yardl.Optional(value); end end function expect_write_aliased_optional_(obj, value) - if isempty(obj.write_aliased_optional_written) - obj.write_aliased_optional_written = Node(value); - else + if obj.write_aliased_optional_written.has_value() last_dim = ndims(value); - obj.write_aliased_optional_written = Node(cat(last_dim, obj.write_aliased_optional_written(1).value, value)); + obj.write_aliased_optional_written = yardl.Optional(cat(last_dim, obj.write_aliased_optional_written.value, value)); + else + obj.write_aliased_optional_written = yardl.Optional(value); end end function expect_write_aliased_generic_optional_(obj, value) - if isempty(obj.write_aliased_generic_optional_written) - obj.write_aliased_generic_optional_written = Node(value); - else + if obj.write_aliased_generic_optional_written.has_value() last_dim = ndims(value); - obj.write_aliased_generic_optional_written = Node(cat(last_dim, obj.write_aliased_generic_optional_written(1).value, value)); + obj.write_aliased_generic_optional_written = yardl.Optional(cat(last_dim, obj.write_aliased_generic_optional_written.value, value)); + else + obj.write_aliased_generic_optional_written = yardl.Optional(value); end end function expect_write_aliased_generic_union_2_(obj, value) - if isempty(obj.write_aliased_generic_union_2_written) - obj.write_aliased_generic_union_2_written = Node(value); - else + if obj.write_aliased_generic_union_2_written.has_value() last_dim = ndims(value); - obj.write_aliased_generic_union_2_written = Node(cat(last_dim, obj.write_aliased_generic_union_2_written(1).value, value)); + obj.write_aliased_generic_union_2_written = yardl.Optional(cat(last_dim, obj.write_aliased_generic_union_2_written.value, value)); + else + obj.write_aliased_generic_union_2_written = yardl.Optional(value); end end function expect_write_aliased_generic_vector_(obj, value) - if isempty(obj.write_aliased_generic_vector_written) - obj.write_aliased_generic_vector_written = Node(value); - else + if obj.write_aliased_generic_vector_written.has_value() last_dim = ndims(value); - obj.write_aliased_generic_vector_written = Node(cat(last_dim, obj.write_aliased_generic_vector_written(1).value, value)); + obj.write_aliased_generic_vector_written = yardl.Optional(cat(last_dim, obj.write_aliased_generic_vector_written.value, value)); + else + obj.write_aliased_generic_vector_written = yardl.Optional(value); end end function expect_write_aliased_generic_fixed_vector_(obj, value) - if isempty(obj.write_aliased_generic_fixed_vector_written) - obj.write_aliased_generic_fixed_vector_written = Node(value); - else + if obj.write_aliased_generic_fixed_vector_written.has_value() last_dim = ndims(value); - obj.write_aliased_generic_fixed_vector_written = Node(cat(last_dim, obj.write_aliased_generic_fixed_vector_written(1).value, value)); + obj.write_aliased_generic_fixed_vector_written = yardl.Optional(cat(last_dim, obj.write_aliased_generic_fixed_vector_written.value, value)); + else + obj.write_aliased_generic_fixed_vector_written = yardl.Optional(value); end end function expect_write_stream_of_aliased_generic_union_2_(obj, value) - if isempty(obj.write_stream_of_aliased_generic_union_2_written) - obj.write_stream_of_aliased_generic_union_2_written = Node(value); - else + if obj.write_stream_of_aliased_generic_union_2_written.has_value() last_dim = ndims(value); - obj.write_stream_of_aliased_generic_union_2_written = Node(cat(last_dim, obj.write_stream_of_aliased_generic_union_2_written(1).value, value)); + obj.write_stream_of_aliased_generic_union_2_written = yardl.Optional(cat(last_dim, obj.write_stream_of_aliased_generic_union_2_written.value, value)); + else + obj.write_stream_of_aliased_generic_union_2_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_aliased_string_written), "Expected call to write_aliased_string_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_aliased_enum_written), "Expected call to write_aliased_enum_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_aliased_open_generic_written), "Expected call to write_aliased_open_generic_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_aliased_closed_generic_written), "Expected call to write_aliased_closed_generic_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_aliased_optional_written), "Expected call to write_aliased_optional_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_aliased_generic_optional_written), "Expected call to write_aliased_generic_optional_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_aliased_generic_union_2_written), "Expected call to write_aliased_generic_union_2_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_aliased_generic_vector_written), "Expected call to write_aliased_generic_vector_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_aliased_generic_fixed_vector_written), "Expected call to write_aliased_generic_fixed_vector_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_stream_of_aliased_generic_union_2_written), "Expected call to write_stream_of_aliased_generic_union_2_ was not received"); + obj.testCase_.verifyEqual(obj.write_aliased_string_written, yardl.None, "Expected call to write_aliased_string_ was not received"); + obj.testCase_.verifyEqual(obj.write_aliased_enum_written, yardl.None, "Expected call to write_aliased_enum_ was not received"); + obj.testCase_.verifyEqual(obj.write_aliased_open_generic_written, yardl.None, "Expected call to write_aliased_open_generic_ was not received"); + obj.testCase_.verifyEqual(obj.write_aliased_closed_generic_written, yardl.None, "Expected call to write_aliased_closed_generic_ was not received"); + obj.testCase_.verifyEqual(obj.write_aliased_optional_written, yardl.None, "Expected call to write_aliased_optional_ was not received"); + obj.testCase_.verifyEqual(obj.write_aliased_generic_optional_written, yardl.None, "Expected call to write_aliased_generic_optional_ was not received"); + obj.testCase_.verifyEqual(obj.write_aliased_generic_union_2_written, yardl.None, "Expected call to write_aliased_generic_union_2_ was not received"); + obj.testCase_.verifyEqual(obj.write_aliased_generic_vector_written, yardl.None, "Expected call to write_aliased_generic_vector_ was not received"); + obj.testCase_.verifyEqual(obj.write_aliased_generic_fixed_vector_written, yardl.None, "Expected call to write_aliased_generic_fixed_vector_ was not received"); + obj.testCase_.verifyEqual(obj.write_stream_of_aliased_generic_union_2_written, yardl.None, "Expected call to write_stream_of_aliased_generic_union_2_ was not received"); end end methods (Access=protected) function write_aliased_string_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_aliased_string_written), "Unexpected call to write_aliased_string_"); - expected = obj.write_aliased_string_written(1).value; + obj.testCase_.verifyTrue(obj.write_aliased_string_written.has_value(), "Unexpected call to write_aliased_string_"); + expected = obj.write_aliased_string_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_string_"); - obj.write_aliased_string_written = Node.empty(); + obj.write_aliased_string_written = yardl.None; end function write_aliased_enum_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_aliased_enum_written), "Unexpected call to write_aliased_enum_"); - expected = obj.write_aliased_enum_written(1).value; + obj.testCase_.verifyTrue(obj.write_aliased_enum_written.has_value(), "Unexpected call to write_aliased_enum_"); + expected = obj.write_aliased_enum_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_enum_"); - obj.write_aliased_enum_written = Node.empty(); + obj.write_aliased_enum_written = yardl.None; end function write_aliased_open_generic_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_aliased_open_generic_written), "Unexpected call to write_aliased_open_generic_"); - expected = obj.write_aliased_open_generic_written(1).value; + obj.testCase_.verifyTrue(obj.write_aliased_open_generic_written.has_value(), "Unexpected call to write_aliased_open_generic_"); + expected = obj.write_aliased_open_generic_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_open_generic_"); - obj.write_aliased_open_generic_written = Node.empty(); + obj.write_aliased_open_generic_written = yardl.None; end function write_aliased_closed_generic_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_aliased_closed_generic_written), "Unexpected call to write_aliased_closed_generic_"); - expected = obj.write_aliased_closed_generic_written(1).value; + obj.testCase_.verifyTrue(obj.write_aliased_closed_generic_written.has_value(), "Unexpected call to write_aliased_closed_generic_"); + expected = obj.write_aliased_closed_generic_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_closed_generic_"); - obj.write_aliased_closed_generic_written = Node.empty(); + obj.write_aliased_closed_generic_written = yardl.None; end function write_aliased_optional_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_aliased_optional_written), "Unexpected call to write_aliased_optional_"); - expected = obj.write_aliased_optional_written(1).value; + obj.testCase_.verifyTrue(obj.write_aliased_optional_written.has_value(), "Unexpected call to write_aliased_optional_"); + expected = obj.write_aliased_optional_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_optional_"); - obj.write_aliased_optional_written = Node.empty(); + obj.write_aliased_optional_written = yardl.None; end function write_aliased_generic_optional_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_aliased_generic_optional_written), "Unexpected call to write_aliased_generic_optional_"); - expected = obj.write_aliased_generic_optional_written(1).value; + obj.testCase_.verifyTrue(obj.write_aliased_generic_optional_written.has_value(), "Unexpected call to write_aliased_generic_optional_"); + expected = obj.write_aliased_generic_optional_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_optional_"); - obj.write_aliased_generic_optional_written = Node.empty(); + obj.write_aliased_generic_optional_written = yardl.None; end function write_aliased_generic_union_2_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_aliased_generic_union_2_written), "Unexpected call to write_aliased_generic_union_2_"); - expected = obj.write_aliased_generic_union_2_written(1).value; + obj.testCase_.verifyTrue(obj.write_aliased_generic_union_2_written.has_value(), "Unexpected call to write_aliased_generic_union_2_"); + expected = obj.write_aliased_generic_union_2_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_union_2_"); - obj.write_aliased_generic_union_2_written = Node.empty(); + obj.write_aliased_generic_union_2_written = yardl.None; end function write_aliased_generic_vector_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_aliased_generic_vector_written), "Unexpected call to write_aliased_generic_vector_"); - expected = obj.write_aliased_generic_vector_written(1).value; + obj.testCase_.verifyTrue(obj.write_aliased_generic_vector_written.has_value(), "Unexpected call to write_aliased_generic_vector_"); + expected = obj.write_aliased_generic_vector_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_vector_"); - obj.write_aliased_generic_vector_written = Node.empty(); + obj.write_aliased_generic_vector_written = yardl.None; end function write_aliased_generic_fixed_vector_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_aliased_generic_fixed_vector_written), "Unexpected call to write_aliased_generic_fixed_vector_"); - expected = obj.write_aliased_generic_fixed_vector_written(1).value; + obj.testCase_.verifyTrue(obj.write_aliased_generic_fixed_vector_written.has_value(), "Unexpected call to write_aliased_generic_fixed_vector_"); + expected = obj.write_aliased_generic_fixed_vector_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_fixed_vector_"); - obj.write_aliased_generic_fixed_vector_written = Node.empty(); + obj.write_aliased_generic_fixed_vector_written = yardl.None; end function write_stream_of_aliased_generic_union_2_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_stream_of_aliased_generic_union_2_written), "Unexpected call to write_stream_of_aliased_generic_union_2_"); - expected = obj.write_stream_of_aliased_generic_union_2_written(1).value; + obj.testCase_.verifyTrue(obj.write_stream_of_aliased_generic_union_2_written.has_value(), "Unexpected call to write_stream_of_aliased_generic_union_2_"); + expected = obj.write_stream_of_aliased_generic_union_2_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_stream_of_aliased_generic_union_2_"); - obj.write_stream_of_aliased_generic_union_2_written = Node.empty(); + obj.write_stream_of_aliased_generic_union_2_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m index 321eba25..41750525 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m @@ -9,29 +9,29 @@ methods function obj = MockBenchmarkFloat256x256Writer(testCase) obj.testCase_ = testCase; - obj.write_float256x256_written = Node.empty(); + obj.write_float256x256_written = yardl.None; end function expect_write_float256x256_(obj, value) - if isempty(obj.write_float256x256_written) - obj.write_float256x256_written = Node(value); - else + if obj.write_float256x256_written.has_value() last_dim = ndims(value); - obj.write_float256x256_written = Node(cat(last_dim, obj.write_float256x256_written(1).value, value)); + obj.write_float256x256_written = yardl.Optional(cat(last_dim, obj.write_float256x256_written.value, value)); + else + obj.write_float256x256_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_float256x256_written), "Expected call to write_float256x256_ was not received"); + obj.testCase_.verifyEqual(obj.write_float256x256_written, yardl.None, "Expected call to write_float256x256_ was not received"); end end methods (Access=protected) function write_float256x256_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_float256x256_written), "Unexpected call to write_float256x256_"); - expected = obj.write_float256x256_written(1).value; + obj.testCase_.verifyTrue(obj.write_float256x256_written.has_value(), "Unexpected call to write_float256x256_"); + expected = obj.write_float256x256_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float256x256_"); - obj.write_float256x256_written = Node.empty(); + obj.write_float256x256_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m index aa92a6ac..6a812981 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m @@ -9,29 +9,29 @@ methods function obj = MockBenchmarkFloatVlenWriter(testCase) obj.testCase_ = testCase; - obj.write_float_array_written = Node.empty(); + obj.write_float_array_written = yardl.None; end function expect_write_float_array_(obj, value) - if isempty(obj.write_float_array_written) - obj.write_float_array_written = Node(value); - else + if obj.write_float_array_written.has_value() last_dim = ndims(value); - obj.write_float_array_written = Node(cat(last_dim, obj.write_float_array_written(1).value, value)); + obj.write_float_array_written = yardl.Optional(cat(last_dim, obj.write_float_array_written.value, value)); + else + obj.write_float_array_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_float_array_written), "Expected call to write_float_array_ was not received"); + obj.testCase_.verifyEqual(obj.write_float_array_written, yardl.None, "Expected call to write_float_array_ was not received"); end end methods (Access=protected) function write_float_array_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_float_array_written), "Unexpected call to write_float_array_"); - expected = obj.write_float_array_written(1).value; + obj.testCase_.verifyTrue(obj.write_float_array_written.has_value(), "Unexpected call to write_float_array_"); + expected = obj.write_float_array_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_array_"); - obj.write_float_array_written = Node.empty(); + obj.write_float_array_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m index 8c5b2ceb..c2df5bb8 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m @@ -9,29 +9,29 @@ methods function obj = MockBenchmarkInt256x256Writer(testCase) obj.testCase_ = testCase; - obj.write_int256x256_written = Node.empty(); + obj.write_int256x256_written = yardl.None; end function expect_write_int256x256_(obj, value) - if isempty(obj.write_int256x256_written) - obj.write_int256x256_written = Node(value); - else + if obj.write_int256x256_written.has_value() last_dim = ndims(value); - obj.write_int256x256_written = Node(cat(last_dim, obj.write_int256x256_written(1).value, value)); + obj.write_int256x256_written = yardl.Optional(cat(last_dim, obj.write_int256x256_written.value, value)); + else + obj.write_int256x256_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_int256x256_written), "Expected call to write_int256x256_ was not received"); + obj.testCase_.verifyEqual(obj.write_int256x256_written, yardl.None, "Expected call to write_int256x256_ was not received"); end end methods (Access=protected) function write_int256x256_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_int256x256_written), "Unexpected call to write_int256x256_"); - expected = obj.write_int256x256_written(1).value; + obj.testCase_.verifyTrue(obj.write_int256x256_written.has_value(), "Unexpected call to write_int256x256_"); + expected = obj.write_int256x256_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int256x256_"); - obj.write_int256x256_written = Node.empty(); + obj.write_int256x256_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m index 9649bf9d..594250a2 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m @@ -9,29 +9,29 @@ methods function obj = MockBenchmarkSimpleMrdWriter(testCase) obj.testCase_ = testCase; - obj.write_data_written = Node.empty(); + obj.write_data_written = yardl.None; end function expect_write_data_(obj, value) - if isempty(obj.write_data_written) - obj.write_data_written = Node(value); - else + if obj.write_data_written.has_value() last_dim = ndims(value); - obj.write_data_written = Node(cat(last_dim, obj.write_data_written(1).value, value)); + obj.write_data_written = yardl.Optional(cat(last_dim, obj.write_data_written.value, value)); + else + obj.write_data_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_data_written), "Expected call to write_data_ was not received"); + obj.testCase_.verifyEqual(obj.write_data_written, yardl.None, "Expected call to write_data_ was not received"); end end methods (Access=protected) function write_data_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_data_written), "Unexpected call to write_data_"); - expected = obj.write_data_written(1).value; + obj.testCase_.verifyTrue(obj.write_data_written.has_value(), "Unexpected call to write_data_"); + expected = obj.write_data_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_data_"); - obj.write_data_written = Node.empty(); + obj.write_data_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m index 8040507d..33bdb030 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m @@ -9,29 +9,29 @@ methods function obj = MockBenchmarkSmallRecordWithOptionalsWriter(testCase) obj.testCase_ = testCase; - obj.write_small_record_written = Node.empty(); + obj.write_small_record_written = yardl.None; end function expect_write_small_record_(obj, value) - if isempty(obj.write_small_record_written) - obj.write_small_record_written = Node(value); - else + if obj.write_small_record_written.has_value() last_dim = ndims(value); - obj.write_small_record_written = Node(cat(last_dim, obj.write_small_record_written(1).value, value)); + obj.write_small_record_written = yardl.Optional(cat(last_dim, obj.write_small_record_written.value, value)); + else + obj.write_small_record_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_small_record_written), "Expected call to write_small_record_ was not received"); + obj.testCase_.verifyEqual(obj.write_small_record_written, yardl.None, "Expected call to write_small_record_ was not received"); end end methods (Access=protected) function write_small_record_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_small_record_written), "Unexpected call to write_small_record_"); - expected = obj.write_small_record_written(1).value; + obj.testCase_.verifyTrue(obj.write_small_record_written.has_value(), "Unexpected call to write_small_record_"); + expected = obj.write_small_record_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_small_record_"); - obj.write_small_record_written = Node.empty(); + obj.write_small_record_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m index 6ec0d87a..ddbce1e4 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m @@ -9,29 +9,29 @@ methods function obj = MockBenchmarkSmallRecordWriter(testCase) obj.testCase_ = testCase; - obj.write_small_record_written = Node.empty(); + obj.write_small_record_written = yardl.None; end function expect_write_small_record_(obj, value) - if isempty(obj.write_small_record_written) - obj.write_small_record_written = Node(value); - else + if obj.write_small_record_written.has_value() last_dim = ndims(value); - obj.write_small_record_written = Node(cat(last_dim, obj.write_small_record_written(1).value, value)); + obj.write_small_record_written = yardl.Optional(cat(last_dim, obj.write_small_record_written.value, value)); + else + obj.write_small_record_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_small_record_written), "Expected call to write_small_record_ was not received"); + obj.testCase_.verifyEqual(obj.write_small_record_written, yardl.None, "Expected call to write_small_record_ was not received"); end end methods (Access=protected) function write_small_record_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_small_record_written), "Unexpected call to write_small_record_"); - expected = obj.write_small_record_written(1).value; + obj.testCase_.verifyTrue(obj.write_small_record_written.has_value(), "Unexpected call to write_small_record_"); + expected = obj.write_small_record_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_small_record_"); - obj.write_small_record_written = Node.empty(); + obj.write_small_record_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m b/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m index 5be1ddf0..ad13e9a6 100644 --- a/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m @@ -12,83 +12,83 @@ methods function obj = MockDynamicNDArraysWriter(testCase) obj.testCase_ = testCase; - obj.write_ints_written = Node.empty(); - obj.write_simple_record_array_written = Node.empty(); - obj.write_record_with_vlens_array_written = Node.empty(); - obj.write_record_with_dynamic_nd_arrays_written = Node.empty(); + obj.write_ints_written = yardl.None; + obj.write_simple_record_array_written = yardl.None; + obj.write_record_with_vlens_array_written = yardl.None; + obj.write_record_with_dynamic_nd_arrays_written = yardl.None; end function expect_write_ints_(obj, value) - if isempty(obj.write_ints_written) - obj.write_ints_written = Node(value); - else + if obj.write_ints_written.has_value() last_dim = ndims(value); - obj.write_ints_written = Node(cat(last_dim, obj.write_ints_written(1).value, value)); + obj.write_ints_written = yardl.Optional(cat(last_dim, obj.write_ints_written.value, value)); + else + obj.write_ints_written = yardl.Optional(value); end end function expect_write_simple_record_array_(obj, value) - if isempty(obj.write_simple_record_array_written) - obj.write_simple_record_array_written = Node(value); - else + if obj.write_simple_record_array_written.has_value() last_dim = ndims(value); - obj.write_simple_record_array_written = Node(cat(last_dim, obj.write_simple_record_array_written(1).value, value)); + obj.write_simple_record_array_written = yardl.Optional(cat(last_dim, obj.write_simple_record_array_written.value, value)); + else + obj.write_simple_record_array_written = yardl.Optional(value); end end function expect_write_record_with_vlens_array_(obj, value) - if isempty(obj.write_record_with_vlens_array_written) - obj.write_record_with_vlens_array_written = Node(value); - else + if obj.write_record_with_vlens_array_written.has_value() last_dim = ndims(value); - obj.write_record_with_vlens_array_written = Node(cat(last_dim, obj.write_record_with_vlens_array_written(1).value, value)); + obj.write_record_with_vlens_array_written = yardl.Optional(cat(last_dim, obj.write_record_with_vlens_array_written.value, value)); + else + obj.write_record_with_vlens_array_written = yardl.Optional(value); end end function expect_write_record_with_dynamic_nd_arrays_(obj, value) - if isempty(obj.write_record_with_dynamic_nd_arrays_written) - obj.write_record_with_dynamic_nd_arrays_written = Node(value); - else + if obj.write_record_with_dynamic_nd_arrays_written.has_value() last_dim = ndims(value); - obj.write_record_with_dynamic_nd_arrays_written = Node(cat(last_dim, obj.write_record_with_dynamic_nd_arrays_written(1).value, value)); + obj.write_record_with_dynamic_nd_arrays_written = yardl.Optional(cat(last_dim, obj.write_record_with_dynamic_nd_arrays_written.value, value)); + else + obj.write_record_with_dynamic_nd_arrays_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_ints_written), "Expected call to write_ints_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_simple_record_array_written), "Expected call to write_simple_record_array_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_record_with_vlens_array_written), "Expected call to write_record_with_vlens_array_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_record_with_dynamic_nd_arrays_written), "Expected call to write_record_with_dynamic_nd_arrays_ was not received"); + obj.testCase_.verifyEqual(obj.write_ints_written, yardl.None, "Expected call to write_ints_ was not received"); + obj.testCase_.verifyEqual(obj.write_simple_record_array_written, yardl.None, "Expected call to write_simple_record_array_ was not received"); + obj.testCase_.verifyEqual(obj.write_record_with_vlens_array_written, yardl.None, "Expected call to write_record_with_vlens_array_ was not received"); + obj.testCase_.verifyEqual(obj.write_record_with_dynamic_nd_arrays_written, yardl.None, "Expected call to write_record_with_dynamic_nd_arrays_ was not received"); end end methods (Access=protected) function write_ints_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_ints_written), "Unexpected call to write_ints_"); - expected = obj.write_ints_written(1).value; + obj.testCase_.verifyTrue(obj.write_ints_written.has_value(), "Unexpected call to write_ints_"); + expected = obj.write_ints_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); - obj.write_ints_written = Node.empty(); + obj.write_ints_written = yardl.None; end function write_simple_record_array_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_simple_record_array_written), "Unexpected call to write_simple_record_array_"); - expected = obj.write_simple_record_array_written(1).value; + obj.testCase_.verifyTrue(obj.write_simple_record_array_written.has_value(), "Unexpected call to write_simple_record_array_"); + expected = obj.write_simple_record_array_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_simple_record_array_"); - obj.write_simple_record_array_written = Node.empty(); + obj.write_simple_record_array_written = yardl.None; end function write_record_with_vlens_array_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_record_with_vlens_array_written), "Unexpected call to write_record_with_vlens_array_"); - expected = obj.write_record_with_vlens_array_written(1).value; + obj.testCase_.verifyTrue(obj.write_record_with_vlens_array_written.has_value(), "Unexpected call to write_record_with_vlens_array_"); + expected = obj.write_record_with_vlens_array_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_array_"); - obj.write_record_with_vlens_array_written = Node.empty(); + obj.write_record_with_vlens_array_written = yardl.None; end function write_record_with_dynamic_nd_arrays_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_record_with_dynamic_nd_arrays_written), "Unexpected call to write_record_with_dynamic_nd_arrays_"); - expected = obj.write_record_with_dynamic_nd_arrays_written(1).value; + obj.testCase_.verifyTrue(obj.write_record_with_dynamic_nd_arrays_written.has_value(), "Unexpected call to write_record_with_dynamic_nd_arrays_"); + expected = obj.write_record_with_dynamic_nd_arrays_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_dynamic_nd_arrays_"); - obj.write_record_with_dynamic_nd_arrays_written = Node.empty(); + obj.write_record_with_dynamic_nd_arrays_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockEnumsWriter.m b/matlab/generated/+test_model/+testing/MockEnumsWriter.m index bb4394b7..5c35af06 100644 --- a/matlab/generated/+test_model/+testing/MockEnumsWriter.m +++ b/matlab/generated/+test_model/+testing/MockEnumsWriter.m @@ -11,65 +11,65 @@ methods function obj = MockEnumsWriter(testCase) obj.testCase_ = testCase; - obj.write_single_written = Node.empty(); - obj.write_vec_written = Node.empty(); - obj.write_size_written = Node.empty(); + obj.write_single_written = yardl.None; + obj.write_vec_written = yardl.None; + obj.write_size_written = yardl.None; end function expect_write_single_(obj, value) - if isempty(obj.write_single_written) - obj.write_single_written = Node(value); - else + if obj.write_single_written.has_value() last_dim = ndims(value); - obj.write_single_written = Node(cat(last_dim, obj.write_single_written(1).value, value)); + obj.write_single_written = yardl.Optional(cat(last_dim, obj.write_single_written.value, value)); + else + obj.write_single_written = yardl.Optional(value); end end function expect_write_vec_(obj, value) - if isempty(obj.write_vec_written) - obj.write_vec_written = Node(value); - else + if obj.write_vec_written.has_value() last_dim = ndims(value); - obj.write_vec_written = Node(cat(last_dim, obj.write_vec_written(1).value, value)); + obj.write_vec_written = yardl.Optional(cat(last_dim, obj.write_vec_written.value, value)); + else + obj.write_vec_written = yardl.Optional(value); end end function expect_write_size_(obj, value) - if isempty(obj.write_size_written) - obj.write_size_written = Node(value); - else + if obj.write_size_written.has_value() last_dim = ndims(value); - obj.write_size_written = Node(cat(last_dim, obj.write_size_written(1).value, value)); + obj.write_size_written = yardl.Optional(cat(last_dim, obj.write_size_written.value, value)); + else + obj.write_size_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_single_written), "Expected call to write_single_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_vec_written), "Expected call to write_vec_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_size_written), "Expected call to write_size_ was not received"); + obj.testCase_.verifyEqual(obj.write_single_written, yardl.None, "Expected call to write_single_ was not received"); + obj.testCase_.verifyEqual(obj.write_vec_written, yardl.None, "Expected call to write_vec_ was not received"); + obj.testCase_.verifyEqual(obj.write_size_written, yardl.None, "Expected call to write_size_ was not received"); end end methods (Access=protected) function write_single_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_single_written), "Unexpected call to write_single_"); - expected = obj.write_single_written(1).value; + obj.testCase_.verifyTrue(obj.write_single_written.has_value(), "Unexpected call to write_single_"); + expected = obj.write_single_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_single_"); - obj.write_single_written = Node.empty(); + obj.write_single_written = yardl.None; end function write_vec_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_vec_written), "Unexpected call to write_vec_"); - expected = obj.write_vec_written(1).value; + obj.testCase_.verifyTrue(obj.write_vec_written.has_value(), "Unexpected call to write_vec_"); + expected = obj.write_vec_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_vec_"); - obj.write_vec_written = Node.empty(); + obj.write_vec_written = yardl.None; end function write_size_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_size_written), "Unexpected call to write_size_"); - expected = obj.write_size_written(1).value; + obj.testCase_.verifyTrue(obj.write_size_written.has_value(), "Unexpected call to write_size_"); + expected = obj.write_size_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_size_"); - obj.write_size_written = Node.empty(); + obj.write_size_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m b/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m index 06f824e9..814f9ec1 100644 --- a/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m @@ -13,101 +13,101 @@ methods function obj = MockFixedArraysWriter(testCase) obj.testCase_ = testCase; - obj.write_ints_written = Node.empty(); - obj.write_fixed_simple_record_array_written = Node.empty(); - obj.write_fixed_record_with_vlens_array_written = Node.empty(); - obj.write_record_with_fixed_arrays_written = Node.empty(); - obj.write_named_array_written = Node.empty(); + obj.write_ints_written = yardl.None; + obj.write_fixed_simple_record_array_written = yardl.None; + obj.write_fixed_record_with_vlens_array_written = yardl.None; + obj.write_record_with_fixed_arrays_written = yardl.None; + obj.write_named_array_written = yardl.None; end function expect_write_ints_(obj, value) - if isempty(obj.write_ints_written) - obj.write_ints_written = Node(value); - else + if obj.write_ints_written.has_value() last_dim = ndims(value); - obj.write_ints_written = Node(cat(last_dim, obj.write_ints_written(1).value, value)); + obj.write_ints_written = yardl.Optional(cat(last_dim, obj.write_ints_written.value, value)); + else + obj.write_ints_written = yardl.Optional(value); end end function expect_write_fixed_simple_record_array_(obj, value) - if isempty(obj.write_fixed_simple_record_array_written) - obj.write_fixed_simple_record_array_written = Node(value); - else + if obj.write_fixed_simple_record_array_written.has_value() last_dim = ndims(value); - obj.write_fixed_simple_record_array_written = Node(cat(last_dim, obj.write_fixed_simple_record_array_written(1).value, value)); + obj.write_fixed_simple_record_array_written = yardl.Optional(cat(last_dim, obj.write_fixed_simple_record_array_written.value, value)); + else + obj.write_fixed_simple_record_array_written = yardl.Optional(value); end end function expect_write_fixed_record_with_vlens_array_(obj, value) - if isempty(obj.write_fixed_record_with_vlens_array_written) - obj.write_fixed_record_with_vlens_array_written = Node(value); - else + if obj.write_fixed_record_with_vlens_array_written.has_value() last_dim = ndims(value); - obj.write_fixed_record_with_vlens_array_written = Node(cat(last_dim, obj.write_fixed_record_with_vlens_array_written(1).value, value)); + obj.write_fixed_record_with_vlens_array_written = yardl.Optional(cat(last_dim, obj.write_fixed_record_with_vlens_array_written.value, value)); + else + obj.write_fixed_record_with_vlens_array_written = yardl.Optional(value); end end function expect_write_record_with_fixed_arrays_(obj, value) - if isempty(obj.write_record_with_fixed_arrays_written) - obj.write_record_with_fixed_arrays_written = Node(value); - else + if obj.write_record_with_fixed_arrays_written.has_value() last_dim = ndims(value); - obj.write_record_with_fixed_arrays_written = Node(cat(last_dim, obj.write_record_with_fixed_arrays_written(1).value, value)); + obj.write_record_with_fixed_arrays_written = yardl.Optional(cat(last_dim, obj.write_record_with_fixed_arrays_written.value, value)); + else + obj.write_record_with_fixed_arrays_written = yardl.Optional(value); end end function expect_write_named_array_(obj, value) - if isempty(obj.write_named_array_written) - obj.write_named_array_written = Node(value); - else + if obj.write_named_array_written.has_value() last_dim = ndims(value); - obj.write_named_array_written = Node(cat(last_dim, obj.write_named_array_written(1).value, value)); + obj.write_named_array_written = yardl.Optional(cat(last_dim, obj.write_named_array_written.value, value)); + else + obj.write_named_array_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_ints_written), "Expected call to write_ints_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_fixed_simple_record_array_written), "Expected call to write_fixed_simple_record_array_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_fixed_record_with_vlens_array_written), "Expected call to write_fixed_record_with_vlens_array_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_record_with_fixed_arrays_written), "Expected call to write_record_with_fixed_arrays_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_named_array_written), "Expected call to write_named_array_ was not received"); + obj.testCase_.verifyEqual(obj.write_ints_written, yardl.None, "Expected call to write_ints_ was not received"); + obj.testCase_.verifyEqual(obj.write_fixed_simple_record_array_written, yardl.None, "Expected call to write_fixed_simple_record_array_ was not received"); + obj.testCase_.verifyEqual(obj.write_fixed_record_with_vlens_array_written, yardl.None, "Expected call to write_fixed_record_with_vlens_array_ was not received"); + obj.testCase_.verifyEqual(obj.write_record_with_fixed_arrays_written, yardl.None, "Expected call to write_record_with_fixed_arrays_ was not received"); + obj.testCase_.verifyEqual(obj.write_named_array_written, yardl.None, "Expected call to write_named_array_ was not received"); end end methods (Access=protected) function write_ints_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_ints_written), "Unexpected call to write_ints_"); - expected = obj.write_ints_written(1).value; + obj.testCase_.verifyTrue(obj.write_ints_written.has_value(), "Unexpected call to write_ints_"); + expected = obj.write_ints_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); - obj.write_ints_written = Node.empty(); + obj.write_ints_written = yardl.None; end function write_fixed_simple_record_array_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_fixed_simple_record_array_written), "Unexpected call to write_fixed_simple_record_array_"); - expected = obj.write_fixed_simple_record_array_written(1).value; + obj.testCase_.verifyTrue(obj.write_fixed_simple_record_array_written.has_value(), "Unexpected call to write_fixed_simple_record_array_"); + expected = obj.write_fixed_simple_record_array_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_simple_record_array_"); - obj.write_fixed_simple_record_array_written = Node.empty(); + obj.write_fixed_simple_record_array_written = yardl.None; end function write_fixed_record_with_vlens_array_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_fixed_record_with_vlens_array_written), "Unexpected call to write_fixed_record_with_vlens_array_"); - expected = obj.write_fixed_record_with_vlens_array_written(1).value; + obj.testCase_.verifyTrue(obj.write_fixed_record_with_vlens_array_written.has_value(), "Unexpected call to write_fixed_record_with_vlens_array_"); + expected = obj.write_fixed_record_with_vlens_array_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_record_with_vlens_array_"); - obj.write_fixed_record_with_vlens_array_written = Node.empty(); + obj.write_fixed_record_with_vlens_array_written = yardl.None; end function write_record_with_fixed_arrays_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_record_with_fixed_arrays_written), "Unexpected call to write_record_with_fixed_arrays_"); - expected = obj.write_record_with_fixed_arrays_written(1).value; + obj.testCase_.verifyTrue(obj.write_record_with_fixed_arrays_written.has_value(), "Unexpected call to write_record_with_fixed_arrays_"); + expected = obj.write_record_with_fixed_arrays_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_fixed_arrays_"); - obj.write_record_with_fixed_arrays_written = Node.empty(); + obj.write_record_with_fixed_arrays_written = yardl.None; end function write_named_array_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_named_array_written), "Unexpected call to write_named_array_"); - expected = obj.write_named_array_written(1).value; + obj.testCase_.verifyTrue(obj.write_named_array_written.has_value(), "Unexpected call to write_named_array_"); + expected = obj.write_named_array_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_named_array_"); - obj.write_named_array_written = Node.empty(); + obj.write_named_array_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m b/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m index b6bcbf09..27e2b623 100644 --- a/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m @@ -12,83 +12,83 @@ methods function obj = MockFixedVectorsWriter(testCase) obj.testCase_ = testCase; - obj.write_fixed_int_vector_written = Node.empty(); - obj.write_fixed_simple_record_vector_written = Node.empty(); - obj.write_fixed_record_with_vlens_vector_written = Node.empty(); - obj.write_record_with_fixed_vectors_written = Node.empty(); + obj.write_fixed_int_vector_written = yardl.None; + obj.write_fixed_simple_record_vector_written = yardl.None; + obj.write_fixed_record_with_vlens_vector_written = yardl.None; + obj.write_record_with_fixed_vectors_written = yardl.None; end function expect_write_fixed_int_vector_(obj, value) - if isempty(obj.write_fixed_int_vector_written) - obj.write_fixed_int_vector_written = Node(value); - else + if obj.write_fixed_int_vector_written.has_value() last_dim = ndims(value); - obj.write_fixed_int_vector_written = Node(cat(last_dim, obj.write_fixed_int_vector_written(1).value, value)); + obj.write_fixed_int_vector_written = yardl.Optional(cat(last_dim, obj.write_fixed_int_vector_written.value, value)); + else + obj.write_fixed_int_vector_written = yardl.Optional(value); end end function expect_write_fixed_simple_record_vector_(obj, value) - if isempty(obj.write_fixed_simple_record_vector_written) - obj.write_fixed_simple_record_vector_written = Node(value); - else + if obj.write_fixed_simple_record_vector_written.has_value() last_dim = ndims(value); - obj.write_fixed_simple_record_vector_written = Node(cat(last_dim, obj.write_fixed_simple_record_vector_written(1).value, value)); + obj.write_fixed_simple_record_vector_written = yardl.Optional(cat(last_dim, obj.write_fixed_simple_record_vector_written.value, value)); + else + obj.write_fixed_simple_record_vector_written = yardl.Optional(value); end end function expect_write_fixed_record_with_vlens_vector_(obj, value) - if isempty(obj.write_fixed_record_with_vlens_vector_written) - obj.write_fixed_record_with_vlens_vector_written = Node(value); - else + if obj.write_fixed_record_with_vlens_vector_written.has_value() last_dim = ndims(value); - obj.write_fixed_record_with_vlens_vector_written = Node(cat(last_dim, obj.write_fixed_record_with_vlens_vector_written(1).value, value)); + obj.write_fixed_record_with_vlens_vector_written = yardl.Optional(cat(last_dim, obj.write_fixed_record_with_vlens_vector_written.value, value)); + else + obj.write_fixed_record_with_vlens_vector_written = yardl.Optional(value); end end function expect_write_record_with_fixed_vectors_(obj, value) - if isempty(obj.write_record_with_fixed_vectors_written) - obj.write_record_with_fixed_vectors_written = Node(value); - else + if obj.write_record_with_fixed_vectors_written.has_value() last_dim = ndims(value); - obj.write_record_with_fixed_vectors_written = Node(cat(last_dim, obj.write_record_with_fixed_vectors_written(1).value, value)); + obj.write_record_with_fixed_vectors_written = yardl.Optional(cat(last_dim, obj.write_record_with_fixed_vectors_written.value, value)); + else + obj.write_record_with_fixed_vectors_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_fixed_int_vector_written), "Expected call to write_fixed_int_vector_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_fixed_simple_record_vector_written), "Expected call to write_fixed_simple_record_vector_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_fixed_record_with_vlens_vector_written), "Expected call to write_fixed_record_with_vlens_vector_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_record_with_fixed_vectors_written), "Expected call to write_record_with_fixed_vectors_ was not received"); + obj.testCase_.verifyEqual(obj.write_fixed_int_vector_written, yardl.None, "Expected call to write_fixed_int_vector_ was not received"); + obj.testCase_.verifyEqual(obj.write_fixed_simple_record_vector_written, yardl.None, "Expected call to write_fixed_simple_record_vector_ was not received"); + obj.testCase_.verifyEqual(obj.write_fixed_record_with_vlens_vector_written, yardl.None, "Expected call to write_fixed_record_with_vlens_vector_ was not received"); + obj.testCase_.verifyEqual(obj.write_record_with_fixed_vectors_written, yardl.None, "Expected call to write_record_with_fixed_vectors_ was not received"); end end methods (Access=protected) function write_fixed_int_vector_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_fixed_int_vector_written), "Unexpected call to write_fixed_int_vector_"); - expected = obj.write_fixed_int_vector_written(1).value; + obj.testCase_.verifyTrue(obj.write_fixed_int_vector_written.has_value(), "Unexpected call to write_fixed_int_vector_"); + expected = obj.write_fixed_int_vector_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_int_vector_"); - obj.write_fixed_int_vector_written = Node.empty(); + obj.write_fixed_int_vector_written = yardl.None; end function write_fixed_simple_record_vector_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_fixed_simple_record_vector_written), "Unexpected call to write_fixed_simple_record_vector_"); - expected = obj.write_fixed_simple_record_vector_written(1).value; + obj.testCase_.verifyTrue(obj.write_fixed_simple_record_vector_written.has_value(), "Unexpected call to write_fixed_simple_record_vector_"); + expected = obj.write_fixed_simple_record_vector_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_simple_record_vector_"); - obj.write_fixed_simple_record_vector_written = Node.empty(); + obj.write_fixed_simple_record_vector_written = yardl.None; end function write_fixed_record_with_vlens_vector_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_fixed_record_with_vlens_vector_written), "Unexpected call to write_fixed_record_with_vlens_vector_"); - expected = obj.write_fixed_record_with_vlens_vector_written(1).value; + obj.testCase_.verifyTrue(obj.write_fixed_record_with_vlens_vector_written.has_value(), "Unexpected call to write_fixed_record_with_vlens_vector_"); + expected = obj.write_fixed_record_with_vlens_vector_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_record_with_vlens_vector_"); - obj.write_fixed_record_with_vlens_vector_written = Node.empty(); + obj.write_fixed_record_with_vlens_vector_written = yardl.None; end function write_record_with_fixed_vectors_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_record_with_fixed_vectors_written), "Unexpected call to write_record_with_fixed_vectors_"); - expected = obj.write_record_with_fixed_vectors_written(1).value; + obj.testCase_.verifyTrue(obj.write_record_with_fixed_vectors_written.has_value(), "Unexpected call to write_record_with_fixed_vectors_"); + expected = obj.write_record_with_fixed_vectors_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_fixed_vectors_"); - obj.write_record_with_fixed_vectors_written = Node.empty(); + obj.write_record_with_fixed_vectors_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockFlagsWriter.m b/matlab/generated/+test_model/+testing/MockFlagsWriter.m index 4833ee2d..1a560271 100644 --- a/matlab/generated/+test_model/+testing/MockFlagsWriter.m +++ b/matlab/generated/+test_model/+testing/MockFlagsWriter.m @@ -10,47 +10,47 @@ methods function obj = MockFlagsWriter(testCase) obj.testCase_ = testCase; - obj.write_days_written = Node.empty(); - obj.write_formats_written = Node.empty(); + obj.write_days_written = yardl.None; + obj.write_formats_written = yardl.None; end function expect_write_days_(obj, value) - if isempty(obj.write_days_written) - obj.write_days_written = Node(value); - else + if obj.write_days_written.has_value() last_dim = ndims(value); - obj.write_days_written = Node(cat(last_dim, obj.write_days_written(1).value, value)); + obj.write_days_written = yardl.Optional(cat(last_dim, obj.write_days_written.value, value)); + else + obj.write_days_written = yardl.Optional(value); end end function expect_write_formats_(obj, value) - if isempty(obj.write_formats_written) - obj.write_formats_written = Node(value); - else + if obj.write_formats_written.has_value() last_dim = ndims(value); - obj.write_formats_written = Node(cat(last_dim, obj.write_formats_written(1).value, value)); + obj.write_formats_written = yardl.Optional(cat(last_dim, obj.write_formats_written.value, value)); + else + obj.write_formats_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_days_written), "Expected call to write_days_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_formats_written), "Expected call to write_formats_ was not received"); + obj.testCase_.verifyEqual(obj.write_days_written, yardl.None, "Expected call to write_days_ was not received"); + obj.testCase_.verifyEqual(obj.write_formats_written, yardl.None, "Expected call to write_formats_ was not received"); end end methods (Access=protected) function write_days_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_days_written), "Unexpected call to write_days_"); - expected = obj.write_days_written(1).value; + obj.testCase_.verifyTrue(obj.write_days_written.has_value(), "Unexpected call to write_days_"); + expected = obj.write_days_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_days_"); - obj.write_days_written = Node.empty(); + obj.write_days_written = yardl.None; end function write_formats_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_formats_written), "Unexpected call to write_formats_"); - expected = obj.write_formats_written(1).value; + obj.testCase_.verifyTrue(obj.write_formats_written.has_value(), "Unexpected call to write_formats_"); + expected = obj.write_formats_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_formats_"); - obj.write_formats_written = Node.empty(); + obj.write_formats_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockMapsWriter.m b/matlab/generated/+test_model/+testing/MockMapsWriter.m index 6a524c6c..83b06fac 100644 --- a/matlab/generated/+test_model/+testing/MockMapsWriter.m +++ b/matlab/generated/+test_model/+testing/MockMapsWriter.m @@ -12,83 +12,83 @@ methods function obj = MockMapsWriter(testCase) obj.testCase_ = testCase; - obj.write_string_to_int_written = Node.empty(); - obj.write_int_to_string_written = Node.empty(); - obj.write_string_to_union_written = Node.empty(); - obj.write_aliased_generic_written = Node.empty(); + obj.write_string_to_int_written = yardl.None; + obj.write_int_to_string_written = yardl.None; + obj.write_string_to_union_written = yardl.None; + obj.write_aliased_generic_written = yardl.None; end function expect_write_string_to_int_(obj, value) - if isempty(obj.write_string_to_int_written) - obj.write_string_to_int_written = Node(value); - else + if obj.write_string_to_int_written.has_value() last_dim = ndims(value); - obj.write_string_to_int_written = Node(cat(last_dim, obj.write_string_to_int_written(1).value, value)); + obj.write_string_to_int_written = yardl.Optional(cat(last_dim, obj.write_string_to_int_written.value, value)); + else + obj.write_string_to_int_written = yardl.Optional(value); end end function expect_write_int_to_string_(obj, value) - if isempty(obj.write_int_to_string_written) - obj.write_int_to_string_written = Node(value); - else + if obj.write_int_to_string_written.has_value() last_dim = ndims(value); - obj.write_int_to_string_written = Node(cat(last_dim, obj.write_int_to_string_written(1).value, value)); + obj.write_int_to_string_written = yardl.Optional(cat(last_dim, obj.write_int_to_string_written.value, value)); + else + obj.write_int_to_string_written = yardl.Optional(value); end end function expect_write_string_to_union_(obj, value) - if isempty(obj.write_string_to_union_written) - obj.write_string_to_union_written = Node(value); - else + if obj.write_string_to_union_written.has_value() last_dim = ndims(value); - obj.write_string_to_union_written = Node(cat(last_dim, obj.write_string_to_union_written(1).value, value)); + obj.write_string_to_union_written = yardl.Optional(cat(last_dim, obj.write_string_to_union_written.value, value)); + else + obj.write_string_to_union_written = yardl.Optional(value); end end function expect_write_aliased_generic_(obj, value) - if isempty(obj.write_aliased_generic_written) - obj.write_aliased_generic_written = Node(value); - else + if obj.write_aliased_generic_written.has_value() last_dim = ndims(value); - obj.write_aliased_generic_written = Node(cat(last_dim, obj.write_aliased_generic_written(1).value, value)); + obj.write_aliased_generic_written = yardl.Optional(cat(last_dim, obj.write_aliased_generic_written.value, value)); + else + obj.write_aliased_generic_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_string_to_int_written), "Expected call to write_string_to_int_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_int_to_string_written), "Expected call to write_int_to_string_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_string_to_union_written), "Expected call to write_string_to_union_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_aliased_generic_written), "Expected call to write_aliased_generic_ was not received"); + obj.testCase_.verifyEqual(obj.write_string_to_int_written, yardl.None, "Expected call to write_string_to_int_ was not received"); + obj.testCase_.verifyEqual(obj.write_int_to_string_written, yardl.None, "Expected call to write_int_to_string_ was not received"); + obj.testCase_.verifyEqual(obj.write_string_to_union_written, yardl.None, "Expected call to write_string_to_union_ was not received"); + obj.testCase_.verifyEqual(obj.write_aliased_generic_written, yardl.None, "Expected call to write_aliased_generic_ was not received"); end end methods (Access=protected) function write_string_to_int_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_string_to_int_written), "Unexpected call to write_string_to_int_"); - expected = obj.write_string_to_int_written(1).value; + obj.testCase_.verifyTrue(obj.write_string_to_int_written.has_value(), "Unexpected call to write_string_to_int_"); + expected = obj.write_string_to_int_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_string_to_int_"); - obj.write_string_to_int_written = Node.empty(); + obj.write_string_to_int_written = yardl.None; end function write_int_to_string_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_int_to_string_written), "Unexpected call to write_int_to_string_"); - expected = obj.write_int_to_string_written(1).value; + obj.testCase_.verifyTrue(obj.write_int_to_string_written.has_value(), "Unexpected call to write_int_to_string_"); + expected = obj.write_int_to_string_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_to_string_"); - obj.write_int_to_string_written = Node.empty(); + obj.write_int_to_string_written = yardl.None; end function write_string_to_union_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_string_to_union_written), "Unexpected call to write_string_to_union_"); - expected = obj.write_string_to_union_written(1).value; + obj.testCase_.verifyTrue(obj.write_string_to_union_written.has_value(), "Unexpected call to write_string_to_union_"); + expected = obj.write_string_to_union_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_string_to_union_"); - obj.write_string_to_union_written = Node.empty(); + obj.write_string_to_union_written = yardl.None; end function write_aliased_generic_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_aliased_generic_written), "Unexpected call to write_aliased_generic_"); - expected = obj.write_aliased_generic_written(1).value; + obj.testCase_.verifyTrue(obj.write_aliased_generic_written.has_value(), "Unexpected call to write_aliased_generic_"); + expected = obj.write_aliased_generic_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_"); - obj.write_aliased_generic_written = Node.empty(); + obj.write_aliased_generic_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m b/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m index 02474d4b..455a43f6 100644 --- a/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m +++ b/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m @@ -12,83 +12,83 @@ methods function obj = MockNDArraysSingleDimensionWriter(testCase) obj.testCase_ = testCase; - obj.write_ints_written = Node.empty(); - obj.write_simple_record_array_written = Node.empty(); - obj.write_record_with_vlens_array_written = Node.empty(); - obj.write_record_with_nd_arrays_written = Node.empty(); + obj.write_ints_written = yardl.None; + obj.write_simple_record_array_written = yardl.None; + obj.write_record_with_vlens_array_written = yardl.None; + obj.write_record_with_nd_arrays_written = yardl.None; end function expect_write_ints_(obj, value) - if isempty(obj.write_ints_written) - obj.write_ints_written = Node(value); - else + if obj.write_ints_written.has_value() last_dim = ndims(value); - obj.write_ints_written = Node(cat(last_dim, obj.write_ints_written(1).value, value)); + obj.write_ints_written = yardl.Optional(cat(last_dim, obj.write_ints_written.value, value)); + else + obj.write_ints_written = yardl.Optional(value); end end function expect_write_simple_record_array_(obj, value) - if isempty(obj.write_simple_record_array_written) - obj.write_simple_record_array_written = Node(value); - else + if obj.write_simple_record_array_written.has_value() last_dim = ndims(value); - obj.write_simple_record_array_written = Node(cat(last_dim, obj.write_simple_record_array_written(1).value, value)); + obj.write_simple_record_array_written = yardl.Optional(cat(last_dim, obj.write_simple_record_array_written.value, value)); + else + obj.write_simple_record_array_written = yardl.Optional(value); end end function expect_write_record_with_vlens_array_(obj, value) - if isempty(obj.write_record_with_vlens_array_written) - obj.write_record_with_vlens_array_written = Node(value); - else + if obj.write_record_with_vlens_array_written.has_value() last_dim = ndims(value); - obj.write_record_with_vlens_array_written = Node(cat(last_dim, obj.write_record_with_vlens_array_written(1).value, value)); + obj.write_record_with_vlens_array_written = yardl.Optional(cat(last_dim, obj.write_record_with_vlens_array_written.value, value)); + else + obj.write_record_with_vlens_array_written = yardl.Optional(value); end end function expect_write_record_with_nd_arrays_(obj, value) - if isempty(obj.write_record_with_nd_arrays_written) - obj.write_record_with_nd_arrays_written = Node(value); - else + if obj.write_record_with_nd_arrays_written.has_value() last_dim = ndims(value); - obj.write_record_with_nd_arrays_written = Node(cat(last_dim, obj.write_record_with_nd_arrays_written(1).value, value)); + obj.write_record_with_nd_arrays_written = yardl.Optional(cat(last_dim, obj.write_record_with_nd_arrays_written.value, value)); + else + obj.write_record_with_nd_arrays_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_ints_written), "Expected call to write_ints_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_simple_record_array_written), "Expected call to write_simple_record_array_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_record_with_vlens_array_written), "Expected call to write_record_with_vlens_array_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_record_with_nd_arrays_written), "Expected call to write_record_with_nd_arrays_ was not received"); + obj.testCase_.verifyEqual(obj.write_ints_written, yardl.None, "Expected call to write_ints_ was not received"); + obj.testCase_.verifyEqual(obj.write_simple_record_array_written, yardl.None, "Expected call to write_simple_record_array_ was not received"); + obj.testCase_.verifyEqual(obj.write_record_with_vlens_array_written, yardl.None, "Expected call to write_record_with_vlens_array_ was not received"); + obj.testCase_.verifyEqual(obj.write_record_with_nd_arrays_written, yardl.None, "Expected call to write_record_with_nd_arrays_ was not received"); end end methods (Access=protected) function write_ints_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_ints_written), "Unexpected call to write_ints_"); - expected = obj.write_ints_written(1).value; + obj.testCase_.verifyTrue(obj.write_ints_written.has_value(), "Unexpected call to write_ints_"); + expected = obj.write_ints_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); - obj.write_ints_written = Node.empty(); + obj.write_ints_written = yardl.None; end function write_simple_record_array_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_simple_record_array_written), "Unexpected call to write_simple_record_array_"); - expected = obj.write_simple_record_array_written(1).value; + obj.testCase_.verifyTrue(obj.write_simple_record_array_written.has_value(), "Unexpected call to write_simple_record_array_"); + expected = obj.write_simple_record_array_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_simple_record_array_"); - obj.write_simple_record_array_written = Node.empty(); + obj.write_simple_record_array_written = yardl.None; end function write_record_with_vlens_array_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_record_with_vlens_array_written), "Unexpected call to write_record_with_vlens_array_"); - expected = obj.write_record_with_vlens_array_written(1).value; + obj.testCase_.verifyTrue(obj.write_record_with_vlens_array_written.has_value(), "Unexpected call to write_record_with_vlens_array_"); + expected = obj.write_record_with_vlens_array_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_array_"); - obj.write_record_with_vlens_array_written = Node.empty(); + obj.write_record_with_vlens_array_written = yardl.None; end function write_record_with_nd_arrays_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_record_with_nd_arrays_written), "Unexpected call to write_record_with_nd_arrays_"); - expected = obj.write_record_with_nd_arrays_written(1).value; + obj.testCase_.verifyTrue(obj.write_record_with_nd_arrays_written.has_value(), "Unexpected call to write_record_with_nd_arrays_"); + expected = obj.write_record_with_nd_arrays_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_nd_arrays_"); - obj.write_record_with_nd_arrays_written = Node.empty(); + obj.write_record_with_nd_arrays_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockNDArraysWriter.m b/matlab/generated/+test_model/+testing/MockNDArraysWriter.m index 89340084..67625e05 100644 --- a/matlab/generated/+test_model/+testing/MockNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockNDArraysWriter.m @@ -13,101 +13,101 @@ methods function obj = MockNDArraysWriter(testCase) obj.testCase_ = testCase; - obj.write_ints_written = Node.empty(); - obj.write_simple_record_array_written = Node.empty(); - obj.write_record_with_vlens_array_written = Node.empty(); - obj.write_record_with_nd_arrays_written = Node.empty(); - obj.write_named_array_written = Node.empty(); + obj.write_ints_written = yardl.None; + obj.write_simple_record_array_written = yardl.None; + obj.write_record_with_vlens_array_written = yardl.None; + obj.write_record_with_nd_arrays_written = yardl.None; + obj.write_named_array_written = yardl.None; end function expect_write_ints_(obj, value) - if isempty(obj.write_ints_written) - obj.write_ints_written = Node(value); - else + if obj.write_ints_written.has_value() last_dim = ndims(value); - obj.write_ints_written = Node(cat(last_dim, obj.write_ints_written(1).value, value)); + obj.write_ints_written = yardl.Optional(cat(last_dim, obj.write_ints_written.value, value)); + else + obj.write_ints_written = yardl.Optional(value); end end function expect_write_simple_record_array_(obj, value) - if isempty(obj.write_simple_record_array_written) - obj.write_simple_record_array_written = Node(value); - else + if obj.write_simple_record_array_written.has_value() last_dim = ndims(value); - obj.write_simple_record_array_written = Node(cat(last_dim, obj.write_simple_record_array_written(1).value, value)); + obj.write_simple_record_array_written = yardl.Optional(cat(last_dim, obj.write_simple_record_array_written.value, value)); + else + obj.write_simple_record_array_written = yardl.Optional(value); end end function expect_write_record_with_vlens_array_(obj, value) - if isempty(obj.write_record_with_vlens_array_written) - obj.write_record_with_vlens_array_written = Node(value); - else + if obj.write_record_with_vlens_array_written.has_value() last_dim = ndims(value); - obj.write_record_with_vlens_array_written = Node(cat(last_dim, obj.write_record_with_vlens_array_written(1).value, value)); + obj.write_record_with_vlens_array_written = yardl.Optional(cat(last_dim, obj.write_record_with_vlens_array_written.value, value)); + else + obj.write_record_with_vlens_array_written = yardl.Optional(value); end end function expect_write_record_with_nd_arrays_(obj, value) - if isempty(obj.write_record_with_nd_arrays_written) - obj.write_record_with_nd_arrays_written = Node(value); - else + if obj.write_record_with_nd_arrays_written.has_value() last_dim = ndims(value); - obj.write_record_with_nd_arrays_written = Node(cat(last_dim, obj.write_record_with_nd_arrays_written(1).value, value)); + obj.write_record_with_nd_arrays_written = yardl.Optional(cat(last_dim, obj.write_record_with_nd_arrays_written.value, value)); + else + obj.write_record_with_nd_arrays_written = yardl.Optional(value); end end function expect_write_named_array_(obj, value) - if isempty(obj.write_named_array_written) - obj.write_named_array_written = Node(value); - else + if obj.write_named_array_written.has_value() last_dim = ndims(value); - obj.write_named_array_written = Node(cat(last_dim, obj.write_named_array_written(1).value, value)); + obj.write_named_array_written = yardl.Optional(cat(last_dim, obj.write_named_array_written.value, value)); + else + obj.write_named_array_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_ints_written), "Expected call to write_ints_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_simple_record_array_written), "Expected call to write_simple_record_array_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_record_with_vlens_array_written), "Expected call to write_record_with_vlens_array_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_record_with_nd_arrays_written), "Expected call to write_record_with_nd_arrays_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_named_array_written), "Expected call to write_named_array_ was not received"); + obj.testCase_.verifyEqual(obj.write_ints_written, yardl.None, "Expected call to write_ints_ was not received"); + obj.testCase_.verifyEqual(obj.write_simple_record_array_written, yardl.None, "Expected call to write_simple_record_array_ was not received"); + obj.testCase_.verifyEqual(obj.write_record_with_vlens_array_written, yardl.None, "Expected call to write_record_with_vlens_array_ was not received"); + obj.testCase_.verifyEqual(obj.write_record_with_nd_arrays_written, yardl.None, "Expected call to write_record_with_nd_arrays_ was not received"); + obj.testCase_.verifyEqual(obj.write_named_array_written, yardl.None, "Expected call to write_named_array_ was not received"); end end methods (Access=protected) function write_ints_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_ints_written), "Unexpected call to write_ints_"); - expected = obj.write_ints_written(1).value; + obj.testCase_.verifyTrue(obj.write_ints_written.has_value(), "Unexpected call to write_ints_"); + expected = obj.write_ints_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); - obj.write_ints_written = Node.empty(); + obj.write_ints_written = yardl.None; end function write_simple_record_array_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_simple_record_array_written), "Unexpected call to write_simple_record_array_"); - expected = obj.write_simple_record_array_written(1).value; + obj.testCase_.verifyTrue(obj.write_simple_record_array_written.has_value(), "Unexpected call to write_simple_record_array_"); + expected = obj.write_simple_record_array_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_simple_record_array_"); - obj.write_simple_record_array_written = Node.empty(); + obj.write_simple_record_array_written = yardl.None; end function write_record_with_vlens_array_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_record_with_vlens_array_written), "Unexpected call to write_record_with_vlens_array_"); - expected = obj.write_record_with_vlens_array_written(1).value; + obj.testCase_.verifyTrue(obj.write_record_with_vlens_array_written.has_value(), "Unexpected call to write_record_with_vlens_array_"); + expected = obj.write_record_with_vlens_array_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_array_"); - obj.write_record_with_vlens_array_written = Node.empty(); + obj.write_record_with_vlens_array_written = yardl.None; end function write_record_with_nd_arrays_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_record_with_nd_arrays_written), "Unexpected call to write_record_with_nd_arrays_"); - expected = obj.write_record_with_nd_arrays_written(1).value; + obj.testCase_.verifyTrue(obj.write_record_with_nd_arrays_written.has_value(), "Unexpected call to write_record_with_nd_arrays_"); + expected = obj.write_record_with_nd_arrays_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_nd_arrays_"); - obj.write_record_with_nd_arrays_written = Node.empty(); + obj.write_record_with_nd_arrays_written = yardl.None; end function write_named_array_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_named_array_written), "Unexpected call to write_named_array_"); - expected = obj.write_named_array_written(1).value; + obj.testCase_.verifyTrue(obj.write_named_array_written.has_value(), "Unexpected call to write_named_array_"); + expected = obj.write_named_array_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_named_array_"); - obj.write_named_array_written = Node.empty(); + obj.write_named_array_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m b/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m index 842cc2b2..5f76e57a 100644 --- a/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m @@ -9,29 +9,29 @@ methods function obj = MockNestedRecordsWriter(testCase) obj.testCase_ = testCase; - obj.write_tuple_with_records_written = Node.empty(); + obj.write_tuple_with_records_written = yardl.None; end function expect_write_tuple_with_records_(obj, value) - if isempty(obj.write_tuple_with_records_written) - obj.write_tuple_with_records_written = Node(value); - else + if obj.write_tuple_with_records_written.has_value() last_dim = ndims(value); - obj.write_tuple_with_records_written = Node(cat(last_dim, obj.write_tuple_with_records_written(1).value, value)); + obj.write_tuple_with_records_written = yardl.Optional(cat(last_dim, obj.write_tuple_with_records_written.value, value)); + else + obj.write_tuple_with_records_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_tuple_with_records_written), "Expected call to write_tuple_with_records_ was not received"); + obj.testCase_.verifyEqual(obj.write_tuple_with_records_written, yardl.None, "Expected call to write_tuple_with_records_ was not received"); end end methods (Access=protected) function write_tuple_with_records_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_tuple_with_records_written), "Unexpected call to write_tuple_with_records_"); - expected = obj.write_tuple_with_records_written(1).value; + obj.testCase_.verifyTrue(obj.write_tuple_with_records_written.has_value(), "Unexpected call to write_tuple_with_records_"); + expected = obj.write_tuple_with_records_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_with_records_"); - obj.write_tuple_with_records_written = Node.empty(); + obj.write_tuple_with_records_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m b/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m index 85ee3401..624f2e10 100644 --- a/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m @@ -9,29 +9,29 @@ methods function obj = MockOptionalVectorsWriter(testCase) obj.testCase_ = testCase; - obj.write_record_with_optional_vector_written = Node.empty(); + obj.write_record_with_optional_vector_written = yardl.None; end function expect_write_record_with_optional_vector_(obj, value) - if isempty(obj.write_record_with_optional_vector_written) - obj.write_record_with_optional_vector_written = Node(value); - else + if obj.write_record_with_optional_vector_written.has_value() last_dim = ndims(value); - obj.write_record_with_optional_vector_written = Node(cat(last_dim, obj.write_record_with_optional_vector_written(1).value, value)); + obj.write_record_with_optional_vector_written = yardl.Optional(cat(last_dim, obj.write_record_with_optional_vector_written.value, value)); + else + obj.write_record_with_optional_vector_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_record_with_optional_vector_written), "Expected call to write_record_with_optional_vector_ was not received"); + obj.testCase_.verifyEqual(obj.write_record_with_optional_vector_written, yardl.None, "Expected call to write_record_with_optional_vector_ was not received"); end end methods (Access=protected) function write_record_with_optional_vector_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_record_with_optional_vector_written), "Unexpected call to write_record_with_optional_vector_"); - expected = obj.write_record_with_optional_vector_written(1).value; + obj.testCase_.verifyTrue(obj.write_record_with_optional_vector_written.has_value(), "Unexpected call to write_record_with_optional_vector_"); + expected = obj.write_record_with_optional_vector_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_optional_vector_"); - obj.write_record_with_optional_vector_written = Node.empty(); + obj.write_record_with_optional_vector_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m b/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m index 533645a9..96de9ac3 100644 --- a/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m +++ b/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m @@ -9,29 +9,29 @@ methods function obj = MockProtocolWithComputedFieldsWriter(testCase) obj.testCase_ = testCase; - obj.write_record_with_computed_fields_written = Node.empty(); + obj.write_record_with_computed_fields_written = yardl.None; end function expect_write_record_with_computed_fields_(obj, value) - if isempty(obj.write_record_with_computed_fields_written) - obj.write_record_with_computed_fields_written = Node(value); - else + if obj.write_record_with_computed_fields_written.has_value() last_dim = ndims(value); - obj.write_record_with_computed_fields_written = Node(cat(last_dim, obj.write_record_with_computed_fields_written(1).value, value)); + obj.write_record_with_computed_fields_written = yardl.Optional(cat(last_dim, obj.write_record_with_computed_fields_written.value, value)); + else + obj.write_record_with_computed_fields_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_record_with_computed_fields_written), "Expected call to write_record_with_computed_fields_ was not received"); + obj.testCase_.verifyEqual(obj.write_record_with_computed_fields_written, yardl.None, "Expected call to write_record_with_computed_fields_ was not received"); end end methods (Access=protected) function write_record_with_computed_fields_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_record_with_computed_fields_written), "Unexpected call to write_record_with_computed_fields_"); - expected = obj.write_record_with_computed_fields_written(1).value; + obj.testCase_.verifyTrue(obj.write_record_with_computed_fields_written.has_value(), "Unexpected call to write_record_with_computed_fields_"); + expected = obj.write_record_with_computed_fields_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_computed_fields_"); - obj.write_record_with_computed_fields_written = Node.empty(); + obj.write_record_with_computed_fields_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m index 4cfbfbab..abc97e88 100644 --- a/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m +++ b/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m @@ -10,47 +10,47 @@ methods function obj = MockProtocolWithKeywordStepsWriter(testCase) obj.testCase_ = testCase; - obj.write_int_written = Node.empty(); - obj.write_float_written = Node.empty(); + obj.write_int_written = yardl.None; + obj.write_float_written = yardl.None; end function expect_write_int_(obj, value) - if isempty(obj.write_int_written) - obj.write_int_written = Node(value); - else + if obj.write_int_written.has_value() last_dim = ndims(value); - obj.write_int_written = Node(cat(last_dim, obj.write_int_written(1).value, value)); + obj.write_int_written = yardl.Optional(cat(last_dim, obj.write_int_written.value, value)); + else + obj.write_int_written = yardl.Optional(value); end end function expect_write_float_(obj, value) - if isempty(obj.write_float_written) - obj.write_float_written = Node(value); - else + if obj.write_float_written.has_value() last_dim = ndims(value); - obj.write_float_written = Node(cat(last_dim, obj.write_float_written(1).value, value)); + obj.write_float_written = yardl.Optional(cat(last_dim, obj.write_float_written.value, value)); + else + obj.write_float_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_int_written), "Expected call to write_int_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_float_written), "Expected call to write_float_ was not received"); + obj.testCase_.verifyEqual(obj.write_int_written, yardl.None, "Expected call to write_int_ was not received"); + obj.testCase_.verifyEqual(obj.write_float_written, yardl.None, "Expected call to write_float_ was not received"); end end methods (Access=protected) function write_int_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_int_written), "Unexpected call to write_int_"); - expected = obj.write_int_written(1).value; + obj.testCase_.verifyTrue(obj.write_int_written.has_value(), "Unexpected call to write_int_"); + expected = obj.write_int_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_"); - obj.write_int_written = Node.empty(); + obj.write_int_written = yardl.None; end function write_float_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_float_written), "Unexpected call to write_float_"); - expected = obj.write_float_written(1).value; + obj.testCase_.verifyTrue(obj.write_float_written.has_value(), "Unexpected call to write_float_"); + expected = obj.write_float_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_"); - obj.write_float_written = Node.empty(); + obj.write_float_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m b/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m index 0a797a41..4aef7fcc 100644 --- a/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m @@ -12,83 +12,83 @@ methods function obj = MockScalarOptionalsWriter(testCase) obj.testCase_ = testCase; - obj.write_optional_int_written = Node.empty(); - obj.write_optional_record_written = Node.empty(); - obj.write_record_with_optional_fields_written = Node.empty(); - obj.write_optional_record_with_optional_fields_written = Node.empty(); + obj.write_optional_int_written = yardl.None; + obj.write_optional_record_written = yardl.None; + obj.write_record_with_optional_fields_written = yardl.None; + obj.write_optional_record_with_optional_fields_written = yardl.None; end function expect_write_optional_int_(obj, value) - if isempty(obj.write_optional_int_written) - obj.write_optional_int_written = Node(value); - else + if obj.write_optional_int_written.has_value() last_dim = ndims(value); - obj.write_optional_int_written = Node(cat(last_dim, obj.write_optional_int_written(1).value, value)); + obj.write_optional_int_written = yardl.Optional(cat(last_dim, obj.write_optional_int_written.value, value)); + else + obj.write_optional_int_written = yardl.Optional(value); end end function expect_write_optional_record_(obj, value) - if isempty(obj.write_optional_record_written) - obj.write_optional_record_written = Node(value); - else + if obj.write_optional_record_written.has_value() last_dim = ndims(value); - obj.write_optional_record_written = Node(cat(last_dim, obj.write_optional_record_written(1).value, value)); + obj.write_optional_record_written = yardl.Optional(cat(last_dim, obj.write_optional_record_written.value, value)); + else + obj.write_optional_record_written = yardl.Optional(value); end end function expect_write_record_with_optional_fields_(obj, value) - if isempty(obj.write_record_with_optional_fields_written) - obj.write_record_with_optional_fields_written = Node(value); - else + if obj.write_record_with_optional_fields_written.has_value() last_dim = ndims(value); - obj.write_record_with_optional_fields_written = Node(cat(last_dim, obj.write_record_with_optional_fields_written(1).value, value)); + obj.write_record_with_optional_fields_written = yardl.Optional(cat(last_dim, obj.write_record_with_optional_fields_written.value, value)); + else + obj.write_record_with_optional_fields_written = yardl.Optional(value); end end function expect_write_optional_record_with_optional_fields_(obj, value) - if isempty(obj.write_optional_record_with_optional_fields_written) - obj.write_optional_record_with_optional_fields_written = Node(value); - else + if obj.write_optional_record_with_optional_fields_written.has_value() last_dim = ndims(value); - obj.write_optional_record_with_optional_fields_written = Node(cat(last_dim, obj.write_optional_record_with_optional_fields_written(1).value, value)); + obj.write_optional_record_with_optional_fields_written = yardl.Optional(cat(last_dim, obj.write_optional_record_with_optional_fields_written.value, value)); + else + obj.write_optional_record_with_optional_fields_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_optional_int_written), "Expected call to write_optional_int_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_optional_record_written), "Expected call to write_optional_record_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_record_with_optional_fields_written), "Expected call to write_record_with_optional_fields_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_optional_record_with_optional_fields_written), "Expected call to write_optional_record_with_optional_fields_ was not received"); + obj.testCase_.verifyEqual(obj.write_optional_int_written, yardl.None, "Expected call to write_optional_int_ was not received"); + obj.testCase_.verifyEqual(obj.write_optional_record_written, yardl.None, "Expected call to write_optional_record_ was not received"); + obj.testCase_.verifyEqual(obj.write_record_with_optional_fields_written, yardl.None, "Expected call to write_record_with_optional_fields_ was not received"); + obj.testCase_.verifyEqual(obj.write_optional_record_with_optional_fields_written, yardl.None, "Expected call to write_optional_record_with_optional_fields_ was not received"); end end methods (Access=protected) function write_optional_int_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_optional_int_written), "Unexpected call to write_optional_int_"); - expected = obj.write_optional_int_written(1).value; + obj.testCase_.verifyTrue(obj.write_optional_int_written.has_value(), "Unexpected call to write_optional_int_"); + expected = obj.write_optional_int_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_int_"); - obj.write_optional_int_written = Node.empty(); + obj.write_optional_int_written = yardl.None; end function write_optional_record_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_optional_record_written), "Unexpected call to write_optional_record_"); - expected = obj.write_optional_record_written(1).value; + obj.testCase_.verifyTrue(obj.write_optional_record_written.has_value(), "Unexpected call to write_optional_record_"); + expected = obj.write_optional_record_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_record_"); - obj.write_optional_record_written = Node.empty(); + obj.write_optional_record_written = yardl.None; end function write_record_with_optional_fields_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_record_with_optional_fields_written), "Unexpected call to write_record_with_optional_fields_"); - expected = obj.write_record_with_optional_fields_written(1).value; + obj.testCase_.verifyTrue(obj.write_record_with_optional_fields_written.has_value(), "Unexpected call to write_record_with_optional_fields_"); + expected = obj.write_record_with_optional_fields_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_optional_fields_"); - obj.write_record_with_optional_fields_written = Node.empty(); + obj.write_record_with_optional_fields_written = yardl.None; end function write_optional_record_with_optional_fields_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_optional_record_with_optional_fields_written), "Unexpected call to write_optional_record_with_optional_fields_"); - expected = obj.write_optional_record_with_optional_fields_written(1).value; + obj.testCase_.verifyTrue(obj.write_optional_record_with_optional_fields_written.has_value(), "Unexpected call to write_optional_record_with_optional_fields_"); + expected = obj.write_optional_record_with_optional_fields_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_record_with_optional_fields_"); - obj.write_optional_record_with_optional_fields_written = Node.empty(); + obj.write_optional_record_with_optional_fields_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockScalarsWriter.m b/matlab/generated/+test_model/+testing/MockScalarsWriter.m index ffafe9c1..64c1a6d1 100644 --- a/matlab/generated/+test_model/+testing/MockScalarsWriter.m +++ b/matlab/generated/+test_model/+testing/MockScalarsWriter.m @@ -10,47 +10,47 @@ methods function obj = MockScalarsWriter(testCase) obj.testCase_ = testCase; - obj.write_int32_written = Node.empty(); - obj.write_record_written = Node.empty(); + obj.write_int32_written = yardl.None; + obj.write_record_written = yardl.None; end function expect_write_int32_(obj, value) - if isempty(obj.write_int32_written) - obj.write_int32_written = Node(value); - else + if obj.write_int32_written.has_value() last_dim = ndims(value); - obj.write_int32_written = Node(cat(last_dim, obj.write_int32_written(1).value, value)); + obj.write_int32_written = yardl.Optional(cat(last_dim, obj.write_int32_written.value, value)); + else + obj.write_int32_written = yardl.Optional(value); end end function expect_write_record_(obj, value) - if isempty(obj.write_record_written) - obj.write_record_written = Node(value); - else + if obj.write_record_written.has_value() last_dim = ndims(value); - obj.write_record_written = Node(cat(last_dim, obj.write_record_written(1).value, value)); + obj.write_record_written = yardl.Optional(cat(last_dim, obj.write_record_written.value, value)); + else + obj.write_record_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_int32_written), "Expected call to write_int32_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_record_written), "Expected call to write_record_ was not received"); + obj.testCase_.verifyEqual(obj.write_int32_written, yardl.None, "Expected call to write_int32_ was not received"); + obj.testCase_.verifyEqual(obj.write_record_written, yardl.None, "Expected call to write_record_ was not received"); end end methods (Access=protected) function write_int32_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_int32_written), "Unexpected call to write_int32_"); - expected = obj.write_int32_written(1).value; + obj.testCase_.verifyTrue(obj.write_int32_written.has_value(), "Unexpected call to write_int32_"); + expected = obj.write_int32_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int32_"); - obj.write_int32_written = Node.empty(); + obj.write_int32_written = yardl.None; end function write_record_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_record_written), "Unexpected call to write_record_"); - expected = obj.write_record_written(1).value; + obj.testCase_.verifyTrue(obj.write_record_written.has_value(), "Unexpected call to write_record_"); + expected = obj.write_record_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_"); - obj.write_record_written = Node.empty(); + obj.write_record_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m b/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m index 20c45a97..3591f63f 100644 --- a/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m @@ -17,173 +17,173 @@ methods function obj = MockSimpleGenericsWriter(testCase) obj.testCase_ = testCase; - obj.write_float_image_written = Node.empty(); - obj.write_int_image_written = Node.empty(); - obj.write_int_image_alternate_syntax_written = Node.empty(); - obj.write_string_image_written = Node.empty(); - obj.write_int_float_tuple_written = Node.empty(); - obj.write_float_float_tuple_written = Node.empty(); - obj.write_int_float_tuple_alternate_syntax_written = Node.empty(); - obj.write_int_string_tuple_written = Node.empty(); - obj.write_stream_of_type_variants_written = Node.empty(); + obj.write_float_image_written = yardl.None; + obj.write_int_image_written = yardl.None; + obj.write_int_image_alternate_syntax_written = yardl.None; + obj.write_string_image_written = yardl.None; + obj.write_int_float_tuple_written = yardl.None; + obj.write_float_float_tuple_written = yardl.None; + obj.write_int_float_tuple_alternate_syntax_written = yardl.None; + obj.write_int_string_tuple_written = yardl.None; + obj.write_stream_of_type_variants_written = yardl.None; end function expect_write_float_image_(obj, value) - if isempty(obj.write_float_image_written) - obj.write_float_image_written = Node(value); - else + if obj.write_float_image_written.has_value() last_dim = ndims(value); - obj.write_float_image_written = Node(cat(last_dim, obj.write_float_image_written(1).value, value)); + obj.write_float_image_written = yardl.Optional(cat(last_dim, obj.write_float_image_written.value, value)); + else + obj.write_float_image_written = yardl.Optional(value); end end function expect_write_int_image_(obj, value) - if isempty(obj.write_int_image_written) - obj.write_int_image_written = Node(value); - else + if obj.write_int_image_written.has_value() last_dim = ndims(value); - obj.write_int_image_written = Node(cat(last_dim, obj.write_int_image_written(1).value, value)); + obj.write_int_image_written = yardl.Optional(cat(last_dim, obj.write_int_image_written.value, value)); + else + obj.write_int_image_written = yardl.Optional(value); end end function expect_write_int_image_alternate_syntax_(obj, value) - if isempty(obj.write_int_image_alternate_syntax_written) - obj.write_int_image_alternate_syntax_written = Node(value); - else + if obj.write_int_image_alternate_syntax_written.has_value() last_dim = ndims(value); - obj.write_int_image_alternate_syntax_written = Node(cat(last_dim, obj.write_int_image_alternate_syntax_written(1).value, value)); + obj.write_int_image_alternate_syntax_written = yardl.Optional(cat(last_dim, obj.write_int_image_alternate_syntax_written.value, value)); + else + obj.write_int_image_alternate_syntax_written = yardl.Optional(value); end end function expect_write_string_image_(obj, value) - if isempty(obj.write_string_image_written) - obj.write_string_image_written = Node(value); - else + if obj.write_string_image_written.has_value() last_dim = ndims(value); - obj.write_string_image_written = Node(cat(last_dim, obj.write_string_image_written(1).value, value)); + obj.write_string_image_written = yardl.Optional(cat(last_dim, obj.write_string_image_written.value, value)); + else + obj.write_string_image_written = yardl.Optional(value); end end function expect_write_int_float_tuple_(obj, value) - if isempty(obj.write_int_float_tuple_written) - obj.write_int_float_tuple_written = Node(value); - else + if obj.write_int_float_tuple_written.has_value() last_dim = ndims(value); - obj.write_int_float_tuple_written = Node(cat(last_dim, obj.write_int_float_tuple_written(1).value, value)); + obj.write_int_float_tuple_written = yardl.Optional(cat(last_dim, obj.write_int_float_tuple_written.value, value)); + else + obj.write_int_float_tuple_written = yardl.Optional(value); end end function expect_write_float_float_tuple_(obj, value) - if isempty(obj.write_float_float_tuple_written) - obj.write_float_float_tuple_written = Node(value); - else + if obj.write_float_float_tuple_written.has_value() last_dim = ndims(value); - obj.write_float_float_tuple_written = Node(cat(last_dim, obj.write_float_float_tuple_written(1).value, value)); + obj.write_float_float_tuple_written = yardl.Optional(cat(last_dim, obj.write_float_float_tuple_written.value, value)); + else + obj.write_float_float_tuple_written = yardl.Optional(value); end end function expect_write_int_float_tuple_alternate_syntax_(obj, value) - if isempty(obj.write_int_float_tuple_alternate_syntax_written) - obj.write_int_float_tuple_alternate_syntax_written = Node(value); - else + if obj.write_int_float_tuple_alternate_syntax_written.has_value() last_dim = ndims(value); - obj.write_int_float_tuple_alternate_syntax_written = Node(cat(last_dim, obj.write_int_float_tuple_alternate_syntax_written(1).value, value)); + obj.write_int_float_tuple_alternate_syntax_written = yardl.Optional(cat(last_dim, obj.write_int_float_tuple_alternate_syntax_written.value, value)); + else + obj.write_int_float_tuple_alternate_syntax_written = yardl.Optional(value); end end function expect_write_int_string_tuple_(obj, value) - if isempty(obj.write_int_string_tuple_written) - obj.write_int_string_tuple_written = Node(value); - else + if obj.write_int_string_tuple_written.has_value() last_dim = ndims(value); - obj.write_int_string_tuple_written = Node(cat(last_dim, obj.write_int_string_tuple_written(1).value, value)); + obj.write_int_string_tuple_written = yardl.Optional(cat(last_dim, obj.write_int_string_tuple_written.value, value)); + else + obj.write_int_string_tuple_written = yardl.Optional(value); end end function expect_write_stream_of_type_variants_(obj, value) - if isempty(obj.write_stream_of_type_variants_written) - obj.write_stream_of_type_variants_written = Node(value); - else + if obj.write_stream_of_type_variants_written.has_value() last_dim = ndims(value); - obj.write_stream_of_type_variants_written = Node(cat(last_dim, obj.write_stream_of_type_variants_written(1).value, value)); + obj.write_stream_of_type_variants_written = yardl.Optional(cat(last_dim, obj.write_stream_of_type_variants_written.value, value)); + else + obj.write_stream_of_type_variants_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_float_image_written), "Expected call to write_float_image_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_int_image_written), "Expected call to write_int_image_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_int_image_alternate_syntax_written), "Expected call to write_int_image_alternate_syntax_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_string_image_written), "Expected call to write_string_image_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_int_float_tuple_written), "Expected call to write_int_float_tuple_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_float_float_tuple_written), "Expected call to write_float_float_tuple_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_int_float_tuple_alternate_syntax_written), "Expected call to write_int_float_tuple_alternate_syntax_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_int_string_tuple_written), "Expected call to write_int_string_tuple_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_stream_of_type_variants_written), "Expected call to write_stream_of_type_variants_ was not received"); + obj.testCase_.verifyEqual(obj.write_float_image_written, yardl.None, "Expected call to write_float_image_ was not received"); + obj.testCase_.verifyEqual(obj.write_int_image_written, yardl.None, "Expected call to write_int_image_ was not received"); + obj.testCase_.verifyEqual(obj.write_int_image_alternate_syntax_written, yardl.None, "Expected call to write_int_image_alternate_syntax_ was not received"); + obj.testCase_.verifyEqual(obj.write_string_image_written, yardl.None, "Expected call to write_string_image_ was not received"); + obj.testCase_.verifyEqual(obj.write_int_float_tuple_written, yardl.None, "Expected call to write_int_float_tuple_ was not received"); + obj.testCase_.verifyEqual(obj.write_float_float_tuple_written, yardl.None, "Expected call to write_float_float_tuple_ was not received"); + obj.testCase_.verifyEqual(obj.write_int_float_tuple_alternate_syntax_written, yardl.None, "Expected call to write_int_float_tuple_alternate_syntax_ was not received"); + obj.testCase_.verifyEqual(obj.write_int_string_tuple_written, yardl.None, "Expected call to write_int_string_tuple_ was not received"); + obj.testCase_.verifyEqual(obj.write_stream_of_type_variants_written, yardl.None, "Expected call to write_stream_of_type_variants_ was not received"); end end methods (Access=protected) function write_float_image_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_float_image_written), "Unexpected call to write_float_image_"); - expected = obj.write_float_image_written(1).value; + obj.testCase_.verifyTrue(obj.write_float_image_written.has_value(), "Unexpected call to write_float_image_"); + expected = obj.write_float_image_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_image_"); - obj.write_float_image_written = Node.empty(); + obj.write_float_image_written = yardl.None; end function write_int_image_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_int_image_written), "Unexpected call to write_int_image_"); - expected = obj.write_int_image_written(1).value; + obj.testCase_.verifyTrue(obj.write_int_image_written.has_value(), "Unexpected call to write_int_image_"); + expected = obj.write_int_image_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_image_"); - obj.write_int_image_written = Node.empty(); + obj.write_int_image_written = yardl.None; end function write_int_image_alternate_syntax_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_int_image_alternate_syntax_written), "Unexpected call to write_int_image_alternate_syntax_"); - expected = obj.write_int_image_alternate_syntax_written(1).value; + obj.testCase_.verifyTrue(obj.write_int_image_alternate_syntax_written.has_value(), "Unexpected call to write_int_image_alternate_syntax_"); + expected = obj.write_int_image_alternate_syntax_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_image_alternate_syntax_"); - obj.write_int_image_alternate_syntax_written = Node.empty(); + obj.write_int_image_alternate_syntax_written = yardl.None; end function write_string_image_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_string_image_written), "Unexpected call to write_string_image_"); - expected = obj.write_string_image_written(1).value; + obj.testCase_.verifyTrue(obj.write_string_image_written.has_value(), "Unexpected call to write_string_image_"); + expected = obj.write_string_image_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_string_image_"); - obj.write_string_image_written = Node.empty(); + obj.write_string_image_written = yardl.None; end function write_int_float_tuple_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_int_float_tuple_written), "Unexpected call to write_int_float_tuple_"); - expected = obj.write_int_float_tuple_written(1).value; + obj.testCase_.verifyTrue(obj.write_int_float_tuple_written.has_value(), "Unexpected call to write_int_float_tuple_"); + expected = obj.write_int_float_tuple_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_float_tuple_"); - obj.write_int_float_tuple_written = Node.empty(); + obj.write_int_float_tuple_written = yardl.None; end function write_float_float_tuple_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_float_float_tuple_written), "Unexpected call to write_float_float_tuple_"); - expected = obj.write_float_float_tuple_written(1).value; + obj.testCase_.verifyTrue(obj.write_float_float_tuple_written.has_value(), "Unexpected call to write_float_float_tuple_"); + expected = obj.write_float_float_tuple_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_float_tuple_"); - obj.write_float_float_tuple_written = Node.empty(); + obj.write_float_float_tuple_written = yardl.None; end function write_int_float_tuple_alternate_syntax_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_int_float_tuple_alternate_syntax_written), "Unexpected call to write_int_float_tuple_alternate_syntax_"); - expected = obj.write_int_float_tuple_alternate_syntax_written(1).value; + obj.testCase_.verifyTrue(obj.write_int_float_tuple_alternate_syntax_written.has_value(), "Unexpected call to write_int_float_tuple_alternate_syntax_"); + expected = obj.write_int_float_tuple_alternate_syntax_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_float_tuple_alternate_syntax_"); - obj.write_int_float_tuple_alternate_syntax_written = Node.empty(); + obj.write_int_float_tuple_alternate_syntax_written = yardl.None; end function write_int_string_tuple_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_int_string_tuple_written), "Unexpected call to write_int_string_tuple_"); - expected = obj.write_int_string_tuple_written(1).value; + obj.testCase_.verifyTrue(obj.write_int_string_tuple_written.has_value(), "Unexpected call to write_int_string_tuple_"); + expected = obj.write_int_string_tuple_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_string_tuple_"); - obj.write_int_string_tuple_written = Node.empty(); + obj.write_int_string_tuple_written = yardl.None; end function write_stream_of_type_variants_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_stream_of_type_variants_written), "Unexpected call to write_stream_of_type_variants_"); - expected = obj.write_stream_of_type_variants_written(1).value; + obj.testCase_.verifyTrue(obj.write_stream_of_type_variants_written.has_value(), "Unexpected call to write_stream_of_type_variants_"); + expected = obj.write_stream_of_type_variants_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_stream_of_type_variants_"); - obj.write_stream_of_type_variants_written = Node.empty(); + obj.write_stream_of_type_variants_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockStateTestWriter.m b/matlab/generated/+test_model/+testing/MockStateTestWriter.m index 1d48c013..80b09507 100644 --- a/matlab/generated/+test_model/+testing/MockStateTestWriter.m +++ b/matlab/generated/+test_model/+testing/MockStateTestWriter.m @@ -11,65 +11,65 @@ methods function obj = MockStateTestWriter(testCase) obj.testCase_ = testCase; - obj.write_an_int_written = Node.empty(); - obj.write_a_stream_written = Node.empty(); - obj.write_another_int_written = Node.empty(); + obj.write_an_int_written = yardl.None; + obj.write_a_stream_written = yardl.None; + obj.write_another_int_written = yardl.None; end function expect_write_an_int_(obj, value) - if isempty(obj.write_an_int_written) - obj.write_an_int_written = Node(value); - else + if obj.write_an_int_written.has_value() last_dim = ndims(value); - obj.write_an_int_written = Node(cat(last_dim, obj.write_an_int_written(1).value, value)); + obj.write_an_int_written = yardl.Optional(cat(last_dim, obj.write_an_int_written.value, value)); + else + obj.write_an_int_written = yardl.Optional(value); end end function expect_write_a_stream_(obj, value) - if isempty(obj.write_a_stream_written) - obj.write_a_stream_written = Node(value); - else + if obj.write_a_stream_written.has_value() last_dim = ndims(value); - obj.write_a_stream_written = Node(cat(last_dim, obj.write_a_stream_written(1).value, value)); + obj.write_a_stream_written = yardl.Optional(cat(last_dim, obj.write_a_stream_written.value, value)); + else + obj.write_a_stream_written = yardl.Optional(value); end end function expect_write_another_int_(obj, value) - if isempty(obj.write_another_int_written) - obj.write_another_int_written = Node(value); - else + if obj.write_another_int_written.has_value() last_dim = ndims(value); - obj.write_another_int_written = Node(cat(last_dim, obj.write_another_int_written(1).value, value)); + obj.write_another_int_written = yardl.Optional(cat(last_dim, obj.write_another_int_written.value, value)); + else + obj.write_another_int_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_an_int_written), "Expected call to write_an_int_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_a_stream_written), "Expected call to write_a_stream_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_another_int_written), "Expected call to write_another_int_ was not received"); + obj.testCase_.verifyEqual(obj.write_an_int_written, yardl.None, "Expected call to write_an_int_ was not received"); + obj.testCase_.verifyEqual(obj.write_a_stream_written, yardl.None, "Expected call to write_a_stream_ was not received"); + obj.testCase_.verifyEqual(obj.write_another_int_written, yardl.None, "Expected call to write_another_int_ was not received"); end end methods (Access=protected) function write_an_int_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_an_int_written), "Unexpected call to write_an_int_"); - expected = obj.write_an_int_written(1).value; + obj.testCase_.verifyTrue(obj.write_an_int_written.has_value(), "Unexpected call to write_an_int_"); + expected = obj.write_an_int_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_an_int_"); - obj.write_an_int_written = Node.empty(); + obj.write_an_int_written = yardl.None; end function write_a_stream_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_a_stream_written), "Unexpected call to write_a_stream_"); - expected = obj.write_a_stream_written(1).value; + obj.testCase_.verifyTrue(obj.write_a_stream_written.has_value(), "Unexpected call to write_a_stream_"); + expected = obj.write_a_stream_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_a_stream_"); - obj.write_a_stream_written = Node.empty(); + obj.write_a_stream_written = yardl.None; end function write_another_int_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_another_int_written), "Unexpected call to write_another_int_"); - expected = obj.write_another_int_written(1).value; + obj.testCase_.verifyTrue(obj.write_another_int_written.has_value(), "Unexpected call to write_another_int_"); + expected = obj.write_another_int_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_another_int_"); - obj.write_another_int_written = Node.empty(); + obj.write_another_int_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m index a6354446..41f02e34 100644 --- a/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m @@ -10,47 +10,47 @@ methods function obj = MockStreamsOfAliasedUnionsWriter(testCase) obj.testCase_ = testCase; - obj.write_int_or_simple_record_written = Node.empty(); - obj.write_nullable_int_or_simple_record_written = Node.empty(); + obj.write_int_or_simple_record_written = yardl.None; + obj.write_nullable_int_or_simple_record_written = yardl.None; end function expect_write_int_or_simple_record_(obj, value) - if isempty(obj.write_int_or_simple_record_written) - obj.write_int_or_simple_record_written = Node(value); - else + if obj.write_int_or_simple_record_written.has_value() last_dim = ndims(value); - obj.write_int_or_simple_record_written = Node(cat(last_dim, obj.write_int_or_simple_record_written(1).value, value)); + obj.write_int_or_simple_record_written = yardl.Optional(cat(last_dim, obj.write_int_or_simple_record_written.value, value)); + else + obj.write_int_or_simple_record_written = yardl.Optional(value); end end function expect_write_nullable_int_or_simple_record_(obj, value) - if isempty(obj.write_nullable_int_or_simple_record_written) - obj.write_nullable_int_or_simple_record_written = Node(value); - else + if obj.write_nullable_int_or_simple_record_written.has_value() last_dim = ndims(value); - obj.write_nullable_int_or_simple_record_written = Node(cat(last_dim, obj.write_nullable_int_or_simple_record_written(1).value, value)); + obj.write_nullable_int_or_simple_record_written = yardl.Optional(cat(last_dim, obj.write_nullable_int_or_simple_record_written.value, value)); + else + obj.write_nullable_int_or_simple_record_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_int_or_simple_record_written), "Expected call to write_int_or_simple_record_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_nullable_int_or_simple_record_written), "Expected call to write_nullable_int_or_simple_record_ was not received"); + obj.testCase_.verifyEqual(obj.write_int_or_simple_record_written, yardl.None, "Expected call to write_int_or_simple_record_ was not received"); + obj.testCase_.verifyEqual(obj.write_nullable_int_or_simple_record_written, yardl.None, "Expected call to write_nullable_int_or_simple_record_ was not received"); end end methods (Access=protected) function write_int_or_simple_record_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_int_or_simple_record_written), "Unexpected call to write_int_or_simple_record_"); - expected = obj.write_int_or_simple_record_written(1).value; + obj.testCase_.verifyTrue(obj.write_int_or_simple_record_written.has_value(), "Unexpected call to write_int_or_simple_record_"); + expected = obj.write_int_or_simple_record_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_simple_record_"); - obj.write_int_or_simple_record_written = Node.empty(); + obj.write_int_or_simple_record_written = yardl.None; end function write_nullable_int_or_simple_record_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_nullable_int_or_simple_record_written), "Unexpected call to write_nullable_int_or_simple_record_"); - expected = obj.write_nullable_int_or_simple_record_written(1).value; + obj.testCase_.verifyTrue(obj.write_nullable_int_or_simple_record_written.has_value(), "Unexpected call to write_nullable_int_or_simple_record_"); + expected = obj.write_nullable_int_or_simple_record_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_nullable_int_or_simple_record_"); - obj.write_nullable_int_or_simple_record_written = Node.empty(); + obj.write_nullable_int_or_simple_record_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m index 76ec34b5..45961457 100644 --- a/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m @@ -10,47 +10,47 @@ methods function obj = MockStreamsOfUnionsWriter(testCase) obj.testCase_ = testCase; - obj.write_int_or_simple_record_written = Node.empty(); - obj.write_nullable_int_or_simple_record_written = Node.empty(); + obj.write_int_or_simple_record_written = yardl.None; + obj.write_nullable_int_or_simple_record_written = yardl.None; end function expect_write_int_or_simple_record_(obj, value) - if isempty(obj.write_int_or_simple_record_written) - obj.write_int_or_simple_record_written = Node(value); - else + if obj.write_int_or_simple_record_written.has_value() last_dim = ndims(value); - obj.write_int_or_simple_record_written = Node(cat(last_dim, obj.write_int_or_simple_record_written(1).value, value)); + obj.write_int_or_simple_record_written = yardl.Optional(cat(last_dim, obj.write_int_or_simple_record_written.value, value)); + else + obj.write_int_or_simple_record_written = yardl.Optional(value); end end function expect_write_nullable_int_or_simple_record_(obj, value) - if isempty(obj.write_nullable_int_or_simple_record_written) - obj.write_nullable_int_or_simple_record_written = Node(value); - else + if obj.write_nullable_int_or_simple_record_written.has_value() last_dim = ndims(value); - obj.write_nullable_int_or_simple_record_written = Node(cat(last_dim, obj.write_nullable_int_or_simple_record_written(1).value, value)); + obj.write_nullable_int_or_simple_record_written = yardl.Optional(cat(last_dim, obj.write_nullable_int_or_simple_record_written.value, value)); + else + obj.write_nullable_int_or_simple_record_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_int_or_simple_record_written), "Expected call to write_int_or_simple_record_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_nullable_int_or_simple_record_written), "Expected call to write_nullable_int_or_simple_record_ was not received"); + obj.testCase_.verifyEqual(obj.write_int_or_simple_record_written, yardl.None, "Expected call to write_int_or_simple_record_ was not received"); + obj.testCase_.verifyEqual(obj.write_nullable_int_or_simple_record_written, yardl.None, "Expected call to write_nullable_int_or_simple_record_ was not received"); end end methods (Access=protected) function write_int_or_simple_record_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_int_or_simple_record_written), "Unexpected call to write_int_or_simple_record_"); - expected = obj.write_int_or_simple_record_written(1).value; + obj.testCase_.verifyTrue(obj.write_int_or_simple_record_written.has_value(), "Unexpected call to write_int_or_simple_record_"); + expected = obj.write_int_or_simple_record_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_simple_record_"); - obj.write_int_or_simple_record_written = Node.empty(); + obj.write_int_or_simple_record_written = yardl.None; end function write_nullable_int_or_simple_record_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_nullable_int_or_simple_record_written), "Unexpected call to write_nullable_int_or_simple_record_"); - expected = obj.write_nullable_int_or_simple_record_written(1).value; + obj.testCase_.verifyTrue(obj.write_nullable_int_or_simple_record_written.has_value(), "Unexpected call to write_nullable_int_or_simple_record_"); + expected = obj.write_nullable_int_or_simple_record_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_nullable_int_or_simple_record_"); - obj.write_nullable_int_or_simple_record_written = Node.empty(); + obj.write_nullable_int_or_simple_record_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockStreamsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsWriter.m index 1f6313ac..513ff79e 100644 --- a/matlab/generated/+test_model/+testing/MockStreamsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStreamsWriter.m @@ -12,83 +12,83 @@ methods function obj = MockStreamsWriter(testCase) obj.testCase_ = testCase; - obj.write_int_data_written = Node.empty(); - obj.write_optional_int_data_written = Node.empty(); - obj.write_record_with_optional_vector_data_written = Node.empty(); - obj.write_fixed_vector_written = Node.empty(); + obj.write_int_data_written = yardl.None; + obj.write_optional_int_data_written = yardl.None; + obj.write_record_with_optional_vector_data_written = yardl.None; + obj.write_fixed_vector_written = yardl.None; end function expect_write_int_data_(obj, value) - if isempty(obj.write_int_data_written) - obj.write_int_data_written = Node(value); - else + if obj.write_int_data_written.has_value() last_dim = ndims(value); - obj.write_int_data_written = Node(cat(last_dim, obj.write_int_data_written(1).value, value)); + obj.write_int_data_written = yardl.Optional(cat(last_dim, obj.write_int_data_written.value, value)); + else + obj.write_int_data_written = yardl.Optional(value); end end function expect_write_optional_int_data_(obj, value) - if isempty(obj.write_optional_int_data_written) - obj.write_optional_int_data_written = Node(value); - else + if obj.write_optional_int_data_written.has_value() last_dim = ndims(value); - obj.write_optional_int_data_written = Node(cat(last_dim, obj.write_optional_int_data_written(1).value, value)); + obj.write_optional_int_data_written = yardl.Optional(cat(last_dim, obj.write_optional_int_data_written.value, value)); + else + obj.write_optional_int_data_written = yardl.Optional(value); end end function expect_write_record_with_optional_vector_data_(obj, value) - if isempty(obj.write_record_with_optional_vector_data_written) - obj.write_record_with_optional_vector_data_written = Node(value); - else + if obj.write_record_with_optional_vector_data_written.has_value() last_dim = ndims(value); - obj.write_record_with_optional_vector_data_written = Node(cat(last_dim, obj.write_record_with_optional_vector_data_written(1).value, value)); + obj.write_record_with_optional_vector_data_written = yardl.Optional(cat(last_dim, obj.write_record_with_optional_vector_data_written.value, value)); + else + obj.write_record_with_optional_vector_data_written = yardl.Optional(value); end end function expect_write_fixed_vector_(obj, value) - if isempty(obj.write_fixed_vector_written) - obj.write_fixed_vector_written = Node(value); - else + if obj.write_fixed_vector_written.has_value() last_dim = ndims(value); - obj.write_fixed_vector_written = Node(cat(last_dim, obj.write_fixed_vector_written(1).value, value)); + obj.write_fixed_vector_written = yardl.Optional(cat(last_dim, obj.write_fixed_vector_written.value, value)); + else + obj.write_fixed_vector_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_int_data_written), "Expected call to write_int_data_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_optional_int_data_written), "Expected call to write_optional_int_data_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_record_with_optional_vector_data_written), "Expected call to write_record_with_optional_vector_data_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_fixed_vector_written), "Expected call to write_fixed_vector_ was not received"); + obj.testCase_.verifyEqual(obj.write_int_data_written, yardl.None, "Expected call to write_int_data_ was not received"); + obj.testCase_.verifyEqual(obj.write_optional_int_data_written, yardl.None, "Expected call to write_optional_int_data_ was not received"); + obj.testCase_.verifyEqual(obj.write_record_with_optional_vector_data_written, yardl.None, "Expected call to write_record_with_optional_vector_data_ was not received"); + obj.testCase_.verifyEqual(obj.write_fixed_vector_written, yardl.None, "Expected call to write_fixed_vector_ was not received"); end end methods (Access=protected) function write_int_data_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_int_data_written), "Unexpected call to write_int_data_"); - expected = obj.write_int_data_written(1).value; + obj.testCase_.verifyTrue(obj.write_int_data_written.has_value(), "Unexpected call to write_int_data_"); + expected = obj.write_int_data_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_data_"); - obj.write_int_data_written = Node.empty(); + obj.write_int_data_written = yardl.None; end function write_optional_int_data_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_optional_int_data_written), "Unexpected call to write_optional_int_data_"); - expected = obj.write_optional_int_data_written(1).value; + obj.testCase_.verifyTrue(obj.write_optional_int_data_written.has_value(), "Unexpected call to write_optional_int_data_"); + expected = obj.write_optional_int_data_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_int_data_"); - obj.write_optional_int_data_written = Node.empty(); + obj.write_optional_int_data_written = yardl.None; end function write_record_with_optional_vector_data_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_record_with_optional_vector_data_written), "Unexpected call to write_record_with_optional_vector_data_"); - expected = obj.write_record_with_optional_vector_data_written(1).value; + obj.testCase_.verifyTrue(obj.write_record_with_optional_vector_data_written.has_value(), "Unexpected call to write_record_with_optional_vector_data_"); + expected = obj.write_record_with_optional_vector_data_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_optional_vector_data_"); - obj.write_record_with_optional_vector_data_written = Node.empty(); + obj.write_record_with_optional_vector_data_written = yardl.None; end function write_fixed_vector_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_fixed_vector_written), "Unexpected call to write_fixed_vector_"); - expected = obj.write_fixed_vector_written(1).value; + obj.testCase_.verifyTrue(obj.write_fixed_vector_written.has_value(), "Unexpected call to write_fixed_vector_"); + expected = obj.write_fixed_vector_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_vector_"); - obj.write_fixed_vector_written = Node.empty(); + obj.write_fixed_vector_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockStringsWriter.m b/matlab/generated/+test_model/+testing/MockStringsWriter.m index d2ac995f..c2073b7b 100644 --- a/matlab/generated/+test_model/+testing/MockStringsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStringsWriter.m @@ -10,47 +10,47 @@ methods function obj = MockStringsWriter(testCase) obj.testCase_ = testCase; - obj.write_single_string_written = Node.empty(); - obj.write_rec_with_string_written = Node.empty(); + obj.write_single_string_written = yardl.None; + obj.write_rec_with_string_written = yardl.None; end function expect_write_single_string_(obj, value) - if isempty(obj.write_single_string_written) - obj.write_single_string_written = Node(value); - else + if obj.write_single_string_written.has_value() last_dim = ndims(value); - obj.write_single_string_written = Node(cat(last_dim, obj.write_single_string_written(1).value, value)); + obj.write_single_string_written = yardl.Optional(cat(last_dim, obj.write_single_string_written.value, value)); + else + obj.write_single_string_written = yardl.Optional(value); end end function expect_write_rec_with_string_(obj, value) - if isempty(obj.write_rec_with_string_written) - obj.write_rec_with_string_written = Node(value); - else + if obj.write_rec_with_string_written.has_value() last_dim = ndims(value); - obj.write_rec_with_string_written = Node(cat(last_dim, obj.write_rec_with_string_written(1).value, value)); + obj.write_rec_with_string_written = yardl.Optional(cat(last_dim, obj.write_rec_with_string_written.value, value)); + else + obj.write_rec_with_string_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_single_string_written), "Expected call to write_single_string_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_rec_with_string_written), "Expected call to write_rec_with_string_ was not received"); + obj.testCase_.verifyEqual(obj.write_single_string_written, yardl.None, "Expected call to write_single_string_ was not received"); + obj.testCase_.verifyEqual(obj.write_rec_with_string_written, yardl.None, "Expected call to write_rec_with_string_ was not received"); end end methods (Access=protected) function write_single_string_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_single_string_written), "Unexpected call to write_single_string_"); - expected = obj.write_single_string_written(1).value; + obj.testCase_.verifyTrue(obj.write_single_string_written.has_value(), "Unexpected call to write_single_string_"); + expected = obj.write_single_string_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_single_string_"); - obj.write_single_string_written = Node.empty(); + obj.write_single_string_written = yardl.None; end function write_rec_with_string_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_rec_with_string_written), "Unexpected call to write_rec_with_string_"); - expected = obj.write_rec_with_string_written(1).value; + obj.testCase_.verifyTrue(obj.write_rec_with_string_written.has_value(), "Unexpected call to write_rec_with_string_"); + expected = obj.write_rec_with_string_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_rec_with_string_"); - obj.write_rec_with_string_written = Node.empty(); + obj.write_rec_with_string_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m b/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m index d10f651e..31b1f106 100644 --- a/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m @@ -10,47 +10,47 @@ methods function obj = MockSubarraysInRecordsWriter(testCase) obj.testCase_ = testCase; - obj.write_with_fixed_subarrays_written = Node.empty(); - obj.write_with_vlen_subarrays_written = Node.empty(); + obj.write_with_fixed_subarrays_written = yardl.None; + obj.write_with_vlen_subarrays_written = yardl.None; end function expect_write_with_fixed_subarrays_(obj, value) - if isempty(obj.write_with_fixed_subarrays_written) - obj.write_with_fixed_subarrays_written = Node(value); - else + if obj.write_with_fixed_subarrays_written.has_value() last_dim = ndims(value); - obj.write_with_fixed_subarrays_written = Node(cat(last_dim, obj.write_with_fixed_subarrays_written(1).value, value)); + obj.write_with_fixed_subarrays_written = yardl.Optional(cat(last_dim, obj.write_with_fixed_subarrays_written.value, value)); + else + obj.write_with_fixed_subarrays_written = yardl.Optional(value); end end function expect_write_with_vlen_subarrays_(obj, value) - if isempty(obj.write_with_vlen_subarrays_written) - obj.write_with_vlen_subarrays_written = Node(value); - else + if obj.write_with_vlen_subarrays_written.has_value() last_dim = ndims(value); - obj.write_with_vlen_subarrays_written = Node(cat(last_dim, obj.write_with_vlen_subarrays_written(1).value, value)); + obj.write_with_vlen_subarrays_written = yardl.Optional(cat(last_dim, obj.write_with_vlen_subarrays_written.value, value)); + else + obj.write_with_vlen_subarrays_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_with_fixed_subarrays_written), "Expected call to write_with_fixed_subarrays_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_with_vlen_subarrays_written), "Expected call to write_with_vlen_subarrays_ was not received"); + obj.testCase_.verifyEqual(obj.write_with_fixed_subarrays_written, yardl.None, "Expected call to write_with_fixed_subarrays_ was not received"); + obj.testCase_.verifyEqual(obj.write_with_vlen_subarrays_written, yardl.None, "Expected call to write_with_vlen_subarrays_ was not received"); end end methods (Access=protected) function write_with_fixed_subarrays_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_with_fixed_subarrays_written), "Unexpected call to write_with_fixed_subarrays_"); - expected = obj.write_with_fixed_subarrays_written(1).value; + obj.testCase_.verifyTrue(obj.write_with_fixed_subarrays_written.has_value(), "Unexpected call to write_with_fixed_subarrays_"); + expected = obj.write_with_fixed_subarrays_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_with_fixed_subarrays_"); - obj.write_with_fixed_subarrays_written = Node.empty(); + obj.write_with_fixed_subarrays_written = yardl.None; end function write_with_vlen_subarrays_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_with_vlen_subarrays_written), "Unexpected call to write_with_vlen_subarrays_"); - expected = obj.write_with_vlen_subarrays_written(1).value; + obj.testCase_.verifyTrue(obj.write_with_vlen_subarrays_written.has_value(), "Unexpected call to write_with_vlen_subarrays_"); + expected = obj.write_with_vlen_subarrays_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_with_vlen_subarrays_"); - obj.write_with_vlen_subarrays_written = Node.empty(); + obj.write_with_vlen_subarrays_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockSubarraysWriter.m b/matlab/generated/+test_model/+testing/MockSubarraysWriter.m index 7e965bf0..149a47fd 100644 --- a/matlab/generated/+test_model/+testing/MockSubarraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockSubarraysWriter.m @@ -17,173 +17,173 @@ methods function obj = MockSubarraysWriter(testCase) obj.testCase_ = testCase; - obj.write_dynamic_with_fixed_int_subarray_written = Node.empty(); - obj.write_dynamic_with_fixed_float_subarray_written = Node.empty(); - obj.write_known_dim_count_with_fixed_int_subarray_written = Node.empty(); - obj.write_known_dim_count_with_fixed_float_subarray_written = Node.empty(); - obj.write_fixed_with_fixed_int_subarray_written = Node.empty(); - obj.write_fixed_with_fixed_float_subarray_written = Node.empty(); - obj.write_nested_subarray_written = Node.empty(); - obj.write_dynamic_with_fixed_vector_subarray_written = Node.empty(); - obj.write_generic_subarray_written = Node.empty(); + obj.write_dynamic_with_fixed_int_subarray_written = yardl.None; + obj.write_dynamic_with_fixed_float_subarray_written = yardl.None; + obj.write_known_dim_count_with_fixed_int_subarray_written = yardl.None; + obj.write_known_dim_count_with_fixed_float_subarray_written = yardl.None; + obj.write_fixed_with_fixed_int_subarray_written = yardl.None; + obj.write_fixed_with_fixed_float_subarray_written = yardl.None; + obj.write_nested_subarray_written = yardl.None; + obj.write_dynamic_with_fixed_vector_subarray_written = yardl.None; + obj.write_generic_subarray_written = yardl.None; end function expect_write_dynamic_with_fixed_int_subarray_(obj, value) - if isempty(obj.write_dynamic_with_fixed_int_subarray_written) - obj.write_dynamic_with_fixed_int_subarray_written = Node(value); - else + if obj.write_dynamic_with_fixed_int_subarray_written.has_value() last_dim = ndims(value); - obj.write_dynamic_with_fixed_int_subarray_written = Node(cat(last_dim, obj.write_dynamic_with_fixed_int_subarray_written(1).value, value)); + obj.write_dynamic_with_fixed_int_subarray_written = yardl.Optional(cat(last_dim, obj.write_dynamic_with_fixed_int_subarray_written.value, value)); + else + obj.write_dynamic_with_fixed_int_subarray_written = yardl.Optional(value); end end function expect_write_dynamic_with_fixed_float_subarray_(obj, value) - if isempty(obj.write_dynamic_with_fixed_float_subarray_written) - obj.write_dynamic_with_fixed_float_subarray_written = Node(value); - else + if obj.write_dynamic_with_fixed_float_subarray_written.has_value() last_dim = ndims(value); - obj.write_dynamic_with_fixed_float_subarray_written = Node(cat(last_dim, obj.write_dynamic_with_fixed_float_subarray_written(1).value, value)); + obj.write_dynamic_with_fixed_float_subarray_written = yardl.Optional(cat(last_dim, obj.write_dynamic_with_fixed_float_subarray_written.value, value)); + else + obj.write_dynamic_with_fixed_float_subarray_written = yardl.Optional(value); end end function expect_write_known_dim_count_with_fixed_int_subarray_(obj, value) - if isempty(obj.write_known_dim_count_with_fixed_int_subarray_written) - obj.write_known_dim_count_with_fixed_int_subarray_written = Node(value); - else + if obj.write_known_dim_count_with_fixed_int_subarray_written.has_value() last_dim = ndims(value); - obj.write_known_dim_count_with_fixed_int_subarray_written = Node(cat(last_dim, obj.write_known_dim_count_with_fixed_int_subarray_written(1).value, value)); + obj.write_known_dim_count_with_fixed_int_subarray_written = yardl.Optional(cat(last_dim, obj.write_known_dim_count_with_fixed_int_subarray_written.value, value)); + else + obj.write_known_dim_count_with_fixed_int_subarray_written = yardl.Optional(value); end end function expect_write_known_dim_count_with_fixed_float_subarray_(obj, value) - if isempty(obj.write_known_dim_count_with_fixed_float_subarray_written) - obj.write_known_dim_count_with_fixed_float_subarray_written = Node(value); - else + if obj.write_known_dim_count_with_fixed_float_subarray_written.has_value() last_dim = ndims(value); - obj.write_known_dim_count_with_fixed_float_subarray_written = Node(cat(last_dim, obj.write_known_dim_count_with_fixed_float_subarray_written(1).value, value)); + obj.write_known_dim_count_with_fixed_float_subarray_written = yardl.Optional(cat(last_dim, obj.write_known_dim_count_with_fixed_float_subarray_written.value, value)); + else + obj.write_known_dim_count_with_fixed_float_subarray_written = yardl.Optional(value); end end function expect_write_fixed_with_fixed_int_subarray_(obj, value) - if isempty(obj.write_fixed_with_fixed_int_subarray_written) - obj.write_fixed_with_fixed_int_subarray_written = Node(value); - else + if obj.write_fixed_with_fixed_int_subarray_written.has_value() last_dim = ndims(value); - obj.write_fixed_with_fixed_int_subarray_written = Node(cat(last_dim, obj.write_fixed_with_fixed_int_subarray_written(1).value, value)); + obj.write_fixed_with_fixed_int_subarray_written = yardl.Optional(cat(last_dim, obj.write_fixed_with_fixed_int_subarray_written.value, value)); + else + obj.write_fixed_with_fixed_int_subarray_written = yardl.Optional(value); end end function expect_write_fixed_with_fixed_float_subarray_(obj, value) - if isempty(obj.write_fixed_with_fixed_float_subarray_written) - obj.write_fixed_with_fixed_float_subarray_written = Node(value); - else + if obj.write_fixed_with_fixed_float_subarray_written.has_value() last_dim = ndims(value); - obj.write_fixed_with_fixed_float_subarray_written = Node(cat(last_dim, obj.write_fixed_with_fixed_float_subarray_written(1).value, value)); + obj.write_fixed_with_fixed_float_subarray_written = yardl.Optional(cat(last_dim, obj.write_fixed_with_fixed_float_subarray_written.value, value)); + else + obj.write_fixed_with_fixed_float_subarray_written = yardl.Optional(value); end end function expect_write_nested_subarray_(obj, value) - if isempty(obj.write_nested_subarray_written) - obj.write_nested_subarray_written = Node(value); - else + if obj.write_nested_subarray_written.has_value() last_dim = ndims(value); - obj.write_nested_subarray_written = Node(cat(last_dim, obj.write_nested_subarray_written(1).value, value)); + obj.write_nested_subarray_written = yardl.Optional(cat(last_dim, obj.write_nested_subarray_written.value, value)); + else + obj.write_nested_subarray_written = yardl.Optional(value); end end function expect_write_dynamic_with_fixed_vector_subarray_(obj, value) - if isempty(obj.write_dynamic_with_fixed_vector_subarray_written) - obj.write_dynamic_with_fixed_vector_subarray_written = Node(value); - else + if obj.write_dynamic_with_fixed_vector_subarray_written.has_value() last_dim = ndims(value); - obj.write_dynamic_with_fixed_vector_subarray_written = Node(cat(last_dim, obj.write_dynamic_with_fixed_vector_subarray_written(1).value, value)); + obj.write_dynamic_with_fixed_vector_subarray_written = yardl.Optional(cat(last_dim, obj.write_dynamic_with_fixed_vector_subarray_written.value, value)); + else + obj.write_dynamic_with_fixed_vector_subarray_written = yardl.Optional(value); end end function expect_write_generic_subarray_(obj, value) - if isempty(obj.write_generic_subarray_written) - obj.write_generic_subarray_written = Node(value); - else + if obj.write_generic_subarray_written.has_value() last_dim = ndims(value); - obj.write_generic_subarray_written = Node(cat(last_dim, obj.write_generic_subarray_written(1).value, value)); + obj.write_generic_subarray_written = yardl.Optional(cat(last_dim, obj.write_generic_subarray_written.value, value)); + else + obj.write_generic_subarray_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_dynamic_with_fixed_int_subarray_written), "Expected call to write_dynamic_with_fixed_int_subarray_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_dynamic_with_fixed_float_subarray_written), "Expected call to write_dynamic_with_fixed_float_subarray_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_known_dim_count_with_fixed_int_subarray_written), "Expected call to write_known_dim_count_with_fixed_int_subarray_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_known_dim_count_with_fixed_float_subarray_written), "Expected call to write_known_dim_count_with_fixed_float_subarray_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_fixed_with_fixed_int_subarray_written), "Expected call to write_fixed_with_fixed_int_subarray_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_fixed_with_fixed_float_subarray_written), "Expected call to write_fixed_with_fixed_float_subarray_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_nested_subarray_written), "Expected call to write_nested_subarray_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_dynamic_with_fixed_vector_subarray_written), "Expected call to write_dynamic_with_fixed_vector_subarray_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_generic_subarray_written), "Expected call to write_generic_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.write_dynamic_with_fixed_int_subarray_written, yardl.None, "Expected call to write_dynamic_with_fixed_int_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.write_dynamic_with_fixed_float_subarray_written, yardl.None, "Expected call to write_dynamic_with_fixed_float_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.write_known_dim_count_with_fixed_int_subarray_written, yardl.None, "Expected call to write_known_dim_count_with_fixed_int_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.write_known_dim_count_with_fixed_float_subarray_written, yardl.None, "Expected call to write_known_dim_count_with_fixed_float_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.write_fixed_with_fixed_int_subarray_written, yardl.None, "Expected call to write_fixed_with_fixed_int_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.write_fixed_with_fixed_float_subarray_written, yardl.None, "Expected call to write_fixed_with_fixed_float_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.write_nested_subarray_written, yardl.None, "Expected call to write_nested_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.write_dynamic_with_fixed_vector_subarray_written, yardl.None, "Expected call to write_dynamic_with_fixed_vector_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.write_generic_subarray_written, yardl.None, "Expected call to write_generic_subarray_ was not received"); end end methods (Access=protected) function write_dynamic_with_fixed_int_subarray_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_dynamic_with_fixed_int_subarray_written), "Unexpected call to write_dynamic_with_fixed_int_subarray_"); - expected = obj.write_dynamic_with_fixed_int_subarray_written(1).value; + obj.testCase_.verifyTrue(obj.write_dynamic_with_fixed_int_subarray_written.has_value(), "Unexpected call to write_dynamic_with_fixed_int_subarray_"); + expected = obj.write_dynamic_with_fixed_int_subarray_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_dynamic_with_fixed_int_subarray_"); - obj.write_dynamic_with_fixed_int_subarray_written = Node.empty(); + obj.write_dynamic_with_fixed_int_subarray_written = yardl.None; end function write_dynamic_with_fixed_float_subarray_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_dynamic_with_fixed_float_subarray_written), "Unexpected call to write_dynamic_with_fixed_float_subarray_"); - expected = obj.write_dynamic_with_fixed_float_subarray_written(1).value; + obj.testCase_.verifyTrue(obj.write_dynamic_with_fixed_float_subarray_written.has_value(), "Unexpected call to write_dynamic_with_fixed_float_subarray_"); + expected = obj.write_dynamic_with_fixed_float_subarray_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_dynamic_with_fixed_float_subarray_"); - obj.write_dynamic_with_fixed_float_subarray_written = Node.empty(); + obj.write_dynamic_with_fixed_float_subarray_written = yardl.None; end function write_known_dim_count_with_fixed_int_subarray_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_known_dim_count_with_fixed_int_subarray_written), "Unexpected call to write_known_dim_count_with_fixed_int_subarray_"); - expected = obj.write_known_dim_count_with_fixed_int_subarray_written(1).value; + obj.testCase_.verifyTrue(obj.write_known_dim_count_with_fixed_int_subarray_written.has_value(), "Unexpected call to write_known_dim_count_with_fixed_int_subarray_"); + expected = obj.write_known_dim_count_with_fixed_int_subarray_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_known_dim_count_with_fixed_int_subarray_"); - obj.write_known_dim_count_with_fixed_int_subarray_written = Node.empty(); + obj.write_known_dim_count_with_fixed_int_subarray_written = yardl.None; end function write_known_dim_count_with_fixed_float_subarray_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_known_dim_count_with_fixed_float_subarray_written), "Unexpected call to write_known_dim_count_with_fixed_float_subarray_"); - expected = obj.write_known_dim_count_with_fixed_float_subarray_written(1).value; + obj.testCase_.verifyTrue(obj.write_known_dim_count_with_fixed_float_subarray_written.has_value(), "Unexpected call to write_known_dim_count_with_fixed_float_subarray_"); + expected = obj.write_known_dim_count_with_fixed_float_subarray_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_known_dim_count_with_fixed_float_subarray_"); - obj.write_known_dim_count_with_fixed_float_subarray_written = Node.empty(); + obj.write_known_dim_count_with_fixed_float_subarray_written = yardl.None; end function write_fixed_with_fixed_int_subarray_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_fixed_with_fixed_int_subarray_written), "Unexpected call to write_fixed_with_fixed_int_subarray_"); - expected = obj.write_fixed_with_fixed_int_subarray_written(1).value; + obj.testCase_.verifyTrue(obj.write_fixed_with_fixed_int_subarray_written.has_value(), "Unexpected call to write_fixed_with_fixed_int_subarray_"); + expected = obj.write_fixed_with_fixed_int_subarray_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_with_fixed_int_subarray_"); - obj.write_fixed_with_fixed_int_subarray_written = Node.empty(); + obj.write_fixed_with_fixed_int_subarray_written = yardl.None; end function write_fixed_with_fixed_float_subarray_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_fixed_with_fixed_float_subarray_written), "Unexpected call to write_fixed_with_fixed_float_subarray_"); - expected = obj.write_fixed_with_fixed_float_subarray_written(1).value; + obj.testCase_.verifyTrue(obj.write_fixed_with_fixed_float_subarray_written.has_value(), "Unexpected call to write_fixed_with_fixed_float_subarray_"); + expected = obj.write_fixed_with_fixed_float_subarray_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_with_fixed_float_subarray_"); - obj.write_fixed_with_fixed_float_subarray_written = Node.empty(); + obj.write_fixed_with_fixed_float_subarray_written = yardl.None; end function write_nested_subarray_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_nested_subarray_written), "Unexpected call to write_nested_subarray_"); - expected = obj.write_nested_subarray_written(1).value; + obj.testCase_.verifyTrue(obj.write_nested_subarray_written.has_value(), "Unexpected call to write_nested_subarray_"); + expected = obj.write_nested_subarray_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_nested_subarray_"); - obj.write_nested_subarray_written = Node.empty(); + obj.write_nested_subarray_written = yardl.None; end function write_dynamic_with_fixed_vector_subarray_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_dynamic_with_fixed_vector_subarray_written), "Unexpected call to write_dynamic_with_fixed_vector_subarray_"); - expected = obj.write_dynamic_with_fixed_vector_subarray_written(1).value; + obj.testCase_.verifyTrue(obj.write_dynamic_with_fixed_vector_subarray_written.has_value(), "Unexpected call to write_dynamic_with_fixed_vector_subarray_"); + expected = obj.write_dynamic_with_fixed_vector_subarray_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_dynamic_with_fixed_vector_subarray_"); - obj.write_dynamic_with_fixed_vector_subarray_written = Node.empty(); + obj.write_dynamic_with_fixed_vector_subarray_written = yardl.None; end function write_generic_subarray_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_generic_subarray_written), "Unexpected call to write_generic_subarray_"); - expected = obj.write_generic_subarray_written(1).value; + obj.testCase_.verifyTrue(obj.write_generic_subarray_written.has_value(), "Unexpected call to write_generic_subarray_"); + expected = obj.write_generic_subarray_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_generic_subarray_"); - obj.write_generic_subarray_written = Node.empty(); + obj.write_generic_subarray_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockUnionsWriter.m b/matlab/generated/+test_model/+testing/MockUnionsWriter.m index ae2baf9f..e704730b 100644 --- a/matlab/generated/+test_model/+testing/MockUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/MockUnionsWriter.m @@ -12,83 +12,83 @@ methods function obj = MockUnionsWriter(testCase) obj.testCase_ = testCase; - obj.write_int_or_simple_record_written = Node.empty(); - obj.write_int_or_record_with_vlens_written = Node.empty(); - obj.write_monosotate_or_int_or_simple_record_written = Node.empty(); - obj.write_record_with_unions_written = Node.empty(); + obj.write_int_or_simple_record_written = yardl.None; + obj.write_int_or_record_with_vlens_written = yardl.None; + obj.write_monosotate_or_int_or_simple_record_written = yardl.None; + obj.write_record_with_unions_written = yardl.None; end function expect_write_int_or_simple_record_(obj, value) - if isempty(obj.write_int_or_simple_record_written) - obj.write_int_or_simple_record_written = Node(value); - else + if obj.write_int_or_simple_record_written.has_value() last_dim = ndims(value); - obj.write_int_or_simple_record_written = Node(cat(last_dim, obj.write_int_or_simple_record_written(1).value, value)); + obj.write_int_or_simple_record_written = yardl.Optional(cat(last_dim, obj.write_int_or_simple_record_written.value, value)); + else + obj.write_int_or_simple_record_written = yardl.Optional(value); end end function expect_write_int_or_record_with_vlens_(obj, value) - if isempty(obj.write_int_or_record_with_vlens_written) - obj.write_int_or_record_with_vlens_written = Node(value); - else + if obj.write_int_or_record_with_vlens_written.has_value() last_dim = ndims(value); - obj.write_int_or_record_with_vlens_written = Node(cat(last_dim, obj.write_int_or_record_with_vlens_written(1).value, value)); + obj.write_int_or_record_with_vlens_written = yardl.Optional(cat(last_dim, obj.write_int_or_record_with_vlens_written.value, value)); + else + obj.write_int_or_record_with_vlens_written = yardl.Optional(value); end end function expect_write_monosotate_or_int_or_simple_record_(obj, value) - if isempty(obj.write_monosotate_or_int_or_simple_record_written) - obj.write_monosotate_or_int_or_simple_record_written = Node(value); - else + if obj.write_monosotate_or_int_or_simple_record_written.has_value() last_dim = ndims(value); - obj.write_monosotate_or_int_or_simple_record_written = Node(cat(last_dim, obj.write_monosotate_or_int_or_simple_record_written(1).value, value)); + obj.write_monosotate_or_int_or_simple_record_written = yardl.Optional(cat(last_dim, obj.write_monosotate_or_int_or_simple_record_written.value, value)); + else + obj.write_monosotate_or_int_or_simple_record_written = yardl.Optional(value); end end function expect_write_record_with_unions_(obj, value) - if isempty(obj.write_record_with_unions_written) - obj.write_record_with_unions_written = Node(value); - else + if obj.write_record_with_unions_written.has_value() last_dim = ndims(value); - obj.write_record_with_unions_written = Node(cat(last_dim, obj.write_record_with_unions_written(1).value, value)); + obj.write_record_with_unions_written = yardl.Optional(cat(last_dim, obj.write_record_with_unions_written.value, value)); + else + obj.write_record_with_unions_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_int_or_simple_record_written), "Expected call to write_int_or_simple_record_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_int_or_record_with_vlens_written), "Expected call to write_int_or_record_with_vlens_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_monosotate_or_int_or_simple_record_written), "Expected call to write_monosotate_or_int_or_simple_record_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_record_with_unions_written), "Expected call to write_record_with_unions_ was not received"); + obj.testCase_.verifyEqual(obj.write_int_or_simple_record_written, yardl.None, "Expected call to write_int_or_simple_record_ was not received"); + obj.testCase_.verifyEqual(obj.write_int_or_record_with_vlens_written, yardl.None, "Expected call to write_int_or_record_with_vlens_ was not received"); + obj.testCase_.verifyEqual(obj.write_monosotate_or_int_or_simple_record_written, yardl.None, "Expected call to write_monosotate_or_int_or_simple_record_ was not received"); + obj.testCase_.verifyEqual(obj.write_record_with_unions_written, yardl.None, "Expected call to write_record_with_unions_ was not received"); end end methods (Access=protected) function write_int_or_simple_record_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_int_or_simple_record_written), "Unexpected call to write_int_or_simple_record_"); - expected = obj.write_int_or_simple_record_written(1).value; + obj.testCase_.verifyTrue(obj.write_int_or_simple_record_written.has_value(), "Unexpected call to write_int_or_simple_record_"); + expected = obj.write_int_or_simple_record_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_simple_record_"); - obj.write_int_or_simple_record_written = Node.empty(); + obj.write_int_or_simple_record_written = yardl.None; end function write_int_or_record_with_vlens_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_int_or_record_with_vlens_written), "Unexpected call to write_int_or_record_with_vlens_"); - expected = obj.write_int_or_record_with_vlens_written(1).value; + obj.testCase_.verifyTrue(obj.write_int_or_record_with_vlens_written.has_value(), "Unexpected call to write_int_or_record_with_vlens_"); + expected = obj.write_int_or_record_with_vlens_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_record_with_vlens_"); - obj.write_int_or_record_with_vlens_written = Node.empty(); + obj.write_int_or_record_with_vlens_written = yardl.None; end function write_monosotate_or_int_or_simple_record_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_monosotate_or_int_or_simple_record_written), "Unexpected call to write_monosotate_or_int_or_simple_record_"); - expected = obj.write_monosotate_or_int_or_simple_record_written(1).value; + obj.testCase_.verifyTrue(obj.write_monosotate_or_int_or_simple_record_written.has_value(), "Unexpected call to write_monosotate_or_int_or_simple_record_"); + expected = obj.write_monosotate_or_int_or_simple_record_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_monosotate_or_int_or_simple_record_"); - obj.write_monosotate_or_int_or_simple_record_written = Node.empty(); + obj.write_monosotate_or_int_or_simple_record_written = yardl.None; end function write_record_with_unions_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_record_with_unions_written), "Unexpected call to write_record_with_unions_"); - expected = obj.write_record_with_unions_written(1).value; + obj.testCase_.verifyTrue(obj.write_record_with_unions_written.has_value(), "Unexpected call to write_record_with_unions_"); + expected = obj.write_record_with_unions_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_unions_"); - obj.write_record_with_unions_written = Node.empty(); + obj.write_record_with_unions_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockVlensWriter.m b/matlab/generated/+test_model/+testing/MockVlensWriter.m index 0b64ae03..08e029b1 100644 --- a/matlab/generated/+test_model/+testing/MockVlensWriter.m +++ b/matlab/generated/+test_model/+testing/MockVlensWriter.m @@ -12,83 +12,83 @@ methods function obj = MockVlensWriter(testCase) obj.testCase_ = testCase; - obj.write_int_vector_written = Node.empty(); - obj.write_complex_vector_written = Node.empty(); - obj.write_record_with_vlens_written = Node.empty(); - obj.write_vlen_of_record_with_vlens_written = Node.empty(); + obj.write_int_vector_written = yardl.None; + obj.write_complex_vector_written = yardl.None; + obj.write_record_with_vlens_written = yardl.None; + obj.write_vlen_of_record_with_vlens_written = yardl.None; end function expect_write_int_vector_(obj, value) - if isempty(obj.write_int_vector_written) - obj.write_int_vector_written = Node(value); - else + if obj.write_int_vector_written.has_value() last_dim = ndims(value); - obj.write_int_vector_written = Node(cat(last_dim, obj.write_int_vector_written(1).value, value)); + obj.write_int_vector_written = yardl.Optional(cat(last_dim, obj.write_int_vector_written.value, value)); + else + obj.write_int_vector_written = yardl.Optional(value); end end function expect_write_complex_vector_(obj, value) - if isempty(obj.write_complex_vector_written) - obj.write_complex_vector_written = Node(value); - else + if obj.write_complex_vector_written.has_value() last_dim = ndims(value); - obj.write_complex_vector_written = Node(cat(last_dim, obj.write_complex_vector_written(1).value, value)); + obj.write_complex_vector_written = yardl.Optional(cat(last_dim, obj.write_complex_vector_written.value, value)); + else + obj.write_complex_vector_written = yardl.Optional(value); end end function expect_write_record_with_vlens_(obj, value) - if isempty(obj.write_record_with_vlens_written) - obj.write_record_with_vlens_written = Node(value); - else + if obj.write_record_with_vlens_written.has_value() last_dim = ndims(value); - obj.write_record_with_vlens_written = Node(cat(last_dim, obj.write_record_with_vlens_written(1).value, value)); + obj.write_record_with_vlens_written = yardl.Optional(cat(last_dim, obj.write_record_with_vlens_written.value, value)); + else + obj.write_record_with_vlens_written = yardl.Optional(value); end end function expect_write_vlen_of_record_with_vlens_(obj, value) - if isempty(obj.write_vlen_of_record_with_vlens_written) - obj.write_vlen_of_record_with_vlens_written = Node(value); - else + if obj.write_vlen_of_record_with_vlens_written.has_value() last_dim = ndims(value); - obj.write_vlen_of_record_with_vlens_written = Node(cat(last_dim, obj.write_vlen_of_record_with_vlens_written(1).value, value)); + obj.write_vlen_of_record_with_vlens_written = yardl.Optional(cat(last_dim, obj.write_vlen_of_record_with_vlens_written.value, value)); + else + obj.write_vlen_of_record_with_vlens_written = yardl.Optional(value); end end function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.write_int_vector_written), "Expected call to write_int_vector_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_complex_vector_written), "Expected call to write_complex_vector_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_record_with_vlens_written), "Expected call to write_record_with_vlens_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.write_vlen_of_record_with_vlens_written), "Expected call to write_vlen_of_record_with_vlens_ was not received"); + obj.testCase_.verifyEqual(obj.write_int_vector_written, yardl.None, "Expected call to write_int_vector_ was not received"); + obj.testCase_.verifyEqual(obj.write_complex_vector_written, yardl.None, "Expected call to write_complex_vector_ was not received"); + obj.testCase_.verifyEqual(obj.write_record_with_vlens_written, yardl.None, "Expected call to write_record_with_vlens_ was not received"); + obj.testCase_.verifyEqual(obj.write_vlen_of_record_with_vlens_written, yardl.None, "Expected call to write_vlen_of_record_with_vlens_ was not received"); end end methods (Access=protected) function write_int_vector_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_int_vector_written), "Unexpected call to write_int_vector_"); - expected = obj.write_int_vector_written(1).value; + obj.testCase_.verifyTrue(obj.write_int_vector_written.has_value(), "Unexpected call to write_int_vector_"); + expected = obj.write_int_vector_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_vector_"); - obj.write_int_vector_written = Node.empty(); + obj.write_int_vector_written = yardl.None; end function write_complex_vector_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_complex_vector_written), "Unexpected call to write_complex_vector_"); - expected = obj.write_complex_vector_written(1).value; + obj.testCase_.verifyTrue(obj.write_complex_vector_written.has_value(), "Unexpected call to write_complex_vector_"); + expected = obj.write_complex_vector_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_complex_vector_"); - obj.write_complex_vector_written = Node.empty(); + obj.write_complex_vector_written = yardl.None; end function write_record_with_vlens_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_record_with_vlens_written), "Unexpected call to write_record_with_vlens_"); - expected = obj.write_record_with_vlens_written(1).value; + obj.testCase_.verifyTrue(obj.write_record_with_vlens_written.has_value(), "Unexpected call to write_record_with_vlens_"); + expected = obj.write_record_with_vlens_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_"); - obj.write_record_with_vlens_written = Node.empty(); + obj.write_record_with_vlens_written = yardl.None; end function write_vlen_of_record_with_vlens_(obj, value) - obj.testCase_.verifyTrue(~isempty(obj.write_vlen_of_record_with_vlens_written), "Unexpected call to write_vlen_of_record_with_vlens_"); - expected = obj.write_vlen_of_record_with_vlens_written(1).value; + obj.testCase_.verifyTrue(obj.write_vlen_of_record_with_vlens_written.has_value(), "Unexpected call to write_vlen_of_record_with_vlens_"); + expected = obj.write_vlen_of_record_with_vlens_written.value; obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_vlen_of_record_with_vlens_"); - obj.write_vlen_of_record_with_vlens_written = Node.empty(); + obj.write_vlen_of_record_with_vlens_written = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m b/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m index 02156af8..426b08e2 100644 --- a/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestAdvancedGenericsWriter' to verify mocks")); @@ -72,7 +72,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestAliasesWriter.m b/matlab/generated/+test_model/+testing/TestAliasesWriter.m index e9053022..aa322949 100644 --- a/matlab/generated/+test_model/+testing/TestAliasesWriter.m +++ b/matlab/generated/+test_model/+testing/TestAliasesWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestAliasesWriter' to verify mocks")); @@ -97,7 +97,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m index cfbfcf67..7060fe97 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkFloat256x256Writer' to verify mocks")); @@ -52,7 +52,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m index 25460c1a..d11b6220 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkFloatVlenWriter' to verify mocks")); @@ -52,7 +52,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m index c4d5bb14..292dd8ce 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkInt256x256Writer' to verify mocks")); @@ -52,7 +52,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m index 44907283..580738c3 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkSimpleMrdWriter' to verify mocks")); @@ -52,7 +52,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m index d3a01189..2b18a1f3 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkSmallRecordWithOptionalsWriter' to verify mocks")); @@ -52,7 +52,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m index 8a33ec97..13450136 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkSmallRecordWriter' to verify mocks")); @@ -52,7 +52,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m b/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m index 739674e5..f7dd8751 100644 --- a/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestDynamicNDArraysWriter' to verify mocks")); @@ -67,7 +67,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestEnumsWriter.m b/matlab/generated/+test_model/+testing/TestEnumsWriter.m index f5347b03..767bfad0 100644 --- a/matlab/generated/+test_model/+testing/TestEnumsWriter.m +++ b/matlab/generated/+test_model/+testing/TestEnumsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestEnumsWriter' to verify mocks")); @@ -62,7 +62,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m b/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m index 0edfd48c..55011793 100644 --- a/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestFixedArraysWriter' to verify mocks")); @@ -72,7 +72,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m b/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m index 1a8ceb70..8849fd5a 100644 --- a/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestFixedVectorsWriter' to verify mocks")); @@ -67,7 +67,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestFlagsWriter.m b/matlab/generated/+test_model/+testing/TestFlagsWriter.m index 45dda4de..3ec3a83e 100644 --- a/matlab/generated/+test_model/+testing/TestFlagsWriter.m +++ b/matlab/generated/+test_model/+testing/TestFlagsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestFlagsWriter' to verify mocks")); @@ -57,7 +57,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestMapsWriter.m b/matlab/generated/+test_model/+testing/TestMapsWriter.m index bf33b865..97cd6d2f 100644 --- a/matlab/generated/+test_model/+testing/TestMapsWriter.m +++ b/matlab/generated/+test_model/+testing/TestMapsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestMapsWriter' to verify mocks")); @@ -67,7 +67,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m b/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m index f88bc9de..b8651220 100644 --- a/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m +++ b/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestNDArraysSingleDimensionWriter' to verify mocks")); @@ -67,7 +67,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestNDArraysWriter.m b/matlab/generated/+test_model/+testing/TestNDArraysWriter.m index cbead3e9..2d3d7b77 100644 --- a/matlab/generated/+test_model/+testing/TestNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestNDArraysWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestNDArraysWriter' to verify mocks")); @@ -72,7 +72,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m b/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m index c298e402..93b63669 100644 --- a/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestNestedRecordsWriter' to verify mocks")); @@ -52,7 +52,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m b/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m index a489df7a..d03459d9 100644 --- a/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestOptionalVectorsWriter' to verify mocks")); @@ -52,7 +52,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m b/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m index 5ce8e409..7cfd0e6b 100644 --- a/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m +++ b/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestProtocolWithComputedFieldsWriter' to verify mocks")); @@ -52,7 +52,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m index ef40690f..21a6a284 100644 --- a/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m +++ b/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestProtocolWithKeywordStepsWriter' to verify mocks")); @@ -57,7 +57,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m b/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m index c7438c65..cd5fa608 100644 --- a/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestScalarOptionalsWriter' to verify mocks")); @@ -67,7 +67,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestScalarsWriter.m b/matlab/generated/+test_model/+testing/TestScalarsWriter.m index 2c3bfa64..a8cd6cbc 100644 --- a/matlab/generated/+test_model/+testing/TestScalarsWriter.m +++ b/matlab/generated/+test_model/+testing/TestScalarsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestScalarsWriter' to verify mocks")); @@ -57,7 +57,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m b/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m index 5b377580..659f8e78 100644 --- a/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestSimpleGenericsWriter' to verify mocks")); @@ -92,7 +92,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestStateTestWriter.m b/matlab/generated/+test_model/+testing/TestStateTestWriter.m index 2bafbfef..48f60c9b 100644 --- a/matlab/generated/+test_model/+testing/TestStateTestWriter.m +++ b/matlab/generated/+test_model/+testing/TestStateTestWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestStateTestWriter' to verify mocks")); @@ -62,7 +62,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m index 01cad8e2..5fa99131 100644 --- a/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestStreamsOfAliasedUnionsWriter' to verify mocks")); @@ -57,7 +57,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m index 790189d5..f41ea9b3 100644 --- a/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestStreamsOfUnionsWriter' to verify mocks")); @@ -57,7 +57,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestStreamsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsWriter.m index 9b6ddda8..256eb235 100644 --- a/matlab/generated/+test_model/+testing/TestStreamsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStreamsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestStreamsWriter' to verify mocks")); @@ -67,7 +67,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestStringsWriter.m b/matlab/generated/+test_model/+testing/TestStringsWriter.m index 4889b4fc..4587d767 100644 --- a/matlab/generated/+test_model/+testing/TestStringsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStringsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestStringsWriter' to verify mocks")); @@ -57,7 +57,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m b/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m index 5e74c33f..38c2ac15 100644 --- a/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestSubarraysInRecordsWriter' to verify mocks")); @@ -57,7 +57,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestSubarraysWriter.m b/matlab/generated/+test_model/+testing/TestSubarraysWriter.m index 7417c09e..98ede257 100644 --- a/matlab/generated/+test_model/+testing/TestSubarraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestSubarraysWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestSubarraysWriter' to verify mocks")); @@ -92,7 +92,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestUnionsWriter.m b/matlab/generated/+test_model/+testing/TestUnionsWriter.m index 0a68bc32..90e25dce 100644 --- a/matlab/generated/+test_model/+testing/TestUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/TestUnionsWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestUnionsWriter' to verify mocks")); @@ -67,7 +67,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/+testing/TestVlensWriter.m b/matlab/generated/+test_model/+testing/TestVlensWriter.m index e4e8ddd9..0b389af0 100644 --- a/matlab/generated/+test_model/+testing/TestVlensWriter.m +++ b/matlab/generated/+test_model/+testing/TestVlensWriter.m @@ -21,7 +21,7 @@ end function delete(obj) - % delete(obj.filename_); + delete(obj.filename_); if ~obj.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestVlensWriter' to verify mocks")); @@ -67,7 +67,7 @@ function close_(obj) reader.close(); mock_copy.verify(); mock_copy.close(); - % delete(translated); + delete(translated); end function end_stream_(obj) diff --git a/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m b/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m index 85b14a03..1e98e674 100644 --- a/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m +++ b/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m @@ -32,7 +32,7 @@ function write_record_with_computed_fields(obj, value) methods (Static) function res = schema() - res = string('{"protocol":{"name":"ProtocolWithComputedFields","sequence":[{"name":"recordWithComputedFields","type":"TestModel.RecordWithComputedFields"}]},"types":[{"name":"GenericRecordWithComputedFields","typeParameters":["T0","T1"],"fields":[{"name":"f1","type":[{"tag":"T0","type":"T0"},{"tag":"T1","type":"T1"}]}]},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"Tuples.Tuple","typeArguments":["T1","T2"]}},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"BasicTypes.MyTuple","typeArguments":["T1","T2"]}},{"name":"NamedNDArray","type":{"array":{"items":"int32","dimensions":[{"name":"dimA"},{"name":"dimB"}]}}},{"name":"RecordWithComputedFields","fields":[{"name":"arrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"arrayFieldMapDimensions","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"dynamicArrayField","type":{"array":{"items":"int32"}}},{"name":"fixedArrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x","length":3},{"name":"y","length":4}]}}},{"name":"intField","type":"int32"},{"name":"int8Field","type":"int8"},{"name":"uint8Field","type":"uint8"},{"name":"int16Field","type":"int16"},{"name":"uint16Field","type":"uint16"},{"name":"uint32Field","type":"uint32"},{"name":"int64Field","type":"int64"},{"name":"uint64Field","type":"uint64"},{"name":"sizeField","type":"size"},{"name":"float32Field","type":"float32"},{"name":"float64Field","type":"float64"},{"name":"complexfloat32Field","type":"complexfloat32"},{"name":"complexfloat64Field","type":"complexfloat64"},{"name":"stringField","type":"string"},{"name":"tupleField","type":{"name":"TestModel.MyTuple","typeArguments":["int32","int32"]}},{"name":"vectorField","type":{"vector":{"items":"int32"}}},{"name":"vectorOfVectorsField","type":{"vector":{"items":{"vector":{"items":"int32"}}}}},{"name":"fixedVectorField","type":{"vector":{"items":"int32","length":3}}},{"name":"optionalNamedArray","type":[null,"TestModel.NamedNDArray"]},{"name":"intFloatUnion","type":[{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"nullableIntFloatUnion","type":[null,{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"unionWithNestedGenericUnion","type":[{"tag":"int","explicitTag":true,"type":"int32"},{"tag":"genericRecordWithComputedFields","explicitTag":true,"type":{"name":"BasicTypes.GenericRecordWithComputedFields","typeArguments":["string","float32"]}}]},{"name":"mapField","type":{"map":{"keys":"string","values":"string"}}}]},{"name":"Tuple","typeParameters":["T1","T2"],"fields":[{"name":"v1","type":"T1"},{"name":"v2","type":"T2"}]}]}'); + res = string('{"protocol":{"name":"ProtocolWithComputedFields","sequence":[{"name":"recordWithComputedFields","type":"TestModel.RecordWithComputedFields"}]},"types":[{"name":"GenericRecordWithComputedFields","typeParameters":["T0","T1"],"fields":[{"name":"f1","type":[{"tag":"T0","type":"T0"},{"tag":"T1","type":"T1"}]}]},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"Tuples.Tuple","typeArguments":["T1","T2"]}},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"BasicTypes.MyTuple","typeArguments":["T1","T2"]}},{"name":"NamedNDArray","type":{"array":{"items":"int32","dimensions":[{"name":"dimA"},{"name":"dimB"}]}}},{"name":"RecordWithComputedFields","fields":[{"name":"arrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"arrayFieldMapDimensions","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"dynamicArrayField","type":{"array":{"items":"int32"}}},{"name":"fixedArrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x","length":3},{"name":"y","length":4}]}}},{"name":"intField","type":"int32"},{"name":"int8Field","type":"int8"},{"name":"uint8Field","type":"uint8"},{"name":"int16Field","type":"int16"},{"name":"uint16Field","type":"uint16"},{"name":"uint32Field","type":"uint32"},{"name":"int64Field","type":"int64"},{"name":"uint64Field","type":"uint64"},{"name":"sizeField","type":"size"},{"name":"float32Field","type":"float32"},{"name":"float64Field","type":"float64"},{"name":"complexfloat32Field","type":"complexfloat32"},{"name":"complexfloat64Field","type":"complexfloat64"},{"name":"stringField","type":"string"},{"name":"tupleField","type":{"name":"TestModel.MyTuple","typeArguments":["int32","int32"]}},{"name":"vectorField","type":{"vector":{"items":"int32"}}},{"name":"vectorOfVectorsField","type":{"vector":{"items":{"vector":{"items":"int32"}}}}},{"name":"fixedVectorField","type":{"vector":{"items":"int32","length":3}}},{"name":"fixedVectorOfVectorsField","type":{"vector":{"items":{"vector":{"items":"int32","length":3}},"length":2}}},{"name":"optionalNamedArray","type":[null,"TestModel.NamedNDArray"]},{"name":"intFloatUnion","type":[{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"nullableIntFloatUnion","type":[null,{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"unionWithNestedGenericUnion","type":[{"tag":"int","explicitTag":true,"type":"int32"},{"tag":"genericRecordWithComputedFields","explicitTag":true,"type":{"name":"BasicTypes.GenericRecordWithComputedFields","typeArguments":["string","float32"]}}]},{"name":"mapField","type":{"map":{"keys":"string","values":"string"}}}]},{"name":"Tuple","typeParameters":["T1","T2"],"fields":[{"name":"v1","type":"T1"},{"name":"v2","type":"T2"}]}]}'); end end diff --git a/matlab/generated/+test_model/RecordWithComputedFields.m b/matlab/generated/+test_model/RecordWithComputedFields.m index 50bf9752..1af53603 100644 --- a/matlab/generated/+test_model/RecordWithComputedFields.m +++ b/matlab/generated/+test_model/RecordWithComputedFields.m @@ -24,6 +24,7 @@ vector_field vector_of_vectors_field fixed_vector_field + fixed_vector_of_vectors_field optional_named_array int_float_union nullable_int_float_union @@ -32,7 +33,7 @@ end methods - function obj = RecordWithComputedFields(array_field, array_field_map_dimensions, dynamic_array_field, fixed_array_field, int_field, int8_field, uint8_field, int16_field, uint16_field, uint32_field, int64_field, uint64_field, size_field, float32_field, float64_field, complexfloat32_field, complexfloat64_field, string_field, tuple_field, vector_field, vector_of_vectors_field, fixed_vector_field, optional_named_array, int_float_union, nullable_int_float_union, union_with_nested_generic_union, map_field) + function obj = RecordWithComputedFields(array_field, array_field_map_dimensions, dynamic_array_field, fixed_array_field, int_field, int8_field, uint8_field, int16_field, uint16_field, uint32_field, int64_field, uint64_field, size_field, float32_field, float64_field, complexfloat32_field, complexfloat64_field, string_field, tuple_field, vector_field, vector_of_vectors_field, fixed_vector_field, fixed_vector_of_vectors_field, optional_named_array, int_float_union, nullable_int_float_union, union_with_nested_generic_union, map_field) if nargin > 0 obj.array_field = array_field; obj.array_field_map_dimensions = array_field_map_dimensions; @@ -56,6 +57,7 @@ obj.vector_field = vector_field; obj.vector_of_vectors_field = vector_of_vectors_field; obj.fixed_vector_field = fixed_vector_field; + obj.fixed_vector_of_vectors_field = fixed_vector_of_vectors_field; obj.optional_named_array = optional_named_array; obj.int_float_union = int_float_union; obj.nullable_int_float_union = nullable_int_float_union; @@ -84,6 +86,7 @@ obj.vector_field = int32.empty(); obj.vector_of_vectors_field = int32.empty(); obj.fixed_vector_field = repelem(int32(0), 3); + obj.fixed_vector_of_vectors_field = repelem({repelem(int32(0), 3)}, 2); obj.optional_named_array = yardl.None; obj.int_float_union = test_model.Int32OrFloat32.Int32(int32(0)); obj.nullable_int_float_union = yardl.None; @@ -158,12 +161,12 @@ end function res = access_array_field_element(self) - res = self.array_field(1+0, 1+1); + res = self.array_field(1+1, 1+0); return end function res = access_array_field_element_by_name(self) - res = self.array_field(1+0, 1+1); + res = self.array_field(1+1, 1+0); return end @@ -178,7 +181,12 @@ end function res = access_vector_of_vectors_field(self) - res = self.vector_of_vectors_field(1+1, 1+2); + res = self.vector_of_vectors_field(1+2, 1+1); + return + end + + function res = access_fixed_vector_of_vectors_field(self) + res = self.fixed_vector_of_vectors_field(1+2, 1+1); return end @@ -188,27 +196,27 @@ end function res = array_x_size(self) - res = size(self.array_field, 1+0); + res = size(self.array_field, ndims(self.array_field)-(0)); return end function res = array_y_size(self) - res = size(self.array_field, 1+1); + res = size(self.array_field, ndims(self.array_field)-(1)); return end function res = array_0_size(self) - res = size(self.array_field, 1+0); + res = size(self.array_field, ndims(self.array_field)-(0)); return end function res = array_1_size(self) - res = size(self.array_field, 1+1); + res = size(self.array_field, ndims(self.array_field)-(1)); return end function res = array_size_from_int_field(self) - res = size(self.array_field, 1+self.int_field); + res = size(self.array_field, ndims(self.array_field)-(self.int_field)); return end @@ -223,17 +231,17 @@ end end - res = size(self.array_field, 1+1 + helper_0_(self.string_field)); + res = size(self.array_field, ndims(self.array_field)-(helper_0_(self.string_field))); return end function res = array_size_from_nested_int_field(self) - res = size(self.array_field, 1+self.tuple_field.v1); + res = size(self.array_field, ndims(self.array_field)-(self.tuple_field.v1)); return end function res = array_field_map_dimensions_x_size(self) - res = size(self.array_field_map_dimensions, 1+0); + res = size(self.array_field_map_dimensions, ndims(self.array_field_map_dimensions)-(0)); return end @@ -262,33 +270,18 @@ return end - function res = array_dimension_x_index(self) - function dim = helper_0_(dim_name) - if dim_name == "x" - dim = 0; - elseif dim_name == "y" - dim = 1; - else - throw(yardl.KeyError("Unknown dimension name: '%s'", dim_name)); - end + function res = fixed_vector_of_vectors_size(self) + res = 2; + return + end - end - res = 1 + helper_0_("x"); + function res = array_dimension_x_index(self) + res = 0; return end function res = array_dimension_y_index(self) - function dim = helper_0_(dim_name) - if dim_name == "x" - dim = 0; - elseif dim_name == "y" - dim = 1; - else - throw(yardl.KeyError("Unknown dimension name: '%s'", dim_name)); - end - - end - res = 1 + helper_0_("y"); + res = 1; return end @@ -303,7 +296,7 @@ end end - res = 1 + helper_0_(self.string_field); + res = helper_0_(self.string_field); return end @@ -401,7 +394,6 @@ end res = "float"; return - throw(yardl.RuntimeError("Unexpected union case")) end function res = nested_switch(self) @@ -468,7 +460,7 @@ end function res = arithmetic_5(self) - res = size(self.array_field, 1+2 - 1); + res = size(self.array_field, ndims(self.array_field)-(2 - 1)); return end @@ -558,6 +550,7 @@ all([obj.vector_field] == [other.vector_field]) && ... all([obj.vector_of_vectors_field] == [other.vector_of_vectors_field]) && ... all([obj.fixed_vector_field] == [other.fixed_vector_field]) && ... + all([obj.fixed_vector_of_vectors_field] == [other.fixed_vector_of_vectors_field]) && ... isequal(obj.optional_named_array, other.optional_named_array) && ... all([obj.int_float_union] == [other.int_float_union]) && ... all([obj.nullable_int_float_union] == [other.nullable_int_float_union]) && ... diff --git a/matlab/generated/+test_model/RecordWithKeywordFields.m b/matlab/generated/+test_model/RecordWithKeywordFields.m index a0fdf907..6809fcb4 100644 --- a/matlab/generated/+test_model/RecordWithKeywordFields.m +++ b/matlab/generated/+test_model/RecordWithKeywordFields.m @@ -4,14 +4,14 @@ properties int sizeof - if + if_ end methods - function obj = RecordWithKeywordFields(int, sizeof, if) + function obj = RecordWithKeywordFields(int, sizeof, if_) obj.int = int; obj.sizeof = sizeof; - obj.if = if; + obj.if_ = if_; end function res = float(self) @@ -24,8 +24,8 @@ return end - function res = return(self) - res = self.sizeof(1, 2); + function res = return_(self) + res = self.sizeof(2, 1); return end @@ -35,7 +35,7 @@ isa(other, 'test_model.RecordWithKeywordFields') && ... all([obj.int] == [other.int]) && ... isequal(obj.sizeof, other.sizeof) && ... - all([obj.if] == [other.if]); + all([obj.if_] == [other.if_]); end function res = ne(obj, other) diff --git a/matlab/tests/ComputedFieldsTest.m b/matlab/tests/ComputedFieldsTest.m index 4f27b55d..baada9e1 100644 --- a/matlab/tests/ComputedFieldsTest.m +++ b/matlab/tests/ComputedFieldsTest.m @@ -4,34 +4,37 @@ function testFieldAccess(testCase) r = test_model.RecordWithComputedFields(); - r.int_field = 42; - testCase.verifyEqual(r.access_int_field(), 42); + r.int_field = int32(42); + testCase.verifyEqual(r.access_int_field(), int32(42)); + testCase.verifyEqual(r.access_other_computed_field(), r.access_int_field()); r.string_field = "hello"; testCase.verifyEqual(r.access_string_field(), "hello"); - r.tuple_field = test_model.MyTuple(1, 1); + r.tuple_field = test_model.MyTuple(1, 2); testCase.verifyEqual(r.access_tuple_field(), r.tuple_field); testCase.verifyEqual(r.access_nested_tuple_field(), r.tuple_field.v2); - r.array_field = int32([[1, 2, 3]; [4, 5, 6]]); + r.array_field = int32([[1; 2; 3], [4; 5; 6]]); testCase.verifyEqual(r.access_array_field(), r.array_field); - testCase.verifyEqual(r.access_array_field_element(), r.array_field(1, 2)); - testCase.verifyEqual(r.access_array_field_element_by_name(), r.array_field(1, 2)); - - testCase.verifyEqual(r.access_other_computed_field(), r.access_int_field()); - - r.vector_of_vectors_field = [[1, 2, 3]; [4, 5, 6]]; - testCase.verifyEqual(r.access_vector_of_vectors_field(), r.vector_of_vectors_field(2, 3)); + testCase.verifyEqual(r.access_array_field_element(), r.array_field(2, 1)); + testCase.verifyEqual(r.access_array_field_element_by_name(), r.array_field(2, 1)); - % NOTE: containers.Map supports only `char` keys/values, not `string` - r.map_field = containers.Map(["hello", "world"], ["world", "bye"], 'UniformValues', true); + r.vector_field = [1, 2, 3, 4]; + testCase.verifyEqual(r.access_vector_field, r.vector_field); + testCase.verifyEqual(r.access_vector_field_element(), r.vector_field(2)); + r.vector_of_vectors_field = int32([[1; 2; 3], [4; 5; 6]]); + testCase.verifyEqual(r.access_vector_of_vectors_field(), r.vector_of_vectors_field(3, 2)); + r.fixed_vector_of_vectors_field = int32([[1; 2; 3], [4; 5; 6]]); + testCase.verifyEqual(r.access_fixed_vector_of_vectors_field(), r.fixed_vector_of_vectors_field(3, 2)); + + r.map_field = dictionary(["hello", "world"], ["world", "bye"]); testCase.verifyEqual(r.access_map(), r.map_field); - testCase.verifyEqual(r.access_map_entry(), 'world'); - testCase.verifyEqual(r.access_map_entry_with_computed_field(), 'world'); - testCase.verifyEqual(r.access_map_entry_with_computed_field_nested(), 'bye'); + testCase.verifyEqual(r.access_map_entry(), "world"); + testCase.verifyEqual(r.access_map_entry_with_computed_field(), "world"); + testCase.verifyEqual(r.access_map_entry_with_computed_field_nested(), "bye"); - testCase.verifyError(@() r.access_missing_map_entry(), "MATLAB:Containers:Map:NoKey"); + testCase.verifyError(@() r.access_missing_map_entry(), "MATLAB:dictionary:ScalarKeyNotFound"); end function testLiterals(testCase) @@ -45,11 +48,11 @@ function testLiterals(testCase) function testDimensionIndex(testCase) r = test_model.RecordWithComputedFields(); - testCase.verifyEqual(r.array_dimension_x_index(), 1); - testCase.verifyEqual(r.array_dimension_y_index(), 2); + testCase.verifyEqual(r.array_dimension_x_index(), 0); + testCase.verifyEqual(r.array_dimension_y_index(), 1); r.string_field = "y"; - testCase.verifyEqual(r.array_dimension_index_from_string_field(), 2); + testCase.verifyEqual(r.array_dimension_index_from_string_field(), 1); r.string_field = "missing"; testCase.verifyError(@() r.array_dimension_index_from_string_field(), "yardl:KeyError"); @@ -60,7 +63,7 @@ function testDimensionCount(testCase) testCase.verifyEqual(r.array_dimension_count(), 2); - r.dynamic_array_field = int32([[1, 2, 3]; [4, 5, 6]]); + r.dynamic_array_field = int32([[1; 2; 3], [4; 5; 6]]); testCase.verifyEqual(r.dynamic_array_dimension_count(), 2); r.dynamic_array_field = int32([1, 2, 3]); testCase.verifyEqual(r.dynamic_array_dimension_count(), 1); @@ -73,23 +76,19 @@ function testVectorSize(testCase) testCase.verifyEqual(r.vector_size(), 4); testCase.verifyEqual(r.fixed_vector_size(), 3); + testCase.verifyEqual(r.fixed_vector_of_vectors_size(), 2); end function testMapSize(testCase) r = test_model.RecordWithComputedFields(); testCase.verifyEqual(r.map_size(), 0); - % r.map_field = containers.Map(["hello", "bonjour"], ["world", "monde"], 'UniformValues', true); r.map_field = dictionary(["hello", "bonjour"], ["world", "monde"]); testCase.verifyEqual(r.map_size(), 2); end function testArraySize(testCase) - %%%%%%%%%%%%%%%%%%%%%% - % TODO: Fix 1-based array indexing - testCase.assumeFail(); - r = test_model.RecordWithComputedFields(); - r.array_field = int32([[1, 2, 3]; [4, 5, 6]]); + r.array_field = int32([[1; 2; 3], [4; 5; 6]]); testCase.verifyEqual(r.array_size(), 6); testCase.verifyEqual(r.array_x_size(), 2); @@ -97,12 +96,10 @@ function testArraySize(testCase) testCase.verifyEqual(r.array_0_size(), 2); testCase.verifyEqual(r.array_1_size(), 3); - testCase.verifyEqual(r.array_size_from_int_field(), 2); r.int_field = 1; testCase.verifyEqual(r.array_size_from_int_field(), 3); - % TODO: Bug in computed field codegen 1-based indexing! r.string_field = "x"; testCase.verifyEqual(r.array_size_from_string_field(), 2); r.string_field = "y"; @@ -113,22 +110,17 @@ function testArraySize(testCase) r.tuple_field.v1 = 1; testCase.verifyEqual(r.array_size_from_nested_int_field(), 3); - testCase.verifyEqual(r.fixed_array_size(), numel(r.fixed_array_field)); - % TODO: Bug in dimension ordering... - testCase.verifyEqual(r.fixed_array_x_size(), size(r.fixed_array_field, 1)); - testCase.verifyEqual(r.fixed_array_0_size(), size(r.fixed_array_field, 1)); + testCase.verifyEqual(r.fixed_array_size(), 12); + testCase.verifyEqual(r.fixed_array_x_size(), 3); + testCase.verifyEqual(r.fixed_array_0_size(), 3); - r.array_field_map_dimensions = int32([[1, 2, 3]; [4, 5, 6]]); + r.array_field_map_dimensions = int32([[1; 2; 3], [4; 5; 6]]); testCase.verifyEqual(r.array_field_map_dimensions_x_size(), 2); end function testSwitch(testCase) - %%%%%%%%%%%%%%%%%%%%%% - % TODO: Fix Optionals elsewhere before fixing computed switch statements - testCase.assumeFail(); - r = test_model.RecordWithComputedFields(); - r.optional_named_array = int32([[1, 2, 3]; [4, 5, 6]]); + r.optional_named_array = int32([[1; 2; 3], [4; 5; 6]]); testCase.verifyEqual(r.optional_named_array_length(), 6); testCase.verifyEqual(r.optional_named_array_length_with_discard(), 6); @@ -180,7 +172,7 @@ function testArithmetic(testCase) testCase.verifyEqual(r.arithmetic_2(), 11); testCase.verifyEqual(r.arithmetic_3(), 13); - r.array_field = int32([[1, 2, 3]; [4, 5, 6]]); + r.array_field = int32([[1; 2; 3], [4; 5; 6]]); r.int_field = 1; testCase.verifyEqual(r.arithmetic_4(), 5); testCase.verifyEqual(r.arithmetic_5(), 3); diff --git a/matlab/tests/EqualityTest.m b/matlab/tests/EqualityTest.m index 335995cb..c3108d01 100644 --- a/matlab/tests/EqualityTest.m +++ b/matlab/tests/EqualityTest.m @@ -1,9 +1,6 @@ classdef EqualityTest < matlab.unittest.TestCase methods (Test) - % TODO: Add tests for equality of *arrays* of each type, - % since Matlab eq method applies to both scalar and non-scalar values - function testSimpleEquality(testCase) a = test_model.SimpleRecord(1, 2, 3); b = test_model.SimpleRecord(1, 2, 3); @@ -11,6 +8,9 @@ function testSimpleEquality(testCase) c = test_model.SimpleRecord(1, 2, 4); testCase.verifyNotEqual(a, c); + + testCase.verifyEqual([a, b], [b, a]); + testCase.verifyNotEqual([a, b], [b, c]); end function testFlagsEquality(testCase) @@ -26,6 +26,8 @@ function testFlagsEquality(testCase) e = test_model.DaysOfWeek(0xFFFF); f = test_model.DaysOfWeek(0xFFFF); testCase.verifyEqual(e, f); + + testCase.verifyEqual([a, b, c, d, e, f], [b, a, d, c, f, e]); end function testEnumEquality(testCase) @@ -36,6 +38,9 @@ function testEnumEquality(testCase) c = test_model.Fruits(10000); d = test_model.Fruits(10000); testCase.verifyEqual(c, d); + + testCase.verifyEqual([a, b, c, d], [b, a, d, c]); + testCase.verifyNotEqual([a, b, c, d], [b, c, a, d]); end function testRecordWithEnumEquality(testCase) @@ -45,6 +50,8 @@ function testRecordWithEnumEquality(testCase) c = test_model.RecordWithEnums(test_model.Fruits.APPLE, test_model.DaysOfWeek.SATURDAY, 0); testCase.verifyNotEqual(a, c); + + testCase.verifyEqual([a, b, c], [b, a, c]); end function testDateEquality(testCase) @@ -58,6 +65,8 @@ function testDateEquality(testCase) c = test_model.RecordWithPrimitives(); c.date_field = yardl.Date.from_components(2020, 1, 2); testCase.verifyNotEqual(a, c); + + testCase.verifyEqual([a, b, c], [b, a, c]); end function testTimeEquality(testCase) @@ -71,6 +80,8 @@ function testTimeEquality(testCase) c = test_model.RecordWithPrimitives(); c.time_field = yardl.Time.from_components(12, 22, 45, 0); testCase.verifyNotEqual(a, c); + + testCase.verifyEqual([a, b, c], [b, a, c]); end function testDateTimeEquality(testCase) @@ -84,6 +95,8 @@ function testDateTimeEquality(testCase) c = test_model.RecordWithPrimitives(); c.datetime_field = yardl.DateTime.from_components(2020, 1, 1, 12, 22, 45, 0); testCase.verifyNotEqual(a, c); + + testCase.verifyEqual([a, b, c], [b, a, c]); end function testStringEquality(testCase) @@ -93,6 +106,8 @@ function testStringEquality(testCase) c = test_model.RecordWithStrings("a", "c"); testCase.verifyNotEqual(a, c); + + testCase.verifyEqual([a, b, c], [b, a, c]); end @@ -110,6 +125,8 @@ function testRecordWithPrimitiveVectorsEquality(testCase) ); testCase.verifyEqual(a, b); + + testCase.verifyEqual([a, b], [b, a]); end function testOptionalIntEquality(testCase) @@ -128,6 +145,8 @@ function testOptionalIntEquality(testCase) e = test_model.RecordWithOptionalFields(); testCase.verifyEqual(d, e); testCase.verifyNotEqual(a, d); + + testCase.verifyEqual([a, b, c, d, e], [b, a, c, e, d]); end function testTimeVectorEquality(testCase) @@ -143,6 +162,8 @@ function testTimeVectorEquality(testCase) [yardl.Time.from_components(1, 1, 1, 1), yardl.Time.from_components(1, 1, 1, 2)] ... ); testCase.verifyNotEqual(a, c); + + testCase.verifyEqual([a, b, c], [b, a, c]); end function testSimpleArrayEquality(testCase) @@ -155,6 +176,8 @@ function testSimpleArrayEquality(testCase) c = test_model.RecordWithArrays(); c.default_array = int32([1, 2, 4]); testCase.verifyNotEqual(a, c); + + testCase.verifyEqual([a, b, c], [b, a, c]); end function testSimpleUnionEquality(testCase) @@ -173,11 +196,13 @@ function testSimpleUnionEquality(testCase) e = basic_types.RecordWithUnions(); e.null_or_int_or_string = basic_types.Int32OrString.String("hello"); - d = basic_types.RecordWithUnions(); - d.null_or_int_or_string = basic_types.Int32OrString.String("hello"); - testCase.verifyEqual(e, d); + f = basic_types.RecordWithUnions(); + f.null_or_int_or_string = basic_types.Int32OrString.String("hello"); + testCase.verifyEqual(e, f); testCase.verifyNotEqual(a, e); testCase.verifyNotEqual(c, e); + + testCase.verifyEqual([a, b, c, d, e, f], [b, a, d, c, f, e]); end function testTimeUnionEquality(testCase) @@ -186,6 +211,8 @@ function testTimeUnionEquality(testCase) b = basic_types.RecordWithUnions(); b.date_or_datetime = basic_types.TimeOrDatetime.Time(yardl.Time.from_components(1, 1, 1, 1)); testCase.verifyEqual(a, b); + + testCase.verifyEqual([a, b], [b, a]); end function testGenericEquality(testCase) @@ -199,6 +226,8 @@ function testGenericEquality(testCase) e = test_model.AliasedTuple(42.0, "hello, world"); testCase.verifyTrue(c == e); + + testCase.verifyEqual({a, b, c, d, e}, {b, a, d, c, e}); end end diff --git a/matlab/tests/GeneratedTypesTest.m b/matlab/tests/GeneratedTypesTest.m index 19c0f8c0..df5d6284 100644 --- a/matlab/tests/GeneratedTypesTest.m +++ b/matlab/tests/GeneratedTypesTest.m @@ -1,8 +1,6 @@ classdef GeneratedTypesTest < matlab.unittest.TestCase methods (Test) - % TODO: Add test for yardl.allocate for "each" kind of type - function testDefaultRecordWithPrimitives(testCase) r = test_model.RecordWithPrimitives(); @@ -54,7 +52,6 @@ function testDefaultRecordWithOptionalFields(testCase) function testDefaultRecordWithUnionsOfContainers(testCase) r = test_model.RecordWithUnionsOfContainers(); - % testCase.verifyEqual(r.map_or_scalar, test_model.MapOrScalar.Map(containers.Map)); testCase.verifyEqual(r.map_or_scalar, test_model.MapOrScalar.Map(dictionary)); testCase.verifyEqual(r.vector_or_scalar, test_model.VectorOrScalar.Vector(int32([]))); testCase.verifyEqual(r.array_or_scalar, test_model.ArrayOrScalar.Array(int32([]))); @@ -84,7 +81,6 @@ function testDefaultRecordGenericEmpty(testCase) testCase.verifyError(@() test_model.MyTuple(), 'MATLAB:minrhs'); rm = test_model.RecordWithGenericMaps(); - % testCase.verifyEqual(rm.m, containers.Map()); testCase.verifyEqual(rm.m, dictionary); testCase.verifyEqual(rm.am, rm.m); end @@ -137,5 +133,46 @@ function testDefaultRecordContainingNestedGenericRecords(testCase) testCase.verifyEqual(r.nested.g7, g7); end + function testYardlAllocate(testCase) + rs = yardl.allocate('test_model.RecordWithPrimitives', 5); + testCase.verifyEqual(size(rs), [5, 5]); + testCase.verifyTrue(all(rs == test_model.RecordWithPrimitives())); + + os = yardl.allocate('yardl.Optional', 1, 4); + testCase.verifyEqual(size(os), [1, 4]); + testCase.verifyTrue(all(os == yardl.None)); + + us = yardl.allocate('basic_types.Int32OrString', 5, 2); + testCase.verifyEqual(size(us), [5, 2]); + testCase.verifyTrue(all([us.index] == 0)); + testCase.verifyTrue(all(us == basic_types.Int32OrString(0, yardl.None))); + + ns = yardl.allocate('int16', 0); + testCase.verifyEqual(class(ns), 'int16'); + testCase.verifyEqual(size(ns), [0, 0]); + + bs = yardl.allocate('logical', [2, 3, 4]); + testCase.verifyEqual(class(bs), 'logical'); + testCase.verifyEqual(size(bs), [2, 3, 4]); + testCase.verifyTrue(all(bs(:) == false)); + + ss = yardl.allocate('string', 2); + testCase.verifyEqual(class(ss), 'string'); + testCase.verifyEqual(size(ss), [2, 2]); + testCase.verifyTrue(all(ss(:) == "")); + + ds = yardl.allocate('yardl.Date', 3, 1); + testCase.verifyEqual(size(ds), [3, 1]); + testCase.verifyTrue(all(ds == yardl.Date(0))); + + ts = yardl.allocate('yardl.Time', 3); + testCase.verifyEqual(size(ts), [3, 3]); + testCase.verifyTrue(all(ts == yardl.Time(0))); + + dts = yardl.allocate('yardl.DateTime', 3, 3); + testCase.verifyEqual(size(dts), [3, 3]); + testCase.verifyTrue(all(dts == yardl.DateTime(0))); + end + end end diff --git a/matlab/tests/Node.m b/matlab/tests/Node.m deleted file mode 100644 index c73e8a83..00000000 --- a/matlab/tests/Node.m +++ /dev/null @@ -1,10 +0,0 @@ -classdef Node < handle - properties - value - end - methods - function obj = Node(value) - obj.value = value; - end - end -end diff --git a/matlab/tests/RoundTripTest.m b/matlab/tests/RoundTripTest.m index 7aa01d3d..e1145ba9 100644 --- a/matlab/tests/RoundTripTest.m +++ b/matlab/tests/RoundTripTest.m @@ -137,16 +137,12 @@ function testFixedArrays(testCase, format) w.write_fixed_record_with_vlens_array(vlens_recs); w.write_record_with_fixed_arrays(rec_with_fixed); - % TODO: Like in Python, named fixed arrays are kind of broken since it - % doesn't seem to be possible to specify the shape of the array in the type named_fixed_array = transpose(int32([[1, 2, 3, 4]; [5, 6, 7, 8]])); w.write_named_array(named_fixed_array) w.close(); end function testSubarrays(testCase, format) - % TODO: Add checks for input validation errors (e.g. unexpected array shape). See Python tests. - w = create_validating_writer(testCase, format, 'Subarrays'); ints = transpose(int32([[1, 2, 3]; [4, 5, 6]])); @@ -315,7 +311,6 @@ function testFlags(testCase, format) w.write_days([... test_model.DaysOfWeek.SUNDAY, ... test_model.DaysOfWeek(mon_or_wed_or_fri), ... -... % bitor(bitor(test_model.DaysOfWeek.MONDAY, test_model.DaysOfWeek.WEDNESDAY), test_model.DaysOfWeek.FRIDAY), ... test_model.DaysOfWeek(0), ... test_model.DaysOfWeek(282839), ... test_model.DaysOfWeek(234532) ... @@ -432,11 +427,6 @@ function testAdvancedGenerics(testCase, format) i3 = single([[300, 400, 500]; [600, 700, 800]]); i4 = single([[3000, 4000, 5000]; [6000, 7000, 8000]]); - % img_img_array = zeros([size(i1) 2 2], 'single'); - % img_img_array(:, :, 1, 1) = i1; - % img_img_array(:, :, 1, 2) = i2; - % img_img_array(:, :, 2, 1) = i3; - % img_img_array(:, :, 2, 2) = i4; img_img_array{1, 1} = i1; img_img_array{1, 2} = i2; img_img_array{2, 1} = i3; diff --git a/matlab/tests/YardlTypesTest.m b/matlab/tests/YardlTypesTest.m index 0f73d1e2..74661007 100644 --- a/matlab/tests/YardlTypesTest.m +++ b/matlab/tests/YardlTypesTest.m @@ -2,8 +2,6 @@ methods (Test) - % TODO: Add test for yardl.allocate for "each" kind of type - function testDateTimeFromValidDatetime(testCase) dt = yardl.DateTime.from_datetime(datetime(2020, 2, 29, 12, 22, 44, .111222)); testCase.verifyEqual(dt.value(), int64(1582978964000111222)); diff --git a/matlab/tests/run.m b/matlab/tests/run.m index 1385ea99..74b0b98c 100644 --- a/matlab/tests/run.m +++ b/matlab/tests/run.m @@ -1,13 +1,2 @@ addpath("../generated/"); - -run(YardlTypesTest); -run(CodedStreamTest); -run(ProtocolStateTest); - -run(GeneratedTypesTest); -run(EqualityTest); -run(ComputedFieldsTest); - -run(SerializerShapeTest); - -run(RoundTripTest); +runtests(pwd) diff --git a/models/test/unittests.yml b/models/test/unittests.yml index b37caf96..511ffadc 100644 --- a/models/test/unittests.yml +++ b/models/test/unittests.yml @@ -554,6 +554,7 @@ RecordWithComputedFields: !record vectorField: int* vectorOfVectorsField: int** fixedVectorField: int*3 + fixedVectorOfVectorsField: int*3*2 optionalNamedArray: NamedNDArray? intFloatUnion: [int, float] nullableIntFloatUnion: [null, int, float] @@ -582,6 +583,7 @@ RecordWithComputedFields: !record accessVectorField: vectorField accessVectorFieldElement: vectorField[1] accessVectorOfVectorsField: vectorOfVectorsField[1][2] + accessFixedVectorOfVectorsField: fixedVectorOfVectorsField[1][2] arraySize: size(arrayField) arrayXSize: size(arrayField, "x") arrayYSize: size(arrayField, "y") @@ -596,6 +598,7 @@ RecordWithComputedFields: !record fixedArray0Size: size(fixedArrayField, 0) vectorSize: size(vectorField) fixedVectorSize: size(fixedVectorField) + fixedVectorOfVectorsSize: size(fixedVectorOfVectorsField) arrayDimensionXIndex: dimensionIndex(arrayField, "x") arrayDimensionYIndex: dimensionIndex(arrayField, "y") arrayDimensionIndexFromStringField: dimensionIndex(arrayField, stringField) diff --git a/python/test_model/binary.py b/python/test_model/binary.py index 06e80973..4097c6f5 100644 --- a/python/test_model/binary.py +++ b/python/test_model/binary.py @@ -1873,20 +1873,20 @@ def read(self, stream: _binary.CodedInputStream) -> RecordContainingNestedGeneri class RecordWithComputedFieldsSerializer(_binary.RecordSerializer[RecordWithComputedFields]): def __init__(self) -> None: - super().__init__([("array_field", _binary.NDArraySerializer(_binary.int32_serializer, 2)), ("array_field_map_dimensions", _binary.NDArraySerializer(_binary.int32_serializer, 2)), ("dynamic_array_field", _binary.DynamicNDArraySerializer(_binary.int32_serializer)), ("fixed_array_field", _binary.FixedNDArraySerializer(_binary.int32_serializer, (3, 4,))), ("int_field", _binary.int32_serializer), ("int8_field", _binary.int8_serializer), ("uint8_field", _binary.uint8_serializer), ("int16_field", _binary.int16_serializer), ("uint16_field", _binary.uint16_serializer), ("uint32_field", _binary.uint32_serializer), ("int64_field", _binary.int64_serializer), ("uint64_field", _binary.uint64_serializer), ("size_field", _binary.size_serializer), ("float32_field", _binary.float32_serializer), ("float64_field", _binary.float64_serializer), ("complexfloat32_field", _binary.complexfloat32_serializer), ("complexfloat64_field", _binary.complexfloat64_serializer), ("string_field", _binary.string_serializer), ("tuple_field", tuples.binary.TupleSerializer(_binary.int32_serializer, _binary.int32_serializer)), ("vector_field", _binary.VectorSerializer(_binary.int32_serializer)), ("vector_of_vectors_field", _binary.VectorSerializer(_binary.VectorSerializer(_binary.int32_serializer))), ("fixed_vector_field", _binary.FixedVectorSerializer(_binary.int32_serializer, 3)), ("optional_named_array", _binary.OptionalSerializer(_binary.NDArraySerializer(_binary.int32_serializer, 2))), ("int_float_union", _binary.UnionSerializer(Int32OrFloat32, [(Int32OrFloat32.Int32, _binary.int32_serializer), (Int32OrFloat32.Float32, _binary.float32_serializer)])), ("nullable_int_float_union", _binary.UnionSerializer(Int32OrFloat32, [None, (Int32OrFloat32.Int32, _binary.int32_serializer), (Int32OrFloat32.Float32, _binary.float32_serializer)])), ("union_with_nested_generic_union", _binary.UnionSerializer(IntOrGenericRecordWithComputedFields, [(IntOrGenericRecordWithComputedFields.Int, _binary.int32_serializer), (IntOrGenericRecordWithComputedFields.GenericRecordWithComputedFields, basic_types.binary.GenericRecordWithComputedFieldsSerializer(_binary.string_serializer, _binary.float32_serializer))])), ("map_field", _binary.MapSerializer(_binary.string_serializer, _binary.string_serializer))]) + super().__init__([("array_field", _binary.NDArraySerializer(_binary.int32_serializer, 2)), ("array_field_map_dimensions", _binary.NDArraySerializer(_binary.int32_serializer, 2)), ("dynamic_array_field", _binary.DynamicNDArraySerializer(_binary.int32_serializer)), ("fixed_array_field", _binary.FixedNDArraySerializer(_binary.int32_serializer, (3, 4,))), ("int_field", _binary.int32_serializer), ("int8_field", _binary.int8_serializer), ("uint8_field", _binary.uint8_serializer), ("int16_field", _binary.int16_serializer), ("uint16_field", _binary.uint16_serializer), ("uint32_field", _binary.uint32_serializer), ("int64_field", _binary.int64_serializer), ("uint64_field", _binary.uint64_serializer), ("size_field", _binary.size_serializer), ("float32_field", _binary.float32_serializer), ("float64_field", _binary.float64_serializer), ("complexfloat32_field", _binary.complexfloat32_serializer), ("complexfloat64_field", _binary.complexfloat64_serializer), ("string_field", _binary.string_serializer), ("tuple_field", tuples.binary.TupleSerializer(_binary.int32_serializer, _binary.int32_serializer)), ("vector_field", _binary.VectorSerializer(_binary.int32_serializer)), ("vector_of_vectors_field", _binary.VectorSerializer(_binary.VectorSerializer(_binary.int32_serializer))), ("fixed_vector_field", _binary.FixedVectorSerializer(_binary.int32_serializer, 3)), ("fixed_vector_of_vectors_field", _binary.FixedVectorSerializer(_binary.FixedVectorSerializer(_binary.int32_serializer, 3), 2)), ("optional_named_array", _binary.OptionalSerializer(_binary.NDArraySerializer(_binary.int32_serializer, 2))), ("int_float_union", _binary.UnionSerializer(Int32OrFloat32, [(Int32OrFloat32.Int32, _binary.int32_serializer), (Int32OrFloat32.Float32, _binary.float32_serializer)])), ("nullable_int_float_union", _binary.UnionSerializer(Int32OrFloat32, [None, (Int32OrFloat32.Int32, _binary.int32_serializer), (Int32OrFloat32.Float32, _binary.float32_serializer)])), ("union_with_nested_generic_union", _binary.UnionSerializer(IntOrGenericRecordWithComputedFields, [(IntOrGenericRecordWithComputedFields.Int, _binary.int32_serializer), (IntOrGenericRecordWithComputedFields.GenericRecordWithComputedFields, basic_types.binary.GenericRecordWithComputedFieldsSerializer(_binary.string_serializer, _binary.float32_serializer))])), ("map_field", _binary.MapSerializer(_binary.string_serializer, _binary.string_serializer))]) def write(self, stream: _binary.CodedOutputStream, value: RecordWithComputedFields) -> None: if isinstance(value, np.void): self.write_numpy(stream, value) return - self._write(stream, value.array_field, value.array_field_map_dimensions, value.dynamic_array_field, value.fixed_array_field, value.int_field, value.int8_field, value.uint8_field, value.int16_field, value.uint16_field, value.uint32_field, value.int64_field, value.uint64_field, value.size_field, value.float32_field, value.float64_field, value.complexfloat32_field, value.complexfloat64_field, value.string_field, value.tuple_field, value.vector_field, value.vector_of_vectors_field, value.fixed_vector_field, value.optional_named_array, value.int_float_union, value.nullable_int_float_union, value.union_with_nested_generic_union, value.map_field) + self._write(stream, value.array_field, value.array_field_map_dimensions, value.dynamic_array_field, value.fixed_array_field, value.int_field, value.int8_field, value.uint8_field, value.int16_field, value.uint16_field, value.uint32_field, value.int64_field, value.uint64_field, value.size_field, value.float32_field, value.float64_field, value.complexfloat32_field, value.complexfloat64_field, value.string_field, value.tuple_field, value.vector_field, value.vector_of_vectors_field, value.fixed_vector_field, value.fixed_vector_of_vectors_field, value.optional_named_array, value.int_float_union, value.nullable_int_float_union, value.union_with_nested_generic_union, value.map_field) def write_numpy(self, stream: _binary.CodedOutputStream, value: np.void) -> None: - self._write(stream, value['array_field'], value['array_field_map_dimensions'], value['dynamic_array_field'], value['fixed_array_field'], value['int_field'], value['int8_field'], value['uint8_field'], value['int16_field'], value['uint16_field'], value['uint32_field'], value['int64_field'], value['uint64_field'], value['size_field'], value['float32_field'], value['float64_field'], value['complexfloat32_field'], value['complexfloat64_field'], value['string_field'], value['tuple_field'], value['vector_field'], value['vector_of_vectors_field'], value['fixed_vector_field'], value['optional_named_array'], value['int_float_union'], value['nullable_int_float_union'], value['union_with_nested_generic_union'], value['map_field']) + self._write(stream, value['array_field'], value['array_field_map_dimensions'], value['dynamic_array_field'], value['fixed_array_field'], value['int_field'], value['int8_field'], value['uint8_field'], value['int16_field'], value['uint16_field'], value['uint32_field'], value['int64_field'], value['uint64_field'], value['size_field'], value['float32_field'], value['float64_field'], value['complexfloat32_field'], value['complexfloat64_field'], value['string_field'], value['tuple_field'], value['vector_field'], value['vector_of_vectors_field'], value['fixed_vector_field'], value['fixed_vector_of_vectors_field'], value['optional_named_array'], value['int_float_union'], value['nullable_int_float_union'], value['union_with_nested_generic_union'], value['map_field']) def read(self, stream: _binary.CodedInputStream) -> RecordWithComputedFields: field_values = self._read(stream) - return RecordWithComputedFields(array_field=field_values[0], array_field_map_dimensions=field_values[1], dynamic_array_field=field_values[2], fixed_array_field=field_values[3], int_field=field_values[4], int8_field=field_values[5], uint8_field=field_values[6], int16_field=field_values[7], uint16_field=field_values[8], uint32_field=field_values[9], int64_field=field_values[10], uint64_field=field_values[11], size_field=field_values[12], float32_field=field_values[13], float64_field=field_values[14], complexfloat32_field=field_values[15], complexfloat64_field=field_values[16], string_field=field_values[17], tuple_field=field_values[18], vector_field=field_values[19], vector_of_vectors_field=field_values[20], fixed_vector_field=field_values[21], optional_named_array=field_values[22], int_float_union=field_values[23], nullable_int_float_union=field_values[24], union_with_nested_generic_union=field_values[25], map_field=field_values[26]) + return RecordWithComputedFields(array_field=field_values[0], array_field_map_dimensions=field_values[1], dynamic_array_field=field_values[2], fixed_array_field=field_values[3], int_field=field_values[4], int8_field=field_values[5], uint8_field=field_values[6], int16_field=field_values[7], uint16_field=field_values[8], uint32_field=field_values[9], int64_field=field_values[10], uint64_field=field_values[11], size_field=field_values[12], float32_field=field_values[13], float64_field=field_values[14], complexfloat32_field=field_values[15], complexfloat64_field=field_values[16], string_field=field_values[17], tuple_field=field_values[18], vector_field=field_values[19], vector_of_vectors_field=field_values[20], fixed_vector_field=field_values[21], fixed_vector_of_vectors_field=field_values[22], optional_named_array=field_values[23], int_float_union=field_values[24], nullable_int_float_union=field_values[25], union_with_nested_generic_union=field_values[26], map_field=field_values[27]) class RecordNotUsedInProtocolSerializer(_binary.RecordSerializer[RecordNotUsedInProtocol]): diff --git a/python/test_model/ndjson.py b/python/test_model/ndjson.py index d597c183..582bdebd 100644 --- a/python/test_model/ndjson.py +++ b/python/test_model/ndjson.py @@ -2140,6 +2140,7 @@ def __init__(self) -> None: self._vector_field_converter = _ndjson.VectorConverter(_ndjson.int32_converter) self._vector_of_vectors_field_converter = _ndjson.VectorConverter(_ndjson.VectorConverter(_ndjson.int32_converter)) self._fixed_vector_field_converter = _ndjson.FixedVectorConverter(_ndjson.int32_converter, 3) + self._fixed_vector_of_vectors_field_converter = _ndjson.FixedVectorConverter(_ndjson.FixedVectorConverter(_ndjson.int32_converter, 3), 2) self._optional_named_array_converter = _ndjson.OptionalConverter(_ndjson.NDArrayConverter(_ndjson.int32_converter, 2)) self._int_float_union_converter = _ndjson.UnionConverter(Int32OrFloat32, [(Int32OrFloat32.Int32, _ndjson.int32_converter, [int, float]), (Int32OrFloat32.Float32, _ndjson.float32_converter, [int, float])], False) self._nullable_int_float_union_converter = _ndjson.UnionConverter(Int32OrFloat32, [None, (Int32OrFloat32.Int32, _ndjson.int32_converter, [int, float]), (Int32OrFloat32.Float32, _ndjson.float32_converter, [int, float])], False) @@ -2168,6 +2169,7 @@ def __init__(self) -> None: ("vector_field", self._vector_field_converter.overall_dtype()), ("vector_of_vectors_field", self._vector_of_vectors_field_converter.overall_dtype()), ("fixed_vector_field", self._fixed_vector_field_converter.overall_dtype()), + ("fixed_vector_of_vectors_field", self._fixed_vector_of_vectors_field_converter.overall_dtype()), ("optional_named_array", self._optional_named_array_converter.overall_dtype()), ("int_float_union", self._int_float_union_converter.overall_dtype()), ("nullable_int_float_union", self._nullable_int_float_union_converter.overall_dtype()), @@ -2202,6 +2204,7 @@ def to_json(self, value: RecordWithComputedFields) -> object: json_object["vectorField"] = self._vector_field_converter.to_json(value.vector_field) json_object["vectorOfVectorsField"] = self._vector_of_vectors_field_converter.to_json(value.vector_of_vectors_field) json_object["fixedVectorField"] = self._fixed_vector_field_converter.to_json(value.fixed_vector_field) + json_object["fixedVectorOfVectorsField"] = self._fixed_vector_of_vectors_field_converter.to_json(value.fixed_vector_of_vectors_field) if value.optional_named_array is not None: json_object["optionalNamedArray"] = self._optional_named_array_converter.to_json(value.optional_named_array) json_object["intFloatUnion"] = self._int_float_union_converter.to_json(value.int_float_union) @@ -2238,6 +2241,7 @@ def numpy_to_json(self, value: np.void) -> object: json_object["vectorField"] = self._vector_field_converter.numpy_to_json(value["vector_field"]) json_object["vectorOfVectorsField"] = self._vector_of_vectors_field_converter.numpy_to_json(value["vector_of_vectors_field"]) json_object["fixedVectorField"] = self._fixed_vector_field_converter.numpy_to_json(value["fixed_vector_field"]) + json_object["fixedVectorOfVectorsField"] = self._fixed_vector_of_vectors_field_converter.numpy_to_json(value["fixed_vector_of_vectors_field"]) if (field_val := value["optional_named_array"]) is not None: json_object["optionalNamedArray"] = self._optional_named_array_converter.numpy_to_json(field_val) json_object["intFloatUnion"] = self._int_float_union_converter.numpy_to_json(value["int_float_union"]) @@ -2273,6 +2277,7 @@ def from_json(self, json_object: object) -> RecordWithComputedFields: vector_field=self._vector_field_converter.from_json(json_object["vectorField"],), vector_of_vectors_field=self._vector_of_vectors_field_converter.from_json(json_object["vectorOfVectorsField"],), fixed_vector_field=self._fixed_vector_field_converter.from_json(json_object["fixedVectorField"],), + fixed_vector_of_vectors_field=self._fixed_vector_of_vectors_field_converter.from_json(json_object["fixedVectorOfVectorsField"],), optional_named_array=self._optional_named_array_converter.from_json(json_object.get("optionalNamedArray")), int_float_union=self._int_float_union_converter.from_json(json_object["intFloatUnion"],), nullable_int_float_union=self._nullable_int_float_union_converter.from_json(json_object.get("nullableIntFloatUnion")), @@ -2306,6 +2311,7 @@ def from_json_to_numpy(self, json_object: object) -> np.void: self._vector_field_converter.from_json_to_numpy(json_object["vectorField"]), self._vector_of_vectors_field_converter.from_json_to_numpy(json_object["vectorOfVectorsField"]), self._fixed_vector_field_converter.from_json_to_numpy(json_object["fixedVectorField"]), + self._fixed_vector_of_vectors_field_converter.from_json_to_numpy(json_object["fixedVectorOfVectorsField"]), self._optional_named_array_converter.from_json_to_numpy(json_object.get("optionalNamedArray")), self._int_float_union_converter.from_json_to_numpy(json_object["intFloatUnion"]), self._nullable_int_float_union_converter.from_json_to_numpy(json_object.get("nullableIntFloatUnion")), diff --git a/python/test_model/protocols.py b/python/test_model/protocols.py index 30f019bd..7c4e622c 100644 --- a/python/test_model/protocols.py +++ b/python/test_model/protocols.py @@ -6166,7 +6166,7 @@ class ProtocolWithComputedFieldsWriterBase(abc.ABC): def __init__(self) -> None: self._state = 0 - schema = r"""{"protocol":{"name":"ProtocolWithComputedFields","sequence":[{"name":"recordWithComputedFields","type":"TestModel.RecordWithComputedFields"}]},"types":[{"name":"GenericRecordWithComputedFields","typeParameters":["T0","T1"],"fields":[{"name":"f1","type":[{"tag":"T0","type":"T0"},{"tag":"T1","type":"T1"}]}]},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"Tuples.Tuple","typeArguments":["T1","T2"]}},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"BasicTypes.MyTuple","typeArguments":["T1","T2"]}},{"name":"NamedNDArray","type":{"array":{"items":"int32","dimensions":[{"name":"dimA"},{"name":"dimB"}]}}},{"name":"RecordWithComputedFields","fields":[{"name":"arrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"arrayFieldMapDimensions","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"dynamicArrayField","type":{"array":{"items":"int32"}}},{"name":"fixedArrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x","length":3},{"name":"y","length":4}]}}},{"name":"intField","type":"int32"},{"name":"int8Field","type":"int8"},{"name":"uint8Field","type":"uint8"},{"name":"int16Field","type":"int16"},{"name":"uint16Field","type":"uint16"},{"name":"uint32Field","type":"uint32"},{"name":"int64Field","type":"int64"},{"name":"uint64Field","type":"uint64"},{"name":"sizeField","type":"size"},{"name":"float32Field","type":"float32"},{"name":"float64Field","type":"float64"},{"name":"complexfloat32Field","type":"complexfloat32"},{"name":"complexfloat64Field","type":"complexfloat64"},{"name":"stringField","type":"string"},{"name":"tupleField","type":{"name":"TestModel.MyTuple","typeArguments":["int32","int32"]}},{"name":"vectorField","type":{"vector":{"items":"int32"}}},{"name":"vectorOfVectorsField","type":{"vector":{"items":{"vector":{"items":"int32"}}}}},{"name":"fixedVectorField","type":{"vector":{"items":"int32","length":3}}},{"name":"optionalNamedArray","type":[null,"TestModel.NamedNDArray"]},{"name":"intFloatUnion","type":[{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"nullableIntFloatUnion","type":[null,{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"unionWithNestedGenericUnion","type":[{"tag":"int","explicitTag":true,"type":"int32"},{"tag":"genericRecordWithComputedFields","explicitTag":true,"type":{"name":"BasicTypes.GenericRecordWithComputedFields","typeArguments":["string","float32"]}}]},{"name":"mapField","type":{"map":{"keys":"string","values":"string"}}}]},{"name":"Tuple","typeParameters":["T1","T2"],"fields":[{"name":"v1","type":"T1"},{"name":"v2","type":"T2"}]}]}""" + schema = r"""{"protocol":{"name":"ProtocolWithComputedFields","sequence":[{"name":"recordWithComputedFields","type":"TestModel.RecordWithComputedFields"}]},"types":[{"name":"GenericRecordWithComputedFields","typeParameters":["T0","T1"],"fields":[{"name":"f1","type":[{"tag":"T0","type":"T0"},{"tag":"T1","type":"T1"}]}]},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"Tuples.Tuple","typeArguments":["T1","T2"]}},{"name":"MyTuple","typeParameters":["T1","T2"],"type":{"name":"BasicTypes.MyTuple","typeArguments":["T1","T2"]}},{"name":"NamedNDArray","type":{"array":{"items":"int32","dimensions":[{"name":"dimA"},{"name":"dimB"}]}}},{"name":"RecordWithComputedFields","fields":[{"name":"arrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"arrayFieldMapDimensions","type":{"array":{"items":"int32","dimensions":[{"name":"x"},{"name":"y"}]}}},{"name":"dynamicArrayField","type":{"array":{"items":"int32"}}},{"name":"fixedArrayField","type":{"array":{"items":"int32","dimensions":[{"name":"x","length":3},{"name":"y","length":4}]}}},{"name":"intField","type":"int32"},{"name":"int8Field","type":"int8"},{"name":"uint8Field","type":"uint8"},{"name":"int16Field","type":"int16"},{"name":"uint16Field","type":"uint16"},{"name":"uint32Field","type":"uint32"},{"name":"int64Field","type":"int64"},{"name":"uint64Field","type":"uint64"},{"name":"sizeField","type":"size"},{"name":"float32Field","type":"float32"},{"name":"float64Field","type":"float64"},{"name":"complexfloat32Field","type":"complexfloat32"},{"name":"complexfloat64Field","type":"complexfloat64"},{"name":"stringField","type":"string"},{"name":"tupleField","type":{"name":"TestModel.MyTuple","typeArguments":["int32","int32"]}},{"name":"vectorField","type":{"vector":{"items":"int32"}}},{"name":"vectorOfVectorsField","type":{"vector":{"items":{"vector":{"items":"int32"}}}}},{"name":"fixedVectorField","type":{"vector":{"items":"int32","length":3}}},{"name":"fixedVectorOfVectorsField","type":{"vector":{"items":{"vector":{"items":"int32","length":3}},"length":2}}},{"name":"optionalNamedArray","type":[null,"TestModel.NamedNDArray"]},{"name":"intFloatUnion","type":[{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"nullableIntFloatUnion","type":[null,{"tag":"int32","type":"int32"},{"tag":"float32","type":"float32"}]},{"name":"unionWithNestedGenericUnion","type":[{"tag":"int","explicitTag":true,"type":"int32"},{"tag":"genericRecordWithComputedFields","explicitTag":true,"type":{"name":"BasicTypes.GenericRecordWithComputedFields","typeArguments":["string","float32"]}}]},{"name":"mapField","type":{"map":{"keys":"string","values":"string"}}}]},{"name":"Tuple","typeParameters":["T1","T2"],"fields":[{"name":"v1","type":"T1"},{"name":"v2","type":"T2"}]}]}""" def close(self) -> None: self._close() diff --git a/python/test_model/types.py b/python/test_model/types.py index e66d0aa8..9cd9911d 100644 --- a/python/test_model/types.py +++ b/python/test_model/types.py @@ -1433,6 +1433,7 @@ class RecordWithComputedFields: vector_field: list[yardl.Int32] vector_of_vectors_field: list[list[yardl.Int32]] fixed_vector_field: list[yardl.Int32] + fixed_vector_of_vectors_field: list[list[yardl.Int32]] optional_named_array: typing.Optional[NamedNDArray] int_float_union: Int32OrFloat32 nullable_int_float_union: typing.Optional[Int32OrFloat32] @@ -1462,6 +1463,7 @@ def __init__(self, *, vector_field: typing.Optional[list[yardl.Int32]] = None, vector_of_vectors_field: typing.Optional[list[list[yardl.Int32]]] = None, fixed_vector_field: typing.Optional[list[yardl.Int32]] = None, + fixed_vector_of_vectors_field: typing.Optional[list[list[yardl.Int32]]] = None, optional_named_array: typing.Optional[NamedNDArray] = None, int_float_union: Int32OrFloat32 = Int32OrFloat32.Int32(0), nullable_int_float_union: typing.Optional[Int32OrFloat32] = None, @@ -1490,6 +1492,7 @@ def __init__(self, *, self.vector_field = vector_field if vector_field is not None else [] self.vector_of_vectors_field = vector_of_vectors_field if vector_of_vectors_field is not None else [] self.fixed_vector_field = fixed_vector_field if fixed_vector_field is not None else [0] * 3 + self.fixed_vector_of_vectors_field = fixed_vector_of_vectors_field if fixed_vector_of_vectors_field is not None else [[0] * 3 for _ in range(2)] self.optional_named_array = optional_named_array self.int_float_union = int_float_union self.nullable_int_float_union = nullable_int_float_union @@ -1550,6 +1553,9 @@ def access_vector_field_element(self) -> yardl.Int32: def access_vector_of_vectors_field(self) -> yardl.Int32: return self.vector_of_vectors_field[1][2] + def access_fixed_vector_of_vectors_field(self) -> yardl.Int32: + return self.fixed_vector_of_vectors_field[1][2] + def array_size(self) -> yardl.Size: return self.array_field.size @@ -1599,6 +1605,9 @@ def vector_size(self) -> yardl.Size: def fixed_vector_size(self) -> yardl.Size: return 3 + def fixed_vector_of_vectors_size(self) -> yardl.Size: + return 2 + def array_dimension_x_index(self) -> yardl.Size: return 0 @@ -1779,6 +1788,7 @@ def __eq__(self, other: object) -> bool: and self.vector_field == other.vector_field and self.vector_of_vectors_field == other.vector_of_vectors_field and self.fixed_vector_field == other.fixed_vector_field + and self.fixed_vector_of_vectors_field == other.fixed_vector_of_vectors_field and (other.optional_named_array is None if self.optional_named_array is None else (other.optional_named_array is not None and yardl.structural_equal(self.optional_named_array, other.optional_named_array))) and self.int_float_union == other.int_float_union and self.nullable_int_float_union == other.nullable_int_float_union @@ -1787,10 +1797,10 @@ def __eq__(self, other: object) -> bool: ) def __str__(self) -> str: - return f"RecordWithComputedFields(arrayField={self.array_field}, arrayFieldMapDimensions={self.array_field_map_dimensions}, dynamicArrayField={self.dynamic_array_field}, fixedArrayField={self.fixed_array_field}, intField={self.int_field}, int8Field={self.int8_field}, uint8Field={self.uint8_field}, int16Field={self.int16_field}, uint16Field={self.uint16_field}, uint32Field={self.uint32_field}, int64Field={self.int64_field}, uint64Field={self.uint64_field}, sizeField={self.size_field}, float32Field={self.float32_field}, float64Field={self.float64_field}, complexfloat32Field={self.complexfloat32_field}, complexfloat64Field={self.complexfloat64_field}, stringField={self.string_field}, tupleField={self.tuple_field}, vectorField={self.vector_field}, vectorOfVectorsField={self.vector_of_vectors_field}, fixedVectorField={self.fixed_vector_field}, optionalNamedArray={self.optional_named_array}, intFloatUnion={self.int_float_union}, nullableIntFloatUnion={self.nullable_int_float_union}, unionWithNestedGenericUnion={self.union_with_nested_generic_union}, mapField={self.map_field})" + return f"RecordWithComputedFields(arrayField={self.array_field}, arrayFieldMapDimensions={self.array_field_map_dimensions}, dynamicArrayField={self.dynamic_array_field}, fixedArrayField={self.fixed_array_field}, intField={self.int_field}, int8Field={self.int8_field}, uint8Field={self.uint8_field}, int16Field={self.int16_field}, uint16Field={self.uint16_field}, uint32Field={self.uint32_field}, int64Field={self.int64_field}, uint64Field={self.uint64_field}, sizeField={self.size_field}, float32Field={self.float32_field}, float64Field={self.float64_field}, complexfloat32Field={self.complexfloat32_field}, complexfloat64Field={self.complexfloat64_field}, stringField={self.string_field}, tupleField={self.tuple_field}, vectorField={self.vector_field}, vectorOfVectorsField={self.vector_of_vectors_field}, fixedVectorField={self.fixed_vector_field}, fixedVectorOfVectorsField={self.fixed_vector_of_vectors_field}, optionalNamedArray={self.optional_named_array}, intFloatUnion={self.int_float_union}, nullableIntFloatUnion={self.nullable_int_float_union}, unionWithNestedGenericUnion={self.union_with_nested_generic_union}, mapField={self.map_field})" def __repr__(self) -> str: - return f"RecordWithComputedFields(arrayField={repr(self.array_field)}, arrayFieldMapDimensions={repr(self.array_field_map_dimensions)}, dynamicArrayField={repr(self.dynamic_array_field)}, fixedArrayField={repr(self.fixed_array_field)}, intField={repr(self.int_field)}, int8Field={repr(self.int8_field)}, uint8Field={repr(self.uint8_field)}, int16Field={repr(self.int16_field)}, uint16Field={repr(self.uint16_field)}, uint32Field={repr(self.uint32_field)}, int64Field={repr(self.int64_field)}, uint64Field={repr(self.uint64_field)}, sizeField={repr(self.size_field)}, float32Field={repr(self.float32_field)}, float64Field={repr(self.float64_field)}, complexfloat32Field={repr(self.complexfloat32_field)}, complexfloat64Field={repr(self.complexfloat64_field)}, stringField={repr(self.string_field)}, tupleField={repr(self.tuple_field)}, vectorField={repr(self.vector_field)}, vectorOfVectorsField={repr(self.vector_of_vectors_field)}, fixedVectorField={repr(self.fixed_vector_field)}, optionalNamedArray={repr(self.optional_named_array)}, intFloatUnion={repr(self.int_float_union)}, nullableIntFloatUnion={repr(self.nullable_int_float_union)}, unionWithNestedGenericUnion={repr(self.union_with_nested_generic_union)}, mapField={repr(self.map_field)})" + return f"RecordWithComputedFields(arrayField={repr(self.array_field)}, arrayFieldMapDimensions={repr(self.array_field_map_dimensions)}, dynamicArrayField={repr(self.dynamic_array_field)}, fixedArrayField={repr(self.fixed_array_field)}, intField={repr(self.int_field)}, int8Field={repr(self.int8_field)}, uint8Field={repr(self.uint8_field)}, int16Field={repr(self.int16_field)}, uint16Field={repr(self.uint16_field)}, uint32Field={repr(self.uint32_field)}, int64Field={repr(self.int64_field)}, uint64Field={repr(self.uint64_field)}, sizeField={repr(self.size_field)}, float32Field={repr(self.float32_field)}, float64Field={repr(self.float64_field)}, complexfloat32Field={repr(self.complexfloat32_field)}, complexfloat64Field={repr(self.complexfloat64_field)}, stringField={repr(self.string_field)}, tupleField={repr(self.tuple_field)}, vectorField={repr(self.vector_field)}, vectorOfVectorsField={repr(self.vector_of_vectors_field)}, fixedVectorField={repr(self.fixed_vector_field)}, fixedVectorOfVectorsField={repr(self.fixed_vector_of_vectors_field)}, optionalNamedArray={repr(self.optional_named_array)}, intFloatUnion={repr(self.int_float_union)}, nullableIntFloatUnion={repr(self.nullable_int_float_union)}, unionWithNestedGenericUnion={repr(self.union_with_nested_generic_union)}, mapField={repr(self.map_field)})" class GenericUnionWithRepeatedTypeParameters(typing.Generic[T, T_NP]): @@ -2037,7 +2047,7 @@ def _mk_get_dtype(): dtype_map.setdefault(typing.Optional[AliasedNullableIntSimpleRecord], np.dtype(np.object_)) dtype_map.setdefault(Int32OrFloat32, np.dtype(np.object_)) dtype_map.setdefault(IntOrGenericRecordWithComputedFields, np.dtype(np.object_)) - dtype_map.setdefault(RecordWithComputedFields, np.dtype([('array_field', np.dtype(np.object_)), ('array_field_map_dimensions', np.dtype(np.object_)), ('dynamic_array_field', np.dtype(np.object_)), ('fixed_array_field', np.dtype(np.int32), (3, 4,)), ('int_field', np.dtype(np.int32)), ('int8_field', np.dtype(np.int8)), ('uint8_field', np.dtype(np.uint8)), ('int16_field', np.dtype(np.int16)), ('uint16_field', np.dtype(np.uint16)), ('uint32_field', np.dtype(np.uint32)), ('int64_field', np.dtype(np.int64)), ('uint64_field', np.dtype(np.uint64)), ('size_field', np.dtype(np.uint64)), ('float32_field', np.dtype(np.float32)), ('float64_field', np.dtype(np.float64)), ('complexfloat32_field', np.dtype(np.complex64)), ('complexfloat64_field', np.dtype(np.complex128)), ('string_field', np.dtype(np.object_)), ('tuple_field', get_dtype(types.GenericAlias(tuples.Tuple, (yardl.Int32, yardl.Int32,)))), ('vector_field', np.dtype(np.object_)), ('vector_of_vectors_field', np.dtype(np.object_)), ('fixed_vector_field', np.dtype(np.int32), (3,)), ('optional_named_array', np.dtype([('has_value', np.dtype(np.bool_)), ('value', np.dtype(np.object_))], align=True)), ('int_float_union', np.dtype(np.object_)), ('nullable_int_float_union', np.dtype(np.object_)), ('union_with_nested_generic_union', np.dtype(np.object_)), ('map_field', np.dtype(np.object_))], align=True)) + dtype_map.setdefault(RecordWithComputedFields, np.dtype([('array_field', np.dtype(np.object_)), ('array_field_map_dimensions', np.dtype(np.object_)), ('dynamic_array_field', np.dtype(np.object_)), ('fixed_array_field', np.dtype(np.int32), (3, 4,)), ('int_field', np.dtype(np.int32)), ('int8_field', np.dtype(np.int8)), ('uint8_field', np.dtype(np.uint8)), ('int16_field', np.dtype(np.int16)), ('uint16_field', np.dtype(np.uint16)), ('uint32_field', np.dtype(np.uint32)), ('int64_field', np.dtype(np.int64)), ('uint64_field', np.dtype(np.uint64)), ('size_field', np.dtype(np.uint64)), ('float32_field', np.dtype(np.float32)), ('float64_field', np.dtype(np.float64)), ('complexfloat32_field', np.dtype(np.complex64)), ('complexfloat64_field', np.dtype(np.complex128)), ('string_field', np.dtype(np.object_)), ('tuple_field', get_dtype(types.GenericAlias(tuples.Tuple, (yardl.Int32, yardl.Int32,)))), ('vector_field', np.dtype(np.object_)), ('vector_of_vectors_field', np.dtype(np.object_)), ('fixed_vector_field', np.dtype(np.int32), (3,)), ('fixed_vector_of_vectors_field', np.dtype(np.int32), (2,)), ('optional_named_array', np.dtype([('has_value', np.dtype(np.bool_)), ('value', np.dtype(np.object_))], align=True)), ('int_float_union', np.dtype(np.object_)), ('nullable_int_float_union', np.dtype(np.object_)), ('union_with_nested_generic_union', np.dtype(np.object_)), ('map_field', np.dtype(np.object_))], align=True)) dtype_map.setdefault(GenericUnionWithRepeatedTypeParameters, lambda type_args: np.dtype(np.object_)) dtype_map.setdefault(GenericUnion3, lambda type_args: np.dtype(np.object_)) dtype_map.setdefault(GenericUnion3Alternate, lambda type_args: np.dtype(np.object_)) diff --git a/tooling/internal/matlab/binary/binary.go b/tooling/internal/matlab/binary/binary.go index 1c450847..9d74d005 100644 --- a/tooling/internal/matlab/binary/binary.go +++ b/tooling/internal/matlab/binary/binary.go @@ -206,11 +206,6 @@ func typeDefinitionSerializer(td dsl.TypeDefinition, contextNamespace string) st typeArguments = append(typeArguments, typeSerializer(arg, contextNamespace, nil)) } - if len(typeArguments) == 0 { - panic("How could this be possible?") - return fmt.Sprintf("%s()", qualifiedSerializerName) - } - return fmt.Sprintf("%s(%s)", qualifiedSerializerName, strings.Join(typeArguments, ", ")) case *dsl.GenericTypeParameter: @@ -301,11 +296,9 @@ func typeSerializer(t dsl.Type, contextNamespace string, namedType *dsl.NamedTyp } func BinaryWriterName(p *dsl.ProtocolDefinition) string { - // return fmt.Sprintf("Binary%sWriter", formatting.ToPascalCase(p.Name)) return fmt.Sprintf("%sWriter", formatting.ToPascalCase(p.Name)) } func BinaryReaderName(p *dsl.ProtocolDefinition) string { - // return fmt.Sprintf("Binary%sReader", formatting.ToPascalCase(p.Name)) return fmt.Sprintf("%sReader", formatting.ToPascalCase(p.Name)) } diff --git a/tooling/internal/matlab/common/common.go b/tooling/internal/matlab/common/common.go index 81393e30..300122eb 100644 --- a/tooling/internal/matlab/common/common.go +++ b/tooling/internal/matlab/common/common.go @@ -14,8 +14,28 @@ import ( "github.com/microsoft/yardl/tooling/pkg/dsl" ) -// TODO: Populate all Matlab reserved names -var isReservedName = map[string]bool{} +var isReservedName = map[string]bool{ + "break": true, + "case": true, + "catch": true, + "classdef": true, + "continue": true, + "else": true, + "elseif": true, + "end": true, + "for": true, + "function": true, + "global": true, + "if": true, + "otherwise": true, + "parfor": true, + "persistent": true, + "return": true, + "spmd": true, + "switch": true, + "try": true, + "while": true, +} var TypeSyntaxWriter dsl.TypeSyntaxWriter[string] = func(self dsl.TypeSyntaxWriter[string], t dsl.Node, contextNamespace string) string { switch t := t.(type) { @@ -43,10 +63,6 @@ var TypeSyntaxWriter dsl.TypeSyntaxWriter[string] = func(self dsl.TypeSyntaxWrit return "single" case dsl.Float64, dsl.ComplexFloat64: return "double" - // case dsl.ComplexFloat32: - // return "complex" - // case dsl.ComplexFloat64: - // return "complex" case dsl.String: return "string" case dsl.Date: @@ -84,8 +100,6 @@ var TypeSyntaxWriter dsl.TypeSyntaxWriter[string] = func(self dsl.TypeSyntaxWrit case nil, *dsl.Stream, *dsl.Vector, *dsl.Array: return scalarString case *dsl.Map: - // TODO: Update to Matlab `dictionary` class when we require Matlab version >= r2023b - // return "containers.Map" return "dictionary" default: panic(fmt.Sprintf("unexpected type %T", d)) diff --git a/tooling/internal/matlab/mocks/mocks.go b/tooling/internal/matlab/mocks/mocks.go index f257aa38..8192120f 100644 --- a/tooling/internal/matlab/mocks/mocks.go +++ b/tooling/internal/matlab/mocks/mocks.go @@ -43,7 +43,7 @@ func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) e common.WriteBlockBody(w, func() { w.WriteStringln("obj.testCase_ = testCase;") for _, step := range p.Sequence { - fmt.Fprintf(w, "obj.%swritten = Node.empty();\n", common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "obj.%swritten = yardl.None;\n", common.ProtocolWriteImplMethodName(step)) } }) w.WriteStringln("") @@ -51,14 +51,14 @@ func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) e for _, step := range p.Sequence { fmt.Fprintf(w, "function expect_%s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "if isempty(obj.%swritten)\n", common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "if obj.%swritten.has_value()\n", common.ProtocolWriteImplMethodName(step)) w.Indented(func() { - fmt.Fprintf(w, "obj.%swritten = Node(value);\n", common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "last_dim = ndims(value);\n") + fmt.Fprintf(w, "obj.%swritten = yardl.Optional(cat(last_dim, obj.%swritten.value, value));\n", common.ProtocolWriteImplMethodName(step), common.ProtocolWriteImplMethodName(step)) }) w.WriteStringln("else") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "last_dim = ndims(value);\n") - fmt.Fprintf(w, "obj.%swritten = Node(cat(last_dim, obj.%swritten(1).value, value));\n", common.ProtocolWriteImplMethodName(step), common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "obj.%swritten = yardl.Optional(value);\n", common.ProtocolWriteImplMethodName(step)) }) }) w.WriteStringln("") @@ -68,7 +68,7 @@ func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) e common.WriteBlockBody(w, func() { for _, step := range p.Sequence { diagnostic := fmt.Sprintf("Expected call to %s was not received", common.ProtocolWriteImplMethodName(step)) - fmt.Fprintf(w, "obj.testCase_.verifyTrue(isempty(obj.%swritten), \"%s\");\n", common.ProtocolWriteImplMethodName(step), diagnostic) + fmt.Fprintf(w, "obj.testCase_.verifyEqual(obj.%swritten, yardl.None, \"%s\");\n", common.ProtocolWriteImplMethodName(step), diagnostic) } }) }) @@ -79,10 +79,10 @@ func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) e for _, step := range p.Sequence { fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.testCase_.verifyTrue(~isempty(obj.%swritten), \"Unexpected call to %s\");\n", common.ProtocolWriteImplMethodName(step), common.ProtocolWriteImplMethodName(step)) - fmt.Fprintf(w, "expected = obj.%swritten(1).value;\n", common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "obj.testCase_.verifyTrue(obj.%swritten.has_value(), \"Unexpected call to %s\");\n", common.ProtocolWriteImplMethodName(step), common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "expected = obj.%swritten.value;\n", common.ProtocolWriteImplMethodName(step)) fmt.Fprintf(w, "obj.testCase_.verifyEqual(value, expected, \"Unexpected argument value for call to %s\");\n", common.ProtocolWriteImplMethodName(step)) - fmt.Fprintf(w, "obj.%swritten = Node.empty();\n", common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "obj.%swritten = yardl.None;\n", common.ProtocolWriteImplMethodName(step)) }) w.WriteStringln("") } @@ -118,7 +118,6 @@ func writeProtocolTestWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinit fmt.Fprintf(w, "function obj = %s(testCase, format, create_writer, create_reader)\n", testWriterName(p)) common.WriteBlockBody(w, func() { w.WriteStringln("obj.filename_ = tempname();") - // w.WriteStringln("obj.filename_ = sprintf(\"%s" + formatting.ToPascalCase(p.Name) + ".bin\", tempdir());") w.WriteStringln("obj.format_ = format;") w.WriteStringln("obj.writer_ = create_writer(obj.filename_);") w.WriteStringln("obj.create_reader_ = create_reader;") @@ -130,7 +129,7 @@ func writeProtocolTestWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinit w.WriteStringln("function delete(obj)") common.WriteBlockBody(w, func() { - w.WriteStringln("% delete(obj.filename_);") + w.WriteStringln("delete(obj.filename_);") w.WriteStringln("if ~obj.close_called_") common.WriteBlockBody(w, func() { common.WriteComment(w, "ADD_FAILURE() << ...;") @@ -171,7 +170,7 @@ func writeProtocolTestWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinit w.WriteStringln("reader.close();") w.WriteStringln("mock_copy.verify();") w.WriteStringln("mock_copy.close();") - w.WriteStringln("% delete(translated);") + w.WriteStringln("delete(translated);") }) w.WriteStringln("") diff --git a/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m b/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m index 5d4837fc..605287f6 100755 --- a/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m +++ b/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef BinaryProtocolReader < handle properties (Access=protected) diff --git a/tooling/internal/matlab/static_files/+binary/BinaryProtocolWriter.m b/tooling/internal/matlab/static_files/+binary/BinaryProtocolWriter.m index b584c58f..9a9b5a9d 100755 --- a/tooling/internal/matlab/static_files/+binary/BinaryProtocolWriter.m +++ b/tooling/internal/matlab/static_files/+binary/BinaryProtocolWriter.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef BinaryProtocolWriter < handle properties (Access=protected) diff --git a/tooling/internal/matlab/static_files/+binary/BoolSerializer.m b/tooling/internal/matlab/static_files/+binary/BoolSerializer.m index 0d43a5b3..c59f5f5f 100755 --- a/tooling/internal/matlab/static_files/+binary/BoolSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/BoolSerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef BoolSerializer < yardl.binary.TypeSerializer methods (Static) function write( outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/CURRENT_BINARY_FORMAT_VERSION.m b/tooling/internal/matlab/static_files/+binary/CURRENT_BINARY_FORMAT_VERSION.m index c9286b0a..2fcacad5 100755 --- a/tooling/internal/matlab/static_files/+binary/CURRENT_BINARY_FORMAT_VERSION.m +++ b/tooling/internal/matlab/static_files/+binary/CURRENT_BINARY_FORMAT_VERSION.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + function res = CURRENT_BINARY_FORMAT_VERSION res = int32(1); end diff --git a/tooling/internal/matlab/static_files/+binary/CodedInputStream.m b/tooling/internal/matlab/static_files/+binary/CodedInputStream.m index 3ea1a643..cf449091 100755 --- a/tooling/internal/matlab/static_files/+binary/CodedInputStream.m +++ b/tooling/internal/matlab/static_files/+binary/CodedInputStream.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef CodedInputStream < handle properties (Access=private) diff --git a/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m b/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m index cbec09ca..227620d4 100755 --- a/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m +++ b/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef CodedOutputStream < handle properties (Access=private) diff --git a/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m b/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m index 8caadfb6..f2a1dc37 100755 --- a/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Complexfloat32Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m b/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m index 2b7e6a52..9bb336f7 100755 --- a/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Complexfloat64Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/DateSerializer.m b/tooling/internal/matlab/static_files/+binary/DateSerializer.m index bcb066d6..c0760763 100755 --- a/tooling/internal/matlab/static_files/+binary/DateSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/DateSerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef DateSerializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/DatetimeSerializer.m b/tooling/internal/matlab/static_files/+binary/DatetimeSerializer.m index eb82c840..eada81ad 100755 --- a/tooling/internal/matlab/static_files/+binary/DatetimeSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/DatetimeSerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef DatetimeSerializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m index baa52ec1..d67b9317 100644 --- a/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef DynamicNDArraySerializer < yardl.binary.NDArraySerializerBase methods diff --git a/tooling/internal/matlab/static_files/+binary/EnumSerializer.m b/tooling/internal/matlab/static_files/+binary/EnumSerializer.m index 7af674f9..577722b9 100644 --- a/tooling/internal/matlab/static_files/+binary/EnumSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/EnumSerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef EnumSerializer < yardl.binary.TypeSerializer properties classname_; diff --git a/tooling/internal/matlab/static_files/+binary/Error.m b/tooling/internal/matlab/static_files/+binary/Error.m index 60872510..212e7d83 100755 --- a/tooling/internal/matlab/static_files/+binary/Error.m +++ b/tooling/internal/matlab/static_files/+binary/Error.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + function err = Error(varargin) err = yardl.Exception("yardl:binary:Error", varargin{:}); end diff --git a/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m index 86f05d5d..10122a9c 100644 --- a/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef FixedNDArraySerializer < yardl.binary.NDArraySerializerBase properties diff --git a/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m b/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m index 20128be5..7c084fc8 100644 --- a/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef FixedVectorSerializer < yardl.binary.TypeSerializer properties item_serializer_; diff --git a/tooling/internal/matlab/static_files/+binary/Float32Serializer.m b/tooling/internal/matlab/static_files/+binary/Float32Serializer.m index d3498cda..898d0dd4 100755 --- a/tooling/internal/matlab/static_files/+binary/Float32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Float32Serializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Float32Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/Float64Serializer.m b/tooling/internal/matlab/static_files/+binary/Float64Serializer.m index b50c476c..69723866 100755 --- a/tooling/internal/matlab/static_files/+binary/Float64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Float64Serializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Float64Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/Int16Serializer.m b/tooling/internal/matlab/static_files/+binary/Int16Serializer.m index 4d82b6ba..5a116938 100755 --- a/tooling/internal/matlab/static_files/+binary/Int16Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int16Serializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Int16Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/Int32Serializer.m b/tooling/internal/matlab/static_files/+binary/Int32Serializer.m index 32f1c655..cbe2eae3 100755 --- a/tooling/internal/matlab/static_files/+binary/Int32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int32Serializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Int32Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/Int64Serializer.m b/tooling/internal/matlab/static_files/+binary/Int64Serializer.m index 34fe4225..f9f8658b 100755 --- a/tooling/internal/matlab/static_files/+binary/Int64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int64Serializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Int64Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/Int8Serializer.m b/tooling/internal/matlab/static_files/+binary/Int8Serializer.m index 1187843e..0c98da3f 100755 --- a/tooling/internal/matlab/static_files/+binary/Int8Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int8Serializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Int8Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/MAGIC_BYTES.m b/tooling/internal/matlab/static_files/+binary/MAGIC_BYTES.m index a7a6e67c..43919757 100755 --- a/tooling/internal/matlab/static_files/+binary/MAGIC_BYTES.m +++ b/tooling/internal/matlab/static_files/+binary/MAGIC_BYTES.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + function res = MAGIC_BYTES res = unicode2native('yardl'); end diff --git a/tooling/internal/matlab/static_files/+binary/MapSerializer.m b/tooling/internal/matlab/static_files/+binary/MapSerializer.m index 2ff209e9..6bdf09e0 100644 --- a/tooling/internal/matlab/static_files/+binary/MapSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/MapSerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef MapSerializer < yardl.binary.TypeSerializer properties key_serializer_; @@ -11,19 +14,12 @@ end function write(obj, outstream, value) - % assert(isa(value, 'containers.Map')) - % OR, starting in R2022, Mathworks recommends using `dictionary` assert(isa(value, 'dictionary')) - - % count = length(value); count = numEntries(value); - outstream.write_unsigned_varint(count); ks = keys(value); vs = values(value); for i = 1:count - % obj.key_serializer_.write(outstream, ks{i}); - % obj.value_serializer_.write(outstream, vs{i}); obj.key_serializer_.write(outstream, ks(i)); obj.value_serializer_.write(outstream, vs(i)); end @@ -31,11 +27,7 @@ function write(obj, outstream, value) function res = read(obj, instream) count = instream.read_unsigned_varint(); - - % TODO: If we can require R2022, should use `dictionary` - % res = containers.Map('KeyType', obj.key_serializer_.getClass(), 'ValueType', obj.value_serializer_.getClass()); res = dictionary(); - for i = 1:count k = obj.key_serializer_.read(instream); v = obj.value_serializer_.read(instream); @@ -44,7 +36,6 @@ function write(obj, outstream, value) end function c = getClass(obj) - % c = 'containers.Map'; c = 'dictionary'; end end diff --git a/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m index 52de2fec..58bc487e 100644 --- a/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef NDArraySerializer < yardl.binary.NDArraySerializerBase properties diff --git a/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m b/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m index f00baaf2..a6b21b6e 100644 --- a/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m +++ b/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef NDArraySerializerBase < yardl.binary.TypeSerializer properties diff --git a/tooling/internal/matlab/static_files/+binary/NoneSerializer.m b/tooling/internal/matlab/static_files/+binary/NoneSerializer.m index 5cd0147e..45bf88a0 100755 --- a/tooling/internal/matlab/static_files/+binary/NoneSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/NoneSerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef NoneSerializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m b/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m index 9ad9bf6a..e19856fd 100644 --- a/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef OptionalSerializer < yardl.binary.TypeSerializer properties item_serializer_; @@ -9,13 +12,6 @@ end function write(obj, outstream, value) - % if isa(value, 'yardl.None') - % outstream.write_byte_no_check(0); - % return - % end - % outstream.write_byte_no_check(1); - % obj.item_serializer_.write(outstream, value); - if isa(value, 'yardl.Optional') if value.has_value() outstream.write_byte_no_check(1); @@ -36,14 +32,10 @@ function write(obj, outstream, value) res = yardl.None; else res = obj.item_serializer_.read(instream); - - % value = obj.item_serializer_.read(instream); - % res = yardl.Optional(value); end end function c = getClass(obj) - % c = obj.item_serializer_.getClass(); c = 'yardl.Optional'; end end diff --git a/tooling/internal/matlab/static_files/+binary/RecordSerializer.m b/tooling/internal/matlab/static_files/+binary/RecordSerializer.m index d59a5097..2a1dd7c9 100755 --- a/tooling/internal/matlab/static_files/+binary/RecordSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/RecordSerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef RecordSerializer < yardl.binary.TypeSerializer properties diff --git a/tooling/internal/matlab/static_files/+binary/SizeSerializer.m b/tooling/internal/matlab/static_files/+binary/SizeSerializer.m index 53f51e4d..a613e233 100755 --- a/tooling/internal/matlab/static_files/+binary/SizeSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/SizeSerializer.m @@ -1,2 +1,5 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef SizeSerializer < yardl.binary.Uint64Serializer end diff --git a/tooling/internal/matlab/static_files/+binary/StreamSerializer.m b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m index a82e6680..a6b48d01 100644 --- a/tooling/internal/matlab/static_files/+binary/StreamSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef StreamSerializer < yardl.binary.TypeSerializer properties item_serializer_; diff --git a/tooling/internal/matlab/static_files/+binary/StringSerializer.m b/tooling/internal/matlab/static_files/+binary/StringSerializer.m index 3844acdf..14849a03 100755 --- a/tooling/internal/matlab/static_files/+binary/StringSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/StringSerializer.m @@ -1,9 +1,9 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef StringSerializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - % if ischar(value) - % value = convertCharsToStrings(value); - % end bytes = unicode2native(value, "utf-8"); outstream.write_unsigned_varint(length(bytes)); outstream.write_bytes(bytes); diff --git a/tooling/internal/matlab/static_files/+binary/TimeSerializer.m b/tooling/internal/matlab/static_files/+binary/TimeSerializer.m index 2e14c985..bae74be9 100755 --- a/tooling/internal/matlab/static_files/+binary/TimeSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/TimeSerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef TimeSerializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/TypeSerializer.m b/tooling/internal/matlab/static_files/+binary/TypeSerializer.m index 91e855b0..0f2a2bec 100755 --- a/tooling/internal/matlab/static_files/+binary/TypeSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/TypeSerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef TypeSerializer < handle methods (Static, Abstract) write(obj, stream, value) diff --git a/tooling/internal/matlab/static_files/+binary/Uint16Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint16Serializer.m index 05712b64..a909d929 100755 --- a/tooling/internal/matlab/static_files/+binary/Uint16Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint16Serializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Uint16Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/Uint32Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint32Serializer.m index c2fa58b7..dcb95c05 100755 --- a/tooling/internal/matlab/static_files/+binary/Uint32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint32Serializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Uint32Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/Uint64Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint64Serializer.m index 3bff28ec..f387386a 100755 --- a/tooling/internal/matlab/static_files/+binary/Uint64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint64Serializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Uint64Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) diff --git a/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m index 88dbba27..679589dd 100755 --- a/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m @@ -1,9 +1,11 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Uint8Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) assert(value <= intmax("uint8")); assert(value >= intmin("uint8")); - % bytes = typecast(uint8(value), "uint8"); outstream.write_bytes(uint8(value)); end diff --git a/tooling/internal/matlab/static_files/+binary/UnionSerializer.m b/tooling/internal/matlab/static_files/+binary/UnionSerializer.m index 73b61dc3..3deb9ed9 100755 --- a/tooling/internal/matlab/static_files/+binary/UnionSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/UnionSerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef UnionSerializer < handle properties (Access=protected) @@ -36,15 +39,6 @@ function write(obj, outstream, value) end end - % if isa(value, 'yardl.Optional') && ~value.has_value() - % if isa(obj.case_serializers_{1}, 'yardl.binary.NoneSerializer') - % outstream.write_byte_no_check(0); - % return; - % else - % throw(yardl.TypeError("None is not valid for this union type")) - % end - % end - if ~isa(value, obj.classname_) throw(yardl.TypeError("Expected union value of type %s, got %s", obj.classname_, class(value))) end diff --git a/tooling/internal/matlab/static_files/+binary/VectorSerializer.m b/tooling/internal/matlab/static_files/+binary/VectorSerializer.m index 8d1563c9..30199f5d 100644 --- a/tooling/internal/matlab/static_files/+binary/VectorSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/VectorSerializer.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef VectorSerializer < yardl.binary.TypeSerializer properties item_serializer_; diff --git a/tooling/internal/matlab/static_files/Date.m b/tooling/internal/matlab/static_files/Date.m index 6ba484ec..6ef0cf9f 100644 --- a/tooling/internal/matlab/static_files/Date.m +++ b/tooling/internal/matlab/static_files/Date.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Date < handle properties (Access=private) diff --git a/tooling/internal/matlab/static_files/DateTime.m b/tooling/internal/matlab/static_files/DateTime.m index ba44fd4b..6098c193 100644 --- a/tooling/internal/matlab/static_files/DateTime.m +++ b/tooling/internal/matlab/static_files/DateTime.m @@ -1,5 +1,8 @@ -% A basic datetime with nanosecond precision, always in UTC. +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef DateTime < handle + % A basic datetime with nanosecond precision, always in UTC. properties (Access=private) nanoseconds_since_epoch_ diff --git a/tooling/internal/matlab/static_files/Exception.m b/tooling/internal/matlab/static_files/Exception.m index fc8c6ad7..131fd049 100755 --- a/tooling/internal/matlab/static_files/Exception.m +++ b/tooling/internal/matlab/static_files/Exception.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + function err = Exception(id, varargin) err = MException(id, varargin{:}); end diff --git a/tooling/internal/matlab/static_files/KeyError.m b/tooling/internal/matlab/static_files/KeyError.m index 70aa0034..0e6dfb45 100644 --- a/tooling/internal/matlab/static_files/KeyError.m +++ b/tooling/internal/matlab/static_files/KeyError.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + function err = KeyError(varargin) err = yardl.Exception("yardl:KeyError", varargin{:}); end diff --git a/tooling/internal/matlab/static_files/None.m b/tooling/internal/matlab/static_files/None.m index 4a436fcc..728123da 100644 --- a/tooling/internal/matlab/static_files/None.m +++ b/tooling/internal/matlab/static_files/None.m @@ -1,31 +1,5 @@ -% classdef None < handle -% methods -% function eq = eq(~, other) -% eq = isa(other, 'yardl.None'); -% end - -% function ne = ne(obj, other) -% ne = ~eq(obj, other); -% end -% end -% end - -% classdef None < yardl.Optional -% methods -% function obj = None() -% obj.value_ = NaN; -% obj.has_value_ = false; -% end - -% % function eq = eq(~, other) -% % eq = isa(other, 'yardl.None'); -% % end - -% % function ne = ne(obj, other) -% % ne = ~eq(obj, other); -% % end -% end -% end +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. function n = None() n = yardl.Optional(); diff --git a/tooling/internal/matlab/static_files/Optional.m b/tooling/internal/matlab/static_files/Optional.m index 71b74c61..bd21058c 100644 --- a/tooling/internal/matlab/static_files/Optional.m +++ b/tooling/internal/matlab/static_files/Optional.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Optional < handle properties (SetAccess=protected) has_value @@ -6,7 +9,7 @@ methods function obj = Optional(varargin) - if nargin > 0 && ~isa(varargin{1}, 'yardl.Optional') + if nargin > 0 obj.value = varargin{1}; obj.has_value = true; else @@ -23,32 +26,15 @@ end function eq = eq(a, b) - % if isa(a, 'yardl.Optional') - % if isa(b, 'yardl.Optional') - % if a.has_value && b.has_value - % eq = a.value == b.value; - % else - % eq = a.has_value == b.has_value; - % end - % else - % eq = a.has_value && b == a.value; - % end - % else - % % b is the Optional - % eq = b.has_value && a == b.value; - % end - if isa(a, 'yardl.Optional') if isa(b, 'yardl.Optional') if all([a.has_value]) && all([b.has_value]) - % eq = [a.value] == [b.value]; eq = isequal([a.value], [b.value]); else eq = [a.has_value] == [b.has_value]; end else if all([a.has_value]) - % eq = b == [a.value]; eq = isequal(b, [a.value]); else eq = false; @@ -57,7 +43,6 @@ else % b is the Optional if all([b.has_value]) - % eq = a == [b.value]; eq = isequal(a, [b.value]); else eq = false; diff --git a/tooling/internal/matlab/static_files/ProtocolError.m b/tooling/internal/matlab/static_files/ProtocolError.m index 36b0a6ba..eac33ad3 100644 --- a/tooling/internal/matlab/static_files/ProtocolError.m +++ b/tooling/internal/matlab/static_files/ProtocolError.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + function err = ProtocolError(varargin) err = yardl.Exception("yardl:ProtocolError", varargin{:}); end diff --git a/tooling/internal/matlab/static_files/RuntimeError.m b/tooling/internal/matlab/static_files/RuntimeError.m index 3a9c17d7..d2a2d612 100644 --- a/tooling/internal/matlab/static_files/RuntimeError.m +++ b/tooling/internal/matlab/static_files/RuntimeError.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + function err = RuntimeError(varargin) err = yardl.Exception("yardl:RuntimeError", varargin{:}); end diff --git a/tooling/internal/matlab/static_files/Time.m b/tooling/internal/matlab/static_files/Time.m index 690e02d3..37586d07 100644 --- a/tooling/internal/matlab/static_files/Time.m +++ b/tooling/internal/matlab/static_files/Time.m @@ -1,6 +1,9 @@ -% A basic time of day with nanosecond precision. It is not timezone-aware and is -% meant to represent a wall clock time. +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Time < handle + % A basic time of day with nanosecond precision. It is not timezone-aware and is + % meant to represent a wall clock time. properties (Access=private) nanoseconds_since_midnight_ diff --git a/tooling/internal/matlab/static_files/TypeError.m b/tooling/internal/matlab/static_files/TypeError.m index c4cf18f6..d37b4d6f 100644 --- a/tooling/internal/matlab/static_files/TypeError.m +++ b/tooling/internal/matlab/static_files/TypeError.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + function err = TypeError(varargin) err = yardl.Exception("yardl:TypeError", varargin{:}); end diff --git a/tooling/internal/matlab/static_files/Union.m b/tooling/internal/matlab/static_files/Union.m index 4abbae38..9bc89ae4 100644 --- a/tooling/internal/matlab/static_files/Union.m +++ b/tooling/internal/matlab/static_files/Union.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef Union < handle properties (Access=protected) index_ diff --git a/tooling/internal/matlab/static_files/ValueError.m b/tooling/internal/matlab/static_files/ValueError.m index 59f15c71..3c0bd3f2 100644 --- a/tooling/internal/matlab/static_files/ValueError.m +++ b/tooling/internal/matlab/static_files/ValueError.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + function err = ValueError(varargin) err = yardl.Exception("yardl:ValueError", varargin{:}); end diff --git a/tooling/internal/matlab/static_files/allocate.m b/tooling/internal/matlab/static_files/allocate.m index 1d2267af..f99f87fb 100644 --- a/tooling/internal/matlab/static_files/allocate.m +++ b/tooling/internal/matlab/static_files/allocate.m @@ -1,4 +1,8 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + function res = allocate(classname, varargin) + % Wrapper around zeros, used to preallocate arrays of yardl objects if classname == "string" res = strings(varargin{:}); else diff --git a/tooling/internal/matlab/static_files/dimension_count.m b/tooling/internal/matlab/static_files/dimension_count.m index 78a48c3c..21567677 100644 --- a/tooling/internal/matlab/static_files/dimension_count.m +++ b/tooling/internal/matlab/static_files/dimension_count.m @@ -1,6 +1,9 @@ -% Alternative to Matlab's `ndims` function -% Collapses dimensions of size 1 (making it behave like numpy.array.ndim) +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + function c = dimension_count(arr) + % Alternative to Matlab's `ndims` function + % Collapses dimensions of size 1 (making it behave like numpy.array.ndim) s = size(arr); c = length(s(s > 1)); end diff --git a/tooling/internal/matlab/types/types.go b/tooling/internal/matlab/types/types.go index 3e61dca4..c2cc6488 100644 --- a/tooling/internal/matlab/types/types.go +++ b/tooling/internal/matlab/types/types.go @@ -5,13 +5,13 @@ package types import ( "fmt" + "slices" "strconv" "strings" "github.com/microsoft/yardl/tooling/internal/formatting" "github.com/microsoft/yardl/tooling/internal/matlab/common" "github.com/microsoft/yardl/tooling/pkg/dsl" - "github.com/rs/zerolog/log" ) func WriteTypes(fw *common.MatlabFileWriter, ns *dsl.Namespace, st dsl.SymbolTable) error { @@ -402,7 +402,6 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E for i, d := range *dims { fmt.Fprintf(w, "if dim_name == \"%s\"\n", *d.Name) w.Indented(func() { - // fmt.Fprintf(w, "dim = %d;\n", len(*dims)-i) fmt.Fprintf(w, "dim = %d;\n", i) }) w.WriteString("else") @@ -555,6 +554,7 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E }) w.WriteString(startSubscript) + slices.Reverse(arguments) formatting.Delimited(w, delimeter, arguments, func(w *formatting.IndentedWriter, i int, a *dsl.SubscriptArgument) { self.Visit(a.Value, tailWrapper{}) }) @@ -567,7 +567,6 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E case dsl.FunctionSize: switch dsl.ToGeneralizedType(dsl.GetUnderlyingType(t.Arguments[0].GetResolvedType())).Dimensionality.(type) { case *dsl.Map: - // length for containers.Map, numEntries for dictionary fmt.Fprintf(w, "numEntries(") self.Visit(t.Arguments[0], tailWrapper{}) fmt.Fprintf(w, ")") @@ -581,18 +580,14 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E if len(t.Arguments) > 1 { w.WriteString("size(") self.Visit(t.Arguments[0], tailWrapper{}) - w.WriteString(", 1+") - remainingArgs := t.Arguments[1:] - formatting.Delimited(w, ", 1+", remainingArgs, func(w *formatting.IndentedWriter, i int, arg dsl.Expression) { - // if _, ok := arg.(*dsl.IntegerLiteralExpression); ok { - // // Need to adjust integer literals for 1-based indexing in Matlab - // // fmt.Fprintf(w, "%d", big.NewInt(0).Add(&intArg.Value, big.NewInt(1))) - // w.WriteString("ndims(") - // self.Visit(t.Arguments[0], tailWrapper{}) - // w.WriteString(")-") - // } + for _, arg := range t.Arguments[1:] { + w.WriteString(", ") + w.WriteString("ndims(") + self.Visit(t.Arguments[0], tailWrapper{}) + w.WriteString(")-(") self.Visit(arg, tailWrapper{}) - }) + w.WriteString(")") + } } else { w.WriteString("numel(") self.Visit(t.Arguments[0], tailWrapper{}) @@ -602,7 +597,7 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E case dsl.FunctionDimensionIndex: helperFuncName := helperFunctionLookup[t.Arguments[0].GetResolvedType()] - fmt.Fprintf(w, "1 + %s(", helperFuncName) + fmt.Fprintf(w, "%s(", helperFuncName) self.Visit(t.Arguments[1], tailWrapper{}) w.WriteString(")") @@ -667,7 +662,9 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E writeSwitchCaseOverUnion(w, targetType, unionClassName, switchCase, unionVariableName, self, tail) } - w.WriteStringln(`throw(yardl.RuntimeError("Unexpected union case"))`) + if _, ok := t.Cases[len(t.Cases)-1].Pattern.(*dsl.DiscardPattern); !ok { + w.WriteStringln(`throw(yardl.RuntimeError("Unexpected union case"))`) + } return } @@ -714,12 +711,8 @@ func writeSwitchCaseOverOptional(w *formatting.IndentedWriter, switchCase *dsl.S } if typePattern.Type == nil { - // fmt.Fprintf(w, "if isa(%s, 'yardl.None')\n", variableName) - // fmt.Fprintf(w, "if isa(%s, 'yardl.Optional') && ~%s.has_value()\n", variableName, variableName) fmt.Fprintf(w, "if %s == yardl.None\n", variableName) } else { - // fmt.Fprintf(w, "if ~isa(%s, 'yardl.None')\n", variableName) - // fmt.Fprintf(w, "if isa(%s, 'yardl.Optional') && %s.has_value()\n", variableName, variableName) fmt.Fprintf(w, "if %s ~= yardl.None\n", variableName) } @@ -748,18 +741,13 @@ func writeSwitchCaseOverUnion(w *formatting.IndentedWriter, unionType *dsl.Gener caseIndexOffset = 0 } - log.Warn().Msgf("%d: %s | %d", i, typeCase.Tag, caseIndexOffset) - if dsl.TypesEqual(typePattern.Type, typeCase.Type) { if typePattern.Type == nil { - // fmt.Fprintf(w, "if isa(%s, 'yardl.None')\n", variableName) - // fmt.Fprintf(w, "if isa(%s, 'yardl.Optional') && ~%s.has_value()\n", variableName, variableName) fmt.Fprintf(w, "if %s == yardl.None\n", variableName) common.WriteBlockBody(w, func() { visitor.Visit(switchCase.Expression, tail) }) } else { - // fmt.Fprintf(w, "if isa(%s, %s.%s):\n", variableName, unionClassName, formatting.ToPascalCase(typeCase.Tag)) fmt.Fprintf(w, "if %s.index == %d\n", variableName, i+caseIndexOffset) common.WriteBlockBody(w, func() { if declarationIdentifier != "" { @@ -904,6 +892,12 @@ func typeDefault(t dsl.Type, contextNamespace string, namedType string, st dsl.S case defaultValueKindNone: return "", defaultValueKindNone case defaultValueKindImmutable, defaultValueKindMutable: + if gt, ok := t.Cases[0].Type.(*dsl.GeneralizedType); ok { + switch gt.Dimensionality.(type) { + case *dsl.Vector, *dsl.Array: + return fmt.Sprintf("repelem({%s}, %d)", scalarDefault, *td.Length), scalarDefaultKind + } + } return fmt.Sprintf("repelem(%s, %d)", scalarDefault, *td.Length), defaultValueKindMutable } @@ -935,7 +929,6 @@ func typeDefault(t dsl.Type, contextNamespace string, namedType string, st dsl.S return fmt.Sprintf("%s.empty()", dtype), defaultValueKindMutable case *dsl.Map: - // return "containers.Map", defaultValueKindMutable return "dictionary", defaultValueKindMutable } } From 9d95c90c6fa1d60f8475c08669bc986812d2d762 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Wed, 10 Apr 2024 19:18:12 +0000 Subject: [PATCH 15/32] Add Matlab benchmarking --- .gitignore | 2 + cpp/test/benchmark.cc | 2 +- matlab/{tests => test}/CodedStreamTest.m | 3 + matlab/{tests => test}/ComputedFieldsTest.m | 3 + matlab/{tests => test}/EqualityTest.m | 3 + matlab/{tests => test}/GeneratedTypesTest.m | 3 + matlab/{tests => test}/ProtocolStateTest.m | 3 + .../{tests => test}/ProtocolStateTestReader.m | 3 + .../{tests => test}/ProtocolStateTestWriter.m | 3 + matlab/{tests => test}/RoundTripTest.m | 3 + matlab/{tests => test}/SerializerShapeTest.m | 3 + matlab/{tests => test}/YardlTypesTest.m | 3 + matlab/test/benchmark.m | 265 ++++++++++++++++++ matlab/{tests => test}/invoke_translator.m | 4 +- matlab/test/run.m | 5 + matlab/tests/run.m | 2 - python/benchmark.py | 85 ++++-- .../static_files/+binary/BoolSerializer.m | 4 + .../static_files/+binary/CodedInputStream.m | 5 +- .../static_files/+binary/CodedOutputStream.m | 6 +- .../+binary/Complexfloat32Serializer.m | 22 ++ .../+binary/Complexfloat64Serializer.m | 22 ++ .../static_files/+binary/EnumSerializer.m | 12 + .../+binary/FixedNDArraySerializer.m | 16 +- .../+binary/FixedVectorSerializer.m | 35 ++- .../static_files/+binary/Float32Serializer.m | 4 + .../static_files/+binary/Float64Serializer.m | 4 + .../static_files/+binary/Int8Serializer.m | 4 + .../+binary/NDArraySerializerBase.m | 22 +- .../static_files/+binary/StreamSerializer.m | 43 ++- .../static_files/+binary/TypeSerializer.m | 20 ++ .../static_files/+binary/Uint8Serializer.m | 4 + .../static_files/+binary/VectorSerializer.m | 26 +- 33 files changed, 571 insertions(+), 73 deletions(-) rename matlab/{tests => test}/CodedStreamTest.m (98%) rename matlab/{tests => test}/ComputedFieldsTest.m (99%) rename matlab/{tests => test}/EqualityTest.m (99%) rename matlab/{tests => test}/GeneratedTypesTest.m (99%) rename matlab/{tests => test}/ProtocolStateTest.m (96%) rename matlab/{tests => test}/ProtocolStateTestReader.m (84%) rename matlab/{tests => test}/ProtocolStateTestWriter.m (83%) rename matlab/{tests => test}/RoundTripTest.m (99%) rename matlab/{tests => test}/SerializerShapeTest.m (98%) rename matlab/{tests => test}/YardlTypesTest.m (98%) create mode 100644 matlab/test/benchmark.m rename matlab/{tests => test}/invoke_translator.m (87%) create mode 100644 matlab/test/run.m delete mode 100644 matlab/tests/run.m diff --git a/.gitignore b/.gitignore index 381b10e4..191f3b17 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ cpp/build/ cpp/sandbox/generated/ **/*.bin + +matlab_workspace.mat diff --git a/cpp/test/benchmark.cc b/cpp/test/benchmark.cc index 38001b32..7631e5e1 100644 --- a/cpp/test/benchmark.cc +++ b/cpp/test/benchmark.cc @@ -310,7 +310,7 @@ std::optional> GetScenarioFunction(std::string sce int main(int argc, char* argv[]) { if (argc != 3) { - std::cerr << "Incorrect number of arguments. Usage: banchmark " << std::endl; + std::cerr << "Incorrect number of arguments. Usage: benchmark " << std::endl; return 1; } diff --git a/matlab/tests/CodedStreamTest.m b/matlab/test/CodedStreamTest.m similarity index 98% rename from matlab/tests/CodedStreamTest.m rename to matlab/test/CodedStreamTest.m index d9dffa22..aebec602 100644 --- a/matlab/tests/CodedStreamTest.m +++ b/matlab/test/CodedStreamTest.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef CodedStreamTest < matlab.unittest.TestCase methods (Test) diff --git a/matlab/tests/ComputedFieldsTest.m b/matlab/test/ComputedFieldsTest.m similarity index 99% rename from matlab/tests/ComputedFieldsTest.m rename to matlab/test/ComputedFieldsTest.m index baada9e1..494c844d 100644 --- a/matlab/tests/ComputedFieldsTest.m +++ b/matlab/test/ComputedFieldsTest.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef ComputedFieldsTest < matlab.unittest.TestCase methods (Test) diff --git a/matlab/tests/EqualityTest.m b/matlab/test/EqualityTest.m similarity index 99% rename from matlab/tests/EqualityTest.m rename to matlab/test/EqualityTest.m index c3108d01..9603e4c4 100644 --- a/matlab/tests/EqualityTest.m +++ b/matlab/test/EqualityTest.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef EqualityTest < matlab.unittest.TestCase methods (Test) diff --git a/matlab/tests/GeneratedTypesTest.m b/matlab/test/GeneratedTypesTest.m similarity index 99% rename from matlab/tests/GeneratedTypesTest.m rename to matlab/test/GeneratedTypesTest.m index df5d6284..00de0ce4 100644 --- a/matlab/tests/GeneratedTypesTest.m +++ b/matlab/test/GeneratedTypesTest.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef GeneratedTypesTest < matlab.unittest.TestCase methods (Test) diff --git a/matlab/tests/ProtocolStateTest.m b/matlab/test/ProtocolStateTest.m similarity index 96% rename from matlab/tests/ProtocolStateTest.m rename to matlab/test/ProtocolStateTest.m index 2778fde8..775c7885 100644 --- a/matlab/tests/ProtocolStateTest.m +++ b/matlab/test/ProtocolStateTest.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef ProtocolStateTest < matlab.unittest.TestCase methods (Test) diff --git a/matlab/tests/ProtocolStateTestReader.m b/matlab/test/ProtocolStateTestReader.m similarity index 84% rename from matlab/tests/ProtocolStateTestReader.m rename to matlab/test/ProtocolStateTestReader.m index c803f060..b58701ea 100644 --- a/matlab/tests/ProtocolStateTestReader.m +++ b/matlab/test/ProtocolStateTestReader.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef ProtocolStateTestReader < test_model.StateTestReaderBase methods (Access=protected) diff --git a/matlab/tests/ProtocolStateTestWriter.m b/matlab/test/ProtocolStateTestWriter.m similarity index 83% rename from matlab/tests/ProtocolStateTestWriter.m rename to matlab/test/ProtocolStateTestWriter.m index ce6be5c0..4d49d179 100644 --- a/matlab/tests/ProtocolStateTestWriter.m +++ b/matlab/test/ProtocolStateTestWriter.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef ProtocolStateTestWriter < test_model.StateTestWriterBase methods (Access=protected) diff --git a/matlab/tests/RoundTripTest.m b/matlab/test/RoundTripTest.m similarity index 99% rename from matlab/tests/RoundTripTest.m rename to matlab/test/RoundTripTest.m index e1145ba9..006f8591 100644 --- a/matlab/tests/RoundTripTest.m +++ b/matlab/test/RoundTripTest.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef RoundTripTest < matlab.unittest.TestCase properties (TestParameter) % format = {"binary", "ndjson"}; diff --git a/matlab/tests/SerializerShapeTest.m b/matlab/test/SerializerShapeTest.m similarity index 98% rename from matlab/tests/SerializerShapeTest.m rename to matlab/test/SerializerShapeTest.m index c9433b28..eaf5fd00 100644 --- a/matlab/tests/SerializerShapeTest.m +++ b/matlab/test/SerializerShapeTest.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef SerializerShapeTest < matlab.unittest.TestCase methods (Test) diff --git a/matlab/tests/YardlTypesTest.m b/matlab/test/YardlTypesTest.m similarity index 98% rename from matlab/tests/YardlTypesTest.m rename to matlab/test/YardlTypesTest.m index 74661007..6e034b66 100644 --- a/matlab/tests/YardlTypesTest.m +++ b/matlab/test/YardlTypesTest.m @@ -1,3 +1,6 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + classdef YardlTypesTest < matlab.unittest.TestCase methods (Test) diff --git a/matlab/test/benchmark.m b/matlab/test/benchmark.m new file mode 100644 index 00000000..6c75e704 --- /dev/null +++ b/matlab/test/benchmark.m @@ -0,0 +1,265 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + +function benchmark(varargin) + if nargin ~= 2 + error("Usage: benchmark "); + end + + scenario = parse_scenario(varargin{1}); + format = parse_format(varargin{2}); + + % Matlab support currently implemented for binary format only + if format ~= "binary" + return + end + + addpath("../generated/"); + fprintf("%s\n", scenario(format)); +end + +function output_filename = get_output_filename() + output_filename = "/tmp/benchmark_data.dat"; +end + +function format = parse_format(format) + switch format + case "binary" + format = "binary"; + case "ndjson" + format = "ndjson"; + case "hdf5" + format = "hdf5"; + otherwise + error("Invalid format"); + end +end + +function scenario = parse_scenario(scenario) + switch scenario + case "float256x256" + scenario = @benchmark_float256x256; + case "floatvlen" + scenario = @benchmark_float_vlen; + case "smallint256x256" + scenario = @benchmark_small_int_256x256; + case "smallrecord" + scenario = @benchmark_small_record; + case "smallrecordbatched" + scenario = @benchmark_small_record_batched; + case "smalloptionalsbatched" + scenario = @benchmark_small_optionals_batched; + case "simplemrd" + scenario = @benchmark_simple_mrd; + otherwise + error("Invalid scenario"); + end +end + +function [writer, reader] = create_writer_reader(format, protocol) + format_name = "test_model." + format + "." + protocol; + writer_name = format_name + "Writer"; + reader_name = format_name + "Reader"; + writer = str2func(writer_name); + reader = str2func(reader_name); +end + +function w = create_validating_writer(testCase, format, protocol) + writer_name = "test_model." + format + "." + protocol + "Writer"; + reader_name = "test_model." + format + "." + protocol + "Reader"; + test_writer_name = "test_model.testing.Test" + protocol + "Writer"; + + create_writer = str2func(writer_name); + create_reader = str2func(reader_name); + create_test_writer = str2func(test_writer_name); + + w = create_test_writer(testCase, format, @(f) create_writer(f), @(f) create_reader(f)); +end + +function reps = scale_repetitions(repetitions, scale) + reps = repetitions * scale; +end + +function res = time_scenario(total_bytes_size, write_func, read_func) + delete(get_output_filename()); + + total_size_mi_byte = total_bytes_size / 1024 / 1024; + + write_start = tic; + write_func(); + write_elapsed = toc(write_start); + write_mibps = total_size_mi_byte / write_elapsed; + + read_start = tic; + read_func(); + read_elapsed = toc(read_start); + read_mibps = total_size_mi_byte / read_elapsed; + + s.write_mi_bytes_per_second = write_mibps; + s.read_mi_bytes_per_second = read_mibps; + s.roundtrip_duration_seconds = write_elapsed + read_elapsed; + res = jsonencode(s); +end + +function res = benchmark_float256x256(format) + scale = 1; + + a = zeros(256, 256, 'single'); + for i = 1:numel(a) + a(i) = i - eps; + end + + repetitions = scale_repetitions(1000, scale); + total_bytes = 4 * numel(a) * repetitions; + + [create_writer, create_reader] = create_writer_reader(format, 'BenchmarkFloat256x256'); + + function write() + w = create_writer(get_output_filename()); + for r = 1:repetitions + w.write_float256x256({a}); + end + w.close(); + end + + function read() + r = create_reader(get_output_filename()); + res = r.read_float256x256(); + assert(size(res, 3) == repetitions); + r.close(); + end + + res = time_scenario(total_bytes, @write, @read); +end + +function res = benchmark_float_vlen(format) + scale = 1; + + a = zeros(256, 256, 'single'); + for i = 1:numel(a) + a(i) = i - eps; + end + + repetitions = scale_repetitions(5000, scale); + total_bytes = 4 * numel(a) * repetitions; + + [create_writer, create_reader] = create_writer_reader(format, 'BenchmarkFloatVlen'); + + function write() + w = create_writer(get_output_filename()); + for r = 1:repetitions + w.write_float_array({a}); + end + w.close(); + end + + function read() + r = create_reader(get_output_filename()); + res = r.read_float_array(); + assert(size(res, 2) == repetitions); + r.close(); + end + + res = time_scenario(total_bytes, @write, @read); +end + +function res = benchmark_small_int_256x256(format) + scale = 1; + + a = zeros(256, 256, 'int32'); + for i = 1:numel(a) + a(i) = int32(37); + end + + repetitions = scale_repetitions(10, scale); + total_bytes = 4 * numel(a) * repetitions; + + [create_writer, create_reader] = create_writer_reader(format, 'BenchmarkInt256x256'); + + function write() + w = create_writer(get_output_filename()); + for r = 1:repetitions + w.write_int256x256({a}); + end + w.close(); + end + + function read() + r = create_reader(get_output_filename()); + res = r.read_int256x256(); + assert(size(res, 3) == repetitions); + r.close(); + end + + res = time_scenario(total_bytes, @write, @read); +end + +function res = benchmark_small_record(format) + scale = 1; + + record = test_model.SmallBenchmarkRecord(double(73278383.23123213), single(78323.2820379), single(-2938923.29882)); + + repetitions = scale_repetitions(50000, scale); + total_bytes = 16 * repetitions; + + [create_writer, create_reader] = create_writer_reader(format, 'BenchmarkSmallRecord'); + + function write() + w = create_writer(get_output_filename()); + for r = 1:repetitions + w.write_small_record({record}); + end + w.close(); + end + + function read() + r = create_reader(get_output_filename()); + res = r.read_small_record(); + assert(size(res, 2) == repetitions); + r.close(); + end + + res = time_scenario(total_bytes, @write, @read); +end + +function res = benchmark_small_record_batched(format) + % Batching has not yet been implemented for Matlab + res = ""; +end + +function res = benchmark_small_optionals_batched(format) + % Batching has not yet been implemented for Matlab + res = ""; +end + +function res = benchmark_simple_mrd(format) + scale = 1; + + acq = test_model.SimpleAcquisition(); + acq.data = complex(zeros(256, 32, 'single')); + acq.trajectory = zeros(2, 32, 'single'); + + value = test_model.AcquisitionOrImage.Acquisition(acq); + + repetitions = scale_repetitions(2500, scale); + total_bytes = 66032 * repetitions; + + [create_writer, create_reader] = create_writer_reader(format, 'BenchmarkSimpleMrd'); + + function write() + w = create_writer(get_output_filename()); + for r = 1:repetitions + w.write_data({value}); + end + w.close(); + end + + function read() + r = create_reader(get_output_filename()); + res = r.read_data(); + assert(size(res, 2) == repetitions); + r.close(); + end + + res = time_scenario(total_bytes, @write, @read); +end diff --git a/matlab/tests/invoke_translator.m b/matlab/test/invoke_translator.m similarity index 87% rename from matlab/tests/invoke_translator.m rename to matlab/test/invoke_translator.m index 03bd2611..fee8da68 100644 --- a/matlab/tests/invoke_translator.m +++ b/matlab/test/invoke_translator.m @@ -1,6 +1,8 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + function output_filename = invoke_translator(input_filename, input_format, output_format) translator_path = "../../cpp/build/translator"; - % output_filename = tempname(); output_filename = sprintf("%s.translated", input_filename); dump = "cat"; if ispc diff --git a/matlab/test/run.m b/matlab/test/run.m new file mode 100644 index 00000000..df937d45 --- /dev/null +++ b/matlab/test/run.m @@ -0,0 +1,5 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + +addpath("../generated/"); +runtests(pwd) diff --git a/matlab/tests/run.m b/matlab/tests/run.m deleted file mode 100644 index 74b0b98c..00000000 --- a/matlab/tests/run.m +++ /dev/null @@ -1,2 +0,0 @@ -addpath("../generated/"); -runtests(pwd) diff --git a/python/benchmark.py b/python/benchmark.py index c15f23d5..5912e020 100755 --- a/python/benchmark.py +++ b/python/benchmark.py @@ -39,12 +39,17 @@ class Result: class MutlitingualResults(NamedTuple): cpp: Optional[Result] python: Optional[Result] + matlab: Optional[Result] _cpp_benchmark_path = ( pathlib.Path(__file__).parent / "../cpp/build/benchmark" ).resolve() +_matlab_benchmark_path = ( + (pathlib.Path(__file__).parent / "../matlab/test/benchmark.m").resolve().parent +) + def scale_repetitions(repetitions: int, scale: float): return int(repetitions * scale) @@ -256,6 +261,19 @@ def invoke_cpp_benchmark(scenario: str, format: Format) -> Optional[Result]: return Result(**json.loads(res.stdout), roundtrip_duration_seconds=elapsed_seconds) +def invoke_matlab_benchmark(scenario: str, format: Format) -> Optional[Result]: + res = subprocess.run( + ["matlab", "-batch", f"benchmark('{scenario}', '{format}')"], + cwd=_matlab_benchmark_path, + stdout=subprocess.PIPE, + check=True, + encoding="utf-8", + ) + if res.stdout.strip() == "": + return None + return Result(**json.loads(res.stdout)) + + def scenario_name(scenario_func: Callable[[Format], Optional[Result]]) -> str: return scenario_func.__name__.removeprefix("benchmark").replace("_", "") @@ -265,7 +283,8 @@ def invoke_benchmark( ) -> MutlitingualResults: cpp_res = invoke_cpp_benchmark(scenario_name(scenario_func), format) python_res = scenario_func(format) - return MutlitingualResults(cpp=cpp_res, python=python_res) + matlab_res = invoke_matlab_benchmark(scenario_name(scenario_func), format) + return MutlitingualResults(cpp=cpp_res, python=python_res, matlab=matlab_res) def update_table( @@ -291,28 +310,57 @@ def color(): table.add_row( scenario_name(scenario_func), str(format), - format_float(results.cpp.roundtrip_duration_seconds) - if results.cpp - else None, - format_float(results.python.roundtrip_duration_seconds) - if results.python - else None, + ( + format_float(results.cpp.roundtrip_duration_seconds) + if results.cpp + else None + ), + ( + format_float(results.python.roundtrip_duration_seconds) + if results.python + else None + ), + ( + format_float(results.matlab.roundtrip_duration_seconds) + if results.matlab + else None + ), style=color(), ) else: table.add_row( scenario_name(scenario_func), str(format), - format_float(results.cpp.write_mi_bytes_per_second) - if results.cpp - else None, - format_float(results.cpp.read_mi_bytes_per_second) if results.cpp else None, - format_float(results.python.write_mi_bytes_per_second) - if results.python - else None, - format_float(results.python.read_mi_bytes_per_second) - if results.python - else None, + ( + format_float(results.cpp.write_mi_bytes_per_second) + if results.cpp + else None + ), + ( + format_float(results.cpp.read_mi_bytes_per_second) + if results.cpp + else None + ), + ( + format_float(results.python.write_mi_bytes_per_second) + if results.python + else None + ), + ( + format_float(results.python.read_mi_bytes_per_second) + if results.python + else None + ), + ( + format_float(results.matlab.write_mi_bytes_per_second) + if results.matlab + else None + ), + ( + format_float(results.matlab.read_mi_bytes_per_second) + if results.matlab + else None + ), style=color(), ) live.refresh() @@ -326,6 +374,7 @@ def color(): table.add_column("Format") table.add_column("C++ Duration", justify="right") table.add_column("Python Duration", justify="right") + table.add_column("Matlab Duration", justify="right") else: table.title = "Throughput in MiB/s" table.add_column("Scenario") @@ -334,6 +383,8 @@ def color(): table.add_column("C++ Read", justify="right") table.add_column("Python Write", justify="right") table.add_column("Python Read", justify="right") + table.add_column("Matlab Write", justify="right") + table.add_column("Matlab Read", justify="right") with Live(table, auto_refresh=False) as live: for _, benchmark_func in inspect.getmembers( diff --git a/tooling/internal/matlab/static_files/+binary/BoolSerializer.m b/tooling/internal/matlab/static_files/+binary/BoolSerializer.m index c59f5f5f..aad498cc 100755 --- a/tooling/internal/matlab/static_files/+binary/BoolSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/BoolSerializer.m @@ -17,5 +17,9 @@ function write( outstream, value) function c = getClass() c = 'logical'; end + + function trivial = isTriviallySerializable() + trivial = true; + end end end diff --git a/tooling/internal/matlab/static_files/+binary/CodedInputStream.m b/tooling/internal/matlab/static_files/+binary/CodedInputStream.m index cf449091..9d2e9d12 100755 --- a/tooling/internal/matlab/static_files/+binary/CodedInputStream.m +++ b/tooling/internal/matlab/static_files/+binary/CodedInputStream.m @@ -39,6 +39,10 @@ function close(self) res = fread(self.fid_, 1, "*uint8"); end + function res = read_values_directly(self, shape, precision) + res = fread(self.fid_, shape, "*"+precision); + end + function res = read_unsigned_varint(self) res = uint64(0); shift = uint8(0); @@ -55,7 +59,6 @@ function close(self) function res = zigzag_decode(~, value) value = uint64(value); - % res = int64(bitxor(bitshift(value, -1), -bitand(value, 1))); res = bitxor(int64(bitshift(value, -1)), -int64(bitand(value, 1))); end diff --git a/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m b/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m index 227620d4..d69c2e77 100755 --- a/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m +++ b/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m @@ -11,7 +11,7 @@ methods function self = CodedOutputStream(output) if isa(output, "string") || isa(output, "char") - [fileId, errMsg] = fopen(output, "w"); + [fileId, errMsg] = fopen(output, "W"); if fileId < 0 throw(yardl.binary.Exception(errMsg)); end @@ -47,6 +47,10 @@ function write_byte_no_check(self, value) fwrite(self.fid_, value, "uint8"); end + function write_values_directly(self, values, precision) + fwrite(self.fid_, values, precision); + end + function write_unsigned_varint(self, value) assert(isscalar(value)); diff --git a/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m b/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m index f2a1dc37..dd37f7e9 100755 --- a/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m @@ -25,5 +25,27 @@ function write(outstream, value) function c = getClass() c = 'single'; end + + function trivial = isTriviallySerializable() + trivial = true; + end + end + + methods + function writeTrivially(self, stream, values) + rp = real(values); + ip = imag(values); + parts(1, :) = rp(:); + parts(2, :) = ip(:); + stream.write_values_directly(parts, self.getClass()); + end + + function res = readTrivially(obj, stream, shape) + assert(ndims(shape) == 2); + partshape = [2*shape(1) shape(2)]; + res = stream.read_values_directly(partshape, obj.getClass()); + res = reshape(res, [2 shape]); + res = squeeze(complex(res(1, :, :), res(2, :, :))); + end end end diff --git a/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m b/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m index 9bb336f7..895913a6 100755 --- a/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m @@ -20,5 +20,27 @@ function write(outstream, value) function c = getClass() c = 'double'; end + + function trivial = isTriviallySerializable() + trivial = true; + end + end + + methods + function writeTrivially(self, stream, values) + rp = real(values); + ip = imag(values); + parts(1, :) = rp(:); + parts(2, :) = ip(:); + stream.write_values_directly(parts, self.getClass()); + end + + function res = readTrivially(obj, stream, shape) + assert(ndims(shape) == 2); + partshape = [2*shape(1) shape(2)]; + res = stream.read_values_directly(partshape, obj.getClass()); + res = reshape(res, [2 shape]); + res = squeeze(complex(res(1, :, :), res(2, :, :))); + end end end diff --git a/tooling/internal/matlab/static_files/+binary/EnumSerializer.m b/tooling/internal/matlab/static_files/+binary/EnumSerializer.m index 577722b9..d3bdbc45 100644 --- a/tooling/internal/matlab/static_files/+binary/EnumSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/EnumSerializer.m @@ -27,5 +27,17 @@ function write(obj, outstream, value) function c = getClass(obj) c = obj.classname_; end + + function trivial = isTriviallySerializable(obj) + trivial = obj.integer_serializer_.isTriviallySerializable(); + end + + function writeTrivially(self, outstream, values) + self.integer_serializer_.writeTrivially(outstream, values); + end + + function res = readTrivially(self, instream, shape) + res = self.integer_serializer_.readTrivially(instream, shape); + end end end diff --git a/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m index 10122a9c..96cc47aa 100644 --- a/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m @@ -42,8 +42,6 @@ function write(self, outstream, values) end function value = read(self, instream) - % TODO: Better way of doing this? Possibly needed elsewhere to? - % self.shape_ should really be non-scalar... if isscalar(self.shape_) value = self.read_data_(instream, [1 self.shape_]); else @@ -55,8 +53,6 @@ function write(self, outstream, values) item_shape = obj.item_serializer_.getShape(); if isempty(item_shape) s = obj.shape_; - elseif isscalar(item_shape) - s = [item_shape obj.shape_ ]; else s = [item_shape obj.shape_]; end @@ -65,5 +61,17 @@ function write(self, outstream, values) s = s(s>1); end end + + function trivial = isTriviallySerializable(obj) + trivial = obj.item_serializer_.isTriviallySerializable(); + end + + function writeTrivially(self, outstream, values) + self.item_serializer_.writeTrivially(outstream, values); + end + + function res = readTrivially(self, instream, shape) + res = self.item_serializer_.readTrivially(instream, shape); + end end end diff --git a/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m b/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m index 7c084fc8..ad3d7788 100644 --- a/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m @@ -17,7 +17,6 @@ function write(obj, outstream, values) if iscolumn(values) values = transpose(values); end - s = size(values); count = s(end); @@ -31,6 +30,11 @@ function write(obj, outstream, values) obj.item_serializer_.write(outstream, values{i}); end else + if obj.item_serializer_.isTriviallySerializable() + obj.item_serializer_.writeTrivially(outstream, values); + return + end + if ndims(values) > 2 r = reshape(values, [], count); for i = 1:count @@ -39,7 +43,6 @@ function write(obj, outstream, values) end else for i = 1:count - % obj.item_serializer_.write(outstream, values(:, i)); obj.item_serializer_.write(outstream, transpose(values(:, i))); end end @@ -53,18 +56,22 @@ function write(obj, outstream, values) for i = 1:obj.length_ res{i} = obj.item_serializer_.read(instream); end - elseif isscalar(item_shape) - res = yardl.allocate(obj.getClass(), obj.getShape()); - for i = 1:obj.length_ - res(i) = obj.item_serializer_.read(instream); - end + return + end + + if obj.item_serializer_.isTriviallySerializable() + res = obj.item_serializer_.readTrivially(instream, [prod(item_shape), obj.length_]); else res = yardl.allocate(obj.getClass(), [prod(item_shape), obj.length_]); for i = 1:obj.length_ item = obj.item_serializer_.read(instream); res(:, i) = item(:); end - res = squeeze(reshape(res, [item_shape, obj.length_])); + end + + res = squeeze(reshape(res, [item_shape, obj.length_])); + if iscolumn(res) + res = transpose(res); end end @@ -83,5 +90,17 @@ function write(obj, outstream, values) s = s(s>1); end end + + function trivial = isTriviallySerializable(obj) + trivial = obj.item_serializer_.isTriviallySerializable(); + end + + function writeTrivially(self, outstream, values) + self.item_serializer_.writeTrivially(outstream, values); + end + + function res = readTrivially(self, instream, shape) + res = self.item_serializer_.readTrivially(instream, shape); + end end end diff --git a/tooling/internal/matlab/static_files/+binary/Float32Serializer.m b/tooling/internal/matlab/static_files/+binary/Float32Serializer.m index 898d0dd4..7dce00b2 100755 --- a/tooling/internal/matlab/static_files/+binary/Float32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Float32Serializer.m @@ -20,5 +20,9 @@ function write(outstream, value) function c = getClass() c = 'single'; end + + function trivial = isTriviallySerializable() + trivial = true; + end end end diff --git a/tooling/internal/matlab/static_files/+binary/Float64Serializer.m b/tooling/internal/matlab/static_files/+binary/Float64Serializer.m index 69723866..4a473873 100755 --- a/tooling/internal/matlab/static_files/+binary/Float64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Float64Serializer.m @@ -17,5 +17,9 @@ function write(outstream, value) function c = getClass() c = 'double'; end + + function trivial = isTriviallySerializable() + trivial = true; + end end end diff --git a/tooling/internal/matlab/static_files/+binary/Int8Serializer.m b/tooling/internal/matlab/static_files/+binary/Int8Serializer.m index 0c98da3f..62ddecf0 100755 --- a/tooling/internal/matlab/static_files/+binary/Int8Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int8Serializer.m @@ -17,5 +17,9 @@ function write(outstream, value) function c = getClass() c = 'int8'; end + + function trivial = isTriviallySerializable() + trivial = true; + end end end diff --git a/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m b/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m index a6b21b6e..3f1f28ad 100644 --- a/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m +++ b/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m @@ -22,6 +22,11 @@ function write_data_(self, outstream, values) % N is the "flattened" dimension of the NDArray, and % A, B, ... are the dimensions of the inner items. + if ~iscell(values) && self.item_serializer_.isTriviallySerializable() + self.item_serializer_.writeTrivially(outstream, values); + return; + end + sz = size(values); if ndims(values) > 2 @@ -62,19 +67,22 @@ function write_data_(self, outstream, values) for i = 1:flat_length res{i} = self.item_serializer_.read(instream); end - elseif isscalar(item_shape) - res = yardl.allocate(self.getClass(), shape); - for i = 1:flat_length - res(i) = self.item_serializer_.read(instream); - end - res = squeeze(res); + return + end + + if self.item_serializer_.isTriviallySerializable() + res = self.item_serializer_.readTrivially(instream, [prod(item_shape), flat_length]); else res = yardl.allocate(self.getClass(), [prod(item_shape), flat_length]); for i = 1:flat_length item = self.item_serializer_.read(instream); res(:, i) = item(:); end - res = squeeze(reshape(res, [item_shape shape])); + end + + res = squeeze(reshape(res, [item_shape shape])); + if iscolumn(res) + res = transpose(res); end end end diff --git a/tooling/internal/matlab/static_files/+binary/StreamSerializer.m b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m index a6b48d01..0da21b7e 100644 --- a/tooling/internal/matlab/static_files/+binary/StreamSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m @@ -16,6 +16,9 @@ function write(obj, outstream, values) return; end + if iscolumn(values) + values = transpose(values); + end s = size(values); count = s(end); outstream.write_unsigned_varint(count); @@ -35,7 +38,6 @@ function write(obj, outstream, values) end else for i = 1:count - % obj.item_serializer_.write(outstream, values(:, i)); obj.item_serializer_.write(outstream, transpose(values(:, i))); end end @@ -60,30 +62,25 @@ function write(obj, outstream, values) end count = instream.read_unsigned_varint(); end - elseif isscalar(item_shape) - res = yardl.allocate(obj.getClass(), [item_shape, count]); - idx = 1; - while count > 0 - for c = 1:count - res(idx) = obj.item_serializer_.read(instream); - idx = idx + 1; - end - count = instream.read_unsigned_varint(); - end - else - res = yardl.allocate(obj.getClass(), [prod(item_shape), count]); - total_count = 0; - while count > 0 - for c = 1:count - idx = total_count + c; - item = obj.item_serializer_.read(instream); - res(:, idx) = item(:); - end + return + end - total_count = total_count + count; - count = instream.read_unsigned_varint(); + res = yardl.allocate(obj.getClass(), [prod(item_shape), count]); + total_count = 0; + while count > 0 + for c = 1:count + idx = total_count + c; + item = obj.item_serializer_.read(instream); + res(:, idx) = item(:); end - res = squeeze(reshape(res, [item_shape, total_count])); + + total_count = total_count + count; + count = instream.read_unsigned_varint(); + end + + res = squeeze(reshape(res, [item_shape, total_count])); + if iscolumn(res) + res = transpose(res); end end diff --git a/tooling/internal/matlab/static_files/+binary/TypeSerializer.m b/tooling/internal/matlab/static_files/+binary/TypeSerializer.m index 0f2a2bec..8657bea3 100755 --- a/tooling/internal/matlab/static_files/+binary/TypeSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/TypeSerializer.m @@ -12,5 +12,25 @@ function s = getShape() s = 1; end + + function trivial = isTriviallySerializable() + trivial = false; + end + end + + methods + function writeTrivially(obj, stream, values) + if ~obj.isTriviallySerializable() + error("Not implemented for non-trivially-serializable types") + end + stream.write_values_directly(values, obj.getClass()); + end + + function res = readTrivially(obj, stream, shape) + if ~obj.isTriviallySerializable() + error("Not implemented for non-trivially-serializable types") + end + res = stream.read_values_directly(shape, obj.getClass()); + end end end diff --git a/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m index 679589dd..8ee643db 100755 --- a/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m @@ -16,5 +16,9 @@ function write(outstream, value) function c = getClass() c = 'uint8'; end + + function trivial = isTriviallySerializable() + trivial = true; + end end end diff --git a/tooling/internal/matlab/static_files/+binary/VectorSerializer.m b/tooling/internal/matlab/static_files/+binary/VectorSerializer.m index 30199f5d..2631d815 100644 --- a/tooling/internal/matlab/static_files/+binary/VectorSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/VectorSerializer.m @@ -12,6 +12,9 @@ end function write(obj, outstream, values) + if iscolumn(values) + values = transpose(values); + end s = size(values); count = s(end); outstream.write_unsigned_varint(count); @@ -24,6 +27,11 @@ function write(obj, outstream, values) end else % values is an array, so must have shape [A, B, ..., COUNT] + if obj.item_serializer_.isTriviallySerializable() + obj.item_serializer_.writeTrivially(outstream, values); + return + end + if ndims(values) > 2 r = reshape(values, [], count); for i = 1:count @@ -32,7 +40,6 @@ function write(obj, outstream, values) end else for i = 1:count - % obj.item_serializer_.write(outstream, values(:, i)); obj.item_serializer_.write(outstream, transpose(values(:, i))); end end @@ -52,19 +59,22 @@ function write(obj, outstream, values) for i = 1:count res{i} = obj.item_serializer_.read(instream); end - elseif isscalar(item_shape) - res = yardl.allocate(obj.getClass(), [1 count]); - for i = 1:count - res(i) = obj.item_serializer_.read(instream); - end - res = squeeze(res); + return + end + + if obj.item_serializer_.isTriviallySerializable() + res = obj.item_serializer_.readTrivially(instream, [prod(item_shape), count]); else res = yardl.allocate(obj.getClass(), [prod(item_shape), count]); for i = 1:count item = obj.item_serializer_.read(instream); res(:, i) = item(:); end - res = squeeze(reshape(res, [item_shape, total_count])); + end + + res = squeeze(reshape(res, [item_shape, count])); + if iscolumn(res) + res = transpose(res); end end From df42d4f81ee83bb79989b07cd775fcb21b40976d Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Thu, 11 Apr 2024 21:16:31 +0000 Subject: [PATCH 16/32] Fix streams to read one item at a time Instead of the entire stream into memory. --- .../+binary/AdvancedGenericsReader.m | 28 ++++--- .../+binary/AdvancedGenericsWriter.m | 28 ++++--- .../+test_model/+binary/AliasesReader.m | 57 ++++++++----- .../+test_model/+binary/AliasesWriter.m | 53 +++++++----- .../+binary/BenchmarkFloat256x256Reader.m | 12 ++- .../+binary/BenchmarkFloat256x256Writer.m | 8 +- .../+binary/BenchmarkFloatVlenReader.m | 12 ++- .../+binary/BenchmarkFloatVlenWriter.m | 8 +- .../+binary/BenchmarkInt256x256Reader.m | 12 ++- .../+binary/BenchmarkInt256x256Writer.m | 8 +- .../+binary/BenchmarkSimpleMrdReader.m | 12 ++- .../+binary/BenchmarkSimpleMrdWriter.m | 8 +- .../+binary/BenchmarkSmallRecordReader.m | 12 ++- .../BenchmarkSmallRecordWithOptionalsReader.m | 12 ++- .../BenchmarkSmallRecordWithOptionalsWriter.m | 8 +- .../+binary/BenchmarkSmallRecordWriter.m | 8 +- .../+binary/DynamicNDArraysReader.m | 23 +++-- .../+binary/DynamicNDArraysWriter.m | 23 +++-- .../+test_model/+binary/EnumsReader.m | 18 ++-- .../+test_model/+binary/EnumsWriter.m | 18 ++-- .../+test_model/+binary/FixedArraysReader.m | 28 ++++--- .../+test_model/+binary/FixedArraysWriter.m | 28 ++++--- .../+test_model/+binary/FixedVectorsReader.m | 23 +++-- .../+test_model/+binary/FixedVectorsWriter.m | 23 +++-- .../+test_model/+binary/FlagsReader.m | 21 ++++- .../+test_model/+binary/FlagsWriter.m | 13 ++- .../+test_model/+binary/MapsReader.m | 23 +++-- .../+test_model/+binary/MapsWriter.m | 23 +++-- .../+test_model/+binary/NDArraysReader.m | 28 ++++--- .../+binary/NDArraysSingleDimensionReader.m | 23 +++-- .../+binary/NDArraysSingleDimensionWriter.m | 23 +++-- .../+test_model/+binary/NDArraysWriter.m | 28 ++++--- .../+test_model/+binary/NestedRecordsReader.m | 8 +- .../+test_model/+binary/NestedRecordsWriter.m | 8 +- .../+binary/OptionalVectorsReader.m | 8 +- .../+binary/OptionalVectorsWriter.m | 8 +- .../ProtocolWithComputedFieldsReader.m | 8 +- .../ProtocolWithComputedFieldsWriter.m | 8 +- .../+binary/ProtocolWithKeywordStepsReader.m | 17 +++- .../+binary/ProtocolWithKeywordStepsWriter.m | 13 ++- .../+binary/ScalarOptionalsReader.m | 23 +++-- .../+binary/ScalarOptionalsWriter.m | 23 +++-- .../+test_model/+binary/ScalarsReader.m | 13 ++- .../+test_model/+binary/ScalarsWriter.m | 13 ++- .../+binary/SimpleGenericsReader.m | 52 ++++++++---- .../+binary/SimpleGenericsWriter.m | 48 +++++++---- .../+test_model/+binary/StateTestReader.m | 22 +++-- .../+test_model/+binary/StateTestWriter.m | 18 ++-- .../+binary/StreamsOfAliasedUnionsReader.m | 21 ++++- .../+binary/StreamsOfAliasedUnionsWriter.m | 13 ++- .../+binary/StreamsOfUnionsReader.m | 21 ++++- .../+binary/StreamsOfUnionsWriter.m | 13 ++- .../+test_model/+binary/StreamsReader.m | 39 +++++++-- .../+test_model/+binary/StreamsWriter.m | 23 +++-- .../+test_model/+binary/StringsReader.m | 13 ++- .../+test_model/+binary/StringsWriter.m | 13 ++- .../+binary/SubarraysInRecordsReader.m | 13 ++- .../+binary/SubarraysInRecordsWriter.m | 13 ++- .../+test_model/+binary/SubarraysReader.m | 48 +++++++---- .../+test_model/+binary/SubarraysWriter.m | 48 +++++++---- .../+test_model/+binary/UnionsReader.m | 23 +++-- .../+test_model/+binary/UnionsWriter.m | 23 +++-- .../+test_model/+binary/VlensReader.m | 23 +++-- .../+test_model/+binary/VlensWriter.m | 23 +++-- .../+test_model/AdvancedGenericsReaderBase.m | 35 +++++--- .../generated/+test_model/AliasesReaderBase.m | 83 ++++++++++++++----- .../BenchmarkFloat256x256ReaderBase.m | 20 ++++- .../BenchmarkFloatVlenReaderBase.m | 20 ++++- .../BenchmarkInt256x256ReaderBase.m | 20 ++++- .../BenchmarkSimpleMrdReaderBase.m | 20 ++++- .../BenchmarkSmallRecordReaderBase.m | 20 ++++- ...chmarkSmallRecordWithOptionalsReaderBase.m | 20 ++++- .../+test_model/DynamicNDArraysReaderBase.m | 28 +++++-- .../generated/+test_model/EnumsReaderBase.m | 21 +++-- .../+test_model/FixedArraysReaderBase.m | 35 +++++--- .../+test_model/FixedVectorsReaderBase.m | 28 +++++-- .../generated/+test_model/FlagsReaderBase.m | 40 +++++++-- matlab/generated/+test_model/MapsReaderBase.m | 28 +++++-- .../+test_model/NDArraysReaderBase.m | 35 +++++--- .../NDArraysSingleDimensionReaderBase.m | 28 +++++-- .../+test_model/NestedRecordsReaderBase.m | 7 +- .../+test_model/OptionalVectorsReaderBase.m | 7 +- .../ProtocolWithComputedFieldsReaderBase.m | 7 +- .../ProtocolWithKeywordStepsReaderBase.m | 27 ++++-- .../+test_model/ScalarOptionalsReaderBase.m | 28 +++++-- .../generated/+test_model/ScalarsReaderBase.m | 14 +++- .../+test_model/SimpleGenericsReaderBase.m | 76 ++++++++++++----- .../+test_model/StateTestReaderBase.m | 34 ++++++-- .../StreamsOfAliasedUnionsReaderBase.m | 40 +++++++-- .../+test_model/StreamsOfUnionsReaderBase.m | 40 +++++++-- .../generated/+test_model/StreamsReaderBase.m | 80 +++++++++++++++--- .../generated/+test_model/StringsReaderBase.m | 14 +++- .../SubarraysInRecordsReaderBase.m | 14 +++- .../+test_model/SubarraysReaderBase.m | 63 ++++++++++---- .../generated/+test_model/UnionsReaderBase.m | 28 +++++-- .../generated/+test_model/VlensReaderBase.m | 28 +++++-- matlab/test/CodedStreamTest.m | 40 +++++++++ matlab/test/ProtocolStateTest.m | 9 +- matlab/test/ProtocolStateTestReader.m | 15 +++- matlab/test/benchmark.m | 44 +++++++--- tooling/internal/matlab/binary/binary.go | 41 +++++++-- tooling/internal/matlab/common/common.go | 8 ++ .../internal/matlab/protocols/protocols.go | 35 ++++++-- .../static_files/+binary/CodedInputStream.m | 1 - .../static_files/+binary/StreamSerializer.m | 48 ++++------- 105 files changed, 1835 insertions(+), 706 deletions(-) diff --git a/matlab/generated/+test_model/+binary/AdvancedGenericsReader.m b/matlab/generated/+test_model/+binary/AdvancedGenericsReader.m index 8a04c248..f39d020b 100644 --- a/matlab/generated/+test_model/+binary/AdvancedGenericsReader.m +++ b/matlab/generated/+test_model/+binary/AdvancedGenericsReader.m @@ -2,37 +2,45 @@ classdef AdvancedGenericsReader < yardl.binary.BinaryProtocolReader & test_model.AdvancedGenericsReaderBase % Binary reader for the AdvancedGenerics protocol + properties (Access=protected) + float_image_image_serializer + generic_record_1_serializer + tuple_of_optionals_serializer + tuple_of_optionals_alternate_syntax_serializer + tuple_of_vectors_serializer + end + methods function obj = AdvancedGenericsReader(filename) obj@test_model.AdvancedGenericsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.AdvancedGenericsReaderBase.schema); + obj.float_image_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), 2); + obj.generic_record_1_serializer = test_model.binary.GenericRecordSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + obj.tuple_of_optionals_serializer = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); + obj.tuple_of_optionals_alternate_syntax_serializer = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); + obj.tuple_of_vectors_serializer = tuples.binary.TupleSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), yardl.binary.VectorSerializer(yardl.binary.Float32Serializer)); end end methods (Access=protected) function value = read_float_image_image_(obj) - r = yardl.binary.NDArraySerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), 2); - value = r.read(obj.stream_); + value = obj.float_image_image_serializer.read(obj.stream_); end function value = read_generic_record_1_(obj) - r = test_model.binary.GenericRecordSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); - value = r.read(obj.stream_); + value = obj.generic_record_1_serializer.read(obj.stream_); end function value = read_tuple_of_optionals_(obj) - r = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); - value = r.read(obj.stream_); + value = obj.tuple_of_optionals_serializer.read(obj.stream_); end function value = read_tuple_of_optionals_alternate_syntax_(obj) - r = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); - value = r.read(obj.stream_); + value = obj.tuple_of_optionals_alternate_syntax_serializer.read(obj.stream_); end function value = read_tuple_of_vectors_(obj) - r = tuples.binary.TupleSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), yardl.binary.VectorSerializer(yardl.binary.Float32Serializer)); - value = r.read(obj.stream_); + value = obj.tuple_of_vectors_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m b/matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m index 1ba5e946..78686999 100644 --- a/matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m +++ b/matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m @@ -2,37 +2,45 @@ classdef AdvancedGenericsWriter < yardl.binary.BinaryProtocolWriter & test_model.AdvancedGenericsWriterBase % Binary writer for the AdvancedGenerics protocol + properties (Access=protected) + float_image_image_serializer + generic_record_1_serializer + tuple_of_optionals_serializer + tuple_of_optionals_alternate_syntax_serializer + tuple_of_vectors_serializer + end + methods function obj = AdvancedGenericsWriter(filename) obj@test_model.AdvancedGenericsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.AdvancedGenericsWriterBase.schema); + obj.float_image_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), 2); + obj.generic_record_1_serializer = test_model.binary.GenericRecordSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + obj.tuple_of_optionals_serializer = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); + obj.tuple_of_optionals_alternate_syntax_serializer = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); + obj.tuple_of_vectors_serializer = tuples.binary.TupleSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), yardl.binary.VectorSerializer(yardl.binary.Float32Serializer)); end end methods (Access=protected) function write_float_image_image_(obj, value) - w = yardl.binary.NDArraySerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), 2); - w.write(obj.stream_, value); + obj.float_image_image_serializer.write(obj.stream_, value); end function write_generic_record_1_(obj, value) - w = test_model.binary.GenericRecordSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); - w.write(obj.stream_, value); + obj.generic_record_1_serializer.write(obj.stream_, value); end function write_tuple_of_optionals_(obj, value) - w = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); - w.write(obj.stream_, value); + obj.tuple_of_optionals_serializer.write(obj.stream_, value); end function write_tuple_of_optionals_alternate_syntax_(obj, value) - w = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); - w.write(obj.stream_, value); + obj.tuple_of_optionals_alternate_syntax_serializer.write(obj.stream_, value); end function write_tuple_of_vectors_(obj, value) - w = tuples.binary.TupleSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), yardl.binary.VectorSerializer(yardl.binary.Float32Serializer)); - w.write(obj.stream_, value); + obj.tuple_of_vectors_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/AliasesReader.m b/matlab/generated/+test_model/+binary/AliasesReader.m index 99955a88..aef2cde1 100644 --- a/matlab/generated/+test_model/+binary/AliasesReader.m +++ b/matlab/generated/+test_model/+binary/AliasesReader.m @@ -2,62 +2,79 @@ classdef AliasesReader < yardl.binary.BinaryProtocolReader & test_model.AliasesReaderBase % Binary reader for the Aliases protocol + properties (Access=protected) + aliased_string_serializer + aliased_enum_serializer + aliased_open_generic_serializer + aliased_closed_generic_serializer + aliased_optional_serializer + aliased_generic_optional_serializer + aliased_generic_union_2_serializer + aliased_generic_vector_serializer + aliased_generic_fixed_vector_serializer + stream_of_aliased_generic_union_2_serializer + end + methods function obj = AliasesReader(filename) obj@test_model.AliasesReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.AliasesReaderBase.schema); + obj.aliased_string_serializer = yardl.binary.StringSerializer; + obj.aliased_enum_serializer = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); + obj.aliased_open_generic_serializer = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + obj.aliased_closed_generic_serializer = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + obj.aliased_optional_serializer = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); + obj.aliased_generic_optional_serializer = yardl.binary.OptionalSerializer(yardl.binary.Float32Serializer); + obj.aliased_generic_union_2_serializer = yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2}); + obj.aliased_generic_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Float32Serializer); + obj.aliased_generic_fixed_vector_serializer = yardl.binary.FixedVectorSerializer(yardl.binary.Float32Serializer, 3); + obj.stream_of_aliased_generic_union_2_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2})); end end methods (Access=protected) function value = read_aliased_string_(obj) - r = yardl.binary.StringSerializer; - value = r.read(obj.stream_); + value = obj.aliased_string_serializer.read(obj.stream_); end function value = read_aliased_enum_(obj) - r = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); - value = r.read(obj.stream_); + value = obj.aliased_enum_serializer.read(obj.stream_); end function value = read_aliased_open_generic_(obj) - r = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); - value = r.read(obj.stream_); + value = obj.aliased_open_generic_serializer.read(obj.stream_); end function value = read_aliased_closed_generic_(obj) - r = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); - value = r.read(obj.stream_); + value = obj.aliased_closed_generic_serializer.read(obj.stream_); end function value = read_aliased_optional_(obj) - r = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); - value = r.read(obj.stream_); + value = obj.aliased_optional_serializer.read(obj.stream_); end function value = read_aliased_generic_optional_(obj) - r = yardl.binary.OptionalSerializer(yardl.binary.Float32Serializer); - value = r.read(obj.stream_); + value = obj.aliased_generic_optional_serializer.read(obj.stream_); end function value = read_aliased_generic_union_2_(obj) - r = yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2}); - value = r.read(obj.stream_); + value = obj.aliased_generic_union_2_serializer.read(obj.stream_); end function value = read_aliased_generic_vector_(obj) - r = yardl.binary.VectorSerializer(yardl.binary.Float32Serializer); - value = r.read(obj.stream_); + value = obj.aliased_generic_vector_serializer.read(obj.stream_); end function value = read_aliased_generic_fixed_vector_(obj) - r = yardl.binary.FixedVectorSerializer(yardl.binary.Float32Serializer, 3); - value = r.read(obj.stream_); + value = obj.aliased_generic_fixed_vector_serializer.read(obj.stream_); + end + + function more = has_stream_of_aliased_generic_union_2_(obj) + more = obj.stream_of_aliased_generic_union_2_serializer.hasnext(obj.stream_); end function value = read_stream_of_aliased_generic_union_2_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2})); - value = r.read(obj.stream_); + value = obj.stream_of_aliased_generic_union_2_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/AliasesWriter.m b/matlab/generated/+test_model/+binary/AliasesWriter.m index 39d05136..2982acc9 100644 --- a/matlab/generated/+test_model/+binary/AliasesWriter.m +++ b/matlab/generated/+test_model/+binary/AliasesWriter.m @@ -2,62 +2,75 @@ classdef AliasesWriter < yardl.binary.BinaryProtocolWriter & test_model.AliasesWriterBase % Binary writer for the Aliases protocol + properties (Access=protected) + aliased_string_serializer + aliased_enum_serializer + aliased_open_generic_serializer + aliased_closed_generic_serializer + aliased_optional_serializer + aliased_generic_optional_serializer + aliased_generic_union_2_serializer + aliased_generic_vector_serializer + aliased_generic_fixed_vector_serializer + stream_of_aliased_generic_union_2_serializer + end + methods function obj = AliasesWriter(filename) obj@test_model.AliasesWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.AliasesWriterBase.schema); + obj.aliased_string_serializer = yardl.binary.StringSerializer; + obj.aliased_enum_serializer = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); + obj.aliased_open_generic_serializer = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + obj.aliased_closed_generic_serializer = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + obj.aliased_optional_serializer = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); + obj.aliased_generic_optional_serializer = yardl.binary.OptionalSerializer(yardl.binary.Float32Serializer); + obj.aliased_generic_union_2_serializer = yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2}); + obj.aliased_generic_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Float32Serializer); + obj.aliased_generic_fixed_vector_serializer = yardl.binary.FixedVectorSerializer(yardl.binary.Float32Serializer, 3); + obj.stream_of_aliased_generic_union_2_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2})); end end methods (Access=protected) function write_aliased_string_(obj, value) - w = yardl.binary.StringSerializer; - w.write(obj.stream_, value); + obj.aliased_string_serializer.write(obj.stream_, value); end function write_aliased_enum_(obj, value) - w = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); - w.write(obj.stream_, value); + obj.aliased_enum_serializer.write(obj.stream_, value); end function write_aliased_open_generic_(obj, value) - w = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); - w.write(obj.stream_, value); + obj.aliased_open_generic_serializer.write(obj.stream_, value); end function write_aliased_closed_generic_(obj, value) - w = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); - w.write(obj.stream_, value); + obj.aliased_closed_generic_serializer.write(obj.stream_, value); end function write_aliased_optional_(obj, value) - w = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); - w.write(obj.stream_, value); + obj.aliased_optional_serializer.write(obj.stream_, value); end function write_aliased_generic_optional_(obj, value) - w = yardl.binary.OptionalSerializer(yardl.binary.Float32Serializer); - w.write(obj.stream_, value); + obj.aliased_generic_optional_serializer.write(obj.stream_, value); end function write_aliased_generic_union_2_(obj, value) - w = yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2}); - w.write(obj.stream_, value); + obj.aliased_generic_union_2_serializer.write(obj.stream_, value); end function write_aliased_generic_vector_(obj, value) - w = yardl.binary.VectorSerializer(yardl.binary.Float32Serializer); - w.write(obj.stream_, value); + obj.aliased_generic_vector_serializer.write(obj.stream_, value); end function write_aliased_generic_fixed_vector_(obj, value) - w = yardl.binary.FixedVectorSerializer(yardl.binary.Float32Serializer, 3); - w.write(obj.stream_, value); + obj.aliased_generic_fixed_vector_serializer.write(obj.stream_, value); end function write_stream_of_aliased_generic_union_2_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2})); - w.write(obj.stream_, value); + obj.stream_of_aliased_generic_union_2_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m index 62d563c1..3428aa88 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m @@ -2,17 +2,25 @@ classdef BenchmarkFloat256x256Reader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkFloat256x256ReaderBase % Binary reader for the BenchmarkFloat256x256 protocol + properties (Access=protected) + float256x256_serializer + end + methods function obj = BenchmarkFloat256x256Reader(filename) obj@test_model.BenchmarkFloat256x256ReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkFloat256x256ReaderBase.schema); + obj.float256x256_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [256, 256])); end end methods (Access=protected) + function more = has_float256x256_(obj) + more = obj.float256x256_serializer.hasnext(obj.stream_); + end + function value = read_float256x256_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [256, 256])); - value = r.read(obj.stream_); + value = obj.float256x256_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m index 6ed48fa6..967cb1fd 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m +++ b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m @@ -2,17 +2,21 @@ classdef BenchmarkFloat256x256Writer < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkFloat256x256WriterBase % Binary writer for the BenchmarkFloat256x256 protocol + properties (Access=protected) + float256x256_serializer + end + methods function obj = BenchmarkFloat256x256Writer(filename) obj@test_model.BenchmarkFloat256x256WriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkFloat256x256WriterBase.schema); + obj.float256x256_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [256, 256])); end end methods (Access=protected) function write_float256x256_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [256, 256])); - w.write(obj.stream_, value); + obj.float256x256_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m index b3731de3..93ccdff5 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m @@ -2,17 +2,25 @@ classdef BenchmarkFloatVlenReader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkFloatVlenReaderBase % Binary reader for the BenchmarkFloatVlen protocol + properties (Access=protected) + float_array_serializer + end + methods function obj = BenchmarkFloatVlenReader(filename) obj@test_model.BenchmarkFloatVlenReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkFloatVlenReaderBase.schema); + obj.float_array_serializer = yardl.binary.StreamSerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)); end end methods (Access=protected) + function more = has_float_array_(obj) + more = obj.float_array_serializer.hasnext(obj.stream_); + end + function value = read_float_array_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)); - value = r.read(obj.stream_); + value = obj.float_array_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m index d249a080..de5aeb34 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m +++ b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m @@ -2,17 +2,21 @@ classdef BenchmarkFloatVlenWriter < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkFloatVlenWriterBase % Binary writer for the BenchmarkFloatVlen protocol + properties (Access=protected) + float_array_serializer + end + methods function obj = BenchmarkFloatVlenWriter(filename) obj@test_model.BenchmarkFloatVlenWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkFloatVlenWriterBase.schema); + obj.float_array_serializer = yardl.binary.StreamSerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)); end end methods (Access=protected) function write_float_array_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)); - w.write(obj.stream_, value); + obj.float_array_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m index cbc55f43..7cf64038 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m @@ -2,17 +2,25 @@ classdef BenchmarkInt256x256Reader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkInt256x256ReaderBase % Binary reader for the BenchmarkInt256x256 protocol + properties (Access=protected) + int256x256_serializer + end + methods function obj = BenchmarkInt256x256Reader(filename) obj@test_model.BenchmarkInt256x256ReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkInt256x256ReaderBase.schema); + obj.int256x256_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [256, 256])); end end methods (Access=protected) + function more = has_int256x256_(obj) + more = obj.int256x256_serializer.hasnext(obj.stream_); + end + function value = read_int256x256_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [256, 256])); - value = r.read(obj.stream_); + value = obj.int256x256_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m index 1c7a670d..7f3dc1d5 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m +++ b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m @@ -2,17 +2,21 @@ classdef BenchmarkInt256x256Writer < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkInt256x256WriterBase % Binary writer for the BenchmarkInt256x256 protocol + properties (Access=protected) + int256x256_serializer + end + methods function obj = BenchmarkInt256x256Writer(filename) obj@test_model.BenchmarkInt256x256WriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkInt256x256WriterBase.schema); + obj.int256x256_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [256, 256])); end end methods (Access=protected) function write_int256x256_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [256, 256])); - w.write(obj.stream_, value); + obj.int256x256_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m index 4f00a0f2..fef78270 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m @@ -2,17 +2,25 @@ classdef BenchmarkSimpleMrdReader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkSimpleMrdReaderBase % Binary reader for the BenchmarkSimpleMrd protocol + properties (Access=protected) + data_serializer + end + methods function obj = BenchmarkSimpleMrdReader(filename) obj@test_model.BenchmarkSimpleMrdReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkSimpleMrdReaderBase.schema); + obj.data_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AcquisitionOrImage', {test_model.binary.SimpleAcquisitionSerializer(), yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)}, {@test_model.AcquisitionOrImage.Acquisition, @test_model.AcquisitionOrImage.Image})); end end methods (Access=protected) + function more = has_data_(obj) + more = obj.data_serializer.hasnext(obj.stream_); + end + function value = read_data_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AcquisitionOrImage', {test_model.binary.SimpleAcquisitionSerializer(), yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)}, {@test_model.AcquisitionOrImage.Acquisition, @test_model.AcquisitionOrImage.Image})); - value = r.read(obj.stream_); + value = obj.data_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m index 41e89f1d..eaf98e79 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m @@ -2,17 +2,21 @@ classdef BenchmarkSimpleMrdWriter < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkSimpleMrdWriterBase % Binary writer for the BenchmarkSimpleMrd protocol + properties (Access=protected) + data_serializer + end + methods function obj = BenchmarkSimpleMrdWriter(filename) obj@test_model.BenchmarkSimpleMrdWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkSimpleMrdWriterBase.schema); + obj.data_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AcquisitionOrImage', {test_model.binary.SimpleAcquisitionSerializer(), yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)}, {@test_model.AcquisitionOrImage.Acquisition, @test_model.AcquisitionOrImage.Image})); end end methods (Access=protected) function write_data_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AcquisitionOrImage', {test_model.binary.SimpleAcquisitionSerializer(), yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)}, {@test_model.AcquisitionOrImage.Acquisition, @test_model.AcquisitionOrImage.Image})); - w.write(obj.stream_, value); + obj.data_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m index b02ebfb6..0a0bc5b0 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m @@ -2,17 +2,25 @@ classdef BenchmarkSmallRecordReader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkSmallRecordReaderBase % Binary reader for the BenchmarkSmallRecord protocol + properties (Access=protected) + small_record_serializer + end + methods function obj = BenchmarkSmallRecordReader(filename) obj@test_model.BenchmarkSmallRecordReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkSmallRecordReaderBase.schema); + obj.small_record_serializer = yardl.binary.StreamSerializer(test_model.binary.SmallBenchmarkRecordSerializer()); end end methods (Access=protected) + function more = has_small_record_(obj) + more = obj.small_record_serializer.hasnext(obj.stream_); + end + function value = read_small_record_(obj) - r = yardl.binary.StreamSerializer(test_model.binary.SmallBenchmarkRecordSerializer()); - value = r.read(obj.stream_); + value = obj.small_record_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m index c4b31d7b..745f8266 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m @@ -2,17 +2,25 @@ classdef BenchmarkSmallRecordWithOptionalsReader < yardl.binary.BinaryProtocolReader & test_model.BenchmarkSmallRecordWithOptionalsReaderBase % Binary reader for the BenchmarkSmallRecordWithOptionals protocol + properties (Access=protected) + small_record_serializer + end + methods function obj = BenchmarkSmallRecordWithOptionalsReader(filename) obj@test_model.BenchmarkSmallRecordWithOptionalsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkSmallRecordWithOptionalsReaderBase.schema); + obj.small_record_serializer = yardl.binary.StreamSerializer(test_model.binary.SimpleEncodingCountersSerializer()); end end methods (Access=protected) + function more = has_small_record_(obj) + more = obj.small_record_serializer.hasnext(obj.stream_); + end + function value = read_small_record_(obj) - r = yardl.binary.StreamSerializer(test_model.binary.SimpleEncodingCountersSerializer()); - value = r.read(obj.stream_); + value = obj.small_record_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m index 14c9ea7e..c2040860 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m @@ -2,17 +2,21 @@ classdef BenchmarkSmallRecordWithOptionalsWriter < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkSmallRecordWithOptionalsWriterBase % Binary writer for the BenchmarkSmallRecordWithOptionals protocol + properties (Access=protected) + small_record_serializer + end + methods function obj = BenchmarkSmallRecordWithOptionalsWriter(filename) obj@test_model.BenchmarkSmallRecordWithOptionalsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkSmallRecordWithOptionalsWriterBase.schema); + obj.small_record_serializer = yardl.binary.StreamSerializer(test_model.binary.SimpleEncodingCountersSerializer()); end end methods (Access=protected) function write_small_record_(obj, value) - w = yardl.binary.StreamSerializer(test_model.binary.SimpleEncodingCountersSerializer()); - w.write(obj.stream_, value); + obj.small_record_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m index 76c06d4c..e07730e0 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m @@ -2,17 +2,21 @@ classdef BenchmarkSmallRecordWriter < yardl.binary.BinaryProtocolWriter & test_model.BenchmarkSmallRecordWriterBase % Binary writer for the BenchmarkSmallRecord protocol + properties (Access=protected) + small_record_serializer + end + methods function obj = BenchmarkSmallRecordWriter(filename) obj@test_model.BenchmarkSmallRecordWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkSmallRecordWriterBase.schema); + obj.small_record_serializer = yardl.binary.StreamSerializer(test_model.binary.SmallBenchmarkRecordSerializer()); end end methods (Access=protected) function write_small_record_(obj, value) - w = yardl.binary.StreamSerializer(test_model.binary.SmallBenchmarkRecordSerializer()); - w.write(obj.stream_, value); + obj.small_record_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/DynamicNDArraysReader.m b/matlab/generated/+test_model/+binary/DynamicNDArraysReader.m index 6a84d831..8e840f65 100644 --- a/matlab/generated/+test_model/+binary/DynamicNDArraysReader.m +++ b/matlab/generated/+test_model/+binary/DynamicNDArraysReader.m @@ -2,32 +2,39 @@ classdef DynamicNDArraysReader < yardl.binary.BinaryProtocolReader & test_model.DynamicNDArraysReaderBase % Binary reader for the DynamicNDArrays protocol + properties (Access=protected) + ints_serializer + simple_record_array_serializer + record_with_vlens_array_serializer + record_with_dynamic_nd_arrays_serializer + end + methods function obj = DynamicNDArraysReader(filename) obj@test_model.DynamicNDArraysReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.DynamicNDArraysReaderBase.schema); + obj.ints_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); + obj.simple_record_array_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.SimpleRecordSerializer()); + obj.record_with_vlens_array_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlensSerializer()); + obj.record_with_dynamic_nd_arrays_serializer = test_model.binary.RecordWithDynamicNDArraysSerializer(); end end methods (Access=protected) function value = read_ints_(obj) - r = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); - value = r.read(obj.stream_); + value = obj.ints_serializer.read(obj.stream_); end function value = read_simple_record_array_(obj) - r = yardl.binary.DynamicNDArraySerializer(test_model.binary.SimpleRecordSerializer()); - value = r.read(obj.stream_); + value = obj.simple_record_array_serializer.read(obj.stream_); end function value = read_record_with_vlens_array_(obj) - r = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlensSerializer()); - value = r.read(obj.stream_); + value = obj.record_with_vlens_array_serializer.read(obj.stream_); end function value = read_record_with_dynamic_nd_arrays_(obj) - r = test_model.binary.RecordWithDynamicNDArraysSerializer(); - value = r.read(obj.stream_); + value = obj.record_with_dynamic_nd_arrays_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m b/matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m index a2c18b2c..f4d6ee7f 100644 --- a/matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m +++ b/matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m @@ -2,32 +2,39 @@ classdef DynamicNDArraysWriter < yardl.binary.BinaryProtocolWriter & test_model.DynamicNDArraysWriterBase % Binary writer for the DynamicNDArrays protocol + properties (Access=protected) + ints_serializer + simple_record_array_serializer + record_with_vlens_array_serializer + record_with_dynamic_nd_arrays_serializer + end + methods function obj = DynamicNDArraysWriter(filename) obj@test_model.DynamicNDArraysWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.DynamicNDArraysWriterBase.schema); + obj.ints_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); + obj.simple_record_array_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.SimpleRecordSerializer()); + obj.record_with_vlens_array_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlensSerializer()); + obj.record_with_dynamic_nd_arrays_serializer = test_model.binary.RecordWithDynamicNDArraysSerializer(); end end methods (Access=protected) function write_ints_(obj, value) - w = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); - w.write(obj.stream_, value); + obj.ints_serializer.write(obj.stream_, value); end function write_simple_record_array_(obj, value) - w = yardl.binary.DynamicNDArraySerializer(test_model.binary.SimpleRecordSerializer()); - w.write(obj.stream_, value); + obj.simple_record_array_serializer.write(obj.stream_, value); end function write_record_with_vlens_array_(obj, value) - w = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlensSerializer()); - w.write(obj.stream_, value); + obj.record_with_vlens_array_serializer.write(obj.stream_, value); end function write_record_with_dynamic_nd_arrays_(obj, value) - w = test_model.binary.RecordWithDynamicNDArraysSerializer(); - w.write(obj.stream_, value); + obj.record_with_dynamic_nd_arrays_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/EnumsReader.m b/matlab/generated/+test_model/+binary/EnumsReader.m index 74841ad4..d22e52ab 100644 --- a/matlab/generated/+test_model/+binary/EnumsReader.m +++ b/matlab/generated/+test_model/+binary/EnumsReader.m @@ -2,27 +2,33 @@ classdef EnumsReader < yardl.binary.BinaryProtocolReader & test_model.EnumsReaderBase % Binary reader for the Enums protocol + properties (Access=protected) + single_serializer + vec_serializer + size_serializer + end + methods function obj = EnumsReader(filename) obj@test_model.EnumsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.EnumsReaderBase.schema); + obj.single_serializer = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); + obj.vec_serializer = yardl.binary.VectorSerializer(yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + obj.size_serializer = yardl.binary.EnumSerializer('test_model.SizeBasedEnum', @test_model.SizeBasedEnum, yardl.binary.SizeSerializer); end end methods (Access=protected) function value = read_single_(obj) - r = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); - value = r.read(obj.stream_); + value = obj.single_serializer.read(obj.stream_); end function value = read_vec_(obj) - r = yardl.binary.VectorSerializer(yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); - value = r.read(obj.stream_); + value = obj.vec_serializer.read(obj.stream_); end function value = read_size_(obj) - r = yardl.binary.EnumSerializer('test_model.SizeBasedEnum', @test_model.SizeBasedEnum, yardl.binary.SizeSerializer); - value = r.read(obj.stream_); + value = obj.size_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/EnumsWriter.m b/matlab/generated/+test_model/+binary/EnumsWriter.m index 252fc63b..ce0ef72c 100644 --- a/matlab/generated/+test_model/+binary/EnumsWriter.m +++ b/matlab/generated/+test_model/+binary/EnumsWriter.m @@ -2,27 +2,33 @@ classdef EnumsWriter < yardl.binary.BinaryProtocolWriter & test_model.EnumsWriterBase % Binary writer for the Enums protocol + properties (Access=protected) + single_serializer + vec_serializer + size_serializer + end + methods function obj = EnumsWriter(filename) obj@test_model.EnumsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.EnumsWriterBase.schema); + obj.single_serializer = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); + obj.vec_serializer = yardl.binary.VectorSerializer(yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + obj.size_serializer = yardl.binary.EnumSerializer('test_model.SizeBasedEnum', @test_model.SizeBasedEnum, yardl.binary.SizeSerializer); end end methods (Access=protected) function write_single_(obj, value) - w = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); - w.write(obj.stream_, value); + obj.single_serializer.write(obj.stream_, value); end function write_vec_(obj, value) - w = yardl.binary.VectorSerializer(yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); - w.write(obj.stream_, value); + obj.vec_serializer.write(obj.stream_, value); end function write_size_(obj, value) - w = yardl.binary.EnumSerializer('test_model.SizeBasedEnum', @test_model.SizeBasedEnum, yardl.binary.SizeSerializer); - w.write(obj.stream_, value); + obj.size_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/FixedArraysReader.m b/matlab/generated/+test_model/+binary/FixedArraysReader.m index 0fa10230..21f7294a 100644 --- a/matlab/generated/+test_model/+binary/FixedArraysReader.m +++ b/matlab/generated/+test_model/+binary/FixedArraysReader.m @@ -2,37 +2,45 @@ classdef FixedArraysReader < yardl.binary.BinaryProtocolReader & test_model.FixedArraysReaderBase % Binary reader for the FixedArrays protocol + properties (Access=protected) + ints_serializer + fixed_simple_record_array_serializer + fixed_record_with_vlens_array_serializer + record_with_fixed_arrays_serializer + named_array_serializer + end + methods function obj = FixedArraysReader(filename) obj@test_model.FixedArraysReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.FixedArraysReaderBase.schema); + obj.ints_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); + obj.fixed_simple_record_array_serializer = yardl.binary.FixedNDArraySerializer(test_model.binary.SimpleRecordSerializer(), [2, 3]); + obj.fixed_record_with_vlens_array_serializer = yardl.binary.FixedNDArraySerializer(test_model.binary.RecordWithVlensSerializer(), [2, 2]); + obj.record_with_fixed_arrays_serializer = test_model.binary.RecordWithFixedArraysSerializer(); + obj.named_array_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 2]); end end methods (Access=protected) function value = read_ints_(obj) - r = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); - value = r.read(obj.stream_); + value = obj.ints_serializer.read(obj.stream_); end function value = read_fixed_simple_record_array_(obj) - r = yardl.binary.FixedNDArraySerializer(test_model.binary.SimpleRecordSerializer(), [2, 3]); - value = r.read(obj.stream_); + value = obj.fixed_simple_record_array_serializer.read(obj.stream_); end function value = read_fixed_record_with_vlens_array_(obj) - r = yardl.binary.FixedNDArraySerializer(test_model.binary.RecordWithVlensSerializer(), [2, 2]); - value = r.read(obj.stream_); + value = obj.fixed_record_with_vlens_array_serializer.read(obj.stream_); end function value = read_record_with_fixed_arrays_(obj) - r = test_model.binary.RecordWithFixedArraysSerializer(); - value = r.read(obj.stream_); + value = obj.record_with_fixed_arrays_serializer.read(obj.stream_); end function value = read_named_array_(obj) - r = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 2]); - value = r.read(obj.stream_); + value = obj.named_array_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/FixedArraysWriter.m b/matlab/generated/+test_model/+binary/FixedArraysWriter.m index 5faf2af8..68f820b0 100644 --- a/matlab/generated/+test_model/+binary/FixedArraysWriter.m +++ b/matlab/generated/+test_model/+binary/FixedArraysWriter.m @@ -2,37 +2,45 @@ classdef FixedArraysWriter < yardl.binary.BinaryProtocolWriter & test_model.FixedArraysWriterBase % Binary writer for the FixedArrays protocol + properties (Access=protected) + ints_serializer + fixed_simple_record_array_serializer + fixed_record_with_vlens_array_serializer + record_with_fixed_arrays_serializer + named_array_serializer + end + methods function obj = FixedArraysWriter(filename) obj@test_model.FixedArraysWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.FixedArraysWriterBase.schema); + obj.ints_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); + obj.fixed_simple_record_array_serializer = yardl.binary.FixedNDArraySerializer(test_model.binary.SimpleRecordSerializer(), [2, 3]); + obj.fixed_record_with_vlens_array_serializer = yardl.binary.FixedNDArraySerializer(test_model.binary.RecordWithVlensSerializer(), [2, 2]); + obj.record_with_fixed_arrays_serializer = test_model.binary.RecordWithFixedArraysSerializer(); + obj.named_array_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 2]); end end methods (Access=protected) function write_ints_(obj, value) - w = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); - w.write(obj.stream_, value); + obj.ints_serializer.write(obj.stream_, value); end function write_fixed_simple_record_array_(obj, value) - w = yardl.binary.FixedNDArraySerializer(test_model.binary.SimpleRecordSerializer(), [2, 3]); - w.write(obj.stream_, value); + obj.fixed_simple_record_array_serializer.write(obj.stream_, value); end function write_fixed_record_with_vlens_array_(obj, value) - w = yardl.binary.FixedNDArraySerializer(test_model.binary.RecordWithVlensSerializer(), [2, 2]); - w.write(obj.stream_, value); + obj.fixed_record_with_vlens_array_serializer.write(obj.stream_, value); end function write_record_with_fixed_arrays_(obj, value) - w = test_model.binary.RecordWithFixedArraysSerializer(); - w.write(obj.stream_, value); + obj.record_with_fixed_arrays_serializer.write(obj.stream_, value); end function write_named_array_(obj, value) - w = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 2]); - w.write(obj.stream_, value); + obj.named_array_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/FixedVectorsReader.m b/matlab/generated/+test_model/+binary/FixedVectorsReader.m index 76846984..25b5eebf 100644 --- a/matlab/generated/+test_model/+binary/FixedVectorsReader.m +++ b/matlab/generated/+test_model/+binary/FixedVectorsReader.m @@ -2,32 +2,39 @@ classdef FixedVectorsReader < yardl.binary.BinaryProtocolReader & test_model.FixedVectorsReaderBase % Binary reader for the FixedVectors protocol + properties (Access=protected) + fixed_int_vector_serializer + fixed_simple_record_vector_serializer + fixed_record_with_vlens_vector_serializer + record_with_fixed_vectors_serializer + end + methods function obj = FixedVectorsReader(filename) obj@test_model.FixedVectorsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.FixedVectorsReaderBase.schema); + obj.fixed_int_vector_serializer = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 5); + obj.fixed_simple_record_vector_serializer = yardl.binary.FixedVectorSerializer(test_model.binary.SimpleRecordSerializer(), 3); + obj.fixed_record_with_vlens_vector_serializer = yardl.binary.FixedVectorSerializer(test_model.binary.RecordWithVlensSerializer(), 2); + obj.record_with_fixed_vectors_serializer = test_model.binary.RecordWithFixedVectorsSerializer(); end end methods (Access=protected) function value = read_fixed_int_vector_(obj) - r = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 5); - value = r.read(obj.stream_); + value = obj.fixed_int_vector_serializer.read(obj.stream_); end function value = read_fixed_simple_record_vector_(obj) - r = yardl.binary.FixedVectorSerializer(test_model.binary.SimpleRecordSerializer(), 3); - value = r.read(obj.stream_); + value = obj.fixed_simple_record_vector_serializer.read(obj.stream_); end function value = read_fixed_record_with_vlens_vector_(obj) - r = yardl.binary.FixedVectorSerializer(test_model.binary.RecordWithVlensSerializer(), 2); - value = r.read(obj.stream_); + value = obj.fixed_record_with_vlens_vector_serializer.read(obj.stream_); end function value = read_record_with_fixed_vectors_(obj) - r = test_model.binary.RecordWithFixedVectorsSerializer(); - value = r.read(obj.stream_); + value = obj.record_with_fixed_vectors_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/FixedVectorsWriter.m b/matlab/generated/+test_model/+binary/FixedVectorsWriter.m index c60a738d..cd852da1 100644 --- a/matlab/generated/+test_model/+binary/FixedVectorsWriter.m +++ b/matlab/generated/+test_model/+binary/FixedVectorsWriter.m @@ -2,32 +2,39 @@ classdef FixedVectorsWriter < yardl.binary.BinaryProtocolWriter & test_model.FixedVectorsWriterBase % Binary writer for the FixedVectors protocol + properties (Access=protected) + fixed_int_vector_serializer + fixed_simple_record_vector_serializer + fixed_record_with_vlens_vector_serializer + record_with_fixed_vectors_serializer + end + methods function obj = FixedVectorsWriter(filename) obj@test_model.FixedVectorsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.FixedVectorsWriterBase.schema); + obj.fixed_int_vector_serializer = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 5); + obj.fixed_simple_record_vector_serializer = yardl.binary.FixedVectorSerializer(test_model.binary.SimpleRecordSerializer(), 3); + obj.fixed_record_with_vlens_vector_serializer = yardl.binary.FixedVectorSerializer(test_model.binary.RecordWithVlensSerializer(), 2); + obj.record_with_fixed_vectors_serializer = test_model.binary.RecordWithFixedVectorsSerializer(); end end methods (Access=protected) function write_fixed_int_vector_(obj, value) - w = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 5); - w.write(obj.stream_, value); + obj.fixed_int_vector_serializer.write(obj.stream_, value); end function write_fixed_simple_record_vector_(obj, value) - w = yardl.binary.FixedVectorSerializer(test_model.binary.SimpleRecordSerializer(), 3); - w.write(obj.stream_, value); + obj.fixed_simple_record_vector_serializer.write(obj.stream_, value); end function write_fixed_record_with_vlens_vector_(obj, value) - w = yardl.binary.FixedVectorSerializer(test_model.binary.RecordWithVlensSerializer(), 2); - w.write(obj.stream_, value); + obj.fixed_record_with_vlens_vector_serializer.write(obj.stream_, value); end function write_record_with_fixed_vectors_(obj, value) - w = test_model.binary.RecordWithFixedVectorsSerializer(); - w.write(obj.stream_, value); + obj.record_with_fixed_vectors_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/FlagsReader.m b/matlab/generated/+test_model/+binary/FlagsReader.m index 96508fdb..697dbf35 100644 --- a/matlab/generated/+test_model/+binary/FlagsReader.m +++ b/matlab/generated/+test_model/+binary/FlagsReader.m @@ -2,22 +2,35 @@ classdef FlagsReader < yardl.binary.BinaryProtocolReader & test_model.FlagsReaderBase % Binary reader for the Flags protocol + properties (Access=protected) + days_serializer + formats_serializer + end + methods function obj = FlagsReader(filename) obj@test_model.FlagsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.FlagsReaderBase.schema); + obj.days_serializer = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.DaysOfWeek', @basic_types.DaysOfWeek, yardl.binary.Int32Serializer)); + obj.formats_serializer = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.TextFormat', @basic_types.TextFormat, yardl.binary.Uint64Serializer)); end end methods (Access=protected) + function more = has_days_(obj) + more = obj.days_serializer.hasnext(obj.stream_); + end + function value = read_days_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.DaysOfWeek', @basic_types.DaysOfWeek, yardl.binary.Int32Serializer)); - value = r.read(obj.stream_); + value = obj.days_serializer.read(obj.stream_); + end + + function more = has_formats_(obj) + more = obj.formats_serializer.hasnext(obj.stream_); end function value = read_formats_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.TextFormat', @basic_types.TextFormat, yardl.binary.Uint64Serializer)); - value = r.read(obj.stream_); + value = obj.formats_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/FlagsWriter.m b/matlab/generated/+test_model/+binary/FlagsWriter.m index 8091051f..9a378e7b 100644 --- a/matlab/generated/+test_model/+binary/FlagsWriter.m +++ b/matlab/generated/+test_model/+binary/FlagsWriter.m @@ -2,22 +2,27 @@ classdef FlagsWriter < yardl.binary.BinaryProtocolWriter & test_model.FlagsWriterBase % Binary writer for the Flags protocol + properties (Access=protected) + days_serializer + formats_serializer + end + methods function obj = FlagsWriter(filename) obj@test_model.FlagsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.FlagsWriterBase.schema); + obj.days_serializer = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.DaysOfWeek', @basic_types.DaysOfWeek, yardl.binary.Int32Serializer)); + obj.formats_serializer = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.TextFormat', @basic_types.TextFormat, yardl.binary.Uint64Serializer)); end end methods (Access=protected) function write_days_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.DaysOfWeek', @basic_types.DaysOfWeek, yardl.binary.Int32Serializer)); - w.write(obj.stream_, value); + obj.days_serializer.write(obj.stream_, value); end function write_formats_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.TextFormat', @basic_types.TextFormat, yardl.binary.Uint64Serializer)); - w.write(obj.stream_, value); + obj.formats_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/MapsReader.m b/matlab/generated/+test_model/+binary/MapsReader.m index 12f025d1..48ebad45 100644 --- a/matlab/generated/+test_model/+binary/MapsReader.m +++ b/matlab/generated/+test_model/+binary/MapsReader.m @@ -2,32 +2,39 @@ classdef MapsReader < yardl.binary.BinaryProtocolReader & test_model.MapsReaderBase % Binary reader for the Maps protocol + properties (Access=protected) + string_to_int_serializer + int_to_string_serializer + string_to_union_serializer + aliased_generic_serializer + end + methods function obj = MapsReader(filename) obj@test_model.MapsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.MapsReaderBase.schema); + obj.string_to_int_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); + obj.int_to_string_serializer = yardl.binary.MapSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + obj.string_to_union_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.UnionSerializer('test_model.StringOrInt32', {yardl.binary.StringSerializer, yardl.binary.Int32Serializer}, {@test_model.StringOrInt32.String, @test_model.StringOrInt32.Int32})); + obj.aliased_generic_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); end end methods (Access=protected) function value = read_string_to_int_(obj) - r = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); - value = r.read(obj.stream_); + value = obj.string_to_int_serializer.read(obj.stream_); end function value = read_int_to_string_(obj) - r = yardl.binary.MapSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); - value = r.read(obj.stream_); + value = obj.int_to_string_serializer.read(obj.stream_); end function value = read_string_to_union_(obj) - r = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.UnionSerializer('test_model.StringOrInt32', {yardl.binary.StringSerializer, yardl.binary.Int32Serializer}, {@test_model.StringOrInt32.String, @test_model.StringOrInt32.Int32})); - value = r.read(obj.stream_); + value = obj.string_to_union_serializer.read(obj.stream_); end function value = read_aliased_generic_(obj) - r = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); - value = r.read(obj.stream_); + value = obj.aliased_generic_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/MapsWriter.m b/matlab/generated/+test_model/+binary/MapsWriter.m index 6afabb23..e522badc 100644 --- a/matlab/generated/+test_model/+binary/MapsWriter.m +++ b/matlab/generated/+test_model/+binary/MapsWriter.m @@ -2,32 +2,39 @@ classdef MapsWriter < yardl.binary.BinaryProtocolWriter & test_model.MapsWriterBase % Binary writer for the Maps protocol + properties (Access=protected) + string_to_int_serializer + int_to_string_serializer + string_to_union_serializer + aliased_generic_serializer + end + methods function obj = MapsWriter(filename) obj@test_model.MapsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.MapsWriterBase.schema); + obj.string_to_int_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); + obj.int_to_string_serializer = yardl.binary.MapSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + obj.string_to_union_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.UnionSerializer('test_model.StringOrInt32', {yardl.binary.StringSerializer, yardl.binary.Int32Serializer}, {@test_model.StringOrInt32.String, @test_model.StringOrInt32.Int32})); + obj.aliased_generic_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); end end methods (Access=protected) function write_string_to_int_(obj, value) - w = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); - w.write(obj.stream_, value); + obj.string_to_int_serializer.write(obj.stream_, value); end function write_int_to_string_(obj, value) - w = yardl.binary.MapSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); - w.write(obj.stream_, value); + obj.int_to_string_serializer.write(obj.stream_, value); end function write_string_to_union_(obj, value) - w = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.UnionSerializer('test_model.StringOrInt32', {yardl.binary.StringSerializer, yardl.binary.Int32Serializer}, {@test_model.StringOrInt32.String, @test_model.StringOrInt32.Int32})); - w.write(obj.stream_, value); + obj.string_to_union_serializer.write(obj.stream_, value); end function write_aliased_generic_(obj, value) - w = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); - w.write(obj.stream_, value); + obj.aliased_generic_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/NDArraysReader.m b/matlab/generated/+test_model/+binary/NDArraysReader.m index 15df6904..7d829228 100644 --- a/matlab/generated/+test_model/+binary/NDArraysReader.m +++ b/matlab/generated/+test_model/+binary/NDArraysReader.m @@ -2,37 +2,45 @@ classdef NDArraysReader < yardl.binary.BinaryProtocolReader & test_model.NDArraysReaderBase % Binary reader for the NDArrays protocol + properties (Access=protected) + ints_serializer + simple_record_array_serializer + record_with_vlens_array_serializer + record_with_nd_arrays_serializer + named_array_serializer + end + methods function obj = NDArraysReader(filename) obj@test_model.NDArraysReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.NDArraysReaderBase.schema); + obj.ints_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + obj.simple_record_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 2); + obj.record_with_vlens_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 2); + obj.record_with_nd_arrays_serializer = test_model.binary.RecordWithNDArraysSerializer(); + obj.named_array_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); end end methods (Access=protected) function value = read_ints_(obj) - r = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - value = r.read(obj.stream_); + value = obj.ints_serializer.read(obj.stream_); end function value = read_simple_record_array_(obj) - r = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 2); - value = r.read(obj.stream_); + value = obj.simple_record_array_serializer.read(obj.stream_); end function value = read_record_with_vlens_array_(obj) - r = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 2); - value = r.read(obj.stream_); + value = obj.record_with_vlens_array_serializer.read(obj.stream_); end function value = read_record_with_nd_arrays_(obj) - r = test_model.binary.RecordWithNDArraysSerializer(); - value = r.read(obj.stream_); + value = obj.record_with_nd_arrays_serializer.read(obj.stream_); end function value = read_named_array_(obj) - r = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - value = r.read(obj.stream_); + value = obj.named_array_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m index a0377f06..7be072b4 100644 --- a/matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m +++ b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m @@ -2,32 +2,39 @@ classdef NDArraysSingleDimensionReader < yardl.binary.BinaryProtocolReader & test_model.NDArraysSingleDimensionReaderBase % Binary reader for the NDArraysSingleDimension protocol + properties (Access=protected) + ints_serializer + simple_record_array_serializer + record_with_vlens_array_serializer + record_with_nd_arrays_serializer + end + methods function obj = NDArraysSingleDimensionReader(filename) obj@test_model.NDArraysSingleDimensionReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.NDArraysSingleDimensionReaderBase.schema); + obj.ints_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); + obj.simple_record_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 1); + obj.record_with_vlens_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 1); + obj.record_with_nd_arrays_serializer = test_model.binary.RecordWithNDArraysSingleDimensionSerializer(); end end methods (Access=protected) function value = read_ints_(obj) - r = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); - value = r.read(obj.stream_); + value = obj.ints_serializer.read(obj.stream_); end function value = read_simple_record_array_(obj) - r = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 1); - value = r.read(obj.stream_); + value = obj.simple_record_array_serializer.read(obj.stream_); end function value = read_record_with_vlens_array_(obj) - r = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 1); - value = r.read(obj.stream_); + value = obj.record_with_vlens_array_serializer.read(obj.stream_); end function value = read_record_with_nd_arrays_(obj) - r = test_model.binary.RecordWithNDArraysSingleDimensionSerializer(); - value = r.read(obj.stream_); + value = obj.record_with_nd_arrays_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m index a460257e..71664529 100644 --- a/matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m +++ b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m @@ -2,32 +2,39 @@ classdef NDArraysSingleDimensionWriter < yardl.binary.BinaryProtocolWriter & test_model.NDArraysSingleDimensionWriterBase % Binary writer for the NDArraysSingleDimension protocol + properties (Access=protected) + ints_serializer + simple_record_array_serializer + record_with_vlens_array_serializer + record_with_nd_arrays_serializer + end + methods function obj = NDArraysSingleDimensionWriter(filename) obj@test_model.NDArraysSingleDimensionWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.NDArraysSingleDimensionWriterBase.schema); + obj.ints_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); + obj.simple_record_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 1); + obj.record_with_vlens_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 1); + obj.record_with_nd_arrays_serializer = test_model.binary.RecordWithNDArraysSingleDimensionSerializer(); end end methods (Access=protected) function write_ints_(obj, value) - w = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); - w.write(obj.stream_, value); + obj.ints_serializer.write(obj.stream_, value); end function write_simple_record_array_(obj, value) - w = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 1); - w.write(obj.stream_, value); + obj.simple_record_array_serializer.write(obj.stream_, value); end function write_record_with_vlens_array_(obj, value) - w = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 1); - w.write(obj.stream_, value); + obj.record_with_vlens_array_serializer.write(obj.stream_, value); end function write_record_with_nd_arrays_(obj, value) - w = test_model.binary.RecordWithNDArraysSingleDimensionSerializer(); - w.write(obj.stream_, value); + obj.record_with_nd_arrays_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/NDArraysWriter.m b/matlab/generated/+test_model/+binary/NDArraysWriter.m index 6996cc50..2468160b 100644 --- a/matlab/generated/+test_model/+binary/NDArraysWriter.m +++ b/matlab/generated/+test_model/+binary/NDArraysWriter.m @@ -2,37 +2,45 @@ classdef NDArraysWriter < yardl.binary.BinaryProtocolWriter & test_model.NDArraysWriterBase % Binary writer for the NDArrays protocol + properties (Access=protected) + ints_serializer + simple_record_array_serializer + record_with_vlens_array_serializer + record_with_nd_arrays_serializer + named_array_serializer + end + methods function obj = NDArraysWriter(filename) obj@test_model.NDArraysWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.NDArraysWriterBase.schema); + obj.ints_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + obj.simple_record_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 2); + obj.record_with_vlens_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 2); + obj.record_with_nd_arrays_serializer = test_model.binary.RecordWithNDArraysSerializer(); + obj.named_array_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); end end methods (Access=protected) function write_ints_(obj, value) - w = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - w.write(obj.stream_, value); + obj.ints_serializer.write(obj.stream_, value); end function write_simple_record_array_(obj, value) - w = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 2); - w.write(obj.stream_, value); + obj.simple_record_array_serializer.write(obj.stream_, value); end function write_record_with_vlens_array_(obj, value) - w = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 2); - w.write(obj.stream_, value); + obj.record_with_vlens_array_serializer.write(obj.stream_, value); end function write_record_with_nd_arrays_(obj, value) - w = test_model.binary.RecordWithNDArraysSerializer(); - w.write(obj.stream_, value); + obj.record_with_nd_arrays_serializer.write(obj.stream_, value); end function write_named_array_(obj, value) - w = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - w.write(obj.stream_, value); + obj.named_array_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/NestedRecordsReader.m b/matlab/generated/+test_model/+binary/NestedRecordsReader.m index 4be061ba..4538d286 100644 --- a/matlab/generated/+test_model/+binary/NestedRecordsReader.m +++ b/matlab/generated/+test_model/+binary/NestedRecordsReader.m @@ -2,17 +2,21 @@ classdef NestedRecordsReader < yardl.binary.BinaryProtocolReader & test_model.NestedRecordsReaderBase % Binary reader for the NestedRecords protocol + properties (Access=protected) + tuple_with_records_serializer + end + methods function obj = NestedRecordsReader(filename) obj@test_model.NestedRecordsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.NestedRecordsReaderBase.schema); + obj.tuple_with_records_serializer = test_model.binary.TupleWithRecordsSerializer(); end end methods (Access=protected) function value = read_tuple_with_records_(obj) - r = test_model.binary.TupleWithRecordsSerializer(); - value = r.read(obj.stream_); + value = obj.tuple_with_records_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/NestedRecordsWriter.m b/matlab/generated/+test_model/+binary/NestedRecordsWriter.m index 80383b3a..9882039b 100644 --- a/matlab/generated/+test_model/+binary/NestedRecordsWriter.m +++ b/matlab/generated/+test_model/+binary/NestedRecordsWriter.m @@ -2,17 +2,21 @@ classdef NestedRecordsWriter < yardl.binary.BinaryProtocolWriter & test_model.NestedRecordsWriterBase % Binary writer for the NestedRecords protocol + properties (Access=protected) + tuple_with_records_serializer + end + methods function obj = NestedRecordsWriter(filename) obj@test_model.NestedRecordsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.NestedRecordsWriterBase.schema); + obj.tuple_with_records_serializer = test_model.binary.TupleWithRecordsSerializer(); end end methods (Access=protected) function write_tuple_with_records_(obj, value) - w = test_model.binary.TupleWithRecordsSerializer(); - w.write(obj.stream_, value); + obj.tuple_with_records_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/OptionalVectorsReader.m b/matlab/generated/+test_model/+binary/OptionalVectorsReader.m index 60b7160f..3268b291 100644 --- a/matlab/generated/+test_model/+binary/OptionalVectorsReader.m +++ b/matlab/generated/+test_model/+binary/OptionalVectorsReader.m @@ -2,17 +2,21 @@ classdef OptionalVectorsReader < yardl.binary.BinaryProtocolReader & test_model.OptionalVectorsReaderBase % Binary reader for the OptionalVectors protocol + properties (Access=protected) + record_with_optional_vector_serializer + end + methods function obj = OptionalVectorsReader(filename) obj@test_model.OptionalVectorsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.OptionalVectorsReaderBase.schema); + obj.record_with_optional_vector_serializer = test_model.binary.RecordWithOptionalVectorSerializer(); end end methods (Access=protected) function value = read_record_with_optional_vector_(obj) - r = test_model.binary.RecordWithOptionalVectorSerializer(); - value = r.read(obj.stream_); + value = obj.record_with_optional_vector_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/OptionalVectorsWriter.m b/matlab/generated/+test_model/+binary/OptionalVectorsWriter.m index 640265be..e939008f 100644 --- a/matlab/generated/+test_model/+binary/OptionalVectorsWriter.m +++ b/matlab/generated/+test_model/+binary/OptionalVectorsWriter.m @@ -2,17 +2,21 @@ classdef OptionalVectorsWriter < yardl.binary.BinaryProtocolWriter & test_model.OptionalVectorsWriterBase % Binary writer for the OptionalVectors protocol + properties (Access=protected) + record_with_optional_vector_serializer + end + methods function obj = OptionalVectorsWriter(filename) obj@test_model.OptionalVectorsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.OptionalVectorsWriterBase.schema); + obj.record_with_optional_vector_serializer = test_model.binary.RecordWithOptionalVectorSerializer(); end end methods (Access=protected) function write_record_with_optional_vector_(obj, value) - w = test_model.binary.RecordWithOptionalVectorSerializer(); - w.write(obj.stream_, value); + obj.record_with_optional_vector_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m index 45013f0c..90c8d3fa 100644 --- a/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m +++ b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m @@ -2,17 +2,21 @@ classdef ProtocolWithComputedFieldsReader < yardl.binary.BinaryProtocolReader & test_model.ProtocolWithComputedFieldsReaderBase % Binary reader for the ProtocolWithComputedFields protocol + properties (Access=protected) + record_with_computed_fields_serializer + end + methods function obj = ProtocolWithComputedFieldsReader(filename) obj@test_model.ProtocolWithComputedFieldsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.ProtocolWithComputedFieldsReaderBase.schema); + obj.record_with_computed_fields_serializer = test_model.binary.RecordWithComputedFieldsSerializer(); end end methods (Access=protected) function value = read_record_with_computed_fields_(obj) - r = test_model.binary.RecordWithComputedFieldsSerializer(); - value = r.read(obj.stream_); + value = obj.record_with_computed_fields_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m index c48e59f9..5753fe27 100644 --- a/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m +++ b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m @@ -2,17 +2,21 @@ classdef ProtocolWithComputedFieldsWriter < yardl.binary.BinaryProtocolWriter & test_model.ProtocolWithComputedFieldsWriterBase % Binary writer for the ProtocolWithComputedFields protocol + properties (Access=protected) + record_with_computed_fields_serializer + end + methods function obj = ProtocolWithComputedFieldsWriter(filename) obj@test_model.ProtocolWithComputedFieldsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.ProtocolWithComputedFieldsWriterBase.schema); + obj.record_with_computed_fields_serializer = test_model.binary.RecordWithComputedFieldsSerializer(); end end methods (Access=protected) function write_record_with_computed_fields_(obj, value) - w = test_model.binary.RecordWithComputedFieldsSerializer(); - w.write(obj.stream_, value); + obj.record_with_computed_fields_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m index 549ed2e0..b9258b44 100644 --- a/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m +++ b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m @@ -2,22 +2,31 @@ classdef ProtocolWithKeywordStepsReader < yardl.binary.BinaryProtocolReader & test_model.ProtocolWithKeywordStepsReaderBase % Binary reader for the ProtocolWithKeywordSteps protocol + properties (Access=protected) + int_serializer + float_serializer + end + methods function obj = ProtocolWithKeywordStepsReader(filename) obj@test_model.ProtocolWithKeywordStepsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.ProtocolWithKeywordStepsReaderBase.schema); + obj.int_serializer = yardl.binary.StreamSerializer(test_model.binary.RecordWithKeywordFieldsSerializer()); + obj.float_serializer = yardl.binary.EnumSerializer('test_model.EnumWithKeywordSymbols', @test_model.EnumWithKeywordSymbols, yardl.binary.Int32Serializer); end end methods (Access=protected) + function more = has_int_(obj) + more = obj.int_serializer.hasnext(obj.stream_); + end + function value = read_int_(obj) - r = yardl.binary.StreamSerializer(test_model.binary.RecordWithKeywordFieldsSerializer()); - value = r.read(obj.stream_); + value = obj.int_serializer.read(obj.stream_); end function value = read_float_(obj) - r = yardl.binary.EnumSerializer('test_model.EnumWithKeywordSymbols', @test_model.EnumWithKeywordSymbols, yardl.binary.Int32Serializer); - value = r.read(obj.stream_); + value = obj.float_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m index 36522619..2b5a9906 100644 --- a/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m +++ b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m @@ -2,22 +2,27 @@ classdef ProtocolWithKeywordStepsWriter < yardl.binary.BinaryProtocolWriter & test_model.ProtocolWithKeywordStepsWriterBase % Binary writer for the ProtocolWithKeywordSteps protocol + properties (Access=protected) + int_serializer + float_serializer + end + methods function obj = ProtocolWithKeywordStepsWriter(filename) obj@test_model.ProtocolWithKeywordStepsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.ProtocolWithKeywordStepsWriterBase.schema); + obj.int_serializer = yardl.binary.StreamSerializer(test_model.binary.RecordWithKeywordFieldsSerializer()); + obj.float_serializer = yardl.binary.EnumSerializer('test_model.EnumWithKeywordSymbols', @test_model.EnumWithKeywordSymbols, yardl.binary.Int32Serializer); end end methods (Access=protected) function write_int_(obj, value) - w = yardl.binary.StreamSerializer(test_model.binary.RecordWithKeywordFieldsSerializer()); - w.write(obj.stream_, value); + obj.int_serializer.write(obj.stream_, value); end function write_float_(obj, value) - w = yardl.binary.EnumSerializer('test_model.EnumWithKeywordSymbols', @test_model.EnumWithKeywordSymbols, yardl.binary.Int32Serializer); - w.write(obj.stream_, value); + obj.float_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/ScalarOptionalsReader.m b/matlab/generated/+test_model/+binary/ScalarOptionalsReader.m index f3178bd6..1a70eccc 100644 --- a/matlab/generated/+test_model/+binary/ScalarOptionalsReader.m +++ b/matlab/generated/+test_model/+binary/ScalarOptionalsReader.m @@ -2,32 +2,39 @@ classdef ScalarOptionalsReader < yardl.binary.BinaryProtocolReader & test_model.ScalarOptionalsReaderBase % Binary reader for the ScalarOptionals protocol + properties (Access=protected) + optional_int_serializer + optional_record_serializer + record_with_optional_fields_serializer + optional_record_with_optional_fields_serializer + end + methods function obj = ScalarOptionalsReader(filename) obj@test_model.ScalarOptionalsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.ScalarOptionalsReaderBase.schema); + obj.optional_int_serializer = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); + obj.optional_record_serializer = yardl.binary.OptionalSerializer(test_model.binary.SimpleRecordSerializer()); + obj.record_with_optional_fields_serializer = test_model.binary.RecordWithOptionalFieldsSerializer(); + obj.optional_record_with_optional_fields_serializer = yardl.binary.OptionalSerializer(test_model.binary.RecordWithOptionalFieldsSerializer()); end end methods (Access=protected) function value = read_optional_int_(obj) - r = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); - value = r.read(obj.stream_); + value = obj.optional_int_serializer.read(obj.stream_); end function value = read_optional_record_(obj) - r = yardl.binary.OptionalSerializer(test_model.binary.SimpleRecordSerializer()); - value = r.read(obj.stream_); + value = obj.optional_record_serializer.read(obj.stream_); end function value = read_record_with_optional_fields_(obj) - r = test_model.binary.RecordWithOptionalFieldsSerializer(); - value = r.read(obj.stream_); + value = obj.record_with_optional_fields_serializer.read(obj.stream_); end function value = read_optional_record_with_optional_fields_(obj) - r = yardl.binary.OptionalSerializer(test_model.binary.RecordWithOptionalFieldsSerializer()); - value = r.read(obj.stream_); + value = obj.optional_record_with_optional_fields_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m b/matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m index 05dff021..eb5f307d 100644 --- a/matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m +++ b/matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m @@ -2,32 +2,39 @@ classdef ScalarOptionalsWriter < yardl.binary.BinaryProtocolWriter & test_model.ScalarOptionalsWriterBase % Binary writer for the ScalarOptionals protocol + properties (Access=protected) + optional_int_serializer + optional_record_serializer + record_with_optional_fields_serializer + optional_record_with_optional_fields_serializer + end + methods function obj = ScalarOptionalsWriter(filename) obj@test_model.ScalarOptionalsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.ScalarOptionalsWriterBase.schema); + obj.optional_int_serializer = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); + obj.optional_record_serializer = yardl.binary.OptionalSerializer(test_model.binary.SimpleRecordSerializer()); + obj.record_with_optional_fields_serializer = test_model.binary.RecordWithOptionalFieldsSerializer(); + obj.optional_record_with_optional_fields_serializer = yardl.binary.OptionalSerializer(test_model.binary.RecordWithOptionalFieldsSerializer()); end end methods (Access=protected) function write_optional_int_(obj, value) - w = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); - w.write(obj.stream_, value); + obj.optional_int_serializer.write(obj.stream_, value); end function write_optional_record_(obj, value) - w = yardl.binary.OptionalSerializer(test_model.binary.SimpleRecordSerializer()); - w.write(obj.stream_, value); + obj.optional_record_serializer.write(obj.stream_, value); end function write_record_with_optional_fields_(obj, value) - w = test_model.binary.RecordWithOptionalFieldsSerializer(); - w.write(obj.stream_, value); + obj.record_with_optional_fields_serializer.write(obj.stream_, value); end function write_optional_record_with_optional_fields_(obj, value) - w = yardl.binary.OptionalSerializer(test_model.binary.RecordWithOptionalFieldsSerializer()); - w.write(obj.stream_, value); + obj.optional_record_with_optional_fields_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/ScalarsReader.m b/matlab/generated/+test_model/+binary/ScalarsReader.m index 3dd3a21a..a58b12ef 100644 --- a/matlab/generated/+test_model/+binary/ScalarsReader.m +++ b/matlab/generated/+test_model/+binary/ScalarsReader.m @@ -2,22 +2,27 @@ classdef ScalarsReader < yardl.binary.BinaryProtocolReader & test_model.ScalarsReaderBase % Binary reader for the Scalars protocol + properties (Access=protected) + int32_serializer + record_serializer + end + methods function obj = ScalarsReader(filename) obj@test_model.ScalarsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.ScalarsReaderBase.schema); + obj.int32_serializer = yardl.binary.Int32Serializer; + obj.record_serializer = test_model.binary.RecordWithPrimitivesSerializer(); end end methods (Access=protected) function value = read_int32_(obj) - r = yardl.binary.Int32Serializer; - value = r.read(obj.stream_); + value = obj.int32_serializer.read(obj.stream_); end function value = read_record_(obj) - r = test_model.binary.RecordWithPrimitivesSerializer(); - value = r.read(obj.stream_); + value = obj.record_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/ScalarsWriter.m b/matlab/generated/+test_model/+binary/ScalarsWriter.m index 7eee90ae..0ac9ea93 100644 --- a/matlab/generated/+test_model/+binary/ScalarsWriter.m +++ b/matlab/generated/+test_model/+binary/ScalarsWriter.m @@ -2,22 +2,27 @@ classdef ScalarsWriter < yardl.binary.BinaryProtocolWriter & test_model.ScalarsWriterBase % Binary writer for the Scalars protocol + properties (Access=protected) + int32_serializer + record_serializer + end + methods function obj = ScalarsWriter(filename) obj@test_model.ScalarsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.ScalarsWriterBase.schema); + obj.int32_serializer = yardl.binary.Int32Serializer; + obj.record_serializer = test_model.binary.RecordWithPrimitivesSerializer(); end end methods (Access=protected) function write_int32_(obj, value) - w = yardl.binary.Int32Serializer; - w.write(obj.stream_, value); + obj.int32_serializer.write(obj.stream_, value); end function write_record_(obj, value) - w = test_model.binary.RecordWithPrimitivesSerializer(); - w.write(obj.stream_, value); + obj.record_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/SimpleGenericsReader.m b/matlab/generated/+test_model/+binary/SimpleGenericsReader.m index 404cde80..b700ca37 100644 --- a/matlab/generated/+test_model/+binary/SimpleGenericsReader.m +++ b/matlab/generated/+test_model/+binary/SimpleGenericsReader.m @@ -2,57 +2,73 @@ classdef SimpleGenericsReader < yardl.binary.BinaryProtocolReader & test_model.SimpleGenericsReaderBase % Binary reader for the SimpleGenerics protocol + properties (Access=protected) + float_image_serializer + int_image_serializer + int_image_alternate_syntax_serializer + string_image_serializer + int_float_tuple_serializer + float_float_tuple_serializer + int_float_tuple_alternate_syntax_serializer + int_string_tuple_serializer + stream_of_type_variants_serializer + end + methods function obj = SimpleGenericsReader(filename) obj@test_model.SimpleGenericsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.SimpleGenericsReaderBase.schema); + obj.float_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2); + obj.int_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + obj.int_image_alternate_syntax_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + obj.string_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.StringSerializer, 2); + obj.int_float_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); + obj.float_float_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Float32Serializer, yardl.binary.Float32Serializer); + obj.int_float_tuple_alternate_syntax_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); + obj.int_string_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + obj.stream_of_type_variants_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.ImageFloatOrImageDouble', {yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), yardl.binary.NDArraySerializer(yardl.binary.Float64Serializer, 2)}, {@test_model.ImageFloatOrImageDouble.ImageFloat, @test_model.ImageFloatOrImageDouble.ImageDouble})); end end methods (Access=protected) function value = read_float_image_(obj) - r = yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2); - value = r.read(obj.stream_); + value = obj.float_image_serializer.read(obj.stream_); end function value = read_int_image_(obj) - r = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - value = r.read(obj.stream_); + value = obj.int_image_serializer.read(obj.stream_); end function value = read_int_image_alternate_syntax_(obj) - r = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - value = r.read(obj.stream_); + value = obj.int_image_alternate_syntax_serializer.read(obj.stream_); end function value = read_string_image_(obj) - r = yardl.binary.NDArraySerializer(yardl.binary.StringSerializer, 2); - value = r.read(obj.stream_); + value = obj.string_image_serializer.read(obj.stream_); end function value = read_int_float_tuple_(obj) - r = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); - value = r.read(obj.stream_); + value = obj.int_float_tuple_serializer.read(obj.stream_); end function value = read_float_float_tuple_(obj) - r = tuples.binary.TupleSerializer(yardl.binary.Float32Serializer, yardl.binary.Float32Serializer); - value = r.read(obj.stream_); + value = obj.float_float_tuple_serializer.read(obj.stream_); end function value = read_int_float_tuple_alternate_syntax_(obj) - r = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); - value = r.read(obj.stream_); + value = obj.int_float_tuple_alternate_syntax_serializer.read(obj.stream_); end function value = read_int_string_tuple_(obj) - r = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); - value = r.read(obj.stream_); + value = obj.int_string_tuple_serializer.read(obj.stream_); + end + + function more = has_stream_of_type_variants_(obj) + more = obj.stream_of_type_variants_serializer.hasnext(obj.stream_); end function value = read_stream_of_type_variants_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.ImageFloatOrImageDouble', {yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), yardl.binary.NDArraySerializer(yardl.binary.Float64Serializer, 2)}, {@test_model.ImageFloatOrImageDouble.ImageFloat, @test_model.ImageFloatOrImageDouble.ImageDouble})); - value = r.read(obj.stream_); + value = obj.stream_of_type_variants_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/SimpleGenericsWriter.m b/matlab/generated/+test_model/+binary/SimpleGenericsWriter.m index 8711f243..58addc43 100644 --- a/matlab/generated/+test_model/+binary/SimpleGenericsWriter.m +++ b/matlab/generated/+test_model/+binary/SimpleGenericsWriter.m @@ -2,57 +2,69 @@ classdef SimpleGenericsWriter < yardl.binary.BinaryProtocolWriter & test_model.SimpleGenericsWriterBase % Binary writer for the SimpleGenerics protocol + properties (Access=protected) + float_image_serializer + int_image_serializer + int_image_alternate_syntax_serializer + string_image_serializer + int_float_tuple_serializer + float_float_tuple_serializer + int_float_tuple_alternate_syntax_serializer + int_string_tuple_serializer + stream_of_type_variants_serializer + end + methods function obj = SimpleGenericsWriter(filename) obj@test_model.SimpleGenericsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.SimpleGenericsWriterBase.schema); + obj.float_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2); + obj.int_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + obj.int_image_alternate_syntax_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + obj.string_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.StringSerializer, 2); + obj.int_float_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); + obj.float_float_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Float32Serializer, yardl.binary.Float32Serializer); + obj.int_float_tuple_alternate_syntax_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); + obj.int_string_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + obj.stream_of_type_variants_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.ImageFloatOrImageDouble', {yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), yardl.binary.NDArraySerializer(yardl.binary.Float64Serializer, 2)}, {@test_model.ImageFloatOrImageDouble.ImageFloat, @test_model.ImageFloatOrImageDouble.ImageDouble})); end end methods (Access=protected) function write_float_image_(obj, value) - w = yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2); - w.write(obj.stream_, value); + obj.float_image_serializer.write(obj.stream_, value); end function write_int_image_(obj, value) - w = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - w.write(obj.stream_, value); + obj.int_image_serializer.write(obj.stream_, value); end function write_int_image_alternate_syntax_(obj, value) - w = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - w.write(obj.stream_, value); + obj.int_image_alternate_syntax_serializer.write(obj.stream_, value); end function write_string_image_(obj, value) - w = yardl.binary.NDArraySerializer(yardl.binary.StringSerializer, 2); - w.write(obj.stream_, value); + obj.string_image_serializer.write(obj.stream_, value); end function write_int_float_tuple_(obj, value) - w = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); - w.write(obj.stream_, value); + obj.int_float_tuple_serializer.write(obj.stream_, value); end function write_float_float_tuple_(obj, value) - w = tuples.binary.TupleSerializer(yardl.binary.Float32Serializer, yardl.binary.Float32Serializer); - w.write(obj.stream_, value); + obj.float_float_tuple_serializer.write(obj.stream_, value); end function write_int_float_tuple_alternate_syntax_(obj, value) - w = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); - w.write(obj.stream_, value); + obj.int_float_tuple_alternate_syntax_serializer.write(obj.stream_, value); end function write_int_string_tuple_(obj, value) - w = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); - w.write(obj.stream_, value); + obj.int_string_tuple_serializer.write(obj.stream_, value); end function write_stream_of_type_variants_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.ImageFloatOrImageDouble', {yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), yardl.binary.NDArraySerializer(yardl.binary.Float64Serializer, 2)}, {@test_model.ImageFloatOrImageDouble.ImageFloat, @test_model.ImageFloatOrImageDouble.ImageDouble})); - w.write(obj.stream_, value); + obj.stream_of_type_variants_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/StateTestReader.m b/matlab/generated/+test_model/+binary/StateTestReader.m index 74be1c7d..232b2457 100644 --- a/matlab/generated/+test_model/+binary/StateTestReader.m +++ b/matlab/generated/+test_model/+binary/StateTestReader.m @@ -2,27 +2,37 @@ classdef StateTestReader < yardl.binary.BinaryProtocolReader & test_model.StateTestReaderBase % Binary reader for the StateTest protocol + properties (Access=protected) + an_int_serializer + a_stream_serializer + another_int_serializer + end + methods function obj = StateTestReader(filename) obj@test_model.StateTestReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.StateTestReaderBase.schema); + obj.an_int_serializer = yardl.binary.Int32Serializer; + obj.a_stream_serializer = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); + obj.another_int_serializer = yardl.binary.Int32Serializer; end end methods (Access=protected) function value = read_an_int_(obj) - r = yardl.binary.Int32Serializer; - value = r.read(obj.stream_); + value = obj.an_int_serializer.read(obj.stream_); + end + + function more = has_a_stream_(obj) + more = obj.a_stream_serializer.hasnext(obj.stream_); end function value = read_a_stream_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); - value = r.read(obj.stream_); + value = obj.a_stream_serializer.read(obj.stream_); end function value = read_another_int_(obj) - r = yardl.binary.Int32Serializer; - value = r.read(obj.stream_); + value = obj.another_int_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/StateTestWriter.m b/matlab/generated/+test_model/+binary/StateTestWriter.m index 1ce6f94b..4d4dc965 100644 --- a/matlab/generated/+test_model/+binary/StateTestWriter.m +++ b/matlab/generated/+test_model/+binary/StateTestWriter.m @@ -2,27 +2,33 @@ classdef StateTestWriter < yardl.binary.BinaryProtocolWriter & test_model.StateTestWriterBase % Binary writer for the StateTest protocol + properties (Access=protected) + an_int_serializer + a_stream_serializer + another_int_serializer + end + methods function obj = StateTestWriter(filename) obj@test_model.StateTestWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.StateTestWriterBase.schema); + obj.an_int_serializer = yardl.binary.Int32Serializer; + obj.a_stream_serializer = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); + obj.another_int_serializer = yardl.binary.Int32Serializer; end end methods (Access=protected) function write_an_int_(obj, value) - w = yardl.binary.Int32Serializer; - w.write(obj.stream_, value); + obj.an_int_serializer.write(obj.stream_, value); end function write_a_stream_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); - w.write(obj.stream_, value); + obj.a_stream_serializer.write(obj.stream_, value); end function write_another_int_(obj, value) - w = yardl.binary.Int32Serializer; - w.write(obj.stream_, value); + obj.another_int_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m index 6ad6fbdf..08da91f5 100644 --- a/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m +++ b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m @@ -2,22 +2,35 @@ classdef StreamsOfAliasedUnionsReader < yardl.binary.BinaryProtocolReader & test_model.StreamsOfAliasedUnionsReaderBase % Binary reader for the StreamsOfAliasedUnions protocol + properties (Access=protected) + int_or_simple_record_serializer + nullable_int_or_simple_record_serializer + end + methods function obj = StreamsOfAliasedUnionsReader(filename) obj@test_model.StreamsOfAliasedUnionsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.StreamsOfAliasedUnionsReaderBase.schema); + obj.int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedIntOrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.AliasedIntOrSimpleRecord.Int32, @test_model.AliasedIntOrSimpleRecord.SimpleRecord})); + obj.nullable_int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedNullableIntSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.AliasedNullableIntSimpleRecord.Int32, @test_model.AliasedNullableIntSimpleRecord.SimpleRecord})); end end methods (Access=protected) + function more = has_int_or_simple_record_(obj) + more = obj.int_or_simple_record_serializer.hasnext(obj.stream_); + end + function value = read_int_or_simple_record_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedIntOrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.AliasedIntOrSimpleRecord.Int32, @test_model.AliasedIntOrSimpleRecord.SimpleRecord})); - value = r.read(obj.stream_); + value = obj.int_or_simple_record_serializer.read(obj.stream_); + end + + function more = has_nullable_int_or_simple_record_(obj) + more = obj.nullable_int_or_simple_record_serializer.hasnext(obj.stream_); end function value = read_nullable_int_or_simple_record_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedNullableIntSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.AliasedNullableIntSimpleRecord.Int32, @test_model.AliasedNullableIntSimpleRecord.SimpleRecord})); - value = r.read(obj.stream_); + value = obj.nullable_int_or_simple_record_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m index dc8983bd..80463839 100644 --- a/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m +++ b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m @@ -2,22 +2,27 @@ classdef StreamsOfAliasedUnionsWriter < yardl.binary.BinaryProtocolWriter & test_model.StreamsOfAliasedUnionsWriterBase % Binary writer for the StreamsOfAliasedUnions protocol + properties (Access=protected) + int_or_simple_record_serializer + nullable_int_or_simple_record_serializer + end + methods function obj = StreamsOfAliasedUnionsWriter(filename) obj@test_model.StreamsOfAliasedUnionsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.StreamsOfAliasedUnionsWriterBase.schema); + obj.int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedIntOrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.AliasedIntOrSimpleRecord.Int32, @test_model.AliasedIntOrSimpleRecord.SimpleRecord})); + obj.nullable_int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedNullableIntSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.AliasedNullableIntSimpleRecord.Int32, @test_model.AliasedNullableIntSimpleRecord.SimpleRecord})); end end methods (Access=protected) function write_int_or_simple_record_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedIntOrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.AliasedIntOrSimpleRecord.Int32, @test_model.AliasedIntOrSimpleRecord.SimpleRecord})); - w.write(obj.stream_, value); + obj.int_or_simple_record_serializer.write(obj.stream_, value); end function write_nullable_int_or_simple_record_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedNullableIntSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.AliasedNullableIntSimpleRecord.Int32, @test_model.AliasedNullableIntSimpleRecord.SimpleRecord})); - w.write(obj.stream_, value); + obj.nullable_int_or_simple_record_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m b/matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m index df4c06f0..75ec590c 100644 --- a/matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m +++ b/matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m @@ -2,22 +2,35 @@ classdef StreamsOfUnionsReader < yardl.binary.BinaryProtocolReader & test_model.StreamsOfUnionsReaderBase % Binary reader for the StreamsOfUnions protocol + properties (Access=protected) + int_or_simple_record_serializer + nullable_int_or_simple_record_serializer + end + methods function obj = StreamsOfUnionsReader(filename) obj@test_model.StreamsOfUnionsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.StreamsOfUnionsReaderBase.schema); + obj.int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); + obj.nullable_int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); end end methods (Access=protected) + function more = has_int_or_simple_record_(obj) + more = obj.int_or_simple_record_serializer.hasnext(obj.stream_); + end + function value = read_int_or_simple_record_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); - value = r.read(obj.stream_); + value = obj.int_or_simple_record_serializer.read(obj.stream_); + end + + function more = has_nullable_int_or_simple_record_(obj) + more = obj.nullable_int_or_simple_record_serializer.hasnext(obj.stream_); end function value = read_nullable_int_or_simple_record_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); - value = r.read(obj.stream_); + value = obj.nullable_int_or_simple_record_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m b/matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m index 8a62586a..89e2e3c5 100644 --- a/matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m +++ b/matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m @@ -2,22 +2,27 @@ classdef StreamsOfUnionsWriter < yardl.binary.BinaryProtocolWriter & test_model.StreamsOfUnionsWriterBase % Binary writer for the StreamsOfUnions protocol + properties (Access=protected) + int_or_simple_record_serializer + nullable_int_or_simple_record_serializer + end + methods function obj = StreamsOfUnionsWriter(filename) obj@test_model.StreamsOfUnionsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.StreamsOfUnionsWriterBase.schema); + obj.int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); + obj.nullable_int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); end end methods (Access=protected) function write_int_or_simple_record_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); - w.write(obj.stream_, value); + obj.int_or_simple_record_serializer.write(obj.stream_, value); end function write_nullable_int_or_simple_record_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); - w.write(obj.stream_, value); + obj.nullable_int_or_simple_record_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/StreamsReader.m b/matlab/generated/+test_model/+binary/StreamsReader.m index 32970acb..fe83ca5b 100644 --- a/matlab/generated/+test_model/+binary/StreamsReader.m +++ b/matlab/generated/+test_model/+binary/StreamsReader.m @@ -2,32 +2,55 @@ classdef StreamsReader < yardl.binary.BinaryProtocolReader & test_model.StreamsReaderBase % Binary reader for the Streams protocol + properties (Access=protected) + int_data_serializer + optional_int_data_serializer + record_with_optional_vector_data_serializer + fixed_vector_serializer + end + methods function obj = StreamsReader(filename) obj@test_model.StreamsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.StreamsReaderBase.schema); + obj.int_data_serializer = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); + obj.optional_int_data_serializer = yardl.binary.StreamSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer)); + obj.record_with_optional_vector_data_serializer = yardl.binary.StreamSerializer(test_model.binary.RecordWithOptionalVectorSerializer()); + obj.fixed_vector_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); end end methods (Access=protected) + function more = has_int_data_(obj) + more = obj.int_data_serializer.hasnext(obj.stream_); + end + function value = read_int_data_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); - value = r.read(obj.stream_); + value = obj.int_data_serializer.read(obj.stream_); + end + + function more = has_optional_int_data_(obj) + more = obj.optional_int_data_serializer.hasnext(obj.stream_); end function value = read_optional_int_data_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer)); - value = r.read(obj.stream_); + value = obj.optional_int_data_serializer.read(obj.stream_); + end + + function more = has_record_with_optional_vector_data_(obj) + more = obj.record_with_optional_vector_data_serializer.hasnext(obj.stream_); end function value = read_record_with_optional_vector_data_(obj) - r = yardl.binary.StreamSerializer(test_model.binary.RecordWithOptionalVectorSerializer()); - value = r.read(obj.stream_); + value = obj.record_with_optional_vector_data_serializer.read(obj.stream_); + end + + function more = has_fixed_vector_(obj) + more = obj.fixed_vector_serializer.hasnext(obj.stream_); end function value = read_fixed_vector_(obj) - r = yardl.binary.StreamSerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); - value = r.read(obj.stream_); + value = obj.fixed_vector_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/StreamsWriter.m b/matlab/generated/+test_model/+binary/StreamsWriter.m index bee1eb4d..394f7d49 100644 --- a/matlab/generated/+test_model/+binary/StreamsWriter.m +++ b/matlab/generated/+test_model/+binary/StreamsWriter.m @@ -2,32 +2,39 @@ classdef StreamsWriter < yardl.binary.BinaryProtocolWriter & test_model.StreamsWriterBase % Binary writer for the Streams protocol + properties (Access=protected) + int_data_serializer + optional_int_data_serializer + record_with_optional_vector_data_serializer + fixed_vector_serializer + end + methods function obj = StreamsWriter(filename) obj@test_model.StreamsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.StreamsWriterBase.schema); + obj.int_data_serializer = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); + obj.optional_int_data_serializer = yardl.binary.StreamSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer)); + obj.record_with_optional_vector_data_serializer = yardl.binary.StreamSerializer(test_model.binary.RecordWithOptionalVectorSerializer()); + obj.fixed_vector_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); end end methods (Access=protected) function write_int_data_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); - w.write(obj.stream_, value); + obj.int_data_serializer.write(obj.stream_, value); end function write_optional_int_data_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer)); - w.write(obj.stream_, value); + obj.optional_int_data_serializer.write(obj.stream_, value); end function write_record_with_optional_vector_data_(obj, value) - w = yardl.binary.StreamSerializer(test_model.binary.RecordWithOptionalVectorSerializer()); - w.write(obj.stream_, value); + obj.record_with_optional_vector_data_serializer.write(obj.stream_, value); end function write_fixed_vector_(obj, value) - w = yardl.binary.StreamSerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); - w.write(obj.stream_, value); + obj.fixed_vector_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/StringsReader.m b/matlab/generated/+test_model/+binary/StringsReader.m index efaca4e4..7524f5e8 100644 --- a/matlab/generated/+test_model/+binary/StringsReader.m +++ b/matlab/generated/+test_model/+binary/StringsReader.m @@ -2,22 +2,27 @@ classdef StringsReader < yardl.binary.BinaryProtocolReader & test_model.StringsReaderBase % Binary reader for the Strings protocol + properties (Access=protected) + single_string_serializer + rec_with_string_serializer + end + methods function obj = StringsReader(filename) obj@test_model.StringsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.StringsReaderBase.schema); + obj.single_string_serializer = yardl.binary.StringSerializer; + obj.rec_with_string_serializer = test_model.binary.RecordWithStringsSerializer(); end end methods (Access=protected) function value = read_single_string_(obj) - r = yardl.binary.StringSerializer; - value = r.read(obj.stream_); + value = obj.single_string_serializer.read(obj.stream_); end function value = read_rec_with_string_(obj) - r = test_model.binary.RecordWithStringsSerializer(); - value = r.read(obj.stream_); + value = obj.rec_with_string_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/StringsWriter.m b/matlab/generated/+test_model/+binary/StringsWriter.m index 62368b59..3cdd3f9f 100644 --- a/matlab/generated/+test_model/+binary/StringsWriter.m +++ b/matlab/generated/+test_model/+binary/StringsWriter.m @@ -2,22 +2,27 @@ classdef StringsWriter < yardl.binary.BinaryProtocolWriter & test_model.StringsWriterBase % Binary writer for the Strings protocol + properties (Access=protected) + single_string_serializer + rec_with_string_serializer + end + methods function obj = StringsWriter(filename) obj@test_model.StringsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.StringsWriterBase.schema); + obj.single_string_serializer = yardl.binary.StringSerializer; + obj.rec_with_string_serializer = test_model.binary.RecordWithStringsSerializer(); end end methods (Access=protected) function write_single_string_(obj, value) - w = yardl.binary.StringSerializer; - w.write(obj.stream_, value); + obj.single_string_serializer.write(obj.stream_, value); end function write_rec_with_string_(obj, value) - w = test_model.binary.RecordWithStringsSerializer(); - w.write(obj.stream_, value); + obj.rec_with_string_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m b/matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m index 6bd672eb..637b882c 100644 --- a/matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m +++ b/matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m @@ -2,22 +2,27 @@ classdef SubarraysInRecordsReader < yardl.binary.BinaryProtocolReader & test_model.SubarraysInRecordsReaderBase % Binary reader for the SubarraysInRecords protocol + properties (Access=protected) + with_fixed_subarrays_serializer + with_vlen_subarrays_serializer + end + methods function obj = SubarraysInRecordsReader(filename) obj@test_model.SubarraysInRecordsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.SubarraysInRecordsReaderBase.schema); + obj.with_fixed_subarrays_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithFixedCollectionsSerializer()); + obj.with_vlen_subarrays_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlenCollectionsSerializer()); end end methods (Access=protected) function value = read_with_fixed_subarrays_(obj) - r = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithFixedCollectionsSerializer()); - value = r.read(obj.stream_); + value = obj.with_fixed_subarrays_serializer.read(obj.stream_); end function value = read_with_vlen_subarrays_(obj) - r = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlenCollectionsSerializer()); - value = r.read(obj.stream_); + value = obj.with_vlen_subarrays_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m b/matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m index c8c2477b..5214ef6c 100644 --- a/matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m +++ b/matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m @@ -2,22 +2,27 @@ classdef SubarraysInRecordsWriter < yardl.binary.BinaryProtocolWriter & test_model.SubarraysInRecordsWriterBase % Binary writer for the SubarraysInRecords protocol + properties (Access=protected) + with_fixed_subarrays_serializer + with_vlen_subarrays_serializer + end + methods function obj = SubarraysInRecordsWriter(filename) obj@test_model.SubarraysInRecordsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.SubarraysInRecordsWriterBase.schema); + obj.with_fixed_subarrays_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithFixedCollectionsSerializer()); + obj.with_vlen_subarrays_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlenCollectionsSerializer()); end end methods (Access=protected) function write_with_fixed_subarrays_(obj, value) - w = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithFixedCollectionsSerializer()); - w.write(obj.stream_, value); + obj.with_fixed_subarrays_serializer.write(obj.stream_, value); end function write_with_vlen_subarrays_(obj, value) - w = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlenCollectionsSerializer()); - w.write(obj.stream_, value); + obj.with_vlen_subarrays_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/SubarraysReader.m b/matlab/generated/+test_model/+binary/SubarraysReader.m index 028cbfb0..b8cb7604 100644 --- a/matlab/generated/+test_model/+binary/SubarraysReader.m +++ b/matlab/generated/+test_model/+binary/SubarraysReader.m @@ -2,57 +2,69 @@ classdef SubarraysReader < yardl.binary.BinaryProtocolReader & test_model.SubarraysReaderBase % Binary reader for the Subarrays protocol + properties (Access=protected) + dynamic_with_fixed_int_subarray_serializer + dynamic_with_fixed_float_subarray_serializer + known_dim_count_with_fixed_int_subarray_serializer + known_dim_count_with_fixed_float_subarray_serializer + fixed_with_fixed_int_subarray_serializer + fixed_with_fixed_float_subarray_serializer + nested_subarray_serializer + dynamic_with_fixed_vector_subarray_serializer + generic_subarray_serializer + end + methods function obj = SubarraysReader(filename) obj@test_model.SubarraysReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.SubarraysReaderBase.schema); + obj.dynamic_with_fixed_int_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3])); + obj.dynamic_with_fixed_float_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3])); + obj.known_dim_count_with_fixed_int_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 1); + obj.known_dim_count_with_fixed_float_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), 1); + obj.fixed_with_fixed_int_subarray_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2]); + obj.fixed_with_fixed_float_subarray_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), [2]); + obj.nested_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2])); + obj.dynamic_with_fixed_vector_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); + obj.generic_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 2); end end methods (Access=protected) function value = read_dynamic_with_fixed_int_subarray_(obj) - r = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3])); - value = r.read(obj.stream_); + value = obj.dynamic_with_fixed_int_subarray_serializer.read(obj.stream_); end function value = read_dynamic_with_fixed_float_subarray_(obj) - r = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3])); - value = r.read(obj.stream_); + value = obj.dynamic_with_fixed_float_subarray_serializer.read(obj.stream_); end function value = read_known_dim_count_with_fixed_int_subarray_(obj) - r = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 1); - value = r.read(obj.stream_); + value = obj.known_dim_count_with_fixed_int_subarray_serializer.read(obj.stream_); end function value = read_known_dim_count_with_fixed_float_subarray_(obj) - r = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), 1); - value = r.read(obj.stream_); + value = obj.known_dim_count_with_fixed_float_subarray_serializer.read(obj.stream_); end function value = read_fixed_with_fixed_int_subarray_(obj) - r = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2]); - value = r.read(obj.stream_); + value = obj.fixed_with_fixed_int_subarray_serializer.read(obj.stream_); end function value = read_fixed_with_fixed_float_subarray_(obj) - r = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), [2]); - value = r.read(obj.stream_); + value = obj.fixed_with_fixed_float_subarray_serializer.read(obj.stream_); end function value = read_nested_subarray_(obj) - r = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2])); - value = r.read(obj.stream_); + value = obj.nested_subarray_serializer.read(obj.stream_); end function value = read_dynamic_with_fixed_vector_subarray_(obj) - r = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); - value = r.read(obj.stream_); + value = obj.dynamic_with_fixed_vector_subarray_serializer.read(obj.stream_); end function value = read_generic_subarray_(obj) - r = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 2); - value = r.read(obj.stream_); + value = obj.generic_subarray_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/SubarraysWriter.m b/matlab/generated/+test_model/+binary/SubarraysWriter.m index 4148b185..3bf59340 100644 --- a/matlab/generated/+test_model/+binary/SubarraysWriter.m +++ b/matlab/generated/+test_model/+binary/SubarraysWriter.m @@ -2,57 +2,69 @@ classdef SubarraysWriter < yardl.binary.BinaryProtocolWriter & test_model.SubarraysWriterBase % Binary writer for the Subarrays protocol + properties (Access=protected) + dynamic_with_fixed_int_subarray_serializer + dynamic_with_fixed_float_subarray_serializer + known_dim_count_with_fixed_int_subarray_serializer + known_dim_count_with_fixed_float_subarray_serializer + fixed_with_fixed_int_subarray_serializer + fixed_with_fixed_float_subarray_serializer + nested_subarray_serializer + dynamic_with_fixed_vector_subarray_serializer + generic_subarray_serializer + end + methods function obj = SubarraysWriter(filename) obj@test_model.SubarraysWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.SubarraysWriterBase.schema); + obj.dynamic_with_fixed_int_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3])); + obj.dynamic_with_fixed_float_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3])); + obj.known_dim_count_with_fixed_int_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 1); + obj.known_dim_count_with_fixed_float_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), 1); + obj.fixed_with_fixed_int_subarray_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2]); + obj.fixed_with_fixed_float_subarray_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), [2]); + obj.nested_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2])); + obj.dynamic_with_fixed_vector_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); + obj.generic_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 2); end end methods (Access=protected) function write_dynamic_with_fixed_int_subarray_(obj, value) - w = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3])); - w.write(obj.stream_, value); + obj.dynamic_with_fixed_int_subarray_serializer.write(obj.stream_, value); end function write_dynamic_with_fixed_float_subarray_(obj, value) - w = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3])); - w.write(obj.stream_, value); + obj.dynamic_with_fixed_float_subarray_serializer.write(obj.stream_, value); end function write_known_dim_count_with_fixed_int_subarray_(obj, value) - w = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 1); - w.write(obj.stream_, value); + obj.known_dim_count_with_fixed_int_subarray_serializer.write(obj.stream_, value); end function write_known_dim_count_with_fixed_float_subarray_(obj, value) - w = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), 1); - w.write(obj.stream_, value); + obj.known_dim_count_with_fixed_float_subarray_serializer.write(obj.stream_, value); end function write_fixed_with_fixed_int_subarray_(obj, value) - w = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2]); - w.write(obj.stream_, value); + obj.fixed_with_fixed_int_subarray_serializer.write(obj.stream_, value); end function write_fixed_with_fixed_float_subarray_(obj, value) - w = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), [2]); - w.write(obj.stream_, value); + obj.fixed_with_fixed_float_subarray_serializer.write(obj.stream_, value); end function write_nested_subarray_(obj, value) - w = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2])); - w.write(obj.stream_, value); + obj.nested_subarray_serializer.write(obj.stream_, value); end function write_dynamic_with_fixed_vector_subarray_(obj, value) - w = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); - w.write(obj.stream_, value); + obj.dynamic_with_fixed_vector_subarray_serializer.write(obj.stream_, value); end function write_generic_subarray_(obj, value) - w = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 2); - w.write(obj.stream_, value); + obj.generic_subarray_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/UnionsReader.m b/matlab/generated/+test_model/+binary/UnionsReader.m index c456c4e8..5b64af4f 100644 --- a/matlab/generated/+test_model/+binary/UnionsReader.m +++ b/matlab/generated/+test_model/+binary/UnionsReader.m @@ -2,32 +2,39 @@ classdef UnionsReader < yardl.binary.BinaryProtocolReader & test_model.UnionsReaderBase % Binary reader for the Unions protocol + properties (Access=protected) + int_or_simple_record_serializer + int_or_record_with_vlens_serializer + monosotate_or_int_or_simple_record_serializer + record_with_unions_serializer + end + methods function obj = UnionsReader(filename) obj@test_model.UnionsReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.UnionsReaderBase.schema); + obj.int_or_simple_record_serializer = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); + obj.int_or_record_with_vlens_serializer = yardl.binary.UnionSerializer('test_model.Int32OrRecordWithVlens', {yardl.binary.Int32Serializer, test_model.binary.RecordWithVlensSerializer()}, {@test_model.Int32OrRecordWithVlens.Int32, @test_model.Int32OrRecordWithVlens.RecordWithVlens}); + obj.monosotate_or_int_or_simple_record_serializer = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); + obj.record_with_unions_serializer = basic_types.binary.RecordWithUnionsSerializer(); end end methods (Access=protected) function value = read_int_or_simple_record_(obj) - r = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); - value = r.read(obj.stream_); + value = obj.int_or_simple_record_serializer.read(obj.stream_); end function value = read_int_or_record_with_vlens_(obj) - r = yardl.binary.UnionSerializer('test_model.Int32OrRecordWithVlens', {yardl.binary.Int32Serializer, test_model.binary.RecordWithVlensSerializer()}, {@test_model.Int32OrRecordWithVlens.Int32, @test_model.Int32OrRecordWithVlens.RecordWithVlens}); - value = r.read(obj.stream_); + value = obj.int_or_record_with_vlens_serializer.read(obj.stream_); end function value = read_monosotate_or_int_or_simple_record_(obj) - r = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); - value = r.read(obj.stream_); + value = obj.monosotate_or_int_or_simple_record_serializer.read(obj.stream_); end function value = read_record_with_unions_(obj) - r = basic_types.binary.RecordWithUnionsSerializer(); - value = r.read(obj.stream_); + value = obj.record_with_unions_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/UnionsWriter.m b/matlab/generated/+test_model/+binary/UnionsWriter.m index bbe28c5f..5d711325 100644 --- a/matlab/generated/+test_model/+binary/UnionsWriter.m +++ b/matlab/generated/+test_model/+binary/UnionsWriter.m @@ -2,32 +2,39 @@ classdef UnionsWriter < yardl.binary.BinaryProtocolWriter & test_model.UnionsWriterBase % Binary writer for the Unions protocol + properties (Access=protected) + int_or_simple_record_serializer + int_or_record_with_vlens_serializer + monosotate_or_int_or_simple_record_serializer + record_with_unions_serializer + end + methods function obj = UnionsWriter(filename) obj@test_model.UnionsWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.UnionsWriterBase.schema); + obj.int_or_simple_record_serializer = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); + obj.int_or_record_with_vlens_serializer = yardl.binary.UnionSerializer('test_model.Int32OrRecordWithVlens', {yardl.binary.Int32Serializer, test_model.binary.RecordWithVlensSerializer()}, {@test_model.Int32OrRecordWithVlens.Int32, @test_model.Int32OrRecordWithVlens.RecordWithVlens}); + obj.monosotate_or_int_or_simple_record_serializer = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); + obj.record_with_unions_serializer = basic_types.binary.RecordWithUnionsSerializer(); end end methods (Access=protected) function write_int_or_simple_record_(obj, value) - w = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); - w.write(obj.stream_, value); + obj.int_or_simple_record_serializer.write(obj.stream_, value); end function write_int_or_record_with_vlens_(obj, value) - w = yardl.binary.UnionSerializer('test_model.Int32OrRecordWithVlens', {yardl.binary.Int32Serializer, test_model.binary.RecordWithVlensSerializer()}, {@test_model.Int32OrRecordWithVlens.Int32, @test_model.Int32OrRecordWithVlens.RecordWithVlens}); - w.write(obj.stream_, value); + obj.int_or_record_with_vlens_serializer.write(obj.stream_, value); end function write_monosotate_or_int_or_simple_record_(obj, value) - w = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); - w.write(obj.stream_, value); + obj.monosotate_or_int_or_simple_record_serializer.write(obj.stream_, value); end function write_record_with_unions_(obj, value) - w = basic_types.binary.RecordWithUnionsSerializer(); - w.write(obj.stream_, value); + obj.record_with_unions_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/VlensReader.m b/matlab/generated/+test_model/+binary/VlensReader.m index 539206aa..6f2bb302 100644 --- a/matlab/generated/+test_model/+binary/VlensReader.m +++ b/matlab/generated/+test_model/+binary/VlensReader.m @@ -2,32 +2,39 @@ classdef VlensReader < yardl.binary.BinaryProtocolReader & test_model.VlensReaderBase % Binary reader for the Vlens protocol + properties (Access=protected) + int_vector_serializer + complex_vector_serializer + record_with_vlens_serializer + vlen_of_record_with_vlens_serializer + end + methods function obj = VlensReader(filename) obj@test_model.VlensReaderBase(); obj@yardl.binary.BinaryProtocolReader(filename, test_model.VlensReaderBase.schema); + obj.int_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); + obj.complex_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Complexfloat32Serializer); + obj.record_with_vlens_serializer = test_model.binary.RecordWithVlensSerializer(); + obj.vlen_of_record_with_vlens_serializer = yardl.binary.VectorSerializer(test_model.binary.RecordWithVlensSerializer()); end end methods (Access=protected) function value = read_int_vector_(obj) - r = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); - value = r.read(obj.stream_); + value = obj.int_vector_serializer.read(obj.stream_); end function value = read_complex_vector_(obj) - r = yardl.binary.VectorSerializer(yardl.binary.Complexfloat32Serializer); - value = r.read(obj.stream_); + value = obj.complex_vector_serializer.read(obj.stream_); end function value = read_record_with_vlens_(obj) - r = test_model.binary.RecordWithVlensSerializer(); - value = r.read(obj.stream_); + value = obj.record_with_vlens_serializer.read(obj.stream_); end function value = read_vlen_of_record_with_vlens_(obj) - r = yardl.binary.VectorSerializer(test_model.binary.RecordWithVlensSerializer()); - value = r.read(obj.stream_); + value = obj.vlen_of_record_with_vlens_serializer.read(obj.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/VlensWriter.m b/matlab/generated/+test_model/+binary/VlensWriter.m index 5fd6d54f..891676bf 100644 --- a/matlab/generated/+test_model/+binary/VlensWriter.m +++ b/matlab/generated/+test_model/+binary/VlensWriter.m @@ -2,32 +2,39 @@ classdef VlensWriter < yardl.binary.BinaryProtocolWriter & test_model.VlensWriterBase % Binary writer for the Vlens protocol + properties (Access=protected) + int_vector_serializer + complex_vector_serializer + record_with_vlens_serializer + vlen_of_record_with_vlens_serializer + end + methods function obj = VlensWriter(filename) obj@test_model.VlensWriterBase(); obj@yardl.binary.BinaryProtocolWriter(filename, test_model.VlensWriterBase.schema); + obj.int_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); + obj.complex_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Complexfloat32Serializer); + obj.record_with_vlens_serializer = test_model.binary.RecordWithVlensSerializer(); + obj.vlen_of_record_with_vlens_serializer = yardl.binary.VectorSerializer(test_model.binary.RecordWithVlensSerializer()); end end methods (Access=protected) function write_int_vector_(obj, value) - w = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); - w.write(obj.stream_, value); + obj.int_vector_serializer.write(obj.stream_, value); end function write_complex_vector_(obj, value) - w = yardl.binary.VectorSerializer(yardl.binary.Complexfloat32Serializer); - w.write(obj.stream_, value); + obj.complex_vector_serializer.write(obj.stream_, value); end function write_record_with_vlens_(obj, value) - w = test_model.binary.RecordWithVlensSerializer(); - w.write(obj.stream_, value); + obj.record_with_vlens_serializer.write(obj.stream_, value); end function write_vlen_of_record_with_vlens_(obj, value) - w = yardl.binary.VectorSerializer(test_model.binary.RecordWithVlensSerializer()); - w.write(obj.stream_, value); + obj.vlen_of_record_with_vlens_serializer.write(obj.stream_, value); end end end diff --git a/matlab/generated/+test_model/AdvancedGenericsReaderBase.m b/matlab/generated/+test_model/AdvancedGenericsReaderBase.m index 6d2e1341..d6e770b8 100644 --- a/matlab/generated/+test_model/AdvancedGenericsReaderBase.m +++ b/matlab/generated/+test_model/AdvancedGenericsReaderBase.m @@ -74,11 +74,26 @@ function close(obj) end function copy_to(obj, writer) - writer.write_float_image_image(obj.read_float_image_image()); - writer.write_generic_record_1(obj.read_generic_record_1()); - writer.write_tuple_of_optionals(obj.read_tuple_of_optionals()); - writer.write_tuple_of_optionals_alternate_syntax(obj.read_tuple_of_optionals_alternate_syntax()); - writer.write_tuple_of_vectors(obj.read_tuple_of_vectors()); + while obj.has_float_image_image() + item = obj.read_float_image_image(); + writer.write_float_image_image({item}); + end + while obj.has_generic_record_1() + item = obj.read_generic_record_1(); + writer.write_generic_record_1({item}); + end + while obj.has_tuple_of_optionals() + item = obj.read_tuple_of_optionals(); + writer.write_tuple_of_optionals({item}); + end + while obj.has_tuple_of_optionals_alternate_syntax() + item = obj.read_tuple_of_optionals_alternate_syntax(); + writer.write_tuple_of_optionals_alternate_syntax({item}); + end + while obj.has_tuple_of_vectors() + item = obj.read_tuple_of_vectors(); + writer.write_tuple_of_vectors({item}); + end end end @@ -89,11 +104,11 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_float_image_image_(obj, value) - read_generic_record_1_(obj, value) - read_tuple_of_optionals_(obj, value) - read_tuple_of_optionals_alternate_syntax_(obj, value) - read_tuple_of_vectors_(obj, value) + read_float_image_image_(obj) + read_generic_record_1_(obj) + read_tuple_of_optionals_(obj) + read_tuple_of_optionals_alternate_syntax_(obj) + read_tuple_of_vectors_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/AliasesReaderBase.m b/matlab/generated/+test_model/AliasesReaderBase.m index f6f799c5..78f34d6e 100644 --- a/matlab/generated/+test_model/AliasesReaderBase.m +++ b/matlab/generated/+test_model/AliasesReaderBase.m @@ -114,26 +114,66 @@ function close(obj) end % Ordinal 9 + function more = has_stream_of_aliased_generic_union_2(obj) + if obj.state_ ~= 18 + obj.raise_unexpected_state_(18); + end + + more = obj.has_stream_of_aliased_generic_union_2_(); + if ~more + obj.state_ = 20; + end + end + function value = read_stream_of_aliased_generic_union_2(obj) if obj.state_ ~= 18 obj.raise_unexpected_state_(18); end value = obj.read_stream_of_aliased_generic_union_2_(); - obj.state_ = 20; end function copy_to(obj, writer) - writer.write_aliased_string(obj.read_aliased_string()); - writer.write_aliased_enum(obj.read_aliased_enum()); - writer.write_aliased_open_generic(obj.read_aliased_open_generic()); - writer.write_aliased_closed_generic(obj.read_aliased_closed_generic()); - writer.write_aliased_optional(obj.read_aliased_optional()); - writer.write_aliased_generic_optional(obj.read_aliased_generic_optional()); - writer.write_aliased_generic_union_2(obj.read_aliased_generic_union_2()); - writer.write_aliased_generic_vector(obj.read_aliased_generic_vector()); - writer.write_aliased_generic_fixed_vector(obj.read_aliased_generic_fixed_vector()); - writer.write_stream_of_aliased_generic_union_2(obj.read_stream_of_aliased_generic_union_2()); + while obj.has_aliased_string() + item = obj.read_aliased_string(); + writer.write_aliased_string({item}); + end + while obj.has_aliased_enum() + item = obj.read_aliased_enum(); + writer.write_aliased_enum({item}); + end + while obj.has_aliased_open_generic() + item = obj.read_aliased_open_generic(); + writer.write_aliased_open_generic({item}); + end + while obj.has_aliased_closed_generic() + item = obj.read_aliased_closed_generic(); + writer.write_aliased_closed_generic({item}); + end + while obj.has_aliased_optional() + item = obj.read_aliased_optional(); + writer.write_aliased_optional({item}); + end + while obj.has_aliased_generic_optional() + item = obj.read_aliased_generic_optional(); + writer.write_aliased_generic_optional({item}); + end + while obj.has_aliased_generic_union_2() + item = obj.read_aliased_generic_union_2(); + writer.write_aliased_generic_union_2({item}); + end + while obj.has_aliased_generic_vector() + item = obj.read_aliased_generic_vector(); + writer.write_aliased_generic_vector({item}); + end + while obj.has_aliased_generic_fixed_vector() + item = obj.read_aliased_generic_fixed_vector(); + writer.write_aliased_generic_fixed_vector({item}); + end + while obj.has_stream_of_aliased_generic_union_2() + item = obj.read_stream_of_aliased_generic_union_2(); + writer.write_stream_of_aliased_generic_union_2({item}); + end end end @@ -144,16 +184,17 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_aliased_string_(obj, value) - read_aliased_enum_(obj, value) - read_aliased_open_generic_(obj, value) - read_aliased_closed_generic_(obj, value) - read_aliased_optional_(obj, value) - read_aliased_generic_optional_(obj, value) - read_aliased_generic_union_2_(obj, value) - read_aliased_generic_vector_(obj, value) - read_aliased_generic_fixed_vector_(obj, value) - read_stream_of_aliased_generic_union_2_(obj, value) + read_aliased_string_(obj) + read_aliased_enum_(obj) + read_aliased_open_generic_(obj) + read_aliased_closed_generic_(obj) + read_aliased_optional_(obj) + read_aliased_generic_optional_(obj) + read_aliased_generic_union_2_(obj) + read_aliased_generic_vector_(obj) + read_aliased_generic_fixed_vector_(obj) + has_stream_of_aliased_generic_union_2_(obj) + read_stream_of_aliased_generic_union_2_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m b/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m index fae4377a..6ebda383 100644 --- a/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m @@ -24,17 +24,30 @@ function close(obj) end % Ordinal 0 + function more = has_float256x256(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + more = obj.has_float256x256_(); + if ~more + obj.state_ = 2; + end + end + function value = read_float256x256(obj) if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end value = obj.read_float256x256_(); - obj.state_ = 2; end function copy_to(obj, writer) - writer.write_float256x256(obj.read_float256x256()); + while obj.has_float256x256() + item = obj.read_float256x256(); + writer.write_float256x256({item}); + end end end @@ -45,7 +58,8 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_float256x256_(obj, value) + has_float256x256_(obj) + read_float256x256_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m b/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m index 612e816b..0d1e7363 100644 --- a/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m @@ -24,17 +24,30 @@ function close(obj) end % Ordinal 0 + function more = has_float_array(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + more = obj.has_float_array_(); + if ~more + obj.state_ = 2; + end + end + function value = read_float_array(obj) if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end value = obj.read_float_array_(); - obj.state_ = 2; end function copy_to(obj, writer) - writer.write_float_array(obj.read_float_array()); + while obj.has_float_array() + item = obj.read_float_array(); + writer.write_float_array({item}); + end end end @@ -45,7 +58,8 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_float_array_(obj, value) + has_float_array_(obj) + read_float_array_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m b/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m index 9b64d136..d536eefa 100644 --- a/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m @@ -24,17 +24,30 @@ function close(obj) end % Ordinal 0 + function more = has_int256x256(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + more = obj.has_int256x256_(); + if ~more + obj.state_ = 2; + end + end + function value = read_int256x256(obj) if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end value = obj.read_int256x256_(); - obj.state_ = 2; end function copy_to(obj, writer) - writer.write_int256x256(obj.read_int256x256()); + while obj.has_int256x256() + item = obj.read_int256x256(); + writer.write_int256x256({item}); + end end end @@ -45,7 +58,8 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_int256x256_(obj, value) + has_int256x256_(obj) + read_int256x256_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m b/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m index 4dad134d..17e65407 100644 --- a/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m @@ -24,17 +24,30 @@ function close(obj) end % Ordinal 0 + function more = has_data(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + more = obj.has_data_(); + if ~more + obj.state_ = 2; + end + end + function value = read_data(obj) if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end value = obj.read_data_(); - obj.state_ = 2; end function copy_to(obj, writer) - writer.write_data(obj.read_data()); + while obj.has_data() + item = obj.read_data(); + writer.write_data({item}); + end end end @@ -45,7 +58,8 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_data_(obj, value) + has_data_(obj) + read_data_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m index ac5eeb31..40573f4b 100644 --- a/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m @@ -24,17 +24,30 @@ function close(obj) end % Ordinal 0 + function more = has_small_record(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + more = obj.has_small_record_(); + if ~more + obj.state_ = 2; + end + end + function value = read_small_record(obj) if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end value = obj.read_small_record_(); - obj.state_ = 2; end function copy_to(obj, writer) - writer.write_small_record(obj.read_small_record()); + while obj.has_small_record() + item = obj.read_small_record(); + writer.write_small_record({item}); + end end end @@ -45,7 +58,8 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_small_record_(obj, value) + has_small_record_(obj) + read_small_record_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m index ebfe5304..4af9afa9 100644 --- a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m @@ -24,17 +24,30 @@ function close(obj) end % Ordinal 0 + function more = has_small_record(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + more = obj.has_small_record_(); + if ~more + obj.state_ = 2; + end + end + function value = read_small_record(obj) if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end value = obj.read_small_record_(); - obj.state_ = 2; end function copy_to(obj, writer) - writer.write_small_record(obj.read_small_record()); + while obj.has_small_record() + item = obj.read_small_record(); + writer.write_small_record({item}); + end end end @@ -45,7 +58,8 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_small_record_(obj, value) + has_small_record_(obj) + read_small_record_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/DynamicNDArraysReaderBase.m b/matlab/generated/+test_model/DynamicNDArraysReaderBase.m index 018f09da..35f7bcd8 100644 --- a/matlab/generated/+test_model/DynamicNDArraysReaderBase.m +++ b/matlab/generated/+test_model/DynamicNDArraysReaderBase.m @@ -64,10 +64,22 @@ function close(obj) end function copy_to(obj, writer) - writer.write_ints(obj.read_ints()); - writer.write_simple_record_array(obj.read_simple_record_array()); - writer.write_record_with_vlens_array(obj.read_record_with_vlens_array()); - writer.write_record_with_dynamic_nd_arrays(obj.read_record_with_dynamic_nd_arrays()); + while obj.has_ints() + item = obj.read_ints(); + writer.write_ints({item}); + end + while obj.has_simple_record_array() + item = obj.read_simple_record_array(); + writer.write_simple_record_array({item}); + end + while obj.has_record_with_vlens_array() + item = obj.read_record_with_vlens_array(); + writer.write_record_with_vlens_array({item}); + end + while obj.has_record_with_dynamic_nd_arrays() + item = obj.read_record_with_dynamic_nd_arrays(); + writer.write_record_with_dynamic_nd_arrays({item}); + end end end @@ -78,10 +90,10 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_ints_(obj, value) - read_simple_record_array_(obj, value) - read_record_with_vlens_array_(obj, value) - read_record_with_dynamic_nd_arrays_(obj, value) + read_ints_(obj) + read_simple_record_array_(obj) + read_record_with_vlens_array_(obj) + read_record_with_dynamic_nd_arrays_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/EnumsReaderBase.m b/matlab/generated/+test_model/EnumsReaderBase.m index 3e40bcb5..67464952 100644 --- a/matlab/generated/+test_model/EnumsReaderBase.m +++ b/matlab/generated/+test_model/EnumsReaderBase.m @@ -54,9 +54,18 @@ function close(obj) end function copy_to(obj, writer) - writer.write_single(obj.read_single()); - writer.write_vec(obj.read_vec()); - writer.write_size(obj.read_size()); + while obj.has_single() + item = obj.read_single(); + writer.write_single({item}); + end + while obj.has_vec() + item = obj.read_vec(); + writer.write_vec({item}); + end + while obj.has_size() + item = obj.read_size(); + writer.write_size({item}); + end end end @@ -67,9 +76,9 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_single_(obj, value) - read_vec_(obj, value) - read_size_(obj, value) + read_single_(obj) + read_vec_(obj) + read_size_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/FixedArraysReaderBase.m b/matlab/generated/+test_model/FixedArraysReaderBase.m index cfefaf99..8401e78c 100644 --- a/matlab/generated/+test_model/FixedArraysReaderBase.m +++ b/matlab/generated/+test_model/FixedArraysReaderBase.m @@ -74,11 +74,26 @@ function close(obj) end function copy_to(obj, writer) - writer.write_ints(obj.read_ints()); - writer.write_fixed_simple_record_array(obj.read_fixed_simple_record_array()); - writer.write_fixed_record_with_vlens_array(obj.read_fixed_record_with_vlens_array()); - writer.write_record_with_fixed_arrays(obj.read_record_with_fixed_arrays()); - writer.write_named_array(obj.read_named_array()); + while obj.has_ints() + item = obj.read_ints(); + writer.write_ints({item}); + end + while obj.has_fixed_simple_record_array() + item = obj.read_fixed_simple_record_array(); + writer.write_fixed_simple_record_array({item}); + end + while obj.has_fixed_record_with_vlens_array() + item = obj.read_fixed_record_with_vlens_array(); + writer.write_fixed_record_with_vlens_array({item}); + end + while obj.has_record_with_fixed_arrays() + item = obj.read_record_with_fixed_arrays(); + writer.write_record_with_fixed_arrays({item}); + end + while obj.has_named_array() + item = obj.read_named_array(); + writer.write_named_array({item}); + end end end @@ -89,11 +104,11 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_ints_(obj, value) - read_fixed_simple_record_array_(obj, value) - read_fixed_record_with_vlens_array_(obj, value) - read_record_with_fixed_arrays_(obj, value) - read_named_array_(obj, value) + read_ints_(obj) + read_fixed_simple_record_array_(obj) + read_fixed_record_with_vlens_array_(obj) + read_record_with_fixed_arrays_(obj) + read_named_array_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/FixedVectorsReaderBase.m b/matlab/generated/+test_model/FixedVectorsReaderBase.m index b1a0687d..10d7d731 100644 --- a/matlab/generated/+test_model/FixedVectorsReaderBase.m +++ b/matlab/generated/+test_model/FixedVectorsReaderBase.m @@ -64,10 +64,22 @@ function close(obj) end function copy_to(obj, writer) - writer.write_fixed_int_vector(obj.read_fixed_int_vector()); - writer.write_fixed_simple_record_vector(obj.read_fixed_simple_record_vector()); - writer.write_fixed_record_with_vlens_vector(obj.read_fixed_record_with_vlens_vector()); - writer.write_record_with_fixed_vectors(obj.read_record_with_fixed_vectors()); + while obj.has_fixed_int_vector() + item = obj.read_fixed_int_vector(); + writer.write_fixed_int_vector({item}); + end + while obj.has_fixed_simple_record_vector() + item = obj.read_fixed_simple_record_vector(); + writer.write_fixed_simple_record_vector({item}); + end + while obj.has_fixed_record_with_vlens_vector() + item = obj.read_fixed_record_with_vlens_vector(); + writer.write_fixed_record_with_vlens_vector({item}); + end + while obj.has_record_with_fixed_vectors() + item = obj.read_record_with_fixed_vectors(); + writer.write_record_with_fixed_vectors({item}); + end end end @@ -78,10 +90,10 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_fixed_int_vector_(obj, value) - read_fixed_simple_record_vector_(obj, value) - read_fixed_record_with_vlens_vector_(obj, value) - read_record_with_fixed_vectors_(obj, value) + read_fixed_int_vector_(obj) + read_fixed_simple_record_vector_(obj) + read_fixed_record_with_vlens_vector_(obj) + read_record_with_fixed_vectors_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/FlagsReaderBase.m b/matlab/generated/+test_model/FlagsReaderBase.m index 62be65c2..4d53ef02 100644 --- a/matlab/generated/+test_model/FlagsReaderBase.m +++ b/matlab/generated/+test_model/FlagsReaderBase.m @@ -24,28 +24,54 @@ function close(obj) end % Ordinal 0 + function more = has_days(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + more = obj.has_days_(); + if ~more + obj.state_ = 2; + end + end + function value = read_days(obj) if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end value = obj.read_days_(); - obj.state_ = 2; end % Ordinal 1 + function more = has_formats(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + more = obj.has_formats_(); + if ~more + obj.state_ = 4; + end + end + function value = read_formats(obj) if obj.state_ ~= 2 obj.raise_unexpected_state_(2); end value = obj.read_formats_(); - obj.state_ = 4; end function copy_to(obj, writer) - writer.write_days(obj.read_days()); - writer.write_formats(obj.read_formats()); + while obj.has_days() + item = obj.read_days(); + writer.write_days({item}); + end + while obj.has_formats() + item = obj.read_formats(); + writer.write_formats({item}); + end end end @@ -56,8 +82,10 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_days_(obj, value) - read_formats_(obj, value) + has_days_(obj) + read_days_(obj) + has_formats_(obj) + read_formats_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/MapsReaderBase.m b/matlab/generated/+test_model/MapsReaderBase.m index ad34ca82..27da4559 100644 --- a/matlab/generated/+test_model/MapsReaderBase.m +++ b/matlab/generated/+test_model/MapsReaderBase.m @@ -64,10 +64,22 @@ function close(obj) end function copy_to(obj, writer) - writer.write_string_to_int(obj.read_string_to_int()); - writer.write_int_to_string(obj.read_int_to_string()); - writer.write_string_to_union(obj.read_string_to_union()); - writer.write_aliased_generic(obj.read_aliased_generic()); + while obj.has_string_to_int() + item = obj.read_string_to_int(); + writer.write_string_to_int({item}); + end + while obj.has_int_to_string() + item = obj.read_int_to_string(); + writer.write_int_to_string({item}); + end + while obj.has_string_to_union() + item = obj.read_string_to_union(); + writer.write_string_to_union({item}); + end + while obj.has_aliased_generic() + item = obj.read_aliased_generic(); + writer.write_aliased_generic({item}); + end end end @@ -78,10 +90,10 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_string_to_int_(obj, value) - read_int_to_string_(obj, value) - read_string_to_union_(obj, value) - read_aliased_generic_(obj, value) + read_string_to_int_(obj) + read_int_to_string_(obj) + read_string_to_union_(obj) + read_aliased_generic_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/NDArraysReaderBase.m b/matlab/generated/+test_model/NDArraysReaderBase.m index 976c6378..11952889 100644 --- a/matlab/generated/+test_model/NDArraysReaderBase.m +++ b/matlab/generated/+test_model/NDArraysReaderBase.m @@ -74,11 +74,26 @@ function close(obj) end function copy_to(obj, writer) - writer.write_ints(obj.read_ints()); - writer.write_simple_record_array(obj.read_simple_record_array()); - writer.write_record_with_vlens_array(obj.read_record_with_vlens_array()); - writer.write_record_with_nd_arrays(obj.read_record_with_nd_arrays()); - writer.write_named_array(obj.read_named_array()); + while obj.has_ints() + item = obj.read_ints(); + writer.write_ints({item}); + end + while obj.has_simple_record_array() + item = obj.read_simple_record_array(); + writer.write_simple_record_array({item}); + end + while obj.has_record_with_vlens_array() + item = obj.read_record_with_vlens_array(); + writer.write_record_with_vlens_array({item}); + end + while obj.has_record_with_nd_arrays() + item = obj.read_record_with_nd_arrays(); + writer.write_record_with_nd_arrays({item}); + end + while obj.has_named_array() + item = obj.read_named_array(); + writer.write_named_array({item}); + end end end @@ -89,11 +104,11 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_ints_(obj, value) - read_simple_record_array_(obj, value) - read_record_with_vlens_array_(obj, value) - read_record_with_nd_arrays_(obj, value) - read_named_array_(obj, value) + read_ints_(obj) + read_simple_record_array_(obj) + read_record_with_vlens_array_(obj) + read_record_with_nd_arrays_(obj) + read_named_array_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m b/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m index 7e6c206b..97d4b218 100644 --- a/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m +++ b/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m @@ -64,10 +64,22 @@ function close(obj) end function copy_to(obj, writer) - writer.write_ints(obj.read_ints()); - writer.write_simple_record_array(obj.read_simple_record_array()); - writer.write_record_with_vlens_array(obj.read_record_with_vlens_array()); - writer.write_record_with_nd_arrays(obj.read_record_with_nd_arrays()); + while obj.has_ints() + item = obj.read_ints(); + writer.write_ints({item}); + end + while obj.has_simple_record_array() + item = obj.read_simple_record_array(); + writer.write_simple_record_array({item}); + end + while obj.has_record_with_vlens_array() + item = obj.read_record_with_vlens_array(); + writer.write_record_with_vlens_array({item}); + end + while obj.has_record_with_nd_arrays() + item = obj.read_record_with_nd_arrays(); + writer.write_record_with_nd_arrays({item}); + end end end @@ -78,10 +90,10 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_ints_(obj, value) - read_simple_record_array_(obj, value) - read_record_with_vlens_array_(obj, value) - read_record_with_nd_arrays_(obj, value) + read_ints_(obj) + read_simple_record_array_(obj) + read_record_with_vlens_array_(obj) + read_record_with_nd_arrays_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/NestedRecordsReaderBase.m b/matlab/generated/+test_model/NestedRecordsReaderBase.m index 1d0347c0..3ed687cb 100644 --- a/matlab/generated/+test_model/NestedRecordsReaderBase.m +++ b/matlab/generated/+test_model/NestedRecordsReaderBase.m @@ -34,7 +34,10 @@ function close(obj) end function copy_to(obj, writer) - writer.write_tuple_with_records(obj.read_tuple_with_records()); + while obj.has_tuple_with_records() + item = obj.read_tuple_with_records(); + writer.write_tuple_with_records({item}); + end end end @@ -45,7 +48,7 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_tuple_with_records_(obj, value) + read_tuple_with_records_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/OptionalVectorsReaderBase.m b/matlab/generated/+test_model/OptionalVectorsReaderBase.m index 791a5fda..7e502ca5 100644 --- a/matlab/generated/+test_model/OptionalVectorsReaderBase.m +++ b/matlab/generated/+test_model/OptionalVectorsReaderBase.m @@ -34,7 +34,10 @@ function close(obj) end function copy_to(obj, writer) - writer.write_record_with_optional_vector(obj.read_record_with_optional_vector()); + while obj.has_record_with_optional_vector() + item = obj.read_record_with_optional_vector(); + writer.write_record_with_optional_vector({item}); + end end end @@ -45,7 +48,7 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_record_with_optional_vector_(obj, value) + read_record_with_optional_vector_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m b/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m index 39782e90..020d3e7e 100644 --- a/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m +++ b/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m @@ -34,7 +34,10 @@ function close(obj) end function copy_to(obj, writer) - writer.write_record_with_computed_fields(obj.read_record_with_computed_fields()); + while obj.has_record_with_computed_fields() + item = obj.read_record_with_computed_fields(); + writer.write_record_with_computed_fields({item}); + end end end @@ -45,7 +48,7 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_record_with_computed_fields_(obj, value) + read_record_with_computed_fields_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m b/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m index d93e2ab0..8d3af52f 100644 --- a/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m +++ b/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m @@ -24,13 +24,23 @@ function close(obj) end % Ordinal 0 + function more = has_int(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + more = obj.has_int_(); + if ~more + obj.state_ = 2; + end + end + function value = read_int(obj) if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end value = obj.read_int_(); - obj.state_ = 2; end % Ordinal 1 @@ -44,8 +54,14 @@ function close(obj) end function copy_to(obj, writer) - writer.write_int(obj.read_int()); - writer.write_float(obj.read_float()); + while obj.has_int() + item = obj.read_int(); + writer.write_int({item}); + end + while obj.has_float() + item = obj.read_float(); + writer.write_float({item}); + end end end @@ -56,8 +72,9 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_int_(obj, value) - read_float_(obj, value) + has_int_(obj) + read_int_(obj) + read_float_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/ScalarOptionalsReaderBase.m b/matlab/generated/+test_model/ScalarOptionalsReaderBase.m index 1747919a..10eecb58 100644 --- a/matlab/generated/+test_model/ScalarOptionalsReaderBase.m +++ b/matlab/generated/+test_model/ScalarOptionalsReaderBase.m @@ -64,10 +64,22 @@ function close(obj) end function copy_to(obj, writer) - writer.write_optional_int(obj.read_optional_int()); - writer.write_optional_record(obj.read_optional_record()); - writer.write_record_with_optional_fields(obj.read_record_with_optional_fields()); - writer.write_optional_record_with_optional_fields(obj.read_optional_record_with_optional_fields()); + while obj.has_optional_int() + item = obj.read_optional_int(); + writer.write_optional_int({item}); + end + while obj.has_optional_record() + item = obj.read_optional_record(); + writer.write_optional_record({item}); + end + while obj.has_record_with_optional_fields() + item = obj.read_record_with_optional_fields(); + writer.write_record_with_optional_fields({item}); + end + while obj.has_optional_record_with_optional_fields() + item = obj.read_optional_record_with_optional_fields(); + writer.write_optional_record_with_optional_fields({item}); + end end end @@ -78,10 +90,10 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_optional_int_(obj, value) - read_optional_record_(obj, value) - read_record_with_optional_fields_(obj, value) - read_optional_record_with_optional_fields_(obj, value) + read_optional_int_(obj) + read_optional_record_(obj) + read_record_with_optional_fields_(obj) + read_optional_record_with_optional_fields_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/ScalarsReaderBase.m b/matlab/generated/+test_model/ScalarsReaderBase.m index 311c2c54..5dafbee9 100644 --- a/matlab/generated/+test_model/ScalarsReaderBase.m +++ b/matlab/generated/+test_model/ScalarsReaderBase.m @@ -44,8 +44,14 @@ function close(obj) end function copy_to(obj, writer) - writer.write_int32(obj.read_int32()); - writer.write_record(obj.read_record()); + while obj.has_int32() + item = obj.read_int32(); + writer.write_int32({item}); + end + while obj.has_record() + item = obj.read_record(); + writer.write_record({item}); + end end end @@ -56,8 +62,8 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_int32_(obj, value) - read_record_(obj, value) + read_int32_(obj) + read_record_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/SimpleGenericsReaderBase.m b/matlab/generated/+test_model/SimpleGenericsReaderBase.m index a5a79633..7ca4bbed 100644 --- a/matlab/generated/+test_model/SimpleGenericsReaderBase.m +++ b/matlab/generated/+test_model/SimpleGenericsReaderBase.m @@ -104,25 +104,62 @@ function close(obj) end % Ordinal 8 + function more = has_stream_of_type_variants(obj) + if obj.state_ ~= 16 + obj.raise_unexpected_state_(16); + end + + more = obj.has_stream_of_type_variants_(); + if ~more + obj.state_ = 18; + end + end + function value = read_stream_of_type_variants(obj) if obj.state_ ~= 16 obj.raise_unexpected_state_(16); end value = obj.read_stream_of_type_variants_(); - obj.state_ = 18; end function copy_to(obj, writer) - writer.write_float_image(obj.read_float_image()); - writer.write_int_image(obj.read_int_image()); - writer.write_int_image_alternate_syntax(obj.read_int_image_alternate_syntax()); - writer.write_string_image(obj.read_string_image()); - writer.write_int_float_tuple(obj.read_int_float_tuple()); - writer.write_float_float_tuple(obj.read_float_float_tuple()); - writer.write_int_float_tuple_alternate_syntax(obj.read_int_float_tuple_alternate_syntax()); - writer.write_int_string_tuple(obj.read_int_string_tuple()); - writer.write_stream_of_type_variants(obj.read_stream_of_type_variants()); + while obj.has_float_image() + item = obj.read_float_image(); + writer.write_float_image({item}); + end + while obj.has_int_image() + item = obj.read_int_image(); + writer.write_int_image({item}); + end + while obj.has_int_image_alternate_syntax() + item = obj.read_int_image_alternate_syntax(); + writer.write_int_image_alternate_syntax({item}); + end + while obj.has_string_image() + item = obj.read_string_image(); + writer.write_string_image({item}); + end + while obj.has_int_float_tuple() + item = obj.read_int_float_tuple(); + writer.write_int_float_tuple({item}); + end + while obj.has_float_float_tuple() + item = obj.read_float_float_tuple(); + writer.write_float_float_tuple({item}); + end + while obj.has_int_float_tuple_alternate_syntax() + item = obj.read_int_float_tuple_alternate_syntax(); + writer.write_int_float_tuple_alternate_syntax({item}); + end + while obj.has_int_string_tuple() + item = obj.read_int_string_tuple(); + writer.write_int_string_tuple({item}); + end + while obj.has_stream_of_type_variants() + item = obj.read_stream_of_type_variants(); + writer.write_stream_of_type_variants({item}); + end end end @@ -133,15 +170,16 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_float_image_(obj, value) - read_int_image_(obj, value) - read_int_image_alternate_syntax_(obj, value) - read_string_image_(obj, value) - read_int_float_tuple_(obj, value) - read_float_float_tuple_(obj, value) - read_int_float_tuple_alternate_syntax_(obj, value) - read_int_string_tuple_(obj, value) - read_stream_of_type_variants_(obj, value) + read_float_image_(obj) + read_int_image_(obj) + read_int_image_alternate_syntax_(obj) + read_string_image_(obj) + read_int_float_tuple_(obj) + read_float_float_tuple_(obj) + read_int_float_tuple_alternate_syntax_(obj) + read_int_string_tuple_(obj) + has_stream_of_type_variants_(obj) + read_stream_of_type_variants_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/StateTestReaderBase.m b/matlab/generated/+test_model/StateTestReaderBase.m index b3f53ed5..31d2fbdd 100644 --- a/matlab/generated/+test_model/StateTestReaderBase.m +++ b/matlab/generated/+test_model/StateTestReaderBase.m @@ -34,13 +34,23 @@ function close(obj) end % Ordinal 1 + function more = has_a_stream(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + more = obj.has_a_stream_(); + if ~more + obj.state_ = 4; + end + end + function value = read_a_stream(obj) if obj.state_ ~= 2 obj.raise_unexpected_state_(2); end value = obj.read_a_stream_(); - obj.state_ = 4; end % Ordinal 2 @@ -54,9 +64,18 @@ function close(obj) end function copy_to(obj, writer) - writer.write_an_int(obj.read_an_int()); - writer.write_a_stream(obj.read_a_stream()); - writer.write_another_int(obj.read_another_int()); + while obj.has_an_int() + item = obj.read_an_int(); + writer.write_an_int({item}); + end + while obj.has_a_stream() + item = obj.read_a_stream(); + writer.write_a_stream({item}); + end + while obj.has_another_int() + item = obj.read_another_int(); + writer.write_another_int({item}); + end end end @@ -67,9 +86,10 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_an_int_(obj, value) - read_a_stream_(obj, value) - read_another_int_(obj, value) + read_an_int_(obj) + has_a_stream_(obj) + read_a_stream_(obj) + read_another_int_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m b/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m index b5fe99ec..bd362229 100644 --- a/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m +++ b/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m @@ -24,28 +24,54 @@ function close(obj) end % Ordinal 0 + function more = has_int_or_simple_record(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + more = obj.has_int_or_simple_record_(); + if ~more + obj.state_ = 2; + end + end + function value = read_int_or_simple_record(obj) if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end value = obj.read_int_or_simple_record_(); - obj.state_ = 2; end % Ordinal 1 + function more = has_nullable_int_or_simple_record(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + more = obj.has_nullable_int_or_simple_record_(); + if ~more + obj.state_ = 4; + end + end + function value = read_nullable_int_or_simple_record(obj) if obj.state_ ~= 2 obj.raise_unexpected_state_(2); end value = obj.read_nullable_int_or_simple_record_(); - obj.state_ = 4; end function copy_to(obj, writer) - writer.write_int_or_simple_record(obj.read_int_or_simple_record()); - writer.write_nullable_int_or_simple_record(obj.read_nullable_int_or_simple_record()); + while obj.has_int_or_simple_record() + item = obj.read_int_or_simple_record(); + writer.write_int_or_simple_record({item}); + end + while obj.has_nullable_int_or_simple_record() + item = obj.read_nullable_int_or_simple_record(); + writer.write_nullable_int_or_simple_record({item}); + end end end @@ -56,8 +82,10 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_int_or_simple_record_(obj, value) - read_nullable_int_or_simple_record_(obj, value) + has_int_or_simple_record_(obj) + read_int_or_simple_record_(obj) + has_nullable_int_or_simple_record_(obj) + read_nullable_int_or_simple_record_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m b/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m index 7b7bb4f1..df9e217a 100644 --- a/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m +++ b/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m @@ -24,28 +24,54 @@ function close(obj) end % Ordinal 0 + function more = has_int_or_simple_record(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + more = obj.has_int_or_simple_record_(); + if ~more + obj.state_ = 2; + end + end + function value = read_int_or_simple_record(obj) if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end value = obj.read_int_or_simple_record_(); - obj.state_ = 2; end % Ordinal 1 + function more = has_nullable_int_or_simple_record(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + more = obj.has_nullable_int_or_simple_record_(); + if ~more + obj.state_ = 4; + end + end + function value = read_nullable_int_or_simple_record(obj) if obj.state_ ~= 2 obj.raise_unexpected_state_(2); end value = obj.read_nullable_int_or_simple_record_(); - obj.state_ = 4; end function copy_to(obj, writer) - writer.write_int_or_simple_record(obj.read_int_or_simple_record()); - writer.write_nullable_int_or_simple_record(obj.read_nullable_int_or_simple_record()); + while obj.has_int_or_simple_record() + item = obj.read_int_or_simple_record(); + writer.write_int_or_simple_record({item}); + end + while obj.has_nullable_int_or_simple_record() + item = obj.read_nullable_int_or_simple_record(); + writer.write_nullable_int_or_simple_record({item}); + end end end @@ -56,8 +82,10 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_int_or_simple_record_(obj, value) - read_nullable_int_or_simple_record_(obj, value) + has_int_or_simple_record_(obj) + read_int_or_simple_record_(obj) + has_nullable_int_or_simple_record_(obj) + read_nullable_int_or_simple_record_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/StreamsReaderBase.m b/matlab/generated/+test_model/StreamsReaderBase.m index c46c778e..8f1d3455 100644 --- a/matlab/generated/+test_model/StreamsReaderBase.m +++ b/matlab/generated/+test_model/StreamsReaderBase.m @@ -24,50 +24,102 @@ function close(obj) end % Ordinal 0 + function more = has_int_data(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + more = obj.has_int_data_(); + if ~more + obj.state_ = 2; + end + end + function value = read_int_data(obj) if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end value = obj.read_int_data_(); - obj.state_ = 2; end % Ordinal 1 + function more = has_optional_int_data(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + more = obj.has_optional_int_data_(); + if ~more + obj.state_ = 4; + end + end + function value = read_optional_int_data(obj) if obj.state_ ~= 2 obj.raise_unexpected_state_(2); end value = obj.read_optional_int_data_(); - obj.state_ = 4; end % Ordinal 2 + function more = has_record_with_optional_vector_data(obj) + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); + end + + more = obj.has_record_with_optional_vector_data_(); + if ~more + obj.state_ = 6; + end + end + function value = read_record_with_optional_vector_data(obj) if obj.state_ ~= 4 obj.raise_unexpected_state_(4); end value = obj.read_record_with_optional_vector_data_(); - obj.state_ = 6; end % Ordinal 3 + function more = has_fixed_vector(obj) + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); + end + + more = obj.has_fixed_vector_(); + if ~more + obj.state_ = 8; + end + end + function value = read_fixed_vector(obj) if obj.state_ ~= 6 obj.raise_unexpected_state_(6); end value = obj.read_fixed_vector_(); - obj.state_ = 8; end function copy_to(obj, writer) - writer.write_int_data(obj.read_int_data()); - writer.write_optional_int_data(obj.read_optional_int_data()); - writer.write_record_with_optional_vector_data(obj.read_record_with_optional_vector_data()); - writer.write_fixed_vector(obj.read_fixed_vector()); + while obj.has_int_data() + item = obj.read_int_data(); + writer.write_int_data({item}); + end + while obj.has_optional_int_data() + item = obj.read_optional_int_data(); + writer.write_optional_int_data({item}); + end + while obj.has_record_with_optional_vector_data() + item = obj.read_record_with_optional_vector_data(); + writer.write_record_with_optional_vector_data({item}); + end + while obj.has_fixed_vector() + item = obj.read_fixed_vector(); + writer.write_fixed_vector({item}); + end end end @@ -78,10 +130,14 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_int_data_(obj, value) - read_optional_int_data_(obj, value) - read_record_with_optional_vector_data_(obj, value) - read_fixed_vector_(obj, value) + has_int_data_(obj) + read_int_data_(obj) + has_optional_int_data_(obj) + read_optional_int_data_(obj) + has_record_with_optional_vector_data_(obj) + read_record_with_optional_vector_data_(obj) + has_fixed_vector_(obj) + read_fixed_vector_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/StringsReaderBase.m b/matlab/generated/+test_model/StringsReaderBase.m index fb4f16c7..61739ef0 100644 --- a/matlab/generated/+test_model/StringsReaderBase.m +++ b/matlab/generated/+test_model/StringsReaderBase.m @@ -44,8 +44,14 @@ function close(obj) end function copy_to(obj, writer) - writer.write_single_string(obj.read_single_string()); - writer.write_rec_with_string(obj.read_rec_with_string()); + while obj.has_single_string() + item = obj.read_single_string(); + writer.write_single_string({item}); + end + while obj.has_rec_with_string() + item = obj.read_rec_with_string(); + writer.write_rec_with_string({item}); + end end end @@ -56,8 +62,8 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_single_string_(obj, value) - read_rec_with_string_(obj, value) + read_single_string_(obj) + read_rec_with_string_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m b/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m index 590e3825..f04dbefb 100644 --- a/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m +++ b/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m @@ -44,8 +44,14 @@ function close(obj) end function copy_to(obj, writer) - writer.write_with_fixed_subarrays(obj.read_with_fixed_subarrays()); - writer.write_with_vlen_subarrays(obj.read_with_vlen_subarrays()); + while obj.has_with_fixed_subarrays() + item = obj.read_with_fixed_subarrays(); + writer.write_with_fixed_subarrays({item}); + end + while obj.has_with_vlen_subarrays() + item = obj.read_with_vlen_subarrays(); + writer.write_with_vlen_subarrays({item}); + end end end @@ -56,8 +62,8 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_with_fixed_subarrays_(obj, value) - read_with_vlen_subarrays_(obj, value) + read_with_fixed_subarrays_(obj) + read_with_vlen_subarrays_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/SubarraysReaderBase.m b/matlab/generated/+test_model/SubarraysReaderBase.m index d0b46c64..2263cb3c 100644 --- a/matlab/generated/+test_model/SubarraysReaderBase.m +++ b/matlab/generated/+test_model/SubarraysReaderBase.m @@ -114,15 +114,42 @@ function close(obj) end function copy_to(obj, writer) - writer.write_dynamic_with_fixed_int_subarray(obj.read_dynamic_with_fixed_int_subarray()); - writer.write_dynamic_with_fixed_float_subarray(obj.read_dynamic_with_fixed_float_subarray()); - writer.write_known_dim_count_with_fixed_int_subarray(obj.read_known_dim_count_with_fixed_int_subarray()); - writer.write_known_dim_count_with_fixed_float_subarray(obj.read_known_dim_count_with_fixed_float_subarray()); - writer.write_fixed_with_fixed_int_subarray(obj.read_fixed_with_fixed_int_subarray()); - writer.write_fixed_with_fixed_float_subarray(obj.read_fixed_with_fixed_float_subarray()); - writer.write_nested_subarray(obj.read_nested_subarray()); - writer.write_dynamic_with_fixed_vector_subarray(obj.read_dynamic_with_fixed_vector_subarray()); - writer.write_generic_subarray(obj.read_generic_subarray()); + while obj.has_dynamic_with_fixed_int_subarray() + item = obj.read_dynamic_with_fixed_int_subarray(); + writer.write_dynamic_with_fixed_int_subarray({item}); + end + while obj.has_dynamic_with_fixed_float_subarray() + item = obj.read_dynamic_with_fixed_float_subarray(); + writer.write_dynamic_with_fixed_float_subarray({item}); + end + while obj.has_known_dim_count_with_fixed_int_subarray() + item = obj.read_known_dim_count_with_fixed_int_subarray(); + writer.write_known_dim_count_with_fixed_int_subarray({item}); + end + while obj.has_known_dim_count_with_fixed_float_subarray() + item = obj.read_known_dim_count_with_fixed_float_subarray(); + writer.write_known_dim_count_with_fixed_float_subarray({item}); + end + while obj.has_fixed_with_fixed_int_subarray() + item = obj.read_fixed_with_fixed_int_subarray(); + writer.write_fixed_with_fixed_int_subarray({item}); + end + while obj.has_fixed_with_fixed_float_subarray() + item = obj.read_fixed_with_fixed_float_subarray(); + writer.write_fixed_with_fixed_float_subarray({item}); + end + while obj.has_nested_subarray() + item = obj.read_nested_subarray(); + writer.write_nested_subarray({item}); + end + while obj.has_dynamic_with_fixed_vector_subarray() + item = obj.read_dynamic_with_fixed_vector_subarray(); + writer.write_dynamic_with_fixed_vector_subarray({item}); + end + while obj.has_generic_subarray() + item = obj.read_generic_subarray(); + writer.write_generic_subarray({item}); + end end end @@ -133,15 +160,15 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_dynamic_with_fixed_int_subarray_(obj, value) - read_dynamic_with_fixed_float_subarray_(obj, value) - read_known_dim_count_with_fixed_int_subarray_(obj, value) - read_known_dim_count_with_fixed_float_subarray_(obj, value) - read_fixed_with_fixed_int_subarray_(obj, value) - read_fixed_with_fixed_float_subarray_(obj, value) - read_nested_subarray_(obj, value) - read_dynamic_with_fixed_vector_subarray_(obj, value) - read_generic_subarray_(obj, value) + read_dynamic_with_fixed_int_subarray_(obj) + read_dynamic_with_fixed_float_subarray_(obj) + read_known_dim_count_with_fixed_int_subarray_(obj) + read_known_dim_count_with_fixed_float_subarray_(obj) + read_fixed_with_fixed_int_subarray_(obj) + read_fixed_with_fixed_float_subarray_(obj) + read_nested_subarray_(obj) + read_dynamic_with_fixed_vector_subarray_(obj) + read_generic_subarray_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/UnionsReaderBase.m b/matlab/generated/+test_model/UnionsReaderBase.m index c6e1f878..0f1e4877 100644 --- a/matlab/generated/+test_model/UnionsReaderBase.m +++ b/matlab/generated/+test_model/UnionsReaderBase.m @@ -64,10 +64,22 @@ function close(obj) end function copy_to(obj, writer) - writer.write_int_or_simple_record(obj.read_int_or_simple_record()); - writer.write_int_or_record_with_vlens(obj.read_int_or_record_with_vlens()); - writer.write_monosotate_or_int_or_simple_record(obj.read_monosotate_or_int_or_simple_record()); - writer.write_record_with_unions(obj.read_record_with_unions()); + while obj.has_int_or_simple_record() + item = obj.read_int_or_simple_record(); + writer.write_int_or_simple_record({item}); + end + while obj.has_int_or_record_with_vlens() + item = obj.read_int_or_record_with_vlens(); + writer.write_int_or_record_with_vlens({item}); + end + while obj.has_monosotate_or_int_or_simple_record() + item = obj.read_monosotate_or_int_or_simple_record(); + writer.write_monosotate_or_int_or_simple_record({item}); + end + while obj.has_record_with_unions() + item = obj.read_record_with_unions(); + writer.write_record_with_unions({item}); + end end end @@ -78,10 +90,10 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_int_or_simple_record_(obj, value) - read_int_or_record_with_vlens_(obj, value) - read_monosotate_or_int_or_simple_record_(obj, value) - read_record_with_unions_(obj, value) + read_int_or_simple_record_(obj) + read_int_or_record_with_vlens_(obj) + read_monosotate_or_int_or_simple_record_(obj) + read_record_with_unions_(obj) close_(obj) end diff --git a/matlab/generated/+test_model/VlensReaderBase.m b/matlab/generated/+test_model/VlensReaderBase.m index 19ced834..aa3fb81c 100644 --- a/matlab/generated/+test_model/VlensReaderBase.m +++ b/matlab/generated/+test_model/VlensReaderBase.m @@ -64,10 +64,22 @@ function close(obj) end function copy_to(obj, writer) - writer.write_int_vector(obj.read_int_vector()); - writer.write_complex_vector(obj.read_complex_vector()); - writer.write_record_with_vlens(obj.read_record_with_vlens()); - writer.write_vlen_of_record_with_vlens(obj.read_vlen_of_record_with_vlens()); + while obj.has_int_vector() + item = obj.read_int_vector(); + writer.write_int_vector({item}); + end + while obj.has_complex_vector() + item = obj.read_complex_vector(); + writer.write_complex_vector({item}); + end + while obj.has_record_with_vlens() + item = obj.read_record_with_vlens(); + writer.write_record_with_vlens({item}); + end + while obj.has_vlen_of_record_with_vlens() + item = obj.read_vlen_of_record_with_vlens(); + writer.write_vlen_of_record_with_vlens({item}); + end end end @@ -78,10 +90,10 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_int_vector_(obj, value) - read_complex_vector_(obj, value) - read_record_with_vlens_(obj, value) - read_vlen_of_record_with_vlens_(obj, value) + read_int_vector_(obj) + read_complex_vector_(obj) + read_record_with_vlens_(obj) + read_vlen_of_record_with_vlens_(obj) close_(obj) end diff --git a/matlab/test/CodedStreamTest.m b/matlab/test/CodedStreamTest.m index aebec602..fd07a3f7 100644 --- a/matlab/test/CodedStreamTest.m +++ b/matlab/test/CodedStreamTest.m @@ -88,5 +88,45 @@ function testVarIntegers(testCase) r.close(); end + function testFloats(testCase) + filename = tempname; + + f = single(42.75); + d = double(-42.75); + fs = rand(123, 89, 'single'); + ds = rand(123, 89); + + cf = single(complex(7, -8)); + df = complex(7, -8); + cfs = complex(rand(123, 89, 'single'), rand(123, 89, 'single')); + dfs = complex(rand(123, 89), rand(123, 89)); + + float32Serializer = yardl.binary.Float32Serializer; + float64Serializer = yardl.binary.Float64Serializer; + complexFloat32Serializer = yardl.binary.Complexfloat32Serializer; + complexFloat64Serializer = yardl.binary.Complexfloat64Serializer; + + w = yardl.binary.CodedOutputStream(filename); + float32Serializer.write(w, f); + float64Serializer.write(w, d); + float32Serializer.writeTrivially(w, fs); + float64Serializer.writeTrivially(w, ds); + complexFloat32Serializer.write(w, cf); + complexFloat64Serializer.write(w, df); + complexFloat32Serializer.writeTrivially(w, cfs); + complexFloat64Serializer.writeTrivially(w, dfs); + w.close(); + + r = yardl.binary.CodedInputStream(filename); + testCase.verifyEqual(float32Serializer.read(r), f); + testCase.verifyEqual(float64Serializer.read(r), d); + testCase.verifyEqual(float32Serializer.readTrivially(r, size(fs)), fs); + testCase.verifyEqual(float64Serializer.readTrivially(r, size(ds)), ds); + testCase.verifyEqual(complexFloat32Serializer.read(r), cf); + testCase.verifyEqual(complexFloat64Serializer.read(r), df); + testCase.verifyEqual(complexFloat32Serializer.readTrivially(r, size(cfs)), cfs); + testCase.verifyEqual(complexFloat64Serializer.readTrivially(r, size(dfs)), dfs); + r.close(); + end end end diff --git a/matlab/test/ProtocolStateTest.m b/matlab/test/ProtocolStateTest.m index 775c7885..9ab35db6 100644 --- a/matlab/test/ProtocolStateTest.m +++ b/matlab/test/ProtocolStateTest.m @@ -45,20 +45,25 @@ function testSequenceWritePrematureClose(testCase) function testProperSequenceRead(testCase) r = ProtocolStateTestReader(); r.read_an_int(); - r.read_a_stream(); + while r.has_a_stream() + r.read_a_stream(); + end r.read_another_int(); r.close(); end function testReadSkipFirstStep(testCase) r = ProtocolStateTestReader(); + testCase.verifyError(@() r.has_a_stream(), 'yardl:ProtocolError'); testCase.verifyError(@() r.read_a_stream(), 'yardl:ProtocolError'); end function testReadCloseEarly(testCase) r = ProtocolStateTestReader(); r.read_an_int(); - r.read_a_stream(); + while r.has_a_stream() + r.read_a_stream(); + end testCase.verifyError(@() r.close(), 'yardl:ProtocolError'); end diff --git a/matlab/test/ProtocolStateTestReader.m b/matlab/test/ProtocolStateTestReader.m index b58701ea..157abe6c 100644 --- a/matlab/test/ProtocolStateTestReader.m +++ b/matlab/test/ProtocolStateTestReader.m @@ -9,11 +9,22 @@ res = -2; end - function res =read_a_stream_(self) + function more = has_a_stream_(self) + persistent n + if isempty(n) + n = 0; + more = true; + else + more = false; + end + n = n + 1; + end + + function res = read_a_stream_(self) res = [-1, -2, -3]; end - function res =read_another_int_(self) + function res = read_another_int_(self) res = -4; end diff --git a/matlab/test/benchmark.m b/matlab/test/benchmark.m index 6c75e704..76a79229 100644 --- a/matlab/test/benchmark.m +++ b/matlab/test/benchmark.m @@ -109,7 +109,7 @@ function benchmark(varargin) a(i) = i - eps; end - repetitions = scale_repetitions(1000, scale); + repetitions = scale_repetitions(10000, scale); total_bytes = 4 * numel(a) * repetitions; [create_writer, create_reader] = create_writer_reader(format, 'BenchmarkFloat256x256'); @@ -124,8 +124,12 @@ function write() function read() r = create_reader(get_output_filename()); - res = r.read_float256x256(); - assert(size(res, 3) == repetitions); + count = 0; + while r.has_float256x256() + b = r.read_float256x256(); + count = count + 1; + end + assert(count == repetitions); r.close(); end @@ -140,7 +144,7 @@ function read() a(i) = i - eps; end - repetitions = scale_repetitions(5000, scale); + repetitions = scale_repetitions(10000, scale); total_bytes = 4 * numel(a) * repetitions; [create_writer, create_reader] = create_writer_reader(format, 'BenchmarkFloatVlen'); @@ -155,8 +159,12 @@ function write() function read() r = create_reader(get_output_filename()); - res = r.read_float_array(); - assert(size(res, 2) == repetitions); + count = 0; + while r.has_float_array() + b = r.read_float_array(); + count = count + 1; + end + assert(count == repetitions); r.close(); end @@ -186,8 +194,12 @@ function write() function read() r = create_reader(get_output_filename()); - res = r.read_int256x256(); - assert(size(res, 3) == repetitions); + count = 0; + while r.has_int256x256() + b = r.read_int256x256(); + count = count + 1; + end + assert(count == repetitions); r.close(); end @@ -214,8 +226,12 @@ function write() function read() r = create_reader(get_output_filename()); - res = r.read_small_record(); - assert(size(res, 2) == repetitions); + count = 0; + while r.has_small_record() + b = r.read_small_record(); + count = count + 1; + end + assert(count == repetitions); r.close(); end @@ -256,8 +272,12 @@ function write() function read() r = create_reader(get_output_filename()); - res = r.read_data(); - assert(size(res, 2) == repetitions); + count = 0; + while r.has_data() + b = r.read_data(); + count = count + 1; + end + assert(count == repetitions); r.close(); end diff --git a/tooling/internal/matlab/binary/binary.go b/tooling/internal/matlab/binary/binary.go index 9d74d005..155ba023 100644 --- a/tooling/internal/matlab/binary/binary.go +++ b/tooling/internal/matlab/binary/binary.go @@ -44,12 +44,23 @@ func writeProtocolWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, common.WriteComment(w, fmt.Sprintf("Binary writer for the %s protocol", p.Name)) common.WriteComment(w, p.Comment) + w.WriteStringln("properties (Access=protected)") + common.WriteBlockBody(w, func() { + for _, step := range p.Sequence { + w.WriteStringln(serializerName(step)) + } + }) + + w.WriteStringln("") w.WriteStringln("methods") common.WriteBlockBody(w, func() { fmt.Fprintf(w, "function obj = %s(filename)\n", BinaryWriterName(p)) common.WriteBlockBody(w, func() { fmt.Fprintf(w, "obj@%s();\n", abstractWriterName) fmt.Fprintf(w, "obj@yardl.binary.BinaryProtocolWriter(filename, %s.schema);\n", abstractWriterName) + for _, step := range p.Sequence { + fmt.Fprintf(w, "obj.%s = %s;\n", serializerName(step), typeSerializer(step.Type, ns.Name, nil)) + } }) }) w.WriteStringln("") @@ -59,8 +70,7 @@ func writeProtocolWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, for i, step := range p.Sequence { fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "w = %s;\n", typeSerializer(step.Type, ns.Name, nil)) - w.WriteStringln("w.write(obj.stream_, value);") + fmt.Fprintf(w, "obj.%s.write(obj.stream_, value);\n", serializerName(step)) }) if i < len(p.Sequence)-1 { w.WriteStringln("") @@ -79,12 +89,23 @@ func writeProtocolReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, common.WriteComment(w, fmt.Sprintf("Binary reader for the %s protocol", p.Name)) common.WriteComment(w, p.Comment) + w.WriteStringln("properties (Access=protected)") + common.WriteBlockBody(w, func() { + for _, step := range p.Sequence { + w.WriteStringln(serializerName(step)) + } + }) + w.WriteStringln("") + w.WriteStringln("methods") common.WriteBlockBody(w, func() { fmt.Fprintf(w, "function obj = %s(filename)\n", BinaryReaderName(p)) common.WriteBlockBody(w, func() { fmt.Fprintf(w, "obj@%s();\n", abstractReaderName) fmt.Fprintf(w, "obj@yardl.binary.BinaryProtocolReader(filename, %s.schema);\n", abstractReaderName) + for _, step := range p.Sequence { + fmt.Fprintf(w, "obj.%s = %s;\n", serializerName(step), typeSerializer(step.Type, ns.Name, nil)) + } }) }) w.WriteStringln("") @@ -92,12 +113,18 @@ func writeProtocolReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, w.WriteStringln("methods (Access=protected)") common.WriteBlockBody(w, func() { for i, step := range p.Sequence { + if step.IsStream() { + fmt.Fprintf(w, "function more = %s(obj)\n", common.ProtocolHasMoreImplMethodName(step)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "more = obj.%s.hasnext(obj.stream_);\n", serializerName(step)) + }) + w.WriteStringln("") + } + fmt.Fprintf(w, "function value = %s(obj)\n", common.ProtocolReadImplMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "r = %s;\n", typeSerializer(step.Type, ns.Name, nil)) - w.WriteStringln("value = r.read(obj.stream_);") + fmt.Fprintf(w, "value = obj.%s.read(obj.stream_);\n", serializerName(step)) }) - if i < len(p.Sequence)-1 { w.WriteStringln("") } @@ -107,6 +134,10 @@ func writeProtocolReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, }) } +func serializerName(step *dsl.ProtocolStep) string { + return fmt.Sprintf("%s_serializer", formatting.ToSnakeCase(step.Name)) +} + func writeRecordSerializers(fw *common.MatlabFileWriter, ns *dsl.Namespace) error { for _, td := range ns.TypeDefinitions { switch td := td.(type) { diff --git a/tooling/internal/matlab/common/common.go b/tooling/internal/matlab/common/common.go index 300122eb..a5066795 100644 --- a/tooling/internal/matlab/common/common.go +++ b/tooling/internal/matlab/common/common.go @@ -211,6 +211,14 @@ func ProtocolReadImplMethodName(s *dsl.ProtocolStep) string { return fmt.Sprintf("read_%s_", formatting.ToSnakeCase(s.Name)) } +func ProtocolHasMoreMethodName(s *dsl.ProtocolStep) string { + return fmt.Sprintf("has_%s", formatting.ToSnakeCase(s.Name)) +} + +func ProtocolHasMoreImplMethodName(s *dsl.ProtocolStep) string { + return fmt.Sprintf("has_%s_", formatting.ToSnakeCase(s.Name)) +} + func WriteGeneratedFileHeader(w *formatting.IndentedWriter) { WriteComment(w, "This file was generated by the \"yardl\" tool. DO NOT EDIT.") w.WriteStringln("") diff --git a/tooling/internal/matlab/protocols/protocols.go b/tooling/internal/matlab/protocols/protocols.go index e644c1f6..e16413a4 100644 --- a/tooling/internal/matlab/protocols/protocols.go +++ b/tooling/internal/matlab/protocols/protocols.go @@ -154,7 +154,6 @@ func writeAbstractWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, }) }) }) - }) }) } @@ -201,9 +200,26 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, }) w.WriteStringln("") - // Public read methods + // Public has/read methods for i, step := range p.Sequence { common.WriteComment(w, fmt.Sprintf("Ordinal %d", i)) + if step.IsStream() { + fmt.Fprintf(w, "function more = %s(obj)\n", common.ProtocolHasMoreMethodName(step)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "if obj.state_ ~= %d\n", i*2) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i*2) + }) + w.WriteStringln("") + + fmt.Fprintf(w, "more = obj.%s();\n", common.ProtocolHasMoreImplMethodName(step)) + w.WriteStringln("if ~more") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) + }) + }) + w.WriteStringln("") + } common.WriteComment(w, step.Comment) fmt.Fprintf(w, "function value = %s(obj)\n", common.ProtocolReadMethodName(step)) common.WriteBlockBody(w, func() { @@ -214,9 +230,7 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, w.WriteStringln("") fmt.Fprintf(w, "value = obj.%s();\n", common.ProtocolReadImplMethodName(step)) - if step.IsStream() { - fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) - } else { + if !step.IsStream() { fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) } }) @@ -227,7 +241,11 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, fmt.Fprintf(w, "function copy_to(obj, writer)\n") common.WriteBlockBody(w, func() { for _, step := range p.Sequence { - fmt.Fprintf(w, "writer.%s(obj.%s());\n", common.ProtocolWriteMethodName(step), common.ProtocolReadMethodName(step)) + fmt.Fprintf(w, "while obj.%s()\n", common.ProtocolHasMoreMethodName(step)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "item = obj.%s();\n", common.ProtocolReadMethodName(step)) + fmt.Fprintf(w, "writer.%s({item});\n", common.ProtocolWriteMethodName(step)) + }) } }) }) @@ -246,7 +264,10 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, w.WriteStringln("methods (Abstract, Access=protected)") common.WriteBlockBody(w, func() { for _, step := range p.Sequence { - fmt.Fprintf(w, "%s(obj, value)\n", common.ProtocolReadImplMethodName(step)) + if step.IsStream() { + fmt.Fprintf(w, "%s(obj)\n", common.ProtocolHasMoreImplMethodName(step)) + } + fmt.Fprintf(w, "%s(obj)\n", common.ProtocolReadImplMethodName(step)) } w.WriteStringln("") diff --git a/tooling/internal/matlab/static_files/+binary/CodedInputStream.m b/tooling/internal/matlab/static_files/+binary/CodedInputStream.m index 9d2e9d12..214fe10a 100755 --- a/tooling/internal/matlab/static_files/+binary/CodedInputStream.m +++ b/tooling/internal/matlab/static_files/+binary/CodedInputStream.m @@ -30,7 +30,6 @@ function close(self) end end - % In Python, this uses struct packing for any selfect... function res = read(self, count) res = fread(self.fid_, count, "*uint8"); end diff --git a/tooling/internal/matlab/static_files/+binary/StreamSerializer.m b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m index 0da21b7e..f69b29fd 100644 --- a/tooling/internal/matlab/static_files/+binary/StreamSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m @@ -4,11 +4,13 @@ classdef StreamSerializer < yardl.binary.TypeSerializer properties item_serializer_; + items_remaining_; end methods function obj = StreamSerializer(item_serializer) obj.item_serializer_ = item_serializer; + obj.items_remaining_ = 0; end function write(obj, outstream, values) @@ -44,44 +46,24 @@ function write(obj, outstream, values) end end - function res = read(obj, instream) - count = instream.read_unsigned_varint(); - if count == 0 - res = []; - return; - end - - item_shape = obj.item_serializer_.getShape(); - if isempty(item_shape) - res = cell(1, count); - idx = 1; - while count > 0 - for c = 1:count - res{idx} = obj.item_serializer_.read(instream); - idx = idx + 1; - end - count = instream.read_unsigned_varint(); + function res = hasnext(obj, instream) + if obj.items_remaining_ <= 0 + obj.items_remaining_ = instream.read_unsigned_varint(); + if obj.items_remaining_ <= 0 + res = false; + return; end - return end + res = true; + end - res = yardl.allocate(obj.getClass(), [prod(item_shape), count]); - total_count = 0; - while count > 0 - for c = 1:count - idx = total_count + c; - item = obj.item_serializer_.read(instream); - res(:, idx) = item(:); - end - - total_count = total_count + count; - count = instream.read_unsigned_varint(); + function res = read(obj, instream) + if obj.items_remaining_ <= 0 + throw(yardl.RuntimeError("Stream has been exhausted")); end - res = squeeze(reshape(res, [item_shape, total_count])); - if iscolumn(res) - res = transpose(res); - end + res = obj.item_serializer_.read(instream); + obj.items_remaining_ = obj.items_remaining_ - 1; end function c = getClass(obj) From c37707ebcb45be28cf81f1740be449bc7cc759b9 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Fri, 12 Apr 2024 13:13:36 +0000 Subject: [PATCH 17/32] Add Matlab protocol stream end API --- .../+testing/MockAdvancedGenericsWriter.m | 100 +++------ .../+test_model/+testing/MockAliasesWriter.m | 212 +++++++----------- .../MockBenchmarkFloat256x256Writer.m | 32 ++- .../+testing/MockBenchmarkFloatVlenWriter.m | 32 ++- .../+testing/MockBenchmarkInt256x256Writer.m | 32 ++- .../+testing/MockBenchmarkSimpleMrdWriter.m | 32 ++- ...kBenchmarkSmallRecordWithOptionalsWriter.m | 32 ++- .../+testing/MockBenchmarkSmallRecordWriter.m | 32 ++- .../+testing/MockDynamicNDArraysWriter.m | 80 +++---- .../+test_model/+testing/MockEnumsWriter.m | 60 ++--- .../+testing/MockFixedArraysWriter.m | 100 +++------ .../+testing/MockFixedVectorsWriter.m | 80 +++---- .../+test_model/+testing/MockFlagsWriter.m | 64 ++++-- .../+test_model/+testing/MockMapsWriter.m | 80 +++---- .../MockNDArraysSingleDimensionWriter.m | 80 +++---- .../+test_model/+testing/MockNDArraysWriter.m | 100 +++------ .../+testing/MockNestedRecordsWriter.m | 20 +- .../+testing/MockOptionalVectorsWriter.m | 20 +- .../MockProtocolWithComputedFieldsWriter.m | 20 +- .../MockProtocolWithKeywordStepsWriter.m | 52 ++--- .../+testing/MockScalarOptionalsWriter.m | 80 +++---- .../+test_model/+testing/MockScalarsWriter.m | 40 ++-- .../+testing/MockSimpleGenericsWriter.m | 192 +++++++--------- .../+testing/MockStateTestWriter.m | 72 +++--- .../MockStreamsOfAliasedUnionsWriter.m | 64 ++++-- .../+testing/MockStreamsOfUnionsWriter.m | 64 ++++-- .../+test_model/+testing/MockStreamsWriter.m | 128 +++++++---- .../+test_model/+testing/MockStringsWriter.m | 40 ++-- .../+testing/MockSubarraysInRecordsWriter.m | 40 ++-- .../+testing/MockSubarraysWriter.m | 180 ++++++--------- .../+test_model/+testing/MockUnionsWriter.m | 80 +++---- .../+test_model/+testing/MockVlensWriter.m | 80 +++---- .../+test_model/+testing/TestAliasesWriter.m | 5 + .../TestBenchmarkFloat256x256Writer.m | 5 + .../+testing/TestBenchmarkFloatVlenWriter.m | 5 + .../+testing/TestBenchmarkInt256x256Writer.m | 5 + .../+testing/TestBenchmarkSimpleMrdWriter.m | 5 + ...tBenchmarkSmallRecordWithOptionalsWriter.m | 5 + .../+testing/TestBenchmarkSmallRecordWriter.m | 5 + .../+test_model/+testing/TestFlagsWriter.m | 10 + .../TestProtocolWithKeywordStepsWriter.m | 5 + .../+testing/TestSimpleGenericsWriter.m | 5 + .../+testing/TestStateTestWriter.m | 5 + .../TestStreamsOfAliasedUnionsWriter.m | 10 + .../+testing/TestStreamsOfUnionsWriter.m | 10 + .../+test_model/+testing/TestStreamsWriter.m | 20 ++ .../+test_model/AdvancedGenericsReaderBase.m | 70 +++--- .../+test_model/AdvancedGenericsWriterBase.m | 36 +-- .../generated/+test_model/AliasesReaderBase.m | 135 +++++------ .../generated/+test_model/AliasesWriterBase.m | 91 ++++---- .../BenchmarkFloat256x256ReaderBase.m | 14 +- .../BenchmarkFloat256x256WriterBase.m | 19 +- .../BenchmarkFloatVlenReaderBase.m | 14 +- .../BenchmarkFloatVlenWriterBase.m | 19 +- .../BenchmarkInt256x256ReaderBase.m | 14 +- .../BenchmarkInt256x256WriterBase.m | 19 +- .../BenchmarkSimpleMrdReaderBase.m | 14 +- .../BenchmarkSimpleMrdWriterBase.m | 19 +- .../BenchmarkSmallRecordReaderBase.m | 14 +- ...chmarkSmallRecordWithOptionalsReaderBase.m | 14 +- ...chmarkSmallRecordWithOptionalsWriterBase.m | 19 +- .../BenchmarkSmallRecordWriterBase.m | 19 +- .../+test_model/DynamicNDArraysReaderBase.m | 57 ++--- .../+test_model/DynamicNDArraysWriterBase.m | 28 +-- .../generated/+test_model/EnumsReaderBase.m | 44 ++-- .../generated/+test_model/EnumsWriterBase.m | 20 +- .../+test_model/FixedArraysReaderBase.m | 70 +++--- .../+test_model/FixedArraysWriterBase.m | 36 +-- .../+test_model/FixedVectorsReaderBase.m | 57 ++--- .../+test_model/FixedVectorsWriterBase.m | 28 +-- .../generated/+test_model/FlagsReaderBase.m | 27 +-- .../generated/+test_model/FlagsWriterBase.m | 40 ++-- matlab/generated/+test_model/MapsReaderBase.m | 57 ++--- matlab/generated/+test_model/MapsWriterBase.m | 28 +-- .../+test_model/NDArraysReaderBase.m | 70 +++--- .../NDArraysSingleDimensionReaderBase.m | 57 ++--- .../NDArraysSingleDimensionWriterBase.m | 28 +-- .../+test_model/NDArraysWriterBase.m | 36 +-- .../+test_model/NestedRecordsReaderBase.m | 18 +- .../+test_model/NestedRecordsWriterBase.m | 4 +- .../+test_model/OptionalVectorsReaderBase.m | 18 +- .../+test_model/OptionalVectorsWriterBase.m | 4 +- .../ProtocolWithComputedFieldsReaderBase.m | 18 +- .../ProtocolWithComputedFieldsWriterBase.m | 4 +- .../ProtocolWithKeywordStepsReaderBase.m | 27 +-- .../ProtocolWithKeywordStepsWriterBase.m | 25 ++- .../+test_model/ScalarOptionalsReaderBase.m | 57 ++--- .../+test_model/ScalarOptionalsWriterBase.m | 28 +-- .../generated/+test_model/ScalarsReaderBase.m | 31 +-- .../generated/+test_model/ScalarsWriterBase.m | 12 +- .../+test_model/SimpleGenericsReaderBase.m | 122 ++++------ .../+test_model/SimpleGenericsWriterBase.m | 83 +++---- .../+test_model/StateTestReaderBase.m | 44 ++-- .../+test_model/StateTestWriterBase.m | 31 +-- .../StreamsOfAliasedUnionsReaderBase.m | 27 +-- .../StreamsOfAliasedUnionsWriterBase.m | 40 ++-- .../+test_model/StreamsOfUnionsReaderBase.m | 27 +-- .../+test_model/StreamsOfUnionsWriterBase.m | 40 ++-- .../generated/+test_model/StreamsReaderBase.m | 53 +++-- .../generated/+test_model/StreamsWriterBase.m | 80 ++++--- .../generated/+test_model/StringsReaderBase.m | 31 +-- .../generated/+test_model/StringsWriterBase.m | 12 +- .../SubarraysInRecordsReaderBase.m | 31 +-- .../SubarraysInRecordsWriterBase.m | 12 +- .../+test_model/SubarraysReaderBase.m | 122 ++++------ .../+test_model/SubarraysWriterBase.m | 68 +++--- .../generated/+test_model/UnionsReaderBase.m | 57 ++--- .../generated/+test_model/UnionsWriterBase.m | 28 +-- .../generated/+test_model/VlensReaderBase.m | 57 ++--- .../generated/+test_model/VlensWriterBase.m | 28 +-- matlab/test/ProtocolStateTest.m | 10 + matlab/test/RoundTripTest.m | 41 +++- matlab/test/benchmark.m | 5 + tooling/internal/matlab/common/common.go | 4 + tooling/internal/matlab/mocks/mocks.go | 73 ++++-- .../internal/matlab/protocols/protocols.go | 101 ++++----- 116 files changed, 2311 insertions(+), 2795 deletions(-) diff --git a/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m b/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m index 45e1fde2..cfed485a 100644 --- a/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m @@ -3,111 +3,81 @@ classdef MockAdvancedGenericsWriter < matlab.mixin.Copyable & test_model.AdvancedGenericsWriterBase properties testCase_ - write_float_image_image_written - write_generic_record_1_written - write_tuple_of_optionals_written - write_tuple_of_optionals_alternate_syntax_written - write_tuple_of_vectors_written + expected_float_image_image + expected_generic_record_1 + expected_tuple_of_optionals + expected_tuple_of_optionals_alternate_syntax + expected_tuple_of_vectors end methods function obj = MockAdvancedGenericsWriter(testCase) obj.testCase_ = testCase; - obj.write_float_image_image_written = yardl.None; - obj.write_generic_record_1_written = yardl.None; - obj.write_tuple_of_optionals_written = yardl.None; - obj.write_tuple_of_optionals_alternate_syntax_written = yardl.None; - obj.write_tuple_of_vectors_written = yardl.None; + obj.expected_float_image_image = yardl.None; + obj.expected_generic_record_1 = yardl.None; + obj.expected_tuple_of_optionals = yardl.None; + obj.expected_tuple_of_optionals_alternate_syntax = yardl.None; + obj.expected_tuple_of_vectors = yardl.None; end function expect_write_float_image_image_(obj, value) - if obj.write_float_image_image_written.has_value() - last_dim = ndims(value); - obj.write_float_image_image_written = yardl.Optional(cat(last_dim, obj.write_float_image_image_written.value, value)); - else - obj.write_float_image_image_written = yardl.Optional(value); - end + obj.expected_float_image_image = yardl.Optional(value); end function expect_write_generic_record_1_(obj, value) - if obj.write_generic_record_1_written.has_value() - last_dim = ndims(value); - obj.write_generic_record_1_written = yardl.Optional(cat(last_dim, obj.write_generic_record_1_written.value, value)); - else - obj.write_generic_record_1_written = yardl.Optional(value); - end + obj.expected_generic_record_1 = yardl.Optional(value); end function expect_write_tuple_of_optionals_(obj, value) - if obj.write_tuple_of_optionals_written.has_value() - last_dim = ndims(value); - obj.write_tuple_of_optionals_written = yardl.Optional(cat(last_dim, obj.write_tuple_of_optionals_written.value, value)); - else - obj.write_tuple_of_optionals_written = yardl.Optional(value); - end + obj.expected_tuple_of_optionals = yardl.Optional(value); end function expect_write_tuple_of_optionals_alternate_syntax_(obj, value) - if obj.write_tuple_of_optionals_alternate_syntax_written.has_value() - last_dim = ndims(value); - obj.write_tuple_of_optionals_alternate_syntax_written = yardl.Optional(cat(last_dim, obj.write_tuple_of_optionals_alternate_syntax_written.value, value)); - else - obj.write_tuple_of_optionals_alternate_syntax_written = yardl.Optional(value); - end + obj.expected_tuple_of_optionals_alternate_syntax = yardl.Optional(value); end function expect_write_tuple_of_vectors_(obj, value) - if obj.write_tuple_of_vectors_written.has_value() - last_dim = ndims(value); - obj.write_tuple_of_vectors_written = yardl.Optional(cat(last_dim, obj.write_tuple_of_vectors_written.value, value)); - else - obj.write_tuple_of_vectors_written = yardl.Optional(value); - end + obj.expected_tuple_of_vectors = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_float_image_image_written, yardl.None, "Expected call to write_float_image_image_ was not received"); - obj.testCase_.verifyEqual(obj.write_generic_record_1_written, yardl.None, "Expected call to write_generic_record_1_ was not received"); - obj.testCase_.verifyEqual(obj.write_tuple_of_optionals_written, yardl.None, "Expected call to write_tuple_of_optionals_ was not received"); - obj.testCase_.verifyEqual(obj.write_tuple_of_optionals_alternate_syntax_written, yardl.None, "Expected call to write_tuple_of_optionals_alternate_syntax_ was not received"); - obj.testCase_.verifyEqual(obj.write_tuple_of_vectors_written, yardl.None, "Expected call to write_tuple_of_vectors_ was not received"); + obj.testCase_.verifyEqual(obj.expected_float_image_image, yardl.None, "Expected call to write_float_image_image_ was not received"); + obj.testCase_.verifyEqual(obj.expected_generic_record_1, yardl.None, "Expected call to write_generic_record_1_ was not received"); + obj.testCase_.verifyEqual(obj.expected_tuple_of_optionals, yardl.None, "Expected call to write_tuple_of_optionals_ was not received"); + obj.testCase_.verifyEqual(obj.expected_tuple_of_optionals_alternate_syntax, yardl.None, "Expected call to write_tuple_of_optionals_alternate_syntax_ was not received"); + obj.testCase_.verifyEqual(obj.expected_tuple_of_vectors, yardl.None, "Expected call to write_tuple_of_vectors_ was not received"); end end methods (Access=protected) function write_float_image_image_(obj, value) - obj.testCase_.verifyTrue(obj.write_float_image_image_written.has_value(), "Unexpected call to write_float_image_image_"); - expected = obj.write_float_image_image_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_image_image_"); - obj.write_float_image_image_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_float_image_image.has_value(), "Unexpected call to write_float_image_image_"); + obj.testCase_.verifyEqual(value, obj.expected_float_image_image.value, "Unexpected argument value for call to write_float_image_image_"); + obj.expected_float_image_image = yardl.None; end function write_generic_record_1_(obj, value) - obj.testCase_.verifyTrue(obj.write_generic_record_1_written.has_value(), "Unexpected call to write_generic_record_1_"); - expected = obj.write_generic_record_1_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_generic_record_1_"); - obj.write_generic_record_1_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_generic_record_1.has_value(), "Unexpected call to write_generic_record_1_"); + obj.testCase_.verifyEqual(value, obj.expected_generic_record_1.value, "Unexpected argument value for call to write_generic_record_1_"); + obj.expected_generic_record_1 = yardl.None; end function write_tuple_of_optionals_(obj, value) - obj.testCase_.verifyTrue(obj.write_tuple_of_optionals_written.has_value(), "Unexpected call to write_tuple_of_optionals_"); - expected = obj.write_tuple_of_optionals_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_of_optionals_"); - obj.write_tuple_of_optionals_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_tuple_of_optionals.has_value(), "Unexpected call to write_tuple_of_optionals_"); + obj.testCase_.verifyEqual(value, obj.expected_tuple_of_optionals.value, "Unexpected argument value for call to write_tuple_of_optionals_"); + obj.expected_tuple_of_optionals = yardl.None; end function write_tuple_of_optionals_alternate_syntax_(obj, value) - obj.testCase_.verifyTrue(obj.write_tuple_of_optionals_alternate_syntax_written.has_value(), "Unexpected call to write_tuple_of_optionals_alternate_syntax_"); - expected = obj.write_tuple_of_optionals_alternate_syntax_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_of_optionals_alternate_syntax_"); - obj.write_tuple_of_optionals_alternate_syntax_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_tuple_of_optionals_alternate_syntax.has_value(), "Unexpected call to write_tuple_of_optionals_alternate_syntax_"); + obj.testCase_.verifyEqual(value, obj.expected_tuple_of_optionals_alternate_syntax.value, "Unexpected argument value for call to write_tuple_of_optionals_alternate_syntax_"); + obj.expected_tuple_of_optionals_alternate_syntax = yardl.None; end function write_tuple_of_vectors_(obj, value) - obj.testCase_.verifyTrue(obj.write_tuple_of_vectors_written.has_value(), "Unexpected call to write_tuple_of_vectors_"); - expected = obj.write_tuple_of_vectors_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_of_vectors_"); - obj.write_tuple_of_vectors_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_tuple_of_vectors.has_value(), "Unexpected call to write_tuple_of_vectors_"); + obj.testCase_.verifyEqual(value, obj.expected_tuple_of_vectors.value, "Unexpected argument value for call to write_tuple_of_vectors_"); + obj.expected_tuple_of_vectors = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockAliasesWriter.m b/matlab/generated/+test_model/+testing/MockAliasesWriter.m index eed855bb..43ab50f7 100644 --- a/matlab/generated/+test_model/+testing/MockAliasesWriter.m +++ b/matlab/generated/+test_model/+testing/MockAliasesWriter.m @@ -3,206 +3,160 @@ classdef MockAliasesWriter < matlab.mixin.Copyable & test_model.AliasesWriterBase properties testCase_ - write_aliased_string_written - write_aliased_enum_written - write_aliased_open_generic_written - write_aliased_closed_generic_written - write_aliased_optional_written - write_aliased_generic_optional_written - write_aliased_generic_union_2_written - write_aliased_generic_vector_written - write_aliased_generic_fixed_vector_written - write_stream_of_aliased_generic_union_2_written + expected_aliased_string + expected_aliased_enum + expected_aliased_open_generic + expected_aliased_closed_generic + expected_aliased_optional + expected_aliased_generic_optional + expected_aliased_generic_union_2 + expected_aliased_generic_vector + expected_aliased_generic_fixed_vector + expected_stream_of_aliased_generic_union_2 end methods function obj = MockAliasesWriter(testCase) obj.testCase_ = testCase; - obj.write_aliased_string_written = yardl.None; - obj.write_aliased_enum_written = yardl.None; - obj.write_aliased_open_generic_written = yardl.None; - obj.write_aliased_closed_generic_written = yardl.None; - obj.write_aliased_optional_written = yardl.None; - obj.write_aliased_generic_optional_written = yardl.None; - obj.write_aliased_generic_union_2_written = yardl.None; - obj.write_aliased_generic_vector_written = yardl.None; - obj.write_aliased_generic_fixed_vector_written = yardl.None; - obj.write_stream_of_aliased_generic_union_2_written = yardl.None; + obj.expected_aliased_string = yardl.None; + obj.expected_aliased_enum = yardl.None; + obj.expected_aliased_open_generic = yardl.None; + obj.expected_aliased_closed_generic = yardl.None; + obj.expected_aliased_optional = yardl.None; + obj.expected_aliased_generic_optional = yardl.None; + obj.expected_aliased_generic_union_2 = yardl.None; + obj.expected_aliased_generic_vector = yardl.None; + obj.expected_aliased_generic_fixed_vector = yardl.None; + obj.expected_stream_of_aliased_generic_union_2 = {}; end function expect_write_aliased_string_(obj, value) - if obj.write_aliased_string_written.has_value() - last_dim = ndims(value); - obj.write_aliased_string_written = yardl.Optional(cat(last_dim, obj.write_aliased_string_written.value, value)); - else - obj.write_aliased_string_written = yardl.Optional(value); - end + obj.expected_aliased_string = yardl.Optional(value); end function expect_write_aliased_enum_(obj, value) - if obj.write_aliased_enum_written.has_value() - last_dim = ndims(value); - obj.write_aliased_enum_written = yardl.Optional(cat(last_dim, obj.write_aliased_enum_written.value, value)); - else - obj.write_aliased_enum_written = yardl.Optional(value); - end + obj.expected_aliased_enum = yardl.Optional(value); end function expect_write_aliased_open_generic_(obj, value) - if obj.write_aliased_open_generic_written.has_value() - last_dim = ndims(value); - obj.write_aliased_open_generic_written = yardl.Optional(cat(last_dim, obj.write_aliased_open_generic_written.value, value)); - else - obj.write_aliased_open_generic_written = yardl.Optional(value); - end + obj.expected_aliased_open_generic = yardl.Optional(value); end function expect_write_aliased_closed_generic_(obj, value) - if obj.write_aliased_closed_generic_written.has_value() - last_dim = ndims(value); - obj.write_aliased_closed_generic_written = yardl.Optional(cat(last_dim, obj.write_aliased_closed_generic_written.value, value)); - else - obj.write_aliased_closed_generic_written = yardl.Optional(value); - end + obj.expected_aliased_closed_generic = yardl.Optional(value); end function expect_write_aliased_optional_(obj, value) - if obj.write_aliased_optional_written.has_value() - last_dim = ndims(value); - obj.write_aliased_optional_written = yardl.Optional(cat(last_dim, obj.write_aliased_optional_written.value, value)); - else - obj.write_aliased_optional_written = yardl.Optional(value); - end + obj.expected_aliased_optional = yardl.Optional(value); end function expect_write_aliased_generic_optional_(obj, value) - if obj.write_aliased_generic_optional_written.has_value() - last_dim = ndims(value); - obj.write_aliased_generic_optional_written = yardl.Optional(cat(last_dim, obj.write_aliased_generic_optional_written.value, value)); - else - obj.write_aliased_generic_optional_written = yardl.Optional(value); - end + obj.expected_aliased_generic_optional = yardl.Optional(value); end function expect_write_aliased_generic_union_2_(obj, value) - if obj.write_aliased_generic_union_2_written.has_value() - last_dim = ndims(value); - obj.write_aliased_generic_union_2_written = yardl.Optional(cat(last_dim, obj.write_aliased_generic_union_2_written.value, value)); - else - obj.write_aliased_generic_union_2_written = yardl.Optional(value); - end + obj.expected_aliased_generic_union_2 = yardl.Optional(value); end function expect_write_aliased_generic_vector_(obj, value) - if obj.write_aliased_generic_vector_written.has_value() - last_dim = ndims(value); - obj.write_aliased_generic_vector_written = yardl.Optional(cat(last_dim, obj.write_aliased_generic_vector_written.value, value)); - else - obj.write_aliased_generic_vector_written = yardl.Optional(value); - end + obj.expected_aliased_generic_vector = yardl.Optional(value); end function expect_write_aliased_generic_fixed_vector_(obj, value) - if obj.write_aliased_generic_fixed_vector_written.has_value() - last_dim = ndims(value); - obj.write_aliased_generic_fixed_vector_written = yardl.Optional(cat(last_dim, obj.write_aliased_generic_fixed_vector_written.value, value)); - else - obj.write_aliased_generic_fixed_vector_written = yardl.Optional(value); - end + obj.expected_aliased_generic_fixed_vector = yardl.Optional(value); end function expect_write_stream_of_aliased_generic_union_2_(obj, value) - if obj.write_stream_of_aliased_generic_union_2_written.has_value() - last_dim = ndims(value); - obj.write_stream_of_aliased_generic_union_2_written = yardl.Optional(cat(last_dim, obj.write_stream_of_aliased_generic_union_2_written.value, value)); - else - obj.write_stream_of_aliased_generic_union_2_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_stream_of_aliased_generic_union_2{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_stream_of_aliased_generic_union_2{end+1} = value(index{:}, n); end end function verify(obj) - obj.testCase_.verifyEqual(obj.write_aliased_string_written, yardl.None, "Expected call to write_aliased_string_ was not received"); - obj.testCase_.verifyEqual(obj.write_aliased_enum_written, yardl.None, "Expected call to write_aliased_enum_ was not received"); - obj.testCase_.verifyEqual(obj.write_aliased_open_generic_written, yardl.None, "Expected call to write_aliased_open_generic_ was not received"); - obj.testCase_.verifyEqual(obj.write_aliased_closed_generic_written, yardl.None, "Expected call to write_aliased_closed_generic_ was not received"); - obj.testCase_.verifyEqual(obj.write_aliased_optional_written, yardl.None, "Expected call to write_aliased_optional_ was not received"); - obj.testCase_.verifyEqual(obj.write_aliased_generic_optional_written, yardl.None, "Expected call to write_aliased_generic_optional_ was not received"); - obj.testCase_.verifyEqual(obj.write_aliased_generic_union_2_written, yardl.None, "Expected call to write_aliased_generic_union_2_ was not received"); - obj.testCase_.verifyEqual(obj.write_aliased_generic_vector_written, yardl.None, "Expected call to write_aliased_generic_vector_ was not received"); - obj.testCase_.verifyEqual(obj.write_aliased_generic_fixed_vector_written, yardl.None, "Expected call to write_aliased_generic_fixed_vector_ was not received"); - obj.testCase_.verifyEqual(obj.write_stream_of_aliased_generic_union_2_written, yardl.None, "Expected call to write_stream_of_aliased_generic_union_2_ was not received"); + obj.testCase_.verifyEqual(obj.expected_aliased_string, yardl.None, "Expected call to write_aliased_string_ was not received"); + obj.testCase_.verifyEqual(obj.expected_aliased_enum, yardl.None, "Expected call to write_aliased_enum_ was not received"); + obj.testCase_.verifyEqual(obj.expected_aliased_open_generic, yardl.None, "Expected call to write_aliased_open_generic_ was not received"); + obj.testCase_.verifyEqual(obj.expected_aliased_closed_generic, yardl.None, "Expected call to write_aliased_closed_generic_ was not received"); + obj.testCase_.verifyEqual(obj.expected_aliased_optional, yardl.None, "Expected call to write_aliased_optional_ was not received"); + obj.testCase_.verifyEqual(obj.expected_aliased_generic_optional, yardl.None, "Expected call to write_aliased_generic_optional_ was not received"); + obj.testCase_.verifyEqual(obj.expected_aliased_generic_union_2, yardl.None, "Expected call to write_aliased_generic_union_2_ was not received"); + obj.testCase_.verifyEqual(obj.expected_aliased_generic_vector, yardl.None, "Expected call to write_aliased_generic_vector_ was not received"); + obj.testCase_.verifyEqual(obj.expected_aliased_generic_fixed_vector, yardl.None, "Expected call to write_aliased_generic_fixed_vector_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_stream_of_aliased_generic_union_2), "Expected call to write_stream_of_aliased_generic_union_2_ was not received"); end end methods (Access=protected) function write_aliased_string_(obj, value) - obj.testCase_.verifyTrue(obj.write_aliased_string_written.has_value(), "Unexpected call to write_aliased_string_"); - expected = obj.write_aliased_string_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_string_"); - obj.write_aliased_string_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_aliased_string.has_value(), "Unexpected call to write_aliased_string_"); + obj.testCase_.verifyEqual(value, obj.expected_aliased_string.value, "Unexpected argument value for call to write_aliased_string_"); + obj.expected_aliased_string = yardl.None; end function write_aliased_enum_(obj, value) - obj.testCase_.verifyTrue(obj.write_aliased_enum_written.has_value(), "Unexpected call to write_aliased_enum_"); - expected = obj.write_aliased_enum_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_enum_"); - obj.write_aliased_enum_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_aliased_enum.has_value(), "Unexpected call to write_aliased_enum_"); + obj.testCase_.verifyEqual(value, obj.expected_aliased_enum.value, "Unexpected argument value for call to write_aliased_enum_"); + obj.expected_aliased_enum = yardl.None; end function write_aliased_open_generic_(obj, value) - obj.testCase_.verifyTrue(obj.write_aliased_open_generic_written.has_value(), "Unexpected call to write_aliased_open_generic_"); - expected = obj.write_aliased_open_generic_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_open_generic_"); - obj.write_aliased_open_generic_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_aliased_open_generic.has_value(), "Unexpected call to write_aliased_open_generic_"); + obj.testCase_.verifyEqual(value, obj.expected_aliased_open_generic.value, "Unexpected argument value for call to write_aliased_open_generic_"); + obj.expected_aliased_open_generic = yardl.None; end function write_aliased_closed_generic_(obj, value) - obj.testCase_.verifyTrue(obj.write_aliased_closed_generic_written.has_value(), "Unexpected call to write_aliased_closed_generic_"); - expected = obj.write_aliased_closed_generic_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_closed_generic_"); - obj.write_aliased_closed_generic_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_aliased_closed_generic.has_value(), "Unexpected call to write_aliased_closed_generic_"); + obj.testCase_.verifyEqual(value, obj.expected_aliased_closed_generic.value, "Unexpected argument value for call to write_aliased_closed_generic_"); + obj.expected_aliased_closed_generic = yardl.None; end function write_aliased_optional_(obj, value) - obj.testCase_.verifyTrue(obj.write_aliased_optional_written.has_value(), "Unexpected call to write_aliased_optional_"); - expected = obj.write_aliased_optional_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_optional_"); - obj.write_aliased_optional_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_aliased_optional.has_value(), "Unexpected call to write_aliased_optional_"); + obj.testCase_.verifyEqual(value, obj.expected_aliased_optional.value, "Unexpected argument value for call to write_aliased_optional_"); + obj.expected_aliased_optional = yardl.None; end function write_aliased_generic_optional_(obj, value) - obj.testCase_.verifyTrue(obj.write_aliased_generic_optional_written.has_value(), "Unexpected call to write_aliased_generic_optional_"); - expected = obj.write_aliased_generic_optional_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_optional_"); - obj.write_aliased_generic_optional_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_aliased_generic_optional.has_value(), "Unexpected call to write_aliased_generic_optional_"); + obj.testCase_.verifyEqual(value, obj.expected_aliased_generic_optional.value, "Unexpected argument value for call to write_aliased_generic_optional_"); + obj.expected_aliased_generic_optional = yardl.None; end function write_aliased_generic_union_2_(obj, value) - obj.testCase_.verifyTrue(obj.write_aliased_generic_union_2_written.has_value(), "Unexpected call to write_aliased_generic_union_2_"); - expected = obj.write_aliased_generic_union_2_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_union_2_"); - obj.write_aliased_generic_union_2_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_aliased_generic_union_2.has_value(), "Unexpected call to write_aliased_generic_union_2_"); + obj.testCase_.verifyEqual(value, obj.expected_aliased_generic_union_2.value, "Unexpected argument value for call to write_aliased_generic_union_2_"); + obj.expected_aliased_generic_union_2 = yardl.None; end function write_aliased_generic_vector_(obj, value) - obj.testCase_.verifyTrue(obj.write_aliased_generic_vector_written.has_value(), "Unexpected call to write_aliased_generic_vector_"); - expected = obj.write_aliased_generic_vector_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_vector_"); - obj.write_aliased_generic_vector_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_aliased_generic_vector.has_value(), "Unexpected call to write_aliased_generic_vector_"); + obj.testCase_.verifyEqual(value, obj.expected_aliased_generic_vector.value, "Unexpected argument value for call to write_aliased_generic_vector_"); + obj.expected_aliased_generic_vector = yardl.None; end function write_aliased_generic_fixed_vector_(obj, value) - obj.testCase_.verifyTrue(obj.write_aliased_generic_fixed_vector_written.has_value(), "Unexpected call to write_aliased_generic_fixed_vector_"); - expected = obj.write_aliased_generic_fixed_vector_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_fixed_vector_"); - obj.write_aliased_generic_fixed_vector_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_aliased_generic_fixed_vector.has_value(), "Unexpected call to write_aliased_generic_fixed_vector_"); + obj.testCase_.verifyEqual(value, obj.expected_aliased_generic_fixed_vector.value, "Unexpected argument value for call to write_aliased_generic_fixed_vector_"); + obj.expected_aliased_generic_fixed_vector = yardl.None; end function write_stream_of_aliased_generic_union_2_(obj, value) - obj.testCase_.verifyTrue(obj.write_stream_of_aliased_generic_union_2_written.has_value(), "Unexpected call to write_stream_of_aliased_generic_union_2_"); - expected = obj.write_stream_of_aliased_generic_union_2_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_stream_of_aliased_generic_union_2_"); - obj.write_stream_of_aliased_generic_union_2_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_stream_of_aliased_generic_union_2), "Unexpected call to write_stream_of_aliased_generic_union_2_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_stream_of_aliased_generic_union_2{1}, "Unexpected argument value for call to write_stream_of_aliased_generic_union_2_"); + obj.expected_stream_of_aliased_generic_union_2 = obj.expected_stream_of_aliased_generic_union_2(2:end); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m index 41750525..f1b2fad3 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m @@ -3,35 +3,43 @@ classdef MockBenchmarkFloat256x256Writer < matlab.mixin.Copyable & test_model.BenchmarkFloat256x256WriterBase properties testCase_ - write_float256x256_written + expected_float256x256 end methods function obj = MockBenchmarkFloat256x256Writer(testCase) obj.testCase_ = testCase; - obj.write_float256x256_written = yardl.None; + obj.expected_float256x256 = {}; end function expect_write_float256x256_(obj, value) - if obj.write_float256x256_written.has_value() - last_dim = ndims(value); - obj.write_float256x256_written = yardl.Optional(cat(last_dim, obj.write_float256x256_written.value, value)); - else - obj.write_float256x256_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_float256x256{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_float256x256{end+1} = value(index{:}, n); end end function verify(obj) - obj.testCase_.verifyEqual(obj.write_float256x256_written, yardl.None, "Expected call to write_float256x256_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_float256x256), "Expected call to write_float256x256_ was not received"); end end methods (Access=protected) function write_float256x256_(obj, value) - obj.testCase_.verifyTrue(obj.write_float256x256_written.has_value(), "Unexpected call to write_float256x256_"); - expected = obj.write_float256x256_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float256x256_"); - obj.write_float256x256_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_float256x256), "Unexpected call to write_float256x256_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_float256x256{1}, "Unexpected argument value for call to write_float256x256_"); + obj.expected_float256x256 = obj.expected_float256x256(2:end); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m index 6a812981..a3c62c82 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m @@ -3,35 +3,43 @@ classdef MockBenchmarkFloatVlenWriter < matlab.mixin.Copyable & test_model.BenchmarkFloatVlenWriterBase properties testCase_ - write_float_array_written + expected_float_array end methods function obj = MockBenchmarkFloatVlenWriter(testCase) obj.testCase_ = testCase; - obj.write_float_array_written = yardl.None; + obj.expected_float_array = {}; end function expect_write_float_array_(obj, value) - if obj.write_float_array_written.has_value() - last_dim = ndims(value); - obj.write_float_array_written = yardl.Optional(cat(last_dim, obj.write_float_array_written.value, value)); - else - obj.write_float_array_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_float_array{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_float_array{end+1} = value(index{:}, n); end end function verify(obj) - obj.testCase_.verifyEqual(obj.write_float_array_written, yardl.None, "Expected call to write_float_array_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_float_array), "Expected call to write_float_array_ was not received"); end end methods (Access=protected) function write_float_array_(obj, value) - obj.testCase_.verifyTrue(obj.write_float_array_written.has_value(), "Unexpected call to write_float_array_"); - expected = obj.write_float_array_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_array_"); - obj.write_float_array_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_float_array), "Unexpected call to write_float_array_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_float_array{1}, "Unexpected argument value for call to write_float_array_"); + obj.expected_float_array = obj.expected_float_array(2:end); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m index c2df5bb8..9a578178 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m @@ -3,35 +3,43 @@ classdef MockBenchmarkInt256x256Writer < matlab.mixin.Copyable & test_model.BenchmarkInt256x256WriterBase properties testCase_ - write_int256x256_written + expected_int256x256 end methods function obj = MockBenchmarkInt256x256Writer(testCase) obj.testCase_ = testCase; - obj.write_int256x256_written = yardl.None; + obj.expected_int256x256 = {}; end function expect_write_int256x256_(obj, value) - if obj.write_int256x256_written.has_value() - last_dim = ndims(value); - obj.write_int256x256_written = yardl.Optional(cat(last_dim, obj.write_int256x256_written.value, value)); - else - obj.write_int256x256_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_int256x256{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_int256x256{end+1} = value(index{:}, n); end end function verify(obj) - obj.testCase_.verifyEqual(obj.write_int256x256_written, yardl.None, "Expected call to write_int256x256_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_int256x256), "Expected call to write_int256x256_ was not received"); end end methods (Access=protected) function write_int256x256_(obj, value) - obj.testCase_.verifyTrue(obj.write_int256x256_written.has_value(), "Unexpected call to write_int256x256_"); - expected = obj.write_int256x256_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int256x256_"); - obj.write_int256x256_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_int256x256), "Unexpected call to write_int256x256_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_int256x256{1}, "Unexpected argument value for call to write_int256x256_"); + obj.expected_int256x256 = obj.expected_int256x256(2:end); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m index 594250a2..8db1d155 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m @@ -3,35 +3,43 @@ classdef MockBenchmarkSimpleMrdWriter < matlab.mixin.Copyable & test_model.BenchmarkSimpleMrdWriterBase properties testCase_ - write_data_written + expected_data end methods function obj = MockBenchmarkSimpleMrdWriter(testCase) obj.testCase_ = testCase; - obj.write_data_written = yardl.None; + obj.expected_data = {}; end function expect_write_data_(obj, value) - if obj.write_data_written.has_value() - last_dim = ndims(value); - obj.write_data_written = yardl.Optional(cat(last_dim, obj.write_data_written.value, value)); - else - obj.write_data_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_data{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_data{end+1} = value(index{:}, n); end end function verify(obj) - obj.testCase_.verifyEqual(obj.write_data_written, yardl.None, "Expected call to write_data_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_data), "Expected call to write_data_ was not received"); end end methods (Access=protected) function write_data_(obj, value) - obj.testCase_.verifyTrue(obj.write_data_written.has_value(), "Unexpected call to write_data_"); - expected = obj.write_data_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_data_"); - obj.write_data_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_data), "Unexpected call to write_data_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_data{1}, "Unexpected argument value for call to write_data_"); + obj.expected_data = obj.expected_data(2:end); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m index 33bdb030..ccd19ad5 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m @@ -3,35 +3,43 @@ classdef MockBenchmarkSmallRecordWithOptionalsWriter < matlab.mixin.Copyable & test_model.BenchmarkSmallRecordWithOptionalsWriterBase properties testCase_ - write_small_record_written + expected_small_record end methods function obj = MockBenchmarkSmallRecordWithOptionalsWriter(testCase) obj.testCase_ = testCase; - obj.write_small_record_written = yardl.None; + obj.expected_small_record = {}; end function expect_write_small_record_(obj, value) - if obj.write_small_record_written.has_value() - last_dim = ndims(value); - obj.write_small_record_written = yardl.Optional(cat(last_dim, obj.write_small_record_written.value, value)); - else - obj.write_small_record_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_small_record{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_small_record{end+1} = value(index{:}, n); end end function verify(obj) - obj.testCase_.verifyEqual(obj.write_small_record_written, yardl.None, "Expected call to write_small_record_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_small_record), "Expected call to write_small_record_ was not received"); end end methods (Access=protected) function write_small_record_(obj, value) - obj.testCase_.verifyTrue(obj.write_small_record_written.has_value(), "Unexpected call to write_small_record_"); - expected = obj.write_small_record_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_small_record_"); - obj.write_small_record_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_small_record), "Unexpected call to write_small_record_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_small_record{1}, "Unexpected argument value for call to write_small_record_"); + obj.expected_small_record = obj.expected_small_record(2:end); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m index ddbce1e4..1cf45503 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m @@ -3,35 +3,43 @@ classdef MockBenchmarkSmallRecordWriter < matlab.mixin.Copyable & test_model.BenchmarkSmallRecordWriterBase properties testCase_ - write_small_record_written + expected_small_record end methods function obj = MockBenchmarkSmallRecordWriter(testCase) obj.testCase_ = testCase; - obj.write_small_record_written = yardl.None; + obj.expected_small_record = {}; end function expect_write_small_record_(obj, value) - if obj.write_small_record_written.has_value() - last_dim = ndims(value); - obj.write_small_record_written = yardl.Optional(cat(last_dim, obj.write_small_record_written.value, value)); - else - obj.write_small_record_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_small_record{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_small_record{end+1} = value(index{:}, n); end end function verify(obj) - obj.testCase_.verifyEqual(obj.write_small_record_written, yardl.None, "Expected call to write_small_record_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_small_record), "Expected call to write_small_record_ was not received"); end end methods (Access=protected) function write_small_record_(obj, value) - obj.testCase_.verifyTrue(obj.write_small_record_written.has_value(), "Unexpected call to write_small_record_"); - expected = obj.write_small_record_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_small_record_"); - obj.write_small_record_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_small_record), "Unexpected call to write_small_record_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_small_record{1}, "Unexpected argument value for call to write_small_record_"); + obj.expected_small_record = obj.expected_small_record(2:end); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m b/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m index ad13e9a6..74e1a7ca 100644 --- a/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m @@ -3,92 +3,68 @@ classdef MockDynamicNDArraysWriter < matlab.mixin.Copyable & test_model.DynamicNDArraysWriterBase properties testCase_ - write_ints_written - write_simple_record_array_written - write_record_with_vlens_array_written - write_record_with_dynamic_nd_arrays_written + expected_ints + expected_simple_record_array + expected_record_with_vlens_array + expected_record_with_dynamic_nd_arrays end methods function obj = MockDynamicNDArraysWriter(testCase) obj.testCase_ = testCase; - obj.write_ints_written = yardl.None; - obj.write_simple_record_array_written = yardl.None; - obj.write_record_with_vlens_array_written = yardl.None; - obj.write_record_with_dynamic_nd_arrays_written = yardl.None; + obj.expected_ints = yardl.None; + obj.expected_simple_record_array = yardl.None; + obj.expected_record_with_vlens_array = yardl.None; + obj.expected_record_with_dynamic_nd_arrays = yardl.None; end function expect_write_ints_(obj, value) - if obj.write_ints_written.has_value() - last_dim = ndims(value); - obj.write_ints_written = yardl.Optional(cat(last_dim, obj.write_ints_written.value, value)); - else - obj.write_ints_written = yardl.Optional(value); - end + obj.expected_ints = yardl.Optional(value); end function expect_write_simple_record_array_(obj, value) - if obj.write_simple_record_array_written.has_value() - last_dim = ndims(value); - obj.write_simple_record_array_written = yardl.Optional(cat(last_dim, obj.write_simple_record_array_written.value, value)); - else - obj.write_simple_record_array_written = yardl.Optional(value); - end + obj.expected_simple_record_array = yardl.Optional(value); end function expect_write_record_with_vlens_array_(obj, value) - if obj.write_record_with_vlens_array_written.has_value() - last_dim = ndims(value); - obj.write_record_with_vlens_array_written = yardl.Optional(cat(last_dim, obj.write_record_with_vlens_array_written.value, value)); - else - obj.write_record_with_vlens_array_written = yardl.Optional(value); - end + obj.expected_record_with_vlens_array = yardl.Optional(value); end function expect_write_record_with_dynamic_nd_arrays_(obj, value) - if obj.write_record_with_dynamic_nd_arrays_written.has_value() - last_dim = ndims(value); - obj.write_record_with_dynamic_nd_arrays_written = yardl.Optional(cat(last_dim, obj.write_record_with_dynamic_nd_arrays_written.value, value)); - else - obj.write_record_with_dynamic_nd_arrays_written = yardl.Optional(value); - end + obj.expected_record_with_dynamic_nd_arrays = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_ints_written, yardl.None, "Expected call to write_ints_ was not received"); - obj.testCase_.verifyEqual(obj.write_simple_record_array_written, yardl.None, "Expected call to write_simple_record_array_ was not received"); - obj.testCase_.verifyEqual(obj.write_record_with_vlens_array_written, yardl.None, "Expected call to write_record_with_vlens_array_ was not received"); - obj.testCase_.verifyEqual(obj.write_record_with_dynamic_nd_arrays_written, yardl.None, "Expected call to write_record_with_dynamic_nd_arrays_ was not received"); + obj.testCase_.verifyEqual(obj.expected_ints, yardl.None, "Expected call to write_ints_ was not received"); + obj.testCase_.verifyEqual(obj.expected_simple_record_array, yardl.None, "Expected call to write_simple_record_array_ was not received"); + obj.testCase_.verifyEqual(obj.expected_record_with_vlens_array, yardl.None, "Expected call to write_record_with_vlens_array_ was not received"); + obj.testCase_.verifyEqual(obj.expected_record_with_dynamic_nd_arrays, yardl.None, "Expected call to write_record_with_dynamic_nd_arrays_ was not received"); end end methods (Access=protected) function write_ints_(obj, value) - obj.testCase_.verifyTrue(obj.write_ints_written.has_value(), "Unexpected call to write_ints_"); - expected = obj.write_ints_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); - obj.write_ints_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_ints.has_value(), "Unexpected call to write_ints_"); + obj.testCase_.verifyEqual(value, obj.expected_ints.value, "Unexpected argument value for call to write_ints_"); + obj.expected_ints = yardl.None; end function write_simple_record_array_(obj, value) - obj.testCase_.verifyTrue(obj.write_simple_record_array_written.has_value(), "Unexpected call to write_simple_record_array_"); - expected = obj.write_simple_record_array_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_simple_record_array_"); - obj.write_simple_record_array_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_simple_record_array.has_value(), "Unexpected call to write_simple_record_array_"); + obj.testCase_.verifyEqual(value, obj.expected_simple_record_array.value, "Unexpected argument value for call to write_simple_record_array_"); + obj.expected_simple_record_array = yardl.None; end function write_record_with_vlens_array_(obj, value) - obj.testCase_.verifyTrue(obj.write_record_with_vlens_array_written.has_value(), "Unexpected call to write_record_with_vlens_array_"); - expected = obj.write_record_with_vlens_array_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_array_"); - obj.write_record_with_vlens_array_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_record_with_vlens_array.has_value(), "Unexpected call to write_record_with_vlens_array_"); + obj.testCase_.verifyEqual(value, obj.expected_record_with_vlens_array.value, "Unexpected argument value for call to write_record_with_vlens_array_"); + obj.expected_record_with_vlens_array = yardl.None; end function write_record_with_dynamic_nd_arrays_(obj, value) - obj.testCase_.verifyTrue(obj.write_record_with_dynamic_nd_arrays_written.has_value(), "Unexpected call to write_record_with_dynamic_nd_arrays_"); - expected = obj.write_record_with_dynamic_nd_arrays_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_dynamic_nd_arrays_"); - obj.write_record_with_dynamic_nd_arrays_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_record_with_dynamic_nd_arrays.has_value(), "Unexpected call to write_record_with_dynamic_nd_arrays_"); + obj.testCase_.verifyEqual(value, obj.expected_record_with_dynamic_nd_arrays.value, "Unexpected argument value for call to write_record_with_dynamic_nd_arrays_"); + obj.expected_record_with_dynamic_nd_arrays = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockEnumsWriter.m b/matlab/generated/+test_model/+testing/MockEnumsWriter.m index 5c35af06..14cd6e97 100644 --- a/matlab/generated/+test_model/+testing/MockEnumsWriter.m +++ b/matlab/generated/+test_model/+testing/MockEnumsWriter.m @@ -3,73 +3,55 @@ classdef MockEnumsWriter < matlab.mixin.Copyable & test_model.EnumsWriterBase properties testCase_ - write_single_written - write_vec_written - write_size_written + expected_single + expected_vec + expected_size end methods function obj = MockEnumsWriter(testCase) obj.testCase_ = testCase; - obj.write_single_written = yardl.None; - obj.write_vec_written = yardl.None; - obj.write_size_written = yardl.None; + obj.expected_single = yardl.None; + obj.expected_vec = yardl.None; + obj.expected_size = yardl.None; end function expect_write_single_(obj, value) - if obj.write_single_written.has_value() - last_dim = ndims(value); - obj.write_single_written = yardl.Optional(cat(last_dim, obj.write_single_written.value, value)); - else - obj.write_single_written = yardl.Optional(value); - end + obj.expected_single = yardl.Optional(value); end function expect_write_vec_(obj, value) - if obj.write_vec_written.has_value() - last_dim = ndims(value); - obj.write_vec_written = yardl.Optional(cat(last_dim, obj.write_vec_written.value, value)); - else - obj.write_vec_written = yardl.Optional(value); - end + obj.expected_vec = yardl.Optional(value); end function expect_write_size_(obj, value) - if obj.write_size_written.has_value() - last_dim = ndims(value); - obj.write_size_written = yardl.Optional(cat(last_dim, obj.write_size_written.value, value)); - else - obj.write_size_written = yardl.Optional(value); - end + obj.expected_size = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_single_written, yardl.None, "Expected call to write_single_ was not received"); - obj.testCase_.verifyEqual(obj.write_vec_written, yardl.None, "Expected call to write_vec_ was not received"); - obj.testCase_.verifyEqual(obj.write_size_written, yardl.None, "Expected call to write_size_ was not received"); + obj.testCase_.verifyEqual(obj.expected_single, yardl.None, "Expected call to write_single_ was not received"); + obj.testCase_.verifyEqual(obj.expected_vec, yardl.None, "Expected call to write_vec_ was not received"); + obj.testCase_.verifyEqual(obj.expected_size, yardl.None, "Expected call to write_size_ was not received"); end end methods (Access=protected) function write_single_(obj, value) - obj.testCase_.verifyTrue(obj.write_single_written.has_value(), "Unexpected call to write_single_"); - expected = obj.write_single_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_single_"); - obj.write_single_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_single.has_value(), "Unexpected call to write_single_"); + obj.testCase_.verifyEqual(value, obj.expected_single.value, "Unexpected argument value for call to write_single_"); + obj.expected_single = yardl.None; end function write_vec_(obj, value) - obj.testCase_.verifyTrue(obj.write_vec_written.has_value(), "Unexpected call to write_vec_"); - expected = obj.write_vec_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_vec_"); - obj.write_vec_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_vec.has_value(), "Unexpected call to write_vec_"); + obj.testCase_.verifyEqual(value, obj.expected_vec.value, "Unexpected argument value for call to write_vec_"); + obj.expected_vec = yardl.None; end function write_size_(obj, value) - obj.testCase_.verifyTrue(obj.write_size_written.has_value(), "Unexpected call to write_size_"); - expected = obj.write_size_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_size_"); - obj.write_size_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_size.has_value(), "Unexpected call to write_size_"); + obj.testCase_.verifyEqual(value, obj.expected_size.value, "Unexpected argument value for call to write_size_"); + obj.expected_size = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m b/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m index 814f9ec1..472ddde3 100644 --- a/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m @@ -3,111 +3,81 @@ classdef MockFixedArraysWriter < matlab.mixin.Copyable & test_model.FixedArraysWriterBase properties testCase_ - write_ints_written - write_fixed_simple_record_array_written - write_fixed_record_with_vlens_array_written - write_record_with_fixed_arrays_written - write_named_array_written + expected_ints + expected_fixed_simple_record_array + expected_fixed_record_with_vlens_array + expected_record_with_fixed_arrays + expected_named_array end methods function obj = MockFixedArraysWriter(testCase) obj.testCase_ = testCase; - obj.write_ints_written = yardl.None; - obj.write_fixed_simple_record_array_written = yardl.None; - obj.write_fixed_record_with_vlens_array_written = yardl.None; - obj.write_record_with_fixed_arrays_written = yardl.None; - obj.write_named_array_written = yardl.None; + obj.expected_ints = yardl.None; + obj.expected_fixed_simple_record_array = yardl.None; + obj.expected_fixed_record_with_vlens_array = yardl.None; + obj.expected_record_with_fixed_arrays = yardl.None; + obj.expected_named_array = yardl.None; end function expect_write_ints_(obj, value) - if obj.write_ints_written.has_value() - last_dim = ndims(value); - obj.write_ints_written = yardl.Optional(cat(last_dim, obj.write_ints_written.value, value)); - else - obj.write_ints_written = yardl.Optional(value); - end + obj.expected_ints = yardl.Optional(value); end function expect_write_fixed_simple_record_array_(obj, value) - if obj.write_fixed_simple_record_array_written.has_value() - last_dim = ndims(value); - obj.write_fixed_simple_record_array_written = yardl.Optional(cat(last_dim, obj.write_fixed_simple_record_array_written.value, value)); - else - obj.write_fixed_simple_record_array_written = yardl.Optional(value); - end + obj.expected_fixed_simple_record_array = yardl.Optional(value); end function expect_write_fixed_record_with_vlens_array_(obj, value) - if obj.write_fixed_record_with_vlens_array_written.has_value() - last_dim = ndims(value); - obj.write_fixed_record_with_vlens_array_written = yardl.Optional(cat(last_dim, obj.write_fixed_record_with_vlens_array_written.value, value)); - else - obj.write_fixed_record_with_vlens_array_written = yardl.Optional(value); - end + obj.expected_fixed_record_with_vlens_array = yardl.Optional(value); end function expect_write_record_with_fixed_arrays_(obj, value) - if obj.write_record_with_fixed_arrays_written.has_value() - last_dim = ndims(value); - obj.write_record_with_fixed_arrays_written = yardl.Optional(cat(last_dim, obj.write_record_with_fixed_arrays_written.value, value)); - else - obj.write_record_with_fixed_arrays_written = yardl.Optional(value); - end + obj.expected_record_with_fixed_arrays = yardl.Optional(value); end function expect_write_named_array_(obj, value) - if obj.write_named_array_written.has_value() - last_dim = ndims(value); - obj.write_named_array_written = yardl.Optional(cat(last_dim, obj.write_named_array_written.value, value)); - else - obj.write_named_array_written = yardl.Optional(value); - end + obj.expected_named_array = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_ints_written, yardl.None, "Expected call to write_ints_ was not received"); - obj.testCase_.verifyEqual(obj.write_fixed_simple_record_array_written, yardl.None, "Expected call to write_fixed_simple_record_array_ was not received"); - obj.testCase_.verifyEqual(obj.write_fixed_record_with_vlens_array_written, yardl.None, "Expected call to write_fixed_record_with_vlens_array_ was not received"); - obj.testCase_.verifyEqual(obj.write_record_with_fixed_arrays_written, yardl.None, "Expected call to write_record_with_fixed_arrays_ was not received"); - obj.testCase_.verifyEqual(obj.write_named_array_written, yardl.None, "Expected call to write_named_array_ was not received"); + obj.testCase_.verifyEqual(obj.expected_ints, yardl.None, "Expected call to write_ints_ was not received"); + obj.testCase_.verifyEqual(obj.expected_fixed_simple_record_array, yardl.None, "Expected call to write_fixed_simple_record_array_ was not received"); + obj.testCase_.verifyEqual(obj.expected_fixed_record_with_vlens_array, yardl.None, "Expected call to write_fixed_record_with_vlens_array_ was not received"); + obj.testCase_.verifyEqual(obj.expected_record_with_fixed_arrays, yardl.None, "Expected call to write_record_with_fixed_arrays_ was not received"); + obj.testCase_.verifyEqual(obj.expected_named_array, yardl.None, "Expected call to write_named_array_ was not received"); end end methods (Access=protected) function write_ints_(obj, value) - obj.testCase_.verifyTrue(obj.write_ints_written.has_value(), "Unexpected call to write_ints_"); - expected = obj.write_ints_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); - obj.write_ints_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_ints.has_value(), "Unexpected call to write_ints_"); + obj.testCase_.verifyEqual(value, obj.expected_ints.value, "Unexpected argument value for call to write_ints_"); + obj.expected_ints = yardl.None; end function write_fixed_simple_record_array_(obj, value) - obj.testCase_.verifyTrue(obj.write_fixed_simple_record_array_written.has_value(), "Unexpected call to write_fixed_simple_record_array_"); - expected = obj.write_fixed_simple_record_array_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_simple_record_array_"); - obj.write_fixed_simple_record_array_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_fixed_simple_record_array.has_value(), "Unexpected call to write_fixed_simple_record_array_"); + obj.testCase_.verifyEqual(value, obj.expected_fixed_simple_record_array.value, "Unexpected argument value for call to write_fixed_simple_record_array_"); + obj.expected_fixed_simple_record_array = yardl.None; end function write_fixed_record_with_vlens_array_(obj, value) - obj.testCase_.verifyTrue(obj.write_fixed_record_with_vlens_array_written.has_value(), "Unexpected call to write_fixed_record_with_vlens_array_"); - expected = obj.write_fixed_record_with_vlens_array_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_record_with_vlens_array_"); - obj.write_fixed_record_with_vlens_array_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_fixed_record_with_vlens_array.has_value(), "Unexpected call to write_fixed_record_with_vlens_array_"); + obj.testCase_.verifyEqual(value, obj.expected_fixed_record_with_vlens_array.value, "Unexpected argument value for call to write_fixed_record_with_vlens_array_"); + obj.expected_fixed_record_with_vlens_array = yardl.None; end function write_record_with_fixed_arrays_(obj, value) - obj.testCase_.verifyTrue(obj.write_record_with_fixed_arrays_written.has_value(), "Unexpected call to write_record_with_fixed_arrays_"); - expected = obj.write_record_with_fixed_arrays_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_fixed_arrays_"); - obj.write_record_with_fixed_arrays_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_record_with_fixed_arrays.has_value(), "Unexpected call to write_record_with_fixed_arrays_"); + obj.testCase_.verifyEqual(value, obj.expected_record_with_fixed_arrays.value, "Unexpected argument value for call to write_record_with_fixed_arrays_"); + obj.expected_record_with_fixed_arrays = yardl.None; end function write_named_array_(obj, value) - obj.testCase_.verifyTrue(obj.write_named_array_written.has_value(), "Unexpected call to write_named_array_"); - expected = obj.write_named_array_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_named_array_"); - obj.write_named_array_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_named_array.has_value(), "Unexpected call to write_named_array_"); + obj.testCase_.verifyEqual(value, obj.expected_named_array.value, "Unexpected argument value for call to write_named_array_"); + obj.expected_named_array = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m b/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m index 27e2b623..354c107e 100644 --- a/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m @@ -3,92 +3,68 @@ classdef MockFixedVectorsWriter < matlab.mixin.Copyable & test_model.FixedVectorsWriterBase properties testCase_ - write_fixed_int_vector_written - write_fixed_simple_record_vector_written - write_fixed_record_with_vlens_vector_written - write_record_with_fixed_vectors_written + expected_fixed_int_vector + expected_fixed_simple_record_vector + expected_fixed_record_with_vlens_vector + expected_record_with_fixed_vectors end methods function obj = MockFixedVectorsWriter(testCase) obj.testCase_ = testCase; - obj.write_fixed_int_vector_written = yardl.None; - obj.write_fixed_simple_record_vector_written = yardl.None; - obj.write_fixed_record_with_vlens_vector_written = yardl.None; - obj.write_record_with_fixed_vectors_written = yardl.None; + obj.expected_fixed_int_vector = yardl.None; + obj.expected_fixed_simple_record_vector = yardl.None; + obj.expected_fixed_record_with_vlens_vector = yardl.None; + obj.expected_record_with_fixed_vectors = yardl.None; end function expect_write_fixed_int_vector_(obj, value) - if obj.write_fixed_int_vector_written.has_value() - last_dim = ndims(value); - obj.write_fixed_int_vector_written = yardl.Optional(cat(last_dim, obj.write_fixed_int_vector_written.value, value)); - else - obj.write_fixed_int_vector_written = yardl.Optional(value); - end + obj.expected_fixed_int_vector = yardl.Optional(value); end function expect_write_fixed_simple_record_vector_(obj, value) - if obj.write_fixed_simple_record_vector_written.has_value() - last_dim = ndims(value); - obj.write_fixed_simple_record_vector_written = yardl.Optional(cat(last_dim, obj.write_fixed_simple_record_vector_written.value, value)); - else - obj.write_fixed_simple_record_vector_written = yardl.Optional(value); - end + obj.expected_fixed_simple_record_vector = yardl.Optional(value); end function expect_write_fixed_record_with_vlens_vector_(obj, value) - if obj.write_fixed_record_with_vlens_vector_written.has_value() - last_dim = ndims(value); - obj.write_fixed_record_with_vlens_vector_written = yardl.Optional(cat(last_dim, obj.write_fixed_record_with_vlens_vector_written.value, value)); - else - obj.write_fixed_record_with_vlens_vector_written = yardl.Optional(value); - end + obj.expected_fixed_record_with_vlens_vector = yardl.Optional(value); end function expect_write_record_with_fixed_vectors_(obj, value) - if obj.write_record_with_fixed_vectors_written.has_value() - last_dim = ndims(value); - obj.write_record_with_fixed_vectors_written = yardl.Optional(cat(last_dim, obj.write_record_with_fixed_vectors_written.value, value)); - else - obj.write_record_with_fixed_vectors_written = yardl.Optional(value); - end + obj.expected_record_with_fixed_vectors = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_fixed_int_vector_written, yardl.None, "Expected call to write_fixed_int_vector_ was not received"); - obj.testCase_.verifyEqual(obj.write_fixed_simple_record_vector_written, yardl.None, "Expected call to write_fixed_simple_record_vector_ was not received"); - obj.testCase_.verifyEqual(obj.write_fixed_record_with_vlens_vector_written, yardl.None, "Expected call to write_fixed_record_with_vlens_vector_ was not received"); - obj.testCase_.verifyEqual(obj.write_record_with_fixed_vectors_written, yardl.None, "Expected call to write_record_with_fixed_vectors_ was not received"); + obj.testCase_.verifyEqual(obj.expected_fixed_int_vector, yardl.None, "Expected call to write_fixed_int_vector_ was not received"); + obj.testCase_.verifyEqual(obj.expected_fixed_simple_record_vector, yardl.None, "Expected call to write_fixed_simple_record_vector_ was not received"); + obj.testCase_.verifyEqual(obj.expected_fixed_record_with_vlens_vector, yardl.None, "Expected call to write_fixed_record_with_vlens_vector_ was not received"); + obj.testCase_.verifyEqual(obj.expected_record_with_fixed_vectors, yardl.None, "Expected call to write_record_with_fixed_vectors_ was not received"); end end methods (Access=protected) function write_fixed_int_vector_(obj, value) - obj.testCase_.verifyTrue(obj.write_fixed_int_vector_written.has_value(), "Unexpected call to write_fixed_int_vector_"); - expected = obj.write_fixed_int_vector_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_int_vector_"); - obj.write_fixed_int_vector_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_fixed_int_vector.has_value(), "Unexpected call to write_fixed_int_vector_"); + obj.testCase_.verifyEqual(value, obj.expected_fixed_int_vector.value, "Unexpected argument value for call to write_fixed_int_vector_"); + obj.expected_fixed_int_vector = yardl.None; end function write_fixed_simple_record_vector_(obj, value) - obj.testCase_.verifyTrue(obj.write_fixed_simple_record_vector_written.has_value(), "Unexpected call to write_fixed_simple_record_vector_"); - expected = obj.write_fixed_simple_record_vector_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_simple_record_vector_"); - obj.write_fixed_simple_record_vector_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_fixed_simple_record_vector.has_value(), "Unexpected call to write_fixed_simple_record_vector_"); + obj.testCase_.verifyEqual(value, obj.expected_fixed_simple_record_vector.value, "Unexpected argument value for call to write_fixed_simple_record_vector_"); + obj.expected_fixed_simple_record_vector = yardl.None; end function write_fixed_record_with_vlens_vector_(obj, value) - obj.testCase_.verifyTrue(obj.write_fixed_record_with_vlens_vector_written.has_value(), "Unexpected call to write_fixed_record_with_vlens_vector_"); - expected = obj.write_fixed_record_with_vlens_vector_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_record_with_vlens_vector_"); - obj.write_fixed_record_with_vlens_vector_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_fixed_record_with_vlens_vector.has_value(), "Unexpected call to write_fixed_record_with_vlens_vector_"); + obj.testCase_.verifyEqual(value, obj.expected_fixed_record_with_vlens_vector.value, "Unexpected argument value for call to write_fixed_record_with_vlens_vector_"); + obj.expected_fixed_record_with_vlens_vector = yardl.None; end function write_record_with_fixed_vectors_(obj, value) - obj.testCase_.verifyTrue(obj.write_record_with_fixed_vectors_written.has_value(), "Unexpected call to write_record_with_fixed_vectors_"); - expected = obj.write_record_with_fixed_vectors_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_fixed_vectors_"); - obj.write_record_with_fixed_vectors_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_record_with_fixed_vectors.has_value(), "Unexpected call to write_record_with_fixed_vectors_"); + obj.testCase_.verifyEqual(value, obj.expected_record_with_fixed_vectors.value, "Unexpected argument value for call to write_record_with_fixed_vectors_"); + obj.expected_record_with_fixed_vectors = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockFlagsWriter.m b/matlab/generated/+test_model/+testing/MockFlagsWriter.m index 1a560271..eddb4be0 100644 --- a/matlab/generated/+test_model/+testing/MockFlagsWriter.m +++ b/matlab/generated/+test_model/+testing/MockFlagsWriter.m @@ -3,54 +3,70 @@ classdef MockFlagsWriter < matlab.mixin.Copyable & test_model.FlagsWriterBase properties testCase_ - write_days_written - write_formats_written + expected_days + expected_formats end methods function obj = MockFlagsWriter(testCase) obj.testCase_ = testCase; - obj.write_days_written = yardl.None; - obj.write_formats_written = yardl.None; + obj.expected_days = {}; + obj.expected_formats = {}; end function expect_write_days_(obj, value) - if obj.write_days_written.has_value() - last_dim = ndims(value); - obj.write_days_written = yardl.Optional(cat(last_dim, obj.write_days_written.value, value)); - else - obj.write_days_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_days{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_days{end+1} = value(index{:}, n); end end function expect_write_formats_(obj, value) - if obj.write_formats_written.has_value() - last_dim = ndims(value); - obj.write_formats_written = yardl.Optional(cat(last_dim, obj.write_formats_written.value, value)); - else - obj.write_formats_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_formats{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_formats{end+1} = value(index{:}, n); end end function verify(obj) - obj.testCase_.verifyEqual(obj.write_days_written, yardl.None, "Expected call to write_days_ was not received"); - obj.testCase_.verifyEqual(obj.write_formats_written, yardl.None, "Expected call to write_formats_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_days), "Expected call to write_days_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_formats), "Expected call to write_formats_ was not received"); end end methods (Access=protected) function write_days_(obj, value) - obj.testCase_.verifyTrue(obj.write_days_written.has_value(), "Unexpected call to write_days_"); - expected = obj.write_days_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_days_"); - obj.write_days_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_days), "Unexpected call to write_days_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_days{1}, "Unexpected argument value for call to write_days_"); + obj.expected_days = obj.expected_days(2:end); end function write_formats_(obj, value) - obj.testCase_.verifyTrue(obj.write_formats_written.has_value(), "Unexpected call to write_formats_"); - expected = obj.write_formats_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_formats_"); - obj.write_formats_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_formats), "Unexpected call to write_formats_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_formats{1}, "Unexpected argument value for call to write_formats_"); + obj.expected_formats = obj.expected_formats(2:end); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockMapsWriter.m b/matlab/generated/+test_model/+testing/MockMapsWriter.m index 83b06fac..a83d4f03 100644 --- a/matlab/generated/+test_model/+testing/MockMapsWriter.m +++ b/matlab/generated/+test_model/+testing/MockMapsWriter.m @@ -3,92 +3,68 @@ classdef MockMapsWriter < matlab.mixin.Copyable & test_model.MapsWriterBase properties testCase_ - write_string_to_int_written - write_int_to_string_written - write_string_to_union_written - write_aliased_generic_written + expected_string_to_int + expected_int_to_string + expected_string_to_union + expected_aliased_generic end methods function obj = MockMapsWriter(testCase) obj.testCase_ = testCase; - obj.write_string_to_int_written = yardl.None; - obj.write_int_to_string_written = yardl.None; - obj.write_string_to_union_written = yardl.None; - obj.write_aliased_generic_written = yardl.None; + obj.expected_string_to_int = yardl.None; + obj.expected_int_to_string = yardl.None; + obj.expected_string_to_union = yardl.None; + obj.expected_aliased_generic = yardl.None; end function expect_write_string_to_int_(obj, value) - if obj.write_string_to_int_written.has_value() - last_dim = ndims(value); - obj.write_string_to_int_written = yardl.Optional(cat(last_dim, obj.write_string_to_int_written.value, value)); - else - obj.write_string_to_int_written = yardl.Optional(value); - end + obj.expected_string_to_int = yardl.Optional(value); end function expect_write_int_to_string_(obj, value) - if obj.write_int_to_string_written.has_value() - last_dim = ndims(value); - obj.write_int_to_string_written = yardl.Optional(cat(last_dim, obj.write_int_to_string_written.value, value)); - else - obj.write_int_to_string_written = yardl.Optional(value); - end + obj.expected_int_to_string = yardl.Optional(value); end function expect_write_string_to_union_(obj, value) - if obj.write_string_to_union_written.has_value() - last_dim = ndims(value); - obj.write_string_to_union_written = yardl.Optional(cat(last_dim, obj.write_string_to_union_written.value, value)); - else - obj.write_string_to_union_written = yardl.Optional(value); - end + obj.expected_string_to_union = yardl.Optional(value); end function expect_write_aliased_generic_(obj, value) - if obj.write_aliased_generic_written.has_value() - last_dim = ndims(value); - obj.write_aliased_generic_written = yardl.Optional(cat(last_dim, obj.write_aliased_generic_written.value, value)); - else - obj.write_aliased_generic_written = yardl.Optional(value); - end + obj.expected_aliased_generic = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_string_to_int_written, yardl.None, "Expected call to write_string_to_int_ was not received"); - obj.testCase_.verifyEqual(obj.write_int_to_string_written, yardl.None, "Expected call to write_int_to_string_ was not received"); - obj.testCase_.verifyEqual(obj.write_string_to_union_written, yardl.None, "Expected call to write_string_to_union_ was not received"); - obj.testCase_.verifyEqual(obj.write_aliased_generic_written, yardl.None, "Expected call to write_aliased_generic_ was not received"); + obj.testCase_.verifyEqual(obj.expected_string_to_int, yardl.None, "Expected call to write_string_to_int_ was not received"); + obj.testCase_.verifyEqual(obj.expected_int_to_string, yardl.None, "Expected call to write_int_to_string_ was not received"); + obj.testCase_.verifyEqual(obj.expected_string_to_union, yardl.None, "Expected call to write_string_to_union_ was not received"); + obj.testCase_.verifyEqual(obj.expected_aliased_generic, yardl.None, "Expected call to write_aliased_generic_ was not received"); end end methods (Access=protected) function write_string_to_int_(obj, value) - obj.testCase_.verifyTrue(obj.write_string_to_int_written.has_value(), "Unexpected call to write_string_to_int_"); - expected = obj.write_string_to_int_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_string_to_int_"); - obj.write_string_to_int_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_string_to_int.has_value(), "Unexpected call to write_string_to_int_"); + obj.testCase_.verifyEqual(value, obj.expected_string_to_int.value, "Unexpected argument value for call to write_string_to_int_"); + obj.expected_string_to_int = yardl.None; end function write_int_to_string_(obj, value) - obj.testCase_.verifyTrue(obj.write_int_to_string_written.has_value(), "Unexpected call to write_int_to_string_"); - expected = obj.write_int_to_string_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_to_string_"); - obj.write_int_to_string_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_int_to_string.has_value(), "Unexpected call to write_int_to_string_"); + obj.testCase_.verifyEqual(value, obj.expected_int_to_string.value, "Unexpected argument value for call to write_int_to_string_"); + obj.expected_int_to_string = yardl.None; end function write_string_to_union_(obj, value) - obj.testCase_.verifyTrue(obj.write_string_to_union_written.has_value(), "Unexpected call to write_string_to_union_"); - expected = obj.write_string_to_union_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_string_to_union_"); - obj.write_string_to_union_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_string_to_union.has_value(), "Unexpected call to write_string_to_union_"); + obj.testCase_.verifyEqual(value, obj.expected_string_to_union.value, "Unexpected argument value for call to write_string_to_union_"); + obj.expected_string_to_union = yardl.None; end function write_aliased_generic_(obj, value) - obj.testCase_.verifyTrue(obj.write_aliased_generic_written.has_value(), "Unexpected call to write_aliased_generic_"); - expected = obj.write_aliased_generic_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_aliased_generic_"); - obj.write_aliased_generic_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_aliased_generic.has_value(), "Unexpected call to write_aliased_generic_"); + obj.testCase_.verifyEqual(value, obj.expected_aliased_generic.value, "Unexpected argument value for call to write_aliased_generic_"); + obj.expected_aliased_generic = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m b/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m index 455a43f6..5adcbaa7 100644 --- a/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m +++ b/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m @@ -3,92 +3,68 @@ classdef MockNDArraysSingleDimensionWriter < matlab.mixin.Copyable & test_model.NDArraysSingleDimensionWriterBase properties testCase_ - write_ints_written - write_simple_record_array_written - write_record_with_vlens_array_written - write_record_with_nd_arrays_written + expected_ints + expected_simple_record_array + expected_record_with_vlens_array + expected_record_with_nd_arrays end methods function obj = MockNDArraysSingleDimensionWriter(testCase) obj.testCase_ = testCase; - obj.write_ints_written = yardl.None; - obj.write_simple_record_array_written = yardl.None; - obj.write_record_with_vlens_array_written = yardl.None; - obj.write_record_with_nd_arrays_written = yardl.None; + obj.expected_ints = yardl.None; + obj.expected_simple_record_array = yardl.None; + obj.expected_record_with_vlens_array = yardl.None; + obj.expected_record_with_nd_arrays = yardl.None; end function expect_write_ints_(obj, value) - if obj.write_ints_written.has_value() - last_dim = ndims(value); - obj.write_ints_written = yardl.Optional(cat(last_dim, obj.write_ints_written.value, value)); - else - obj.write_ints_written = yardl.Optional(value); - end + obj.expected_ints = yardl.Optional(value); end function expect_write_simple_record_array_(obj, value) - if obj.write_simple_record_array_written.has_value() - last_dim = ndims(value); - obj.write_simple_record_array_written = yardl.Optional(cat(last_dim, obj.write_simple_record_array_written.value, value)); - else - obj.write_simple_record_array_written = yardl.Optional(value); - end + obj.expected_simple_record_array = yardl.Optional(value); end function expect_write_record_with_vlens_array_(obj, value) - if obj.write_record_with_vlens_array_written.has_value() - last_dim = ndims(value); - obj.write_record_with_vlens_array_written = yardl.Optional(cat(last_dim, obj.write_record_with_vlens_array_written.value, value)); - else - obj.write_record_with_vlens_array_written = yardl.Optional(value); - end + obj.expected_record_with_vlens_array = yardl.Optional(value); end function expect_write_record_with_nd_arrays_(obj, value) - if obj.write_record_with_nd_arrays_written.has_value() - last_dim = ndims(value); - obj.write_record_with_nd_arrays_written = yardl.Optional(cat(last_dim, obj.write_record_with_nd_arrays_written.value, value)); - else - obj.write_record_with_nd_arrays_written = yardl.Optional(value); - end + obj.expected_record_with_nd_arrays = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_ints_written, yardl.None, "Expected call to write_ints_ was not received"); - obj.testCase_.verifyEqual(obj.write_simple_record_array_written, yardl.None, "Expected call to write_simple_record_array_ was not received"); - obj.testCase_.verifyEqual(obj.write_record_with_vlens_array_written, yardl.None, "Expected call to write_record_with_vlens_array_ was not received"); - obj.testCase_.verifyEqual(obj.write_record_with_nd_arrays_written, yardl.None, "Expected call to write_record_with_nd_arrays_ was not received"); + obj.testCase_.verifyEqual(obj.expected_ints, yardl.None, "Expected call to write_ints_ was not received"); + obj.testCase_.verifyEqual(obj.expected_simple_record_array, yardl.None, "Expected call to write_simple_record_array_ was not received"); + obj.testCase_.verifyEqual(obj.expected_record_with_vlens_array, yardl.None, "Expected call to write_record_with_vlens_array_ was not received"); + obj.testCase_.verifyEqual(obj.expected_record_with_nd_arrays, yardl.None, "Expected call to write_record_with_nd_arrays_ was not received"); end end methods (Access=protected) function write_ints_(obj, value) - obj.testCase_.verifyTrue(obj.write_ints_written.has_value(), "Unexpected call to write_ints_"); - expected = obj.write_ints_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); - obj.write_ints_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_ints.has_value(), "Unexpected call to write_ints_"); + obj.testCase_.verifyEqual(value, obj.expected_ints.value, "Unexpected argument value for call to write_ints_"); + obj.expected_ints = yardl.None; end function write_simple_record_array_(obj, value) - obj.testCase_.verifyTrue(obj.write_simple_record_array_written.has_value(), "Unexpected call to write_simple_record_array_"); - expected = obj.write_simple_record_array_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_simple_record_array_"); - obj.write_simple_record_array_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_simple_record_array.has_value(), "Unexpected call to write_simple_record_array_"); + obj.testCase_.verifyEqual(value, obj.expected_simple_record_array.value, "Unexpected argument value for call to write_simple_record_array_"); + obj.expected_simple_record_array = yardl.None; end function write_record_with_vlens_array_(obj, value) - obj.testCase_.verifyTrue(obj.write_record_with_vlens_array_written.has_value(), "Unexpected call to write_record_with_vlens_array_"); - expected = obj.write_record_with_vlens_array_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_array_"); - obj.write_record_with_vlens_array_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_record_with_vlens_array.has_value(), "Unexpected call to write_record_with_vlens_array_"); + obj.testCase_.verifyEqual(value, obj.expected_record_with_vlens_array.value, "Unexpected argument value for call to write_record_with_vlens_array_"); + obj.expected_record_with_vlens_array = yardl.None; end function write_record_with_nd_arrays_(obj, value) - obj.testCase_.verifyTrue(obj.write_record_with_nd_arrays_written.has_value(), "Unexpected call to write_record_with_nd_arrays_"); - expected = obj.write_record_with_nd_arrays_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_nd_arrays_"); - obj.write_record_with_nd_arrays_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_record_with_nd_arrays.has_value(), "Unexpected call to write_record_with_nd_arrays_"); + obj.testCase_.verifyEqual(value, obj.expected_record_with_nd_arrays.value, "Unexpected argument value for call to write_record_with_nd_arrays_"); + obj.expected_record_with_nd_arrays = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockNDArraysWriter.m b/matlab/generated/+test_model/+testing/MockNDArraysWriter.m index 67625e05..adb9d551 100644 --- a/matlab/generated/+test_model/+testing/MockNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockNDArraysWriter.m @@ -3,111 +3,81 @@ classdef MockNDArraysWriter < matlab.mixin.Copyable & test_model.NDArraysWriterBase properties testCase_ - write_ints_written - write_simple_record_array_written - write_record_with_vlens_array_written - write_record_with_nd_arrays_written - write_named_array_written + expected_ints + expected_simple_record_array + expected_record_with_vlens_array + expected_record_with_nd_arrays + expected_named_array end methods function obj = MockNDArraysWriter(testCase) obj.testCase_ = testCase; - obj.write_ints_written = yardl.None; - obj.write_simple_record_array_written = yardl.None; - obj.write_record_with_vlens_array_written = yardl.None; - obj.write_record_with_nd_arrays_written = yardl.None; - obj.write_named_array_written = yardl.None; + obj.expected_ints = yardl.None; + obj.expected_simple_record_array = yardl.None; + obj.expected_record_with_vlens_array = yardl.None; + obj.expected_record_with_nd_arrays = yardl.None; + obj.expected_named_array = yardl.None; end function expect_write_ints_(obj, value) - if obj.write_ints_written.has_value() - last_dim = ndims(value); - obj.write_ints_written = yardl.Optional(cat(last_dim, obj.write_ints_written.value, value)); - else - obj.write_ints_written = yardl.Optional(value); - end + obj.expected_ints = yardl.Optional(value); end function expect_write_simple_record_array_(obj, value) - if obj.write_simple_record_array_written.has_value() - last_dim = ndims(value); - obj.write_simple_record_array_written = yardl.Optional(cat(last_dim, obj.write_simple_record_array_written.value, value)); - else - obj.write_simple_record_array_written = yardl.Optional(value); - end + obj.expected_simple_record_array = yardl.Optional(value); end function expect_write_record_with_vlens_array_(obj, value) - if obj.write_record_with_vlens_array_written.has_value() - last_dim = ndims(value); - obj.write_record_with_vlens_array_written = yardl.Optional(cat(last_dim, obj.write_record_with_vlens_array_written.value, value)); - else - obj.write_record_with_vlens_array_written = yardl.Optional(value); - end + obj.expected_record_with_vlens_array = yardl.Optional(value); end function expect_write_record_with_nd_arrays_(obj, value) - if obj.write_record_with_nd_arrays_written.has_value() - last_dim = ndims(value); - obj.write_record_with_nd_arrays_written = yardl.Optional(cat(last_dim, obj.write_record_with_nd_arrays_written.value, value)); - else - obj.write_record_with_nd_arrays_written = yardl.Optional(value); - end + obj.expected_record_with_nd_arrays = yardl.Optional(value); end function expect_write_named_array_(obj, value) - if obj.write_named_array_written.has_value() - last_dim = ndims(value); - obj.write_named_array_written = yardl.Optional(cat(last_dim, obj.write_named_array_written.value, value)); - else - obj.write_named_array_written = yardl.Optional(value); - end + obj.expected_named_array = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_ints_written, yardl.None, "Expected call to write_ints_ was not received"); - obj.testCase_.verifyEqual(obj.write_simple_record_array_written, yardl.None, "Expected call to write_simple_record_array_ was not received"); - obj.testCase_.verifyEqual(obj.write_record_with_vlens_array_written, yardl.None, "Expected call to write_record_with_vlens_array_ was not received"); - obj.testCase_.verifyEqual(obj.write_record_with_nd_arrays_written, yardl.None, "Expected call to write_record_with_nd_arrays_ was not received"); - obj.testCase_.verifyEqual(obj.write_named_array_written, yardl.None, "Expected call to write_named_array_ was not received"); + obj.testCase_.verifyEqual(obj.expected_ints, yardl.None, "Expected call to write_ints_ was not received"); + obj.testCase_.verifyEqual(obj.expected_simple_record_array, yardl.None, "Expected call to write_simple_record_array_ was not received"); + obj.testCase_.verifyEqual(obj.expected_record_with_vlens_array, yardl.None, "Expected call to write_record_with_vlens_array_ was not received"); + obj.testCase_.verifyEqual(obj.expected_record_with_nd_arrays, yardl.None, "Expected call to write_record_with_nd_arrays_ was not received"); + obj.testCase_.verifyEqual(obj.expected_named_array, yardl.None, "Expected call to write_named_array_ was not received"); end end methods (Access=protected) function write_ints_(obj, value) - obj.testCase_.verifyTrue(obj.write_ints_written.has_value(), "Unexpected call to write_ints_"); - expected = obj.write_ints_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_ints_"); - obj.write_ints_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_ints.has_value(), "Unexpected call to write_ints_"); + obj.testCase_.verifyEqual(value, obj.expected_ints.value, "Unexpected argument value for call to write_ints_"); + obj.expected_ints = yardl.None; end function write_simple_record_array_(obj, value) - obj.testCase_.verifyTrue(obj.write_simple_record_array_written.has_value(), "Unexpected call to write_simple_record_array_"); - expected = obj.write_simple_record_array_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_simple_record_array_"); - obj.write_simple_record_array_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_simple_record_array.has_value(), "Unexpected call to write_simple_record_array_"); + obj.testCase_.verifyEqual(value, obj.expected_simple_record_array.value, "Unexpected argument value for call to write_simple_record_array_"); + obj.expected_simple_record_array = yardl.None; end function write_record_with_vlens_array_(obj, value) - obj.testCase_.verifyTrue(obj.write_record_with_vlens_array_written.has_value(), "Unexpected call to write_record_with_vlens_array_"); - expected = obj.write_record_with_vlens_array_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_array_"); - obj.write_record_with_vlens_array_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_record_with_vlens_array.has_value(), "Unexpected call to write_record_with_vlens_array_"); + obj.testCase_.verifyEqual(value, obj.expected_record_with_vlens_array.value, "Unexpected argument value for call to write_record_with_vlens_array_"); + obj.expected_record_with_vlens_array = yardl.None; end function write_record_with_nd_arrays_(obj, value) - obj.testCase_.verifyTrue(obj.write_record_with_nd_arrays_written.has_value(), "Unexpected call to write_record_with_nd_arrays_"); - expected = obj.write_record_with_nd_arrays_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_nd_arrays_"); - obj.write_record_with_nd_arrays_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_record_with_nd_arrays.has_value(), "Unexpected call to write_record_with_nd_arrays_"); + obj.testCase_.verifyEqual(value, obj.expected_record_with_nd_arrays.value, "Unexpected argument value for call to write_record_with_nd_arrays_"); + obj.expected_record_with_nd_arrays = yardl.None; end function write_named_array_(obj, value) - obj.testCase_.verifyTrue(obj.write_named_array_written.has_value(), "Unexpected call to write_named_array_"); - expected = obj.write_named_array_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_named_array_"); - obj.write_named_array_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_named_array.has_value(), "Unexpected call to write_named_array_"); + obj.testCase_.verifyEqual(value, obj.expected_named_array.value, "Unexpected argument value for call to write_named_array_"); + obj.expected_named_array = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m b/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m index 5f76e57a..92cad2c2 100644 --- a/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m @@ -3,35 +3,29 @@ classdef MockNestedRecordsWriter < matlab.mixin.Copyable & test_model.NestedRecordsWriterBase properties testCase_ - write_tuple_with_records_written + expected_tuple_with_records end methods function obj = MockNestedRecordsWriter(testCase) obj.testCase_ = testCase; - obj.write_tuple_with_records_written = yardl.None; + obj.expected_tuple_with_records = yardl.None; end function expect_write_tuple_with_records_(obj, value) - if obj.write_tuple_with_records_written.has_value() - last_dim = ndims(value); - obj.write_tuple_with_records_written = yardl.Optional(cat(last_dim, obj.write_tuple_with_records_written.value, value)); - else - obj.write_tuple_with_records_written = yardl.Optional(value); - end + obj.expected_tuple_with_records = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_tuple_with_records_written, yardl.None, "Expected call to write_tuple_with_records_ was not received"); + obj.testCase_.verifyEqual(obj.expected_tuple_with_records, yardl.None, "Expected call to write_tuple_with_records_ was not received"); end end methods (Access=protected) function write_tuple_with_records_(obj, value) - obj.testCase_.verifyTrue(obj.write_tuple_with_records_written.has_value(), "Unexpected call to write_tuple_with_records_"); - expected = obj.write_tuple_with_records_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_tuple_with_records_"); - obj.write_tuple_with_records_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_tuple_with_records.has_value(), "Unexpected call to write_tuple_with_records_"); + obj.testCase_.verifyEqual(value, obj.expected_tuple_with_records.value, "Unexpected argument value for call to write_tuple_with_records_"); + obj.expected_tuple_with_records = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m b/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m index 624f2e10..84c42647 100644 --- a/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m @@ -3,35 +3,29 @@ classdef MockOptionalVectorsWriter < matlab.mixin.Copyable & test_model.OptionalVectorsWriterBase properties testCase_ - write_record_with_optional_vector_written + expected_record_with_optional_vector end methods function obj = MockOptionalVectorsWriter(testCase) obj.testCase_ = testCase; - obj.write_record_with_optional_vector_written = yardl.None; + obj.expected_record_with_optional_vector = yardl.None; end function expect_write_record_with_optional_vector_(obj, value) - if obj.write_record_with_optional_vector_written.has_value() - last_dim = ndims(value); - obj.write_record_with_optional_vector_written = yardl.Optional(cat(last_dim, obj.write_record_with_optional_vector_written.value, value)); - else - obj.write_record_with_optional_vector_written = yardl.Optional(value); - end + obj.expected_record_with_optional_vector = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_record_with_optional_vector_written, yardl.None, "Expected call to write_record_with_optional_vector_ was not received"); + obj.testCase_.verifyEqual(obj.expected_record_with_optional_vector, yardl.None, "Expected call to write_record_with_optional_vector_ was not received"); end end methods (Access=protected) function write_record_with_optional_vector_(obj, value) - obj.testCase_.verifyTrue(obj.write_record_with_optional_vector_written.has_value(), "Unexpected call to write_record_with_optional_vector_"); - expected = obj.write_record_with_optional_vector_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_optional_vector_"); - obj.write_record_with_optional_vector_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_record_with_optional_vector.has_value(), "Unexpected call to write_record_with_optional_vector_"); + obj.testCase_.verifyEqual(value, obj.expected_record_with_optional_vector.value, "Unexpected argument value for call to write_record_with_optional_vector_"); + obj.expected_record_with_optional_vector = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m b/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m index 96de9ac3..18f057a7 100644 --- a/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m +++ b/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m @@ -3,35 +3,29 @@ classdef MockProtocolWithComputedFieldsWriter < matlab.mixin.Copyable & test_model.ProtocolWithComputedFieldsWriterBase properties testCase_ - write_record_with_computed_fields_written + expected_record_with_computed_fields end methods function obj = MockProtocolWithComputedFieldsWriter(testCase) obj.testCase_ = testCase; - obj.write_record_with_computed_fields_written = yardl.None; + obj.expected_record_with_computed_fields = yardl.None; end function expect_write_record_with_computed_fields_(obj, value) - if obj.write_record_with_computed_fields_written.has_value() - last_dim = ndims(value); - obj.write_record_with_computed_fields_written = yardl.Optional(cat(last_dim, obj.write_record_with_computed_fields_written.value, value)); - else - obj.write_record_with_computed_fields_written = yardl.Optional(value); - end + obj.expected_record_with_computed_fields = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_record_with_computed_fields_written, yardl.None, "Expected call to write_record_with_computed_fields_ was not received"); + obj.testCase_.verifyEqual(obj.expected_record_with_computed_fields, yardl.None, "Expected call to write_record_with_computed_fields_ was not received"); end end methods (Access=protected) function write_record_with_computed_fields_(obj, value) - obj.testCase_.verifyTrue(obj.write_record_with_computed_fields_written.has_value(), "Unexpected call to write_record_with_computed_fields_"); - expected = obj.write_record_with_computed_fields_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_computed_fields_"); - obj.write_record_with_computed_fields_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_record_with_computed_fields.has_value(), "Unexpected call to write_record_with_computed_fields_"); + obj.testCase_.verifyEqual(value, obj.expected_record_with_computed_fields.value, "Unexpected argument value for call to write_record_with_computed_fields_"); + obj.expected_record_with_computed_fields = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m index abc97e88..cf0506f4 100644 --- a/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m +++ b/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m @@ -3,54 +3,56 @@ classdef MockProtocolWithKeywordStepsWriter < matlab.mixin.Copyable & test_model.ProtocolWithKeywordStepsWriterBase properties testCase_ - write_int_written - write_float_written + expected_int + expected_float end methods function obj = MockProtocolWithKeywordStepsWriter(testCase) obj.testCase_ = testCase; - obj.write_int_written = yardl.None; - obj.write_float_written = yardl.None; + obj.expected_int = {}; + obj.expected_float = yardl.None; end function expect_write_int_(obj, value) - if obj.write_int_written.has_value() - last_dim = ndims(value); - obj.write_int_written = yardl.Optional(cat(last_dim, obj.write_int_written.value, value)); - else - obj.write_int_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_int{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_int{end+1} = value(index{:}, n); end end function expect_write_float_(obj, value) - if obj.write_float_written.has_value() - last_dim = ndims(value); - obj.write_float_written = yardl.Optional(cat(last_dim, obj.write_float_written.value, value)); - else - obj.write_float_written = yardl.Optional(value); - end + obj.expected_float = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_int_written, yardl.None, "Expected call to write_int_ was not received"); - obj.testCase_.verifyEqual(obj.write_float_written, yardl.None, "Expected call to write_float_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_int), "Expected call to write_int_ was not received"); + obj.testCase_.verifyEqual(obj.expected_float, yardl.None, "Expected call to write_float_ was not received"); end end methods (Access=protected) function write_int_(obj, value) - obj.testCase_.verifyTrue(obj.write_int_written.has_value(), "Unexpected call to write_int_"); - expected = obj.write_int_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_"); - obj.write_int_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_int), "Unexpected call to write_int_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_int{1}, "Unexpected argument value for call to write_int_"); + obj.expected_int = obj.expected_int(2:end); end function write_float_(obj, value) - obj.testCase_.verifyTrue(obj.write_float_written.has_value(), "Unexpected call to write_float_"); - expected = obj.write_float_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_"); - obj.write_float_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_float.has_value(), "Unexpected call to write_float_"); + obj.testCase_.verifyEqual(value, obj.expected_float.value, "Unexpected argument value for call to write_float_"); + obj.expected_float = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m b/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m index 4aef7fcc..67f04a63 100644 --- a/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m @@ -3,92 +3,68 @@ classdef MockScalarOptionalsWriter < matlab.mixin.Copyable & test_model.ScalarOptionalsWriterBase properties testCase_ - write_optional_int_written - write_optional_record_written - write_record_with_optional_fields_written - write_optional_record_with_optional_fields_written + expected_optional_int + expected_optional_record + expected_record_with_optional_fields + expected_optional_record_with_optional_fields end methods function obj = MockScalarOptionalsWriter(testCase) obj.testCase_ = testCase; - obj.write_optional_int_written = yardl.None; - obj.write_optional_record_written = yardl.None; - obj.write_record_with_optional_fields_written = yardl.None; - obj.write_optional_record_with_optional_fields_written = yardl.None; + obj.expected_optional_int = yardl.None; + obj.expected_optional_record = yardl.None; + obj.expected_record_with_optional_fields = yardl.None; + obj.expected_optional_record_with_optional_fields = yardl.None; end function expect_write_optional_int_(obj, value) - if obj.write_optional_int_written.has_value() - last_dim = ndims(value); - obj.write_optional_int_written = yardl.Optional(cat(last_dim, obj.write_optional_int_written.value, value)); - else - obj.write_optional_int_written = yardl.Optional(value); - end + obj.expected_optional_int = yardl.Optional(value); end function expect_write_optional_record_(obj, value) - if obj.write_optional_record_written.has_value() - last_dim = ndims(value); - obj.write_optional_record_written = yardl.Optional(cat(last_dim, obj.write_optional_record_written.value, value)); - else - obj.write_optional_record_written = yardl.Optional(value); - end + obj.expected_optional_record = yardl.Optional(value); end function expect_write_record_with_optional_fields_(obj, value) - if obj.write_record_with_optional_fields_written.has_value() - last_dim = ndims(value); - obj.write_record_with_optional_fields_written = yardl.Optional(cat(last_dim, obj.write_record_with_optional_fields_written.value, value)); - else - obj.write_record_with_optional_fields_written = yardl.Optional(value); - end + obj.expected_record_with_optional_fields = yardl.Optional(value); end function expect_write_optional_record_with_optional_fields_(obj, value) - if obj.write_optional_record_with_optional_fields_written.has_value() - last_dim = ndims(value); - obj.write_optional_record_with_optional_fields_written = yardl.Optional(cat(last_dim, obj.write_optional_record_with_optional_fields_written.value, value)); - else - obj.write_optional_record_with_optional_fields_written = yardl.Optional(value); - end + obj.expected_optional_record_with_optional_fields = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_optional_int_written, yardl.None, "Expected call to write_optional_int_ was not received"); - obj.testCase_.verifyEqual(obj.write_optional_record_written, yardl.None, "Expected call to write_optional_record_ was not received"); - obj.testCase_.verifyEqual(obj.write_record_with_optional_fields_written, yardl.None, "Expected call to write_record_with_optional_fields_ was not received"); - obj.testCase_.verifyEqual(obj.write_optional_record_with_optional_fields_written, yardl.None, "Expected call to write_optional_record_with_optional_fields_ was not received"); + obj.testCase_.verifyEqual(obj.expected_optional_int, yardl.None, "Expected call to write_optional_int_ was not received"); + obj.testCase_.verifyEqual(obj.expected_optional_record, yardl.None, "Expected call to write_optional_record_ was not received"); + obj.testCase_.verifyEqual(obj.expected_record_with_optional_fields, yardl.None, "Expected call to write_record_with_optional_fields_ was not received"); + obj.testCase_.verifyEqual(obj.expected_optional_record_with_optional_fields, yardl.None, "Expected call to write_optional_record_with_optional_fields_ was not received"); end end methods (Access=protected) function write_optional_int_(obj, value) - obj.testCase_.verifyTrue(obj.write_optional_int_written.has_value(), "Unexpected call to write_optional_int_"); - expected = obj.write_optional_int_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_int_"); - obj.write_optional_int_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_optional_int.has_value(), "Unexpected call to write_optional_int_"); + obj.testCase_.verifyEqual(value, obj.expected_optional_int.value, "Unexpected argument value for call to write_optional_int_"); + obj.expected_optional_int = yardl.None; end function write_optional_record_(obj, value) - obj.testCase_.verifyTrue(obj.write_optional_record_written.has_value(), "Unexpected call to write_optional_record_"); - expected = obj.write_optional_record_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_record_"); - obj.write_optional_record_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_optional_record.has_value(), "Unexpected call to write_optional_record_"); + obj.testCase_.verifyEqual(value, obj.expected_optional_record.value, "Unexpected argument value for call to write_optional_record_"); + obj.expected_optional_record = yardl.None; end function write_record_with_optional_fields_(obj, value) - obj.testCase_.verifyTrue(obj.write_record_with_optional_fields_written.has_value(), "Unexpected call to write_record_with_optional_fields_"); - expected = obj.write_record_with_optional_fields_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_optional_fields_"); - obj.write_record_with_optional_fields_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_record_with_optional_fields.has_value(), "Unexpected call to write_record_with_optional_fields_"); + obj.testCase_.verifyEqual(value, obj.expected_record_with_optional_fields.value, "Unexpected argument value for call to write_record_with_optional_fields_"); + obj.expected_record_with_optional_fields = yardl.None; end function write_optional_record_with_optional_fields_(obj, value) - obj.testCase_.verifyTrue(obj.write_optional_record_with_optional_fields_written.has_value(), "Unexpected call to write_optional_record_with_optional_fields_"); - expected = obj.write_optional_record_with_optional_fields_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_record_with_optional_fields_"); - obj.write_optional_record_with_optional_fields_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_optional_record_with_optional_fields.has_value(), "Unexpected call to write_optional_record_with_optional_fields_"); + obj.testCase_.verifyEqual(value, obj.expected_optional_record_with_optional_fields.value, "Unexpected argument value for call to write_optional_record_with_optional_fields_"); + obj.expected_optional_record_with_optional_fields = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockScalarsWriter.m b/matlab/generated/+test_model/+testing/MockScalarsWriter.m index 64c1a6d1..11db90e8 100644 --- a/matlab/generated/+test_model/+testing/MockScalarsWriter.m +++ b/matlab/generated/+test_model/+testing/MockScalarsWriter.m @@ -3,54 +3,42 @@ classdef MockScalarsWriter < matlab.mixin.Copyable & test_model.ScalarsWriterBase properties testCase_ - write_int32_written - write_record_written + expected_int32 + expected_record end methods function obj = MockScalarsWriter(testCase) obj.testCase_ = testCase; - obj.write_int32_written = yardl.None; - obj.write_record_written = yardl.None; + obj.expected_int32 = yardl.None; + obj.expected_record = yardl.None; end function expect_write_int32_(obj, value) - if obj.write_int32_written.has_value() - last_dim = ndims(value); - obj.write_int32_written = yardl.Optional(cat(last_dim, obj.write_int32_written.value, value)); - else - obj.write_int32_written = yardl.Optional(value); - end + obj.expected_int32 = yardl.Optional(value); end function expect_write_record_(obj, value) - if obj.write_record_written.has_value() - last_dim = ndims(value); - obj.write_record_written = yardl.Optional(cat(last_dim, obj.write_record_written.value, value)); - else - obj.write_record_written = yardl.Optional(value); - end + obj.expected_record = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_int32_written, yardl.None, "Expected call to write_int32_ was not received"); - obj.testCase_.verifyEqual(obj.write_record_written, yardl.None, "Expected call to write_record_ was not received"); + obj.testCase_.verifyEqual(obj.expected_int32, yardl.None, "Expected call to write_int32_ was not received"); + obj.testCase_.verifyEqual(obj.expected_record, yardl.None, "Expected call to write_record_ was not received"); end end methods (Access=protected) function write_int32_(obj, value) - obj.testCase_.verifyTrue(obj.write_int32_written.has_value(), "Unexpected call to write_int32_"); - expected = obj.write_int32_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int32_"); - obj.write_int32_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_int32.has_value(), "Unexpected call to write_int32_"); + obj.testCase_.verifyEqual(value, obj.expected_int32.value, "Unexpected argument value for call to write_int32_"); + obj.expected_int32 = yardl.None; end function write_record_(obj, value) - obj.testCase_.verifyTrue(obj.write_record_written.has_value(), "Unexpected call to write_record_"); - expected = obj.write_record_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_"); - obj.write_record_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_record.has_value(), "Unexpected call to write_record_"); + obj.testCase_.verifyEqual(value, obj.expected_record.value, "Unexpected argument value for call to write_record_"); + obj.expected_record = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m b/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m index 3591f63f..21a86414 100644 --- a/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m @@ -3,187 +3,147 @@ classdef MockSimpleGenericsWriter < matlab.mixin.Copyable & test_model.SimpleGenericsWriterBase properties testCase_ - write_float_image_written - write_int_image_written - write_int_image_alternate_syntax_written - write_string_image_written - write_int_float_tuple_written - write_float_float_tuple_written - write_int_float_tuple_alternate_syntax_written - write_int_string_tuple_written - write_stream_of_type_variants_written + expected_float_image + expected_int_image + expected_int_image_alternate_syntax + expected_string_image + expected_int_float_tuple + expected_float_float_tuple + expected_int_float_tuple_alternate_syntax + expected_int_string_tuple + expected_stream_of_type_variants end methods function obj = MockSimpleGenericsWriter(testCase) obj.testCase_ = testCase; - obj.write_float_image_written = yardl.None; - obj.write_int_image_written = yardl.None; - obj.write_int_image_alternate_syntax_written = yardl.None; - obj.write_string_image_written = yardl.None; - obj.write_int_float_tuple_written = yardl.None; - obj.write_float_float_tuple_written = yardl.None; - obj.write_int_float_tuple_alternate_syntax_written = yardl.None; - obj.write_int_string_tuple_written = yardl.None; - obj.write_stream_of_type_variants_written = yardl.None; + obj.expected_float_image = yardl.None; + obj.expected_int_image = yardl.None; + obj.expected_int_image_alternate_syntax = yardl.None; + obj.expected_string_image = yardl.None; + obj.expected_int_float_tuple = yardl.None; + obj.expected_float_float_tuple = yardl.None; + obj.expected_int_float_tuple_alternate_syntax = yardl.None; + obj.expected_int_string_tuple = yardl.None; + obj.expected_stream_of_type_variants = {}; end function expect_write_float_image_(obj, value) - if obj.write_float_image_written.has_value() - last_dim = ndims(value); - obj.write_float_image_written = yardl.Optional(cat(last_dim, obj.write_float_image_written.value, value)); - else - obj.write_float_image_written = yardl.Optional(value); - end + obj.expected_float_image = yardl.Optional(value); end function expect_write_int_image_(obj, value) - if obj.write_int_image_written.has_value() - last_dim = ndims(value); - obj.write_int_image_written = yardl.Optional(cat(last_dim, obj.write_int_image_written.value, value)); - else - obj.write_int_image_written = yardl.Optional(value); - end + obj.expected_int_image = yardl.Optional(value); end function expect_write_int_image_alternate_syntax_(obj, value) - if obj.write_int_image_alternate_syntax_written.has_value() - last_dim = ndims(value); - obj.write_int_image_alternate_syntax_written = yardl.Optional(cat(last_dim, obj.write_int_image_alternate_syntax_written.value, value)); - else - obj.write_int_image_alternate_syntax_written = yardl.Optional(value); - end + obj.expected_int_image_alternate_syntax = yardl.Optional(value); end function expect_write_string_image_(obj, value) - if obj.write_string_image_written.has_value() - last_dim = ndims(value); - obj.write_string_image_written = yardl.Optional(cat(last_dim, obj.write_string_image_written.value, value)); - else - obj.write_string_image_written = yardl.Optional(value); - end + obj.expected_string_image = yardl.Optional(value); end function expect_write_int_float_tuple_(obj, value) - if obj.write_int_float_tuple_written.has_value() - last_dim = ndims(value); - obj.write_int_float_tuple_written = yardl.Optional(cat(last_dim, obj.write_int_float_tuple_written.value, value)); - else - obj.write_int_float_tuple_written = yardl.Optional(value); - end + obj.expected_int_float_tuple = yardl.Optional(value); end function expect_write_float_float_tuple_(obj, value) - if obj.write_float_float_tuple_written.has_value() - last_dim = ndims(value); - obj.write_float_float_tuple_written = yardl.Optional(cat(last_dim, obj.write_float_float_tuple_written.value, value)); - else - obj.write_float_float_tuple_written = yardl.Optional(value); - end + obj.expected_float_float_tuple = yardl.Optional(value); end function expect_write_int_float_tuple_alternate_syntax_(obj, value) - if obj.write_int_float_tuple_alternate_syntax_written.has_value() - last_dim = ndims(value); - obj.write_int_float_tuple_alternate_syntax_written = yardl.Optional(cat(last_dim, obj.write_int_float_tuple_alternate_syntax_written.value, value)); - else - obj.write_int_float_tuple_alternate_syntax_written = yardl.Optional(value); - end + obj.expected_int_float_tuple_alternate_syntax = yardl.Optional(value); end function expect_write_int_string_tuple_(obj, value) - if obj.write_int_string_tuple_written.has_value() - last_dim = ndims(value); - obj.write_int_string_tuple_written = yardl.Optional(cat(last_dim, obj.write_int_string_tuple_written.value, value)); - else - obj.write_int_string_tuple_written = yardl.Optional(value); - end + obj.expected_int_string_tuple = yardl.Optional(value); end function expect_write_stream_of_type_variants_(obj, value) - if obj.write_stream_of_type_variants_written.has_value() - last_dim = ndims(value); - obj.write_stream_of_type_variants_written = yardl.Optional(cat(last_dim, obj.write_stream_of_type_variants_written.value, value)); - else - obj.write_stream_of_type_variants_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_stream_of_type_variants{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_stream_of_type_variants{end+1} = value(index{:}, n); end end function verify(obj) - obj.testCase_.verifyEqual(obj.write_float_image_written, yardl.None, "Expected call to write_float_image_ was not received"); - obj.testCase_.verifyEqual(obj.write_int_image_written, yardl.None, "Expected call to write_int_image_ was not received"); - obj.testCase_.verifyEqual(obj.write_int_image_alternate_syntax_written, yardl.None, "Expected call to write_int_image_alternate_syntax_ was not received"); - obj.testCase_.verifyEqual(obj.write_string_image_written, yardl.None, "Expected call to write_string_image_ was not received"); - obj.testCase_.verifyEqual(obj.write_int_float_tuple_written, yardl.None, "Expected call to write_int_float_tuple_ was not received"); - obj.testCase_.verifyEqual(obj.write_float_float_tuple_written, yardl.None, "Expected call to write_float_float_tuple_ was not received"); - obj.testCase_.verifyEqual(obj.write_int_float_tuple_alternate_syntax_written, yardl.None, "Expected call to write_int_float_tuple_alternate_syntax_ was not received"); - obj.testCase_.verifyEqual(obj.write_int_string_tuple_written, yardl.None, "Expected call to write_int_string_tuple_ was not received"); - obj.testCase_.verifyEqual(obj.write_stream_of_type_variants_written, yardl.None, "Expected call to write_stream_of_type_variants_ was not received"); + obj.testCase_.verifyEqual(obj.expected_float_image, yardl.None, "Expected call to write_float_image_ was not received"); + obj.testCase_.verifyEqual(obj.expected_int_image, yardl.None, "Expected call to write_int_image_ was not received"); + obj.testCase_.verifyEqual(obj.expected_int_image_alternate_syntax, yardl.None, "Expected call to write_int_image_alternate_syntax_ was not received"); + obj.testCase_.verifyEqual(obj.expected_string_image, yardl.None, "Expected call to write_string_image_ was not received"); + obj.testCase_.verifyEqual(obj.expected_int_float_tuple, yardl.None, "Expected call to write_int_float_tuple_ was not received"); + obj.testCase_.verifyEqual(obj.expected_float_float_tuple, yardl.None, "Expected call to write_float_float_tuple_ was not received"); + obj.testCase_.verifyEqual(obj.expected_int_float_tuple_alternate_syntax, yardl.None, "Expected call to write_int_float_tuple_alternate_syntax_ was not received"); + obj.testCase_.verifyEqual(obj.expected_int_string_tuple, yardl.None, "Expected call to write_int_string_tuple_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_stream_of_type_variants), "Expected call to write_stream_of_type_variants_ was not received"); end end methods (Access=protected) function write_float_image_(obj, value) - obj.testCase_.verifyTrue(obj.write_float_image_written.has_value(), "Unexpected call to write_float_image_"); - expected = obj.write_float_image_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_image_"); - obj.write_float_image_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_float_image.has_value(), "Unexpected call to write_float_image_"); + obj.testCase_.verifyEqual(value, obj.expected_float_image.value, "Unexpected argument value for call to write_float_image_"); + obj.expected_float_image = yardl.None; end function write_int_image_(obj, value) - obj.testCase_.verifyTrue(obj.write_int_image_written.has_value(), "Unexpected call to write_int_image_"); - expected = obj.write_int_image_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_image_"); - obj.write_int_image_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_int_image.has_value(), "Unexpected call to write_int_image_"); + obj.testCase_.verifyEqual(value, obj.expected_int_image.value, "Unexpected argument value for call to write_int_image_"); + obj.expected_int_image = yardl.None; end function write_int_image_alternate_syntax_(obj, value) - obj.testCase_.verifyTrue(obj.write_int_image_alternate_syntax_written.has_value(), "Unexpected call to write_int_image_alternate_syntax_"); - expected = obj.write_int_image_alternate_syntax_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_image_alternate_syntax_"); - obj.write_int_image_alternate_syntax_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_int_image_alternate_syntax.has_value(), "Unexpected call to write_int_image_alternate_syntax_"); + obj.testCase_.verifyEqual(value, obj.expected_int_image_alternate_syntax.value, "Unexpected argument value for call to write_int_image_alternate_syntax_"); + obj.expected_int_image_alternate_syntax = yardl.None; end function write_string_image_(obj, value) - obj.testCase_.verifyTrue(obj.write_string_image_written.has_value(), "Unexpected call to write_string_image_"); - expected = obj.write_string_image_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_string_image_"); - obj.write_string_image_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_string_image.has_value(), "Unexpected call to write_string_image_"); + obj.testCase_.verifyEqual(value, obj.expected_string_image.value, "Unexpected argument value for call to write_string_image_"); + obj.expected_string_image = yardl.None; end function write_int_float_tuple_(obj, value) - obj.testCase_.verifyTrue(obj.write_int_float_tuple_written.has_value(), "Unexpected call to write_int_float_tuple_"); - expected = obj.write_int_float_tuple_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_float_tuple_"); - obj.write_int_float_tuple_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_int_float_tuple.has_value(), "Unexpected call to write_int_float_tuple_"); + obj.testCase_.verifyEqual(value, obj.expected_int_float_tuple.value, "Unexpected argument value for call to write_int_float_tuple_"); + obj.expected_int_float_tuple = yardl.None; end function write_float_float_tuple_(obj, value) - obj.testCase_.verifyTrue(obj.write_float_float_tuple_written.has_value(), "Unexpected call to write_float_float_tuple_"); - expected = obj.write_float_float_tuple_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_float_float_tuple_"); - obj.write_float_float_tuple_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_float_float_tuple.has_value(), "Unexpected call to write_float_float_tuple_"); + obj.testCase_.verifyEqual(value, obj.expected_float_float_tuple.value, "Unexpected argument value for call to write_float_float_tuple_"); + obj.expected_float_float_tuple = yardl.None; end function write_int_float_tuple_alternate_syntax_(obj, value) - obj.testCase_.verifyTrue(obj.write_int_float_tuple_alternate_syntax_written.has_value(), "Unexpected call to write_int_float_tuple_alternate_syntax_"); - expected = obj.write_int_float_tuple_alternate_syntax_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_float_tuple_alternate_syntax_"); - obj.write_int_float_tuple_alternate_syntax_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_int_float_tuple_alternate_syntax.has_value(), "Unexpected call to write_int_float_tuple_alternate_syntax_"); + obj.testCase_.verifyEqual(value, obj.expected_int_float_tuple_alternate_syntax.value, "Unexpected argument value for call to write_int_float_tuple_alternate_syntax_"); + obj.expected_int_float_tuple_alternate_syntax = yardl.None; end function write_int_string_tuple_(obj, value) - obj.testCase_.verifyTrue(obj.write_int_string_tuple_written.has_value(), "Unexpected call to write_int_string_tuple_"); - expected = obj.write_int_string_tuple_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_string_tuple_"); - obj.write_int_string_tuple_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_int_string_tuple.has_value(), "Unexpected call to write_int_string_tuple_"); + obj.testCase_.verifyEqual(value, obj.expected_int_string_tuple.value, "Unexpected argument value for call to write_int_string_tuple_"); + obj.expected_int_string_tuple = yardl.None; end function write_stream_of_type_variants_(obj, value) - obj.testCase_.verifyTrue(obj.write_stream_of_type_variants_written.has_value(), "Unexpected call to write_stream_of_type_variants_"); - expected = obj.write_stream_of_type_variants_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_stream_of_type_variants_"); - obj.write_stream_of_type_variants_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_stream_of_type_variants), "Unexpected call to write_stream_of_type_variants_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_stream_of_type_variants{1}, "Unexpected argument value for call to write_stream_of_type_variants_"); + obj.expected_stream_of_type_variants = obj.expected_stream_of_type_variants(2:end); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockStateTestWriter.m b/matlab/generated/+test_model/+testing/MockStateTestWriter.m index 80b09507..23977099 100644 --- a/matlab/generated/+test_model/+testing/MockStateTestWriter.m +++ b/matlab/generated/+test_model/+testing/MockStateTestWriter.m @@ -3,73 +3,69 @@ classdef MockStateTestWriter < matlab.mixin.Copyable & test_model.StateTestWriterBase properties testCase_ - write_an_int_written - write_a_stream_written - write_another_int_written + expected_an_int + expected_a_stream + expected_another_int end methods function obj = MockStateTestWriter(testCase) obj.testCase_ = testCase; - obj.write_an_int_written = yardl.None; - obj.write_a_stream_written = yardl.None; - obj.write_another_int_written = yardl.None; + obj.expected_an_int = yardl.None; + obj.expected_a_stream = {}; + obj.expected_another_int = yardl.None; end function expect_write_an_int_(obj, value) - if obj.write_an_int_written.has_value() - last_dim = ndims(value); - obj.write_an_int_written = yardl.Optional(cat(last_dim, obj.write_an_int_written.value, value)); - else - obj.write_an_int_written = yardl.Optional(value); - end + obj.expected_an_int = yardl.Optional(value); end function expect_write_a_stream_(obj, value) - if obj.write_a_stream_written.has_value() - last_dim = ndims(value); - obj.write_a_stream_written = yardl.Optional(cat(last_dim, obj.write_a_stream_written.value, value)); - else - obj.write_a_stream_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_a_stream{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_a_stream{end+1} = value(index{:}, n); end end function expect_write_another_int_(obj, value) - if obj.write_another_int_written.has_value() - last_dim = ndims(value); - obj.write_another_int_written = yardl.Optional(cat(last_dim, obj.write_another_int_written.value, value)); - else - obj.write_another_int_written = yardl.Optional(value); - end + obj.expected_another_int = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_an_int_written, yardl.None, "Expected call to write_an_int_ was not received"); - obj.testCase_.verifyEqual(obj.write_a_stream_written, yardl.None, "Expected call to write_a_stream_ was not received"); - obj.testCase_.verifyEqual(obj.write_another_int_written, yardl.None, "Expected call to write_another_int_ was not received"); + obj.testCase_.verifyEqual(obj.expected_an_int, yardl.None, "Expected call to write_an_int_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_a_stream), "Expected call to write_a_stream_ was not received"); + obj.testCase_.verifyEqual(obj.expected_another_int, yardl.None, "Expected call to write_another_int_ was not received"); end end methods (Access=protected) function write_an_int_(obj, value) - obj.testCase_.verifyTrue(obj.write_an_int_written.has_value(), "Unexpected call to write_an_int_"); - expected = obj.write_an_int_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_an_int_"); - obj.write_an_int_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_an_int.has_value(), "Unexpected call to write_an_int_"); + obj.testCase_.verifyEqual(value, obj.expected_an_int.value, "Unexpected argument value for call to write_an_int_"); + obj.expected_an_int = yardl.None; end function write_a_stream_(obj, value) - obj.testCase_.verifyTrue(obj.write_a_stream_written.has_value(), "Unexpected call to write_a_stream_"); - expected = obj.write_a_stream_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_a_stream_"); - obj.write_a_stream_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_a_stream), "Unexpected call to write_a_stream_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_a_stream{1}, "Unexpected argument value for call to write_a_stream_"); + obj.expected_a_stream = obj.expected_a_stream(2:end); end function write_another_int_(obj, value) - obj.testCase_.verifyTrue(obj.write_another_int_written.has_value(), "Unexpected call to write_another_int_"); - expected = obj.write_another_int_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_another_int_"); - obj.write_another_int_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_another_int.has_value(), "Unexpected call to write_another_int_"); + obj.testCase_.verifyEqual(value, obj.expected_another_int.value, "Unexpected argument value for call to write_another_int_"); + obj.expected_another_int = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m index 41f02e34..4f4ac090 100644 --- a/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m @@ -3,54 +3,70 @@ classdef MockStreamsOfAliasedUnionsWriter < matlab.mixin.Copyable & test_model.StreamsOfAliasedUnionsWriterBase properties testCase_ - write_int_or_simple_record_written - write_nullable_int_or_simple_record_written + expected_int_or_simple_record + expected_nullable_int_or_simple_record end methods function obj = MockStreamsOfAliasedUnionsWriter(testCase) obj.testCase_ = testCase; - obj.write_int_or_simple_record_written = yardl.None; - obj.write_nullable_int_or_simple_record_written = yardl.None; + obj.expected_int_or_simple_record = {}; + obj.expected_nullable_int_or_simple_record = {}; end function expect_write_int_or_simple_record_(obj, value) - if obj.write_int_or_simple_record_written.has_value() - last_dim = ndims(value); - obj.write_int_or_simple_record_written = yardl.Optional(cat(last_dim, obj.write_int_or_simple_record_written.value, value)); - else - obj.write_int_or_simple_record_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_int_or_simple_record{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_int_or_simple_record{end+1} = value(index{:}, n); end end function expect_write_nullable_int_or_simple_record_(obj, value) - if obj.write_nullable_int_or_simple_record_written.has_value() - last_dim = ndims(value); - obj.write_nullable_int_or_simple_record_written = yardl.Optional(cat(last_dim, obj.write_nullable_int_or_simple_record_written.value, value)); - else - obj.write_nullable_int_or_simple_record_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_nullable_int_or_simple_record{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_nullable_int_or_simple_record{end+1} = value(index{:}, n); end end function verify(obj) - obj.testCase_.verifyEqual(obj.write_int_or_simple_record_written, yardl.None, "Expected call to write_int_or_simple_record_ was not received"); - obj.testCase_.verifyEqual(obj.write_nullable_int_or_simple_record_written, yardl.None, "Expected call to write_nullable_int_or_simple_record_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_int_or_simple_record), "Expected call to write_int_or_simple_record_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_nullable_int_or_simple_record), "Expected call to write_nullable_int_or_simple_record_ was not received"); end end methods (Access=protected) function write_int_or_simple_record_(obj, value) - obj.testCase_.verifyTrue(obj.write_int_or_simple_record_written.has_value(), "Unexpected call to write_int_or_simple_record_"); - expected = obj.write_int_or_simple_record_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_simple_record_"); - obj.write_int_or_simple_record_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_int_or_simple_record), "Unexpected call to write_int_or_simple_record_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_int_or_simple_record{1}, "Unexpected argument value for call to write_int_or_simple_record_"); + obj.expected_int_or_simple_record = obj.expected_int_or_simple_record(2:end); end function write_nullable_int_or_simple_record_(obj, value) - obj.testCase_.verifyTrue(obj.write_nullable_int_or_simple_record_written.has_value(), "Unexpected call to write_nullable_int_or_simple_record_"); - expected = obj.write_nullable_int_or_simple_record_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_nullable_int_or_simple_record_"); - obj.write_nullable_int_or_simple_record_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_nullable_int_or_simple_record), "Unexpected call to write_nullable_int_or_simple_record_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_nullable_int_or_simple_record{1}, "Unexpected argument value for call to write_nullable_int_or_simple_record_"); + obj.expected_nullable_int_or_simple_record = obj.expected_nullable_int_or_simple_record(2:end); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m index 45961457..392d1aa0 100644 --- a/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m @@ -3,54 +3,70 @@ classdef MockStreamsOfUnionsWriter < matlab.mixin.Copyable & test_model.StreamsOfUnionsWriterBase properties testCase_ - write_int_or_simple_record_written - write_nullable_int_or_simple_record_written + expected_int_or_simple_record + expected_nullable_int_or_simple_record end methods function obj = MockStreamsOfUnionsWriter(testCase) obj.testCase_ = testCase; - obj.write_int_or_simple_record_written = yardl.None; - obj.write_nullable_int_or_simple_record_written = yardl.None; + obj.expected_int_or_simple_record = {}; + obj.expected_nullable_int_or_simple_record = {}; end function expect_write_int_or_simple_record_(obj, value) - if obj.write_int_or_simple_record_written.has_value() - last_dim = ndims(value); - obj.write_int_or_simple_record_written = yardl.Optional(cat(last_dim, obj.write_int_or_simple_record_written.value, value)); - else - obj.write_int_or_simple_record_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_int_or_simple_record{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_int_or_simple_record{end+1} = value(index{:}, n); end end function expect_write_nullable_int_or_simple_record_(obj, value) - if obj.write_nullable_int_or_simple_record_written.has_value() - last_dim = ndims(value); - obj.write_nullable_int_or_simple_record_written = yardl.Optional(cat(last_dim, obj.write_nullable_int_or_simple_record_written.value, value)); - else - obj.write_nullable_int_or_simple_record_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_nullable_int_or_simple_record{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_nullable_int_or_simple_record{end+1} = value(index{:}, n); end end function verify(obj) - obj.testCase_.verifyEqual(obj.write_int_or_simple_record_written, yardl.None, "Expected call to write_int_or_simple_record_ was not received"); - obj.testCase_.verifyEqual(obj.write_nullable_int_or_simple_record_written, yardl.None, "Expected call to write_nullable_int_or_simple_record_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_int_or_simple_record), "Expected call to write_int_or_simple_record_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_nullable_int_or_simple_record), "Expected call to write_nullable_int_or_simple_record_ was not received"); end end methods (Access=protected) function write_int_or_simple_record_(obj, value) - obj.testCase_.verifyTrue(obj.write_int_or_simple_record_written.has_value(), "Unexpected call to write_int_or_simple_record_"); - expected = obj.write_int_or_simple_record_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_simple_record_"); - obj.write_int_or_simple_record_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_int_or_simple_record), "Unexpected call to write_int_or_simple_record_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_int_or_simple_record{1}, "Unexpected argument value for call to write_int_or_simple_record_"); + obj.expected_int_or_simple_record = obj.expected_int_or_simple_record(2:end); end function write_nullable_int_or_simple_record_(obj, value) - obj.testCase_.verifyTrue(obj.write_nullable_int_or_simple_record_written.has_value(), "Unexpected call to write_nullable_int_or_simple_record_"); - expected = obj.write_nullable_int_or_simple_record_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_nullable_int_or_simple_record_"); - obj.write_nullable_int_or_simple_record_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_nullable_int_or_simple_record), "Unexpected call to write_nullable_int_or_simple_record_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_nullable_int_or_simple_record{1}, "Unexpected argument value for call to write_nullable_int_or_simple_record_"); + obj.expected_nullable_int_or_simple_record = obj.expected_nullable_int_or_simple_record(2:end); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockStreamsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsWriter.m index 513ff79e..4518f1fe 100644 --- a/matlab/generated/+test_model/+testing/MockStreamsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStreamsWriter.m @@ -3,92 +3,124 @@ classdef MockStreamsWriter < matlab.mixin.Copyable & test_model.StreamsWriterBase properties testCase_ - write_int_data_written - write_optional_int_data_written - write_record_with_optional_vector_data_written - write_fixed_vector_written + expected_int_data + expected_optional_int_data + expected_record_with_optional_vector_data + expected_fixed_vector end methods function obj = MockStreamsWriter(testCase) obj.testCase_ = testCase; - obj.write_int_data_written = yardl.None; - obj.write_optional_int_data_written = yardl.None; - obj.write_record_with_optional_vector_data_written = yardl.None; - obj.write_fixed_vector_written = yardl.None; + obj.expected_int_data = {}; + obj.expected_optional_int_data = {}; + obj.expected_record_with_optional_vector_data = {}; + obj.expected_fixed_vector = {}; end function expect_write_int_data_(obj, value) - if obj.write_int_data_written.has_value() - last_dim = ndims(value); - obj.write_int_data_written = yardl.Optional(cat(last_dim, obj.write_int_data_written.value, value)); - else - obj.write_int_data_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_int_data{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_int_data{end+1} = value(index{:}, n); end end function expect_write_optional_int_data_(obj, value) - if obj.write_optional_int_data_written.has_value() - last_dim = ndims(value); - obj.write_optional_int_data_written = yardl.Optional(cat(last_dim, obj.write_optional_int_data_written.value, value)); - else - obj.write_optional_int_data_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_optional_int_data{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_optional_int_data{end+1} = value(index{:}, n); end end function expect_write_record_with_optional_vector_data_(obj, value) - if obj.write_record_with_optional_vector_data_written.has_value() - last_dim = ndims(value); - obj.write_record_with_optional_vector_data_written = yardl.Optional(cat(last_dim, obj.write_record_with_optional_vector_data_written.value, value)); - else - obj.write_record_with_optional_vector_data_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_record_with_optional_vector_data{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_record_with_optional_vector_data{end+1} = value(index{:}, n); end end function expect_write_fixed_vector_(obj, value) - if obj.write_fixed_vector_written.has_value() - last_dim = ndims(value); - obj.write_fixed_vector_written = yardl.Optional(cat(last_dim, obj.write_fixed_vector_written.value, value)); - else - obj.write_fixed_vector_written = yardl.Optional(value); + if iscell(value) + for n = 1:numel(value) + obj.expected_fixed_vector{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + obj.expected_fixed_vector{end+1} = value(index{:}, n); end end function verify(obj) - obj.testCase_.verifyEqual(obj.write_int_data_written, yardl.None, "Expected call to write_int_data_ was not received"); - obj.testCase_.verifyEqual(obj.write_optional_int_data_written, yardl.None, "Expected call to write_optional_int_data_ was not received"); - obj.testCase_.verifyEqual(obj.write_record_with_optional_vector_data_written, yardl.None, "Expected call to write_record_with_optional_vector_data_ was not received"); - obj.testCase_.verifyEqual(obj.write_fixed_vector_written, yardl.None, "Expected call to write_fixed_vector_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_int_data), "Expected call to write_int_data_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_optional_int_data), "Expected call to write_optional_int_data_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_record_with_optional_vector_data), "Expected call to write_record_with_optional_vector_data_ was not received"); + obj.testCase_.verifyTrue(isempty(obj.expected_fixed_vector), "Expected call to write_fixed_vector_ was not received"); end end methods (Access=protected) function write_int_data_(obj, value) - obj.testCase_.verifyTrue(obj.write_int_data_written.has_value(), "Unexpected call to write_int_data_"); - expected = obj.write_int_data_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_data_"); - obj.write_int_data_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_int_data), "Unexpected call to write_int_data_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_int_data{1}, "Unexpected argument value for call to write_int_data_"); + obj.expected_int_data = obj.expected_int_data(2:end); end function write_optional_int_data_(obj, value) - obj.testCase_.verifyTrue(obj.write_optional_int_data_written.has_value(), "Unexpected call to write_optional_int_data_"); - expected = obj.write_optional_int_data_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_optional_int_data_"); - obj.write_optional_int_data_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_optional_int_data), "Unexpected call to write_optional_int_data_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_optional_int_data{1}, "Unexpected argument value for call to write_optional_int_data_"); + obj.expected_optional_int_data = obj.expected_optional_int_data(2:end); end function write_record_with_optional_vector_data_(obj, value) - obj.testCase_.verifyTrue(obj.write_record_with_optional_vector_data_written.has_value(), "Unexpected call to write_record_with_optional_vector_data_"); - expected = obj.write_record_with_optional_vector_data_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_optional_vector_data_"); - obj.write_record_with_optional_vector_data_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_record_with_optional_vector_data), "Unexpected call to write_record_with_optional_vector_data_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_record_with_optional_vector_data{1}, "Unexpected argument value for call to write_record_with_optional_vector_data_"); + obj.expected_record_with_optional_vector_data = obj.expected_record_with_optional_vector_data(2:end); end function write_fixed_vector_(obj, value) - obj.testCase_.verifyTrue(obj.write_fixed_vector_written.has_value(), "Unexpected call to write_fixed_vector_"); - expected = obj.write_fixed_vector_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_vector_"); - obj.write_fixed_vector_written = yardl.None; + assert(iscell(value)); + assert(isscalar(value)); + obj.testCase_.verifyFalse(isempty(obj.expected_fixed_vector), "Unexpected call to write_fixed_vector_"); + obj.testCase_.verifyEqual(value{1}, obj.expected_fixed_vector{1}, "Unexpected argument value for call to write_fixed_vector_"); + obj.expected_fixed_vector = obj.expected_fixed_vector(2:end); end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockStringsWriter.m b/matlab/generated/+test_model/+testing/MockStringsWriter.m index c2073b7b..68e9d70c 100644 --- a/matlab/generated/+test_model/+testing/MockStringsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStringsWriter.m @@ -3,54 +3,42 @@ classdef MockStringsWriter < matlab.mixin.Copyable & test_model.StringsWriterBase properties testCase_ - write_single_string_written - write_rec_with_string_written + expected_single_string + expected_rec_with_string end methods function obj = MockStringsWriter(testCase) obj.testCase_ = testCase; - obj.write_single_string_written = yardl.None; - obj.write_rec_with_string_written = yardl.None; + obj.expected_single_string = yardl.None; + obj.expected_rec_with_string = yardl.None; end function expect_write_single_string_(obj, value) - if obj.write_single_string_written.has_value() - last_dim = ndims(value); - obj.write_single_string_written = yardl.Optional(cat(last_dim, obj.write_single_string_written.value, value)); - else - obj.write_single_string_written = yardl.Optional(value); - end + obj.expected_single_string = yardl.Optional(value); end function expect_write_rec_with_string_(obj, value) - if obj.write_rec_with_string_written.has_value() - last_dim = ndims(value); - obj.write_rec_with_string_written = yardl.Optional(cat(last_dim, obj.write_rec_with_string_written.value, value)); - else - obj.write_rec_with_string_written = yardl.Optional(value); - end + obj.expected_rec_with_string = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_single_string_written, yardl.None, "Expected call to write_single_string_ was not received"); - obj.testCase_.verifyEqual(obj.write_rec_with_string_written, yardl.None, "Expected call to write_rec_with_string_ was not received"); + obj.testCase_.verifyEqual(obj.expected_single_string, yardl.None, "Expected call to write_single_string_ was not received"); + obj.testCase_.verifyEqual(obj.expected_rec_with_string, yardl.None, "Expected call to write_rec_with_string_ was not received"); end end methods (Access=protected) function write_single_string_(obj, value) - obj.testCase_.verifyTrue(obj.write_single_string_written.has_value(), "Unexpected call to write_single_string_"); - expected = obj.write_single_string_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_single_string_"); - obj.write_single_string_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_single_string.has_value(), "Unexpected call to write_single_string_"); + obj.testCase_.verifyEqual(value, obj.expected_single_string.value, "Unexpected argument value for call to write_single_string_"); + obj.expected_single_string = yardl.None; end function write_rec_with_string_(obj, value) - obj.testCase_.verifyTrue(obj.write_rec_with_string_written.has_value(), "Unexpected call to write_rec_with_string_"); - expected = obj.write_rec_with_string_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_rec_with_string_"); - obj.write_rec_with_string_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_rec_with_string.has_value(), "Unexpected call to write_rec_with_string_"); + obj.testCase_.verifyEqual(value, obj.expected_rec_with_string.value, "Unexpected argument value for call to write_rec_with_string_"); + obj.expected_rec_with_string = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m b/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m index 31b1f106..10fa51e5 100644 --- a/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m @@ -3,54 +3,42 @@ classdef MockSubarraysInRecordsWriter < matlab.mixin.Copyable & test_model.SubarraysInRecordsWriterBase properties testCase_ - write_with_fixed_subarrays_written - write_with_vlen_subarrays_written + expected_with_fixed_subarrays + expected_with_vlen_subarrays end methods function obj = MockSubarraysInRecordsWriter(testCase) obj.testCase_ = testCase; - obj.write_with_fixed_subarrays_written = yardl.None; - obj.write_with_vlen_subarrays_written = yardl.None; + obj.expected_with_fixed_subarrays = yardl.None; + obj.expected_with_vlen_subarrays = yardl.None; end function expect_write_with_fixed_subarrays_(obj, value) - if obj.write_with_fixed_subarrays_written.has_value() - last_dim = ndims(value); - obj.write_with_fixed_subarrays_written = yardl.Optional(cat(last_dim, obj.write_with_fixed_subarrays_written.value, value)); - else - obj.write_with_fixed_subarrays_written = yardl.Optional(value); - end + obj.expected_with_fixed_subarrays = yardl.Optional(value); end function expect_write_with_vlen_subarrays_(obj, value) - if obj.write_with_vlen_subarrays_written.has_value() - last_dim = ndims(value); - obj.write_with_vlen_subarrays_written = yardl.Optional(cat(last_dim, obj.write_with_vlen_subarrays_written.value, value)); - else - obj.write_with_vlen_subarrays_written = yardl.Optional(value); - end + obj.expected_with_vlen_subarrays = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_with_fixed_subarrays_written, yardl.None, "Expected call to write_with_fixed_subarrays_ was not received"); - obj.testCase_.verifyEqual(obj.write_with_vlen_subarrays_written, yardl.None, "Expected call to write_with_vlen_subarrays_ was not received"); + obj.testCase_.verifyEqual(obj.expected_with_fixed_subarrays, yardl.None, "Expected call to write_with_fixed_subarrays_ was not received"); + obj.testCase_.verifyEqual(obj.expected_with_vlen_subarrays, yardl.None, "Expected call to write_with_vlen_subarrays_ was not received"); end end methods (Access=protected) function write_with_fixed_subarrays_(obj, value) - obj.testCase_.verifyTrue(obj.write_with_fixed_subarrays_written.has_value(), "Unexpected call to write_with_fixed_subarrays_"); - expected = obj.write_with_fixed_subarrays_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_with_fixed_subarrays_"); - obj.write_with_fixed_subarrays_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_with_fixed_subarrays.has_value(), "Unexpected call to write_with_fixed_subarrays_"); + obj.testCase_.verifyEqual(value, obj.expected_with_fixed_subarrays.value, "Unexpected argument value for call to write_with_fixed_subarrays_"); + obj.expected_with_fixed_subarrays = yardl.None; end function write_with_vlen_subarrays_(obj, value) - obj.testCase_.verifyTrue(obj.write_with_vlen_subarrays_written.has_value(), "Unexpected call to write_with_vlen_subarrays_"); - expected = obj.write_with_vlen_subarrays_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_with_vlen_subarrays_"); - obj.write_with_vlen_subarrays_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_with_vlen_subarrays.has_value(), "Unexpected call to write_with_vlen_subarrays_"); + obj.testCase_.verifyEqual(value, obj.expected_with_vlen_subarrays.value, "Unexpected argument value for call to write_with_vlen_subarrays_"); + obj.expected_with_vlen_subarrays = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockSubarraysWriter.m b/matlab/generated/+test_model/+testing/MockSubarraysWriter.m index 149a47fd..23c7b37f 100644 --- a/matlab/generated/+test_model/+testing/MockSubarraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockSubarraysWriter.m @@ -3,187 +3,133 @@ classdef MockSubarraysWriter < matlab.mixin.Copyable & test_model.SubarraysWriterBase properties testCase_ - write_dynamic_with_fixed_int_subarray_written - write_dynamic_with_fixed_float_subarray_written - write_known_dim_count_with_fixed_int_subarray_written - write_known_dim_count_with_fixed_float_subarray_written - write_fixed_with_fixed_int_subarray_written - write_fixed_with_fixed_float_subarray_written - write_nested_subarray_written - write_dynamic_with_fixed_vector_subarray_written - write_generic_subarray_written + expected_dynamic_with_fixed_int_subarray + expected_dynamic_with_fixed_float_subarray + expected_known_dim_count_with_fixed_int_subarray + expected_known_dim_count_with_fixed_float_subarray + expected_fixed_with_fixed_int_subarray + expected_fixed_with_fixed_float_subarray + expected_nested_subarray + expected_dynamic_with_fixed_vector_subarray + expected_generic_subarray end methods function obj = MockSubarraysWriter(testCase) obj.testCase_ = testCase; - obj.write_dynamic_with_fixed_int_subarray_written = yardl.None; - obj.write_dynamic_with_fixed_float_subarray_written = yardl.None; - obj.write_known_dim_count_with_fixed_int_subarray_written = yardl.None; - obj.write_known_dim_count_with_fixed_float_subarray_written = yardl.None; - obj.write_fixed_with_fixed_int_subarray_written = yardl.None; - obj.write_fixed_with_fixed_float_subarray_written = yardl.None; - obj.write_nested_subarray_written = yardl.None; - obj.write_dynamic_with_fixed_vector_subarray_written = yardl.None; - obj.write_generic_subarray_written = yardl.None; + obj.expected_dynamic_with_fixed_int_subarray = yardl.None; + obj.expected_dynamic_with_fixed_float_subarray = yardl.None; + obj.expected_known_dim_count_with_fixed_int_subarray = yardl.None; + obj.expected_known_dim_count_with_fixed_float_subarray = yardl.None; + obj.expected_fixed_with_fixed_int_subarray = yardl.None; + obj.expected_fixed_with_fixed_float_subarray = yardl.None; + obj.expected_nested_subarray = yardl.None; + obj.expected_dynamic_with_fixed_vector_subarray = yardl.None; + obj.expected_generic_subarray = yardl.None; end function expect_write_dynamic_with_fixed_int_subarray_(obj, value) - if obj.write_dynamic_with_fixed_int_subarray_written.has_value() - last_dim = ndims(value); - obj.write_dynamic_with_fixed_int_subarray_written = yardl.Optional(cat(last_dim, obj.write_dynamic_with_fixed_int_subarray_written.value, value)); - else - obj.write_dynamic_with_fixed_int_subarray_written = yardl.Optional(value); - end + obj.expected_dynamic_with_fixed_int_subarray = yardl.Optional(value); end function expect_write_dynamic_with_fixed_float_subarray_(obj, value) - if obj.write_dynamic_with_fixed_float_subarray_written.has_value() - last_dim = ndims(value); - obj.write_dynamic_with_fixed_float_subarray_written = yardl.Optional(cat(last_dim, obj.write_dynamic_with_fixed_float_subarray_written.value, value)); - else - obj.write_dynamic_with_fixed_float_subarray_written = yardl.Optional(value); - end + obj.expected_dynamic_with_fixed_float_subarray = yardl.Optional(value); end function expect_write_known_dim_count_with_fixed_int_subarray_(obj, value) - if obj.write_known_dim_count_with_fixed_int_subarray_written.has_value() - last_dim = ndims(value); - obj.write_known_dim_count_with_fixed_int_subarray_written = yardl.Optional(cat(last_dim, obj.write_known_dim_count_with_fixed_int_subarray_written.value, value)); - else - obj.write_known_dim_count_with_fixed_int_subarray_written = yardl.Optional(value); - end + obj.expected_known_dim_count_with_fixed_int_subarray = yardl.Optional(value); end function expect_write_known_dim_count_with_fixed_float_subarray_(obj, value) - if obj.write_known_dim_count_with_fixed_float_subarray_written.has_value() - last_dim = ndims(value); - obj.write_known_dim_count_with_fixed_float_subarray_written = yardl.Optional(cat(last_dim, obj.write_known_dim_count_with_fixed_float_subarray_written.value, value)); - else - obj.write_known_dim_count_with_fixed_float_subarray_written = yardl.Optional(value); - end + obj.expected_known_dim_count_with_fixed_float_subarray = yardl.Optional(value); end function expect_write_fixed_with_fixed_int_subarray_(obj, value) - if obj.write_fixed_with_fixed_int_subarray_written.has_value() - last_dim = ndims(value); - obj.write_fixed_with_fixed_int_subarray_written = yardl.Optional(cat(last_dim, obj.write_fixed_with_fixed_int_subarray_written.value, value)); - else - obj.write_fixed_with_fixed_int_subarray_written = yardl.Optional(value); - end + obj.expected_fixed_with_fixed_int_subarray = yardl.Optional(value); end function expect_write_fixed_with_fixed_float_subarray_(obj, value) - if obj.write_fixed_with_fixed_float_subarray_written.has_value() - last_dim = ndims(value); - obj.write_fixed_with_fixed_float_subarray_written = yardl.Optional(cat(last_dim, obj.write_fixed_with_fixed_float_subarray_written.value, value)); - else - obj.write_fixed_with_fixed_float_subarray_written = yardl.Optional(value); - end + obj.expected_fixed_with_fixed_float_subarray = yardl.Optional(value); end function expect_write_nested_subarray_(obj, value) - if obj.write_nested_subarray_written.has_value() - last_dim = ndims(value); - obj.write_nested_subarray_written = yardl.Optional(cat(last_dim, obj.write_nested_subarray_written.value, value)); - else - obj.write_nested_subarray_written = yardl.Optional(value); - end + obj.expected_nested_subarray = yardl.Optional(value); end function expect_write_dynamic_with_fixed_vector_subarray_(obj, value) - if obj.write_dynamic_with_fixed_vector_subarray_written.has_value() - last_dim = ndims(value); - obj.write_dynamic_with_fixed_vector_subarray_written = yardl.Optional(cat(last_dim, obj.write_dynamic_with_fixed_vector_subarray_written.value, value)); - else - obj.write_dynamic_with_fixed_vector_subarray_written = yardl.Optional(value); - end + obj.expected_dynamic_with_fixed_vector_subarray = yardl.Optional(value); end function expect_write_generic_subarray_(obj, value) - if obj.write_generic_subarray_written.has_value() - last_dim = ndims(value); - obj.write_generic_subarray_written = yardl.Optional(cat(last_dim, obj.write_generic_subarray_written.value, value)); - else - obj.write_generic_subarray_written = yardl.Optional(value); - end + obj.expected_generic_subarray = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_dynamic_with_fixed_int_subarray_written, yardl.None, "Expected call to write_dynamic_with_fixed_int_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.write_dynamic_with_fixed_float_subarray_written, yardl.None, "Expected call to write_dynamic_with_fixed_float_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.write_known_dim_count_with_fixed_int_subarray_written, yardl.None, "Expected call to write_known_dim_count_with_fixed_int_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.write_known_dim_count_with_fixed_float_subarray_written, yardl.None, "Expected call to write_known_dim_count_with_fixed_float_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.write_fixed_with_fixed_int_subarray_written, yardl.None, "Expected call to write_fixed_with_fixed_int_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.write_fixed_with_fixed_float_subarray_written, yardl.None, "Expected call to write_fixed_with_fixed_float_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.write_nested_subarray_written, yardl.None, "Expected call to write_nested_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.write_dynamic_with_fixed_vector_subarray_written, yardl.None, "Expected call to write_dynamic_with_fixed_vector_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.write_generic_subarray_written, yardl.None, "Expected call to write_generic_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.expected_dynamic_with_fixed_int_subarray, yardl.None, "Expected call to write_dynamic_with_fixed_int_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.expected_dynamic_with_fixed_float_subarray, yardl.None, "Expected call to write_dynamic_with_fixed_float_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.expected_known_dim_count_with_fixed_int_subarray, yardl.None, "Expected call to write_known_dim_count_with_fixed_int_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.expected_known_dim_count_with_fixed_float_subarray, yardl.None, "Expected call to write_known_dim_count_with_fixed_float_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.expected_fixed_with_fixed_int_subarray, yardl.None, "Expected call to write_fixed_with_fixed_int_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.expected_fixed_with_fixed_float_subarray, yardl.None, "Expected call to write_fixed_with_fixed_float_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.expected_nested_subarray, yardl.None, "Expected call to write_nested_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.expected_dynamic_with_fixed_vector_subarray, yardl.None, "Expected call to write_dynamic_with_fixed_vector_subarray_ was not received"); + obj.testCase_.verifyEqual(obj.expected_generic_subarray, yardl.None, "Expected call to write_generic_subarray_ was not received"); end end methods (Access=protected) function write_dynamic_with_fixed_int_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.write_dynamic_with_fixed_int_subarray_written.has_value(), "Unexpected call to write_dynamic_with_fixed_int_subarray_"); - expected = obj.write_dynamic_with_fixed_int_subarray_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_dynamic_with_fixed_int_subarray_"); - obj.write_dynamic_with_fixed_int_subarray_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_dynamic_with_fixed_int_subarray.has_value(), "Unexpected call to write_dynamic_with_fixed_int_subarray_"); + obj.testCase_.verifyEqual(value, obj.expected_dynamic_with_fixed_int_subarray.value, "Unexpected argument value for call to write_dynamic_with_fixed_int_subarray_"); + obj.expected_dynamic_with_fixed_int_subarray = yardl.None; end function write_dynamic_with_fixed_float_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.write_dynamic_with_fixed_float_subarray_written.has_value(), "Unexpected call to write_dynamic_with_fixed_float_subarray_"); - expected = obj.write_dynamic_with_fixed_float_subarray_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_dynamic_with_fixed_float_subarray_"); - obj.write_dynamic_with_fixed_float_subarray_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_dynamic_with_fixed_float_subarray.has_value(), "Unexpected call to write_dynamic_with_fixed_float_subarray_"); + obj.testCase_.verifyEqual(value, obj.expected_dynamic_with_fixed_float_subarray.value, "Unexpected argument value for call to write_dynamic_with_fixed_float_subarray_"); + obj.expected_dynamic_with_fixed_float_subarray = yardl.None; end function write_known_dim_count_with_fixed_int_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.write_known_dim_count_with_fixed_int_subarray_written.has_value(), "Unexpected call to write_known_dim_count_with_fixed_int_subarray_"); - expected = obj.write_known_dim_count_with_fixed_int_subarray_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_known_dim_count_with_fixed_int_subarray_"); - obj.write_known_dim_count_with_fixed_int_subarray_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_known_dim_count_with_fixed_int_subarray.has_value(), "Unexpected call to write_known_dim_count_with_fixed_int_subarray_"); + obj.testCase_.verifyEqual(value, obj.expected_known_dim_count_with_fixed_int_subarray.value, "Unexpected argument value for call to write_known_dim_count_with_fixed_int_subarray_"); + obj.expected_known_dim_count_with_fixed_int_subarray = yardl.None; end function write_known_dim_count_with_fixed_float_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.write_known_dim_count_with_fixed_float_subarray_written.has_value(), "Unexpected call to write_known_dim_count_with_fixed_float_subarray_"); - expected = obj.write_known_dim_count_with_fixed_float_subarray_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_known_dim_count_with_fixed_float_subarray_"); - obj.write_known_dim_count_with_fixed_float_subarray_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_known_dim_count_with_fixed_float_subarray.has_value(), "Unexpected call to write_known_dim_count_with_fixed_float_subarray_"); + obj.testCase_.verifyEqual(value, obj.expected_known_dim_count_with_fixed_float_subarray.value, "Unexpected argument value for call to write_known_dim_count_with_fixed_float_subarray_"); + obj.expected_known_dim_count_with_fixed_float_subarray = yardl.None; end function write_fixed_with_fixed_int_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.write_fixed_with_fixed_int_subarray_written.has_value(), "Unexpected call to write_fixed_with_fixed_int_subarray_"); - expected = obj.write_fixed_with_fixed_int_subarray_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_with_fixed_int_subarray_"); - obj.write_fixed_with_fixed_int_subarray_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_fixed_with_fixed_int_subarray.has_value(), "Unexpected call to write_fixed_with_fixed_int_subarray_"); + obj.testCase_.verifyEqual(value, obj.expected_fixed_with_fixed_int_subarray.value, "Unexpected argument value for call to write_fixed_with_fixed_int_subarray_"); + obj.expected_fixed_with_fixed_int_subarray = yardl.None; end function write_fixed_with_fixed_float_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.write_fixed_with_fixed_float_subarray_written.has_value(), "Unexpected call to write_fixed_with_fixed_float_subarray_"); - expected = obj.write_fixed_with_fixed_float_subarray_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_fixed_with_fixed_float_subarray_"); - obj.write_fixed_with_fixed_float_subarray_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_fixed_with_fixed_float_subarray.has_value(), "Unexpected call to write_fixed_with_fixed_float_subarray_"); + obj.testCase_.verifyEqual(value, obj.expected_fixed_with_fixed_float_subarray.value, "Unexpected argument value for call to write_fixed_with_fixed_float_subarray_"); + obj.expected_fixed_with_fixed_float_subarray = yardl.None; end function write_nested_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.write_nested_subarray_written.has_value(), "Unexpected call to write_nested_subarray_"); - expected = obj.write_nested_subarray_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_nested_subarray_"); - obj.write_nested_subarray_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_nested_subarray.has_value(), "Unexpected call to write_nested_subarray_"); + obj.testCase_.verifyEqual(value, obj.expected_nested_subarray.value, "Unexpected argument value for call to write_nested_subarray_"); + obj.expected_nested_subarray = yardl.None; end function write_dynamic_with_fixed_vector_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.write_dynamic_with_fixed_vector_subarray_written.has_value(), "Unexpected call to write_dynamic_with_fixed_vector_subarray_"); - expected = obj.write_dynamic_with_fixed_vector_subarray_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_dynamic_with_fixed_vector_subarray_"); - obj.write_dynamic_with_fixed_vector_subarray_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_dynamic_with_fixed_vector_subarray.has_value(), "Unexpected call to write_dynamic_with_fixed_vector_subarray_"); + obj.testCase_.verifyEqual(value, obj.expected_dynamic_with_fixed_vector_subarray.value, "Unexpected argument value for call to write_dynamic_with_fixed_vector_subarray_"); + obj.expected_dynamic_with_fixed_vector_subarray = yardl.None; end function write_generic_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.write_generic_subarray_written.has_value(), "Unexpected call to write_generic_subarray_"); - expected = obj.write_generic_subarray_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_generic_subarray_"); - obj.write_generic_subarray_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_generic_subarray.has_value(), "Unexpected call to write_generic_subarray_"); + obj.testCase_.verifyEqual(value, obj.expected_generic_subarray.value, "Unexpected argument value for call to write_generic_subarray_"); + obj.expected_generic_subarray = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockUnionsWriter.m b/matlab/generated/+test_model/+testing/MockUnionsWriter.m index e704730b..e1860edc 100644 --- a/matlab/generated/+test_model/+testing/MockUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/MockUnionsWriter.m @@ -3,92 +3,68 @@ classdef MockUnionsWriter < matlab.mixin.Copyable & test_model.UnionsWriterBase properties testCase_ - write_int_or_simple_record_written - write_int_or_record_with_vlens_written - write_monosotate_or_int_or_simple_record_written - write_record_with_unions_written + expected_int_or_simple_record + expected_int_or_record_with_vlens + expected_monosotate_or_int_or_simple_record + expected_record_with_unions end methods function obj = MockUnionsWriter(testCase) obj.testCase_ = testCase; - obj.write_int_or_simple_record_written = yardl.None; - obj.write_int_or_record_with_vlens_written = yardl.None; - obj.write_monosotate_or_int_or_simple_record_written = yardl.None; - obj.write_record_with_unions_written = yardl.None; + obj.expected_int_or_simple_record = yardl.None; + obj.expected_int_or_record_with_vlens = yardl.None; + obj.expected_monosotate_or_int_or_simple_record = yardl.None; + obj.expected_record_with_unions = yardl.None; end function expect_write_int_or_simple_record_(obj, value) - if obj.write_int_or_simple_record_written.has_value() - last_dim = ndims(value); - obj.write_int_or_simple_record_written = yardl.Optional(cat(last_dim, obj.write_int_or_simple_record_written.value, value)); - else - obj.write_int_or_simple_record_written = yardl.Optional(value); - end + obj.expected_int_or_simple_record = yardl.Optional(value); end function expect_write_int_or_record_with_vlens_(obj, value) - if obj.write_int_or_record_with_vlens_written.has_value() - last_dim = ndims(value); - obj.write_int_or_record_with_vlens_written = yardl.Optional(cat(last_dim, obj.write_int_or_record_with_vlens_written.value, value)); - else - obj.write_int_or_record_with_vlens_written = yardl.Optional(value); - end + obj.expected_int_or_record_with_vlens = yardl.Optional(value); end function expect_write_monosotate_or_int_or_simple_record_(obj, value) - if obj.write_monosotate_or_int_or_simple_record_written.has_value() - last_dim = ndims(value); - obj.write_monosotate_or_int_or_simple_record_written = yardl.Optional(cat(last_dim, obj.write_monosotate_or_int_or_simple_record_written.value, value)); - else - obj.write_monosotate_or_int_or_simple_record_written = yardl.Optional(value); - end + obj.expected_monosotate_or_int_or_simple_record = yardl.Optional(value); end function expect_write_record_with_unions_(obj, value) - if obj.write_record_with_unions_written.has_value() - last_dim = ndims(value); - obj.write_record_with_unions_written = yardl.Optional(cat(last_dim, obj.write_record_with_unions_written.value, value)); - else - obj.write_record_with_unions_written = yardl.Optional(value); - end + obj.expected_record_with_unions = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_int_or_simple_record_written, yardl.None, "Expected call to write_int_or_simple_record_ was not received"); - obj.testCase_.verifyEqual(obj.write_int_or_record_with_vlens_written, yardl.None, "Expected call to write_int_or_record_with_vlens_ was not received"); - obj.testCase_.verifyEqual(obj.write_monosotate_or_int_or_simple_record_written, yardl.None, "Expected call to write_monosotate_or_int_or_simple_record_ was not received"); - obj.testCase_.verifyEqual(obj.write_record_with_unions_written, yardl.None, "Expected call to write_record_with_unions_ was not received"); + obj.testCase_.verifyEqual(obj.expected_int_or_simple_record, yardl.None, "Expected call to write_int_or_simple_record_ was not received"); + obj.testCase_.verifyEqual(obj.expected_int_or_record_with_vlens, yardl.None, "Expected call to write_int_or_record_with_vlens_ was not received"); + obj.testCase_.verifyEqual(obj.expected_monosotate_or_int_or_simple_record, yardl.None, "Expected call to write_monosotate_or_int_or_simple_record_ was not received"); + obj.testCase_.verifyEqual(obj.expected_record_with_unions, yardl.None, "Expected call to write_record_with_unions_ was not received"); end end methods (Access=protected) function write_int_or_simple_record_(obj, value) - obj.testCase_.verifyTrue(obj.write_int_or_simple_record_written.has_value(), "Unexpected call to write_int_or_simple_record_"); - expected = obj.write_int_or_simple_record_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_simple_record_"); - obj.write_int_or_simple_record_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_int_or_simple_record.has_value(), "Unexpected call to write_int_or_simple_record_"); + obj.testCase_.verifyEqual(value, obj.expected_int_or_simple_record.value, "Unexpected argument value for call to write_int_or_simple_record_"); + obj.expected_int_or_simple_record = yardl.None; end function write_int_or_record_with_vlens_(obj, value) - obj.testCase_.verifyTrue(obj.write_int_or_record_with_vlens_written.has_value(), "Unexpected call to write_int_or_record_with_vlens_"); - expected = obj.write_int_or_record_with_vlens_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_or_record_with_vlens_"); - obj.write_int_or_record_with_vlens_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_int_or_record_with_vlens.has_value(), "Unexpected call to write_int_or_record_with_vlens_"); + obj.testCase_.verifyEqual(value, obj.expected_int_or_record_with_vlens.value, "Unexpected argument value for call to write_int_or_record_with_vlens_"); + obj.expected_int_or_record_with_vlens = yardl.None; end function write_monosotate_or_int_or_simple_record_(obj, value) - obj.testCase_.verifyTrue(obj.write_monosotate_or_int_or_simple_record_written.has_value(), "Unexpected call to write_monosotate_or_int_or_simple_record_"); - expected = obj.write_monosotate_or_int_or_simple_record_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_monosotate_or_int_or_simple_record_"); - obj.write_monosotate_or_int_or_simple_record_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_monosotate_or_int_or_simple_record.has_value(), "Unexpected call to write_monosotate_or_int_or_simple_record_"); + obj.testCase_.verifyEqual(value, obj.expected_monosotate_or_int_or_simple_record.value, "Unexpected argument value for call to write_monosotate_or_int_or_simple_record_"); + obj.expected_monosotate_or_int_or_simple_record = yardl.None; end function write_record_with_unions_(obj, value) - obj.testCase_.verifyTrue(obj.write_record_with_unions_written.has_value(), "Unexpected call to write_record_with_unions_"); - expected = obj.write_record_with_unions_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_unions_"); - obj.write_record_with_unions_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_record_with_unions.has_value(), "Unexpected call to write_record_with_unions_"); + obj.testCase_.verifyEqual(value, obj.expected_record_with_unions.value, "Unexpected argument value for call to write_record_with_unions_"); + obj.expected_record_with_unions = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/MockVlensWriter.m b/matlab/generated/+test_model/+testing/MockVlensWriter.m index 08e029b1..b8864fc9 100644 --- a/matlab/generated/+test_model/+testing/MockVlensWriter.m +++ b/matlab/generated/+test_model/+testing/MockVlensWriter.m @@ -3,92 +3,68 @@ classdef MockVlensWriter < matlab.mixin.Copyable & test_model.VlensWriterBase properties testCase_ - write_int_vector_written - write_complex_vector_written - write_record_with_vlens_written - write_vlen_of_record_with_vlens_written + expected_int_vector + expected_complex_vector + expected_record_with_vlens + expected_vlen_of_record_with_vlens end methods function obj = MockVlensWriter(testCase) obj.testCase_ = testCase; - obj.write_int_vector_written = yardl.None; - obj.write_complex_vector_written = yardl.None; - obj.write_record_with_vlens_written = yardl.None; - obj.write_vlen_of_record_with_vlens_written = yardl.None; + obj.expected_int_vector = yardl.None; + obj.expected_complex_vector = yardl.None; + obj.expected_record_with_vlens = yardl.None; + obj.expected_vlen_of_record_with_vlens = yardl.None; end function expect_write_int_vector_(obj, value) - if obj.write_int_vector_written.has_value() - last_dim = ndims(value); - obj.write_int_vector_written = yardl.Optional(cat(last_dim, obj.write_int_vector_written.value, value)); - else - obj.write_int_vector_written = yardl.Optional(value); - end + obj.expected_int_vector = yardl.Optional(value); end function expect_write_complex_vector_(obj, value) - if obj.write_complex_vector_written.has_value() - last_dim = ndims(value); - obj.write_complex_vector_written = yardl.Optional(cat(last_dim, obj.write_complex_vector_written.value, value)); - else - obj.write_complex_vector_written = yardl.Optional(value); - end + obj.expected_complex_vector = yardl.Optional(value); end function expect_write_record_with_vlens_(obj, value) - if obj.write_record_with_vlens_written.has_value() - last_dim = ndims(value); - obj.write_record_with_vlens_written = yardl.Optional(cat(last_dim, obj.write_record_with_vlens_written.value, value)); - else - obj.write_record_with_vlens_written = yardl.Optional(value); - end + obj.expected_record_with_vlens = yardl.Optional(value); end function expect_write_vlen_of_record_with_vlens_(obj, value) - if obj.write_vlen_of_record_with_vlens_written.has_value() - last_dim = ndims(value); - obj.write_vlen_of_record_with_vlens_written = yardl.Optional(cat(last_dim, obj.write_vlen_of_record_with_vlens_written.value, value)); - else - obj.write_vlen_of_record_with_vlens_written = yardl.Optional(value); - end + obj.expected_vlen_of_record_with_vlens = yardl.Optional(value); end function verify(obj) - obj.testCase_.verifyEqual(obj.write_int_vector_written, yardl.None, "Expected call to write_int_vector_ was not received"); - obj.testCase_.verifyEqual(obj.write_complex_vector_written, yardl.None, "Expected call to write_complex_vector_ was not received"); - obj.testCase_.verifyEqual(obj.write_record_with_vlens_written, yardl.None, "Expected call to write_record_with_vlens_ was not received"); - obj.testCase_.verifyEqual(obj.write_vlen_of_record_with_vlens_written, yardl.None, "Expected call to write_vlen_of_record_with_vlens_ was not received"); + obj.testCase_.verifyEqual(obj.expected_int_vector, yardl.None, "Expected call to write_int_vector_ was not received"); + obj.testCase_.verifyEqual(obj.expected_complex_vector, yardl.None, "Expected call to write_complex_vector_ was not received"); + obj.testCase_.verifyEqual(obj.expected_record_with_vlens, yardl.None, "Expected call to write_record_with_vlens_ was not received"); + obj.testCase_.verifyEqual(obj.expected_vlen_of_record_with_vlens, yardl.None, "Expected call to write_vlen_of_record_with_vlens_ was not received"); end end methods (Access=protected) function write_int_vector_(obj, value) - obj.testCase_.verifyTrue(obj.write_int_vector_written.has_value(), "Unexpected call to write_int_vector_"); - expected = obj.write_int_vector_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_int_vector_"); - obj.write_int_vector_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_int_vector.has_value(), "Unexpected call to write_int_vector_"); + obj.testCase_.verifyEqual(value, obj.expected_int_vector.value, "Unexpected argument value for call to write_int_vector_"); + obj.expected_int_vector = yardl.None; end function write_complex_vector_(obj, value) - obj.testCase_.verifyTrue(obj.write_complex_vector_written.has_value(), "Unexpected call to write_complex_vector_"); - expected = obj.write_complex_vector_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_complex_vector_"); - obj.write_complex_vector_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_complex_vector.has_value(), "Unexpected call to write_complex_vector_"); + obj.testCase_.verifyEqual(value, obj.expected_complex_vector.value, "Unexpected argument value for call to write_complex_vector_"); + obj.expected_complex_vector = yardl.None; end function write_record_with_vlens_(obj, value) - obj.testCase_.verifyTrue(obj.write_record_with_vlens_written.has_value(), "Unexpected call to write_record_with_vlens_"); - expected = obj.write_record_with_vlens_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_record_with_vlens_"); - obj.write_record_with_vlens_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_record_with_vlens.has_value(), "Unexpected call to write_record_with_vlens_"); + obj.testCase_.verifyEqual(value, obj.expected_record_with_vlens.value, "Unexpected argument value for call to write_record_with_vlens_"); + obj.expected_record_with_vlens = yardl.None; end function write_vlen_of_record_with_vlens_(obj, value) - obj.testCase_.verifyTrue(obj.write_vlen_of_record_with_vlens_written.has_value(), "Unexpected call to write_vlen_of_record_with_vlens_"); - expected = obj.write_vlen_of_record_with_vlens_written.value; - obj.testCase_.verifyEqual(value, expected, "Unexpected argument value for call to write_vlen_of_record_with_vlens_"); - obj.write_vlen_of_record_with_vlens_written = yardl.None; + obj.testCase_.verifyTrue(obj.expected_vlen_of_record_with_vlens.has_value(), "Unexpected call to write_vlen_of_record_with_vlens_"); + obj.testCase_.verifyEqual(value, obj.expected_vlen_of_record_with_vlens.value, "Unexpected argument value for call to write_vlen_of_record_with_vlens_"); + obj.expected_vlen_of_record_with_vlens = yardl.None; end function close_(obj) diff --git a/matlab/generated/+test_model/+testing/TestAliasesWriter.m b/matlab/generated/+test_model/+testing/TestAliasesWriter.m index aa322949..9c2b753d 100644 --- a/matlab/generated/+test_model/+testing/TestAliasesWriter.m +++ b/matlab/generated/+test_model/+testing/TestAliasesWriter.m @@ -27,6 +27,11 @@ function delete(obj) throw(yardl.RuntimeError("Close() must be called on 'TestAliasesWriter' to verify mocks")); end end + function end_stream_of_aliased_generic_union_2(obj) + end_stream_of_aliased_generic_union_2@test_model.AliasesWriterBase(obj); + obj.writer_.end_stream_of_aliased_generic_union_2(); + end + end methods (Access=protected) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m index 7060fe97..f8985076 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m @@ -27,6 +27,11 @@ function delete(obj) throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkFloat256x256Writer' to verify mocks")); end end + function end_float256x256(obj) + end_float256x256@test_model.BenchmarkFloat256x256WriterBase(obj); + obj.writer_.end_float256x256(); + end + end methods (Access=protected) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m index d11b6220..e7042ab3 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m @@ -27,6 +27,11 @@ function delete(obj) throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkFloatVlenWriter' to verify mocks")); end end + function end_float_array(obj) + end_float_array@test_model.BenchmarkFloatVlenWriterBase(obj); + obj.writer_.end_float_array(); + end + end methods (Access=protected) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m index 292dd8ce..adcc80cf 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m @@ -27,6 +27,11 @@ function delete(obj) throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkInt256x256Writer' to verify mocks")); end end + function end_int256x256(obj) + end_int256x256@test_model.BenchmarkInt256x256WriterBase(obj); + obj.writer_.end_int256x256(); + end + end methods (Access=protected) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m index 580738c3..fe31d261 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m @@ -27,6 +27,11 @@ function delete(obj) throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkSimpleMrdWriter' to verify mocks")); end end + function end_data(obj) + end_data@test_model.BenchmarkSimpleMrdWriterBase(obj); + obj.writer_.end_data(); + end + end methods (Access=protected) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m index 2b18a1f3..bcedfb46 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m @@ -27,6 +27,11 @@ function delete(obj) throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkSmallRecordWithOptionalsWriter' to verify mocks")); end end + function end_small_record(obj) + end_small_record@test_model.BenchmarkSmallRecordWithOptionalsWriterBase(obj); + obj.writer_.end_small_record(); + end + end methods (Access=protected) diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m index 13450136..c1e98dfb 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m @@ -27,6 +27,11 @@ function delete(obj) throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkSmallRecordWriter' to verify mocks")); end end + function end_small_record(obj) + end_small_record@test_model.BenchmarkSmallRecordWriterBase(obj); + obj.writer_.end_small_record(); + end + end methods (Access=protected) diff --git a/matlab/generated/+test_model/+testing/TestFlagsWriter.m b/matlab/generated/+test_model/+testing/TestFlagsWriter.m index 3ec3a83e..0e590ec0 100644 --- a/matlab/generated/+test_model/+testing/TestFlagsWriter.m +++ b/matlab/generated/+test_model/+testing/TestFlagsWriter.m @@ -27,6 +27,16 @@ function delete(obj) throw(yardl.RuntimeError("Close() must be called on 'TestFlagsWriter' to verify mocks")); end end + function end_days(obj) + end_days@test_model.FlagsWriterBase(obj); + obj.writer_.end_days(); + end + + function end_formats(obj) + end_formats@test_model.FlagsWriterBase(obj); + obj.writer_.end_formats(); + end + end methods (Access=protected) diff --git a/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m index 21a6a284..48c67fb6 100644 --- a/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m +++ b/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m @@ -27,6 +27,11 @@ function delete(obj) throw(yardl.RuntimeError("Close() must be called on 'TestProtocolWithKeywordStepsWriter' to verify mocks")); end end + function end_int(obj) + end_int@test_model.ProtocolWithKeywordStepsWriterBase(obj); + obj.writer_.end_int(); + end + end methods (Access=protected) diff --git a/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m b/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m index 659f8e78..74d4e62b 100644 --- a/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m @@ -27,6 +27,11 @@ function delete(obj) throw(yardl.RuntimeError("Close() must be called on 'TestSimpleGenericsWriter' to verify mocks")); end end + function end_stream_of_type_variants(obj) + end_stream_of_type_variants@test_model.SimpleGenericsWriterBase(obj); + obj.writer_.end_stream_of_type_variants(); + end + end methods (Access=protected) diff --git a/matlab/generated/+test_model/+testing/TestStateTestWriter.m b/matlab/generated/+test_model/+testing/TestStateTestWriter.m index 48f60c9b..3bda765b 100644 --- a/matlab/generated/+test_model/+testing/TestStateTestWriter.m +++ b/matlab/generated/+test_model/+testing/TestStateTestWriter.m @@ -27,6 +27,11 @@ function delete(obj) throw(yardl.RuntimeError("Close() must be called on 'TestStateTestWriter' to verify mocks")); end end + function end_a_stream(obj) + end_a_stream@test_model.StateTestWriterBase(obj); + obj.writer_.end_a_stream(); + end + end methods (Access=protected) diff --git a/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m index 5fa99131..28ccadc6 100644 --- a/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m @@ -27,6 +27,16 @@ function delete(obj) throw(yardl.RuntimeError("Close() must be called on 'TestStreamsOfAliasedUnionsWriter' to verify mocks")); end end + function end_int_or_simple_record(obj) + end_int_or_simple_record@test_model.StreamsOfAliasedUnionsWriterBase(obj); + obj.writer_.end_int_or_simple_record(); + end + + function end_nullable_int_or_simple_record(obj) + end_nullable_int_or_simple_record@test_model.StreamsOfAliasedUnionsWriterBase(obj); + obj.writer_.end_nullable_int_or_simple_record(); + end + end methods (Access=protected) diff --git a/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m index f41ea9b3..1cf0bbe7 100644 --- a/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m @@ -27,6 +27,16 @@ function delete(obj) throw(yardl.RuntimeError("Close() must be called on 'TestStreamsOfUnionsWriter' to verify mocks")); end end + function end_int_or_simple_record(obj) + end_int_or_simple_record@test_model.StreamsOfUnionsWriterBase(obj); + obj.writer_.end_int_or_simple_record(); + end + + function end_nullable_int_or_simple_record(obj) + end_nullable_int_or_simple_record@test_model.StreamsOfUnionsWriterBase(obj); + obj.writer_.end_nullable_int_or_simple_record(); + end + end methods (Access=protected) diff --git a/matlab/generated/+test_model/+testing/TestStreamsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsWriter.m index 256eb235..dfe5aa9d 100644 --- a/matlab/generated/+test_model/+testing/TestStreamsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStreamsWriter.m @@ -27,6 +27,26 @@ function delete(obj) throw(yardl.RuntimeError("Close() must be called on 'TestStreamsWriter' to verify mocks")); end end + function end_int_data(obj) + end_int_data@test_model.StreamsWriterBase(obj); + obj.writer_.end_int_data(); + end + + function end_optional_int_data(obj) + end_optional_int_data@test_model.StreamsWriterBase(obj); + obj.writer_.end_optional_int_data(); + end + + function end_record_with_optional_vector_data(obj) + end_record_with_optional_vector_data@test_model.StreamsWriterBase(obj); + obj.writer_.end_record_with_optional_vector_data(); + end + + function end_fixed_vector(obj) + end_fixed_vector@test_model.StreamsWriterBase(obj); + obj.writer_.end_fixed_vector(); + end + end methods (Access=protected) diff --git a/matlab/generated/+test_model/AdvancedGenericsReaderBase.m b/matlab/generated/+test_model/AdvancedGenericsReaderBase.m index d6e770b8..124cb299 100644 --- a/matlab/generated/+test_model/AdvancedGenericsReaderBase.m +++ b/matlab/generated/+test_model/AdvancedGenericsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 10 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 5 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,70 +25,55 @@ function close(obj) end value = obj.read_float_image_image_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_generic_record_1(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_generic_record_1_(); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function value = read_tuple_of_optionals(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_tuple_of_optionals_(); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function value = read_tuple_of_optionals_alternate_syntax(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end value = obj.read_tuple_of_optionals_alternate_syntax_(); - obj.state_ = 8; + obj.state_ = 4; end % Ordinal 4 function value = read_tuple_of_vectors(obj) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); end value = obj.read_tuple_of_vectors_(); - obj.state_ = 10; + obj.state_ = 5; end function copy_to(obj, writer) - while obj.has_float_image_image() - item = obj.read_float_image_image(); - writer.write_float_image_image({item}); - end - while obj.has_generic_record_1() - item = obj.read_generic_record_1(); - writer.write_generic_record_1({item}); - end - while obj.has_tuple_of_optionals() - item = obj.read_tuple_of_optionals(); - writer.write_tuple_of_optionals({item}); - end - while obj.has_tuple_of_optionals_alternate_syntax() - item = obj.read_tuple_of_optionals_alternate_syntax(); - writer.write_tuple_of_optionals_alternate_syntax({item}); - end - while obj.has_tuple_of_vectors() - item = obj.read_tuple_of_vectors(); - writer.write_tuple_of_vectors({item}); - end + writer.write_float_image_image(obj.read_float_image_image()); + writer.write_generic_record_1(obj.read_generic_record_1()); + writer.write_tuple_of_optionals(obj.read_tuple_of_optionals()); + writer.write_tuple_of_optionals_alternate_syntax(obj.read_tuple_of_optionals_alternate_syntax()); + writer.write_tuple_of_vectors(obj.read_tuple_of_vectors()); end end @@ -123,13 +103,13 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_float_image_image'; - elseif state == 2 + elseif state == 1 name = 'read_generic_record_1'; - elseif state == 4 + elseif state == 2 name = 'read_tuple_of_optionals'; - elseif state == 6 + elseif state == 3 name = 'read_tuple_of_optionals_alternate_syntax'; - elseif state == 8 + elseif state == 4 name = 'read_tuple_of_vectors'; else name = ''; diff --git a/matlab/generated/+test_model/AdvancedGenericsWriterBase.m b/matlab/generated/+test_model/AdvancedGenericsWriterBase.m index 4aca7a6a..b492e163 100644 --- a/matlab/generated/+test_model/AdvancedGenericsWriterBase.m +++ b/matlab/generated/+test_model/AdvancedGenericsWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 10 + if obj.state_ ~= 5 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,47 +26,47 @@ function write_float_image_image(obj, value) end obj.write_float_image_image_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_generic_record_1(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_generic_record_1_(value); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function write_tuple_of_optionals(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_tuple_of_optionals_(value); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function write_tuple_of_optionals_alternate_syntax(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end obj.write_tuple_of_optionals_alternate_syntax_(value); - obj.state_ = 8; + obj.state_ = 4; end % Ordinal 4 function write_tuple_of_vectors(obj, value) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); end obj.write_tuple_of_vectors_(value); - obj.state_ = 10; + obj.state_ = 5; end end @@ -97,13 +97,13 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_float_image_image'; - elseif state == 2 + elseif state == 1 name = 'write_generic_record_1'; - elseif state == 4 + elseif state == 2 name = 'write_tuple_of_optionals'; - elseif state == 6 + elseif state == 3 name = 'write_tuple_of_optionals_alternate_syntax'; - elseif state == 8 + elseif state == 4 name = 'write_tuple_of_vectors'; else name = ''; diff --git a/matlab/generated/+test_model/AliasesReaderBase.m b/matlab/generated/+test_model/AliasesReaderBase.m index 78f34d6e..1684481d 100644 --- a/matlab/generated/+test_model/AliasesReaderBase.m +++ b/matlab/generated/+test_model/AliasesReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 20 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 10 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,150 +25,124 @@ function close(obj) end value = obj.read_aliased_string_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_aliased_enum(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_aliased_enum_(); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function value = read_aliased_open_generic(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_aliased_open_generic_(); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function value = read_aliased_closed_generic(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end value = obj.read_aliased_closed_generic_(); - obj.state_ = 8; + obj.state_ = 4; end % Ordinal 4 function value = read_aliased_optional(obj) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); end value = obj.read_aliased_optional_(); - obj.state_ = 10; + obj.state_ = 5; end % Ordinal 5 function value = read_aliased_generic_optional(obj) - if obj.state_ ~= 10 - obj.raise_unexpected_state_(10); + if obj.state_ ~= 5 + obj.raise_unexpected_state_(5); end value = obj.read_aliased_generic_optional_(); - obj.state_ = 12; + obj.state_ = 6; end % Ordinal 6 function value = read_aliased_generic_union_2(obj) - if obj.state_ ~= 12 - obj.raise_unexpected_state_(12); + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); end value = obj.read_aliased_generic_union_2_(); - obj.state_ = 14; + obj.state_ = 7; end % Ordinal 7 function value = read_aliased_generic_vector(obj) - if obj.state_ ~= 14 - obj.raise_unexpected_state_(14); + if obj.state_ ~= 7 + obj.raise_unexpected_state_(7); end value = obj.read_aliased_generic_vector_(); - obj.state_ = 16; + obj.state_ = 8; end % Ordinal 8 function value = read_aliased_generic_fixed_vector(obj) - if obj.state_ ~= 16 - obj.raise_unexpected_state_(16); + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); end value = obj.read_aliased_generic_fixed_vector_(); - obj.state_ = 18; + obj.state_ = 9; end % Ordinal 9 function more = has_stream_of_aliased_generic_union_2(obj) - if obj.state_ ~= 18 - obj.raise_unexpected_state_(18); + if obj.state_ ~= 9 + obj.raise_unexpected_state_(9); end more = obj.has_stream_of_aliased_generic_union_2_(); if ~more - obj.state_ = 20; + obj.state_ = 10; end end function value = read_stream_of_aliased_generic_union_2(obj) - if obj.state_ ~= 18 - obj.raise_unexpected_state_(18); + if obj.state_ ~= 9 + obj.raise_unexpected_state_(9); end value = obj.read_stream_of_aliased_generic_union_2_(); end function copy_to(obj, writer) - while obj.has_aliased_string() - item = obj.read_aliased_string(); - writer.write_aliased_string({item}); - end - while obj.has_aliased_enum() - item = obj.read_aliased_enum(); - writer.write_aliased_enum({item}); - end - while obj.has_aliased_open_generic() - item = obj.read_aliased_open_generic(); - writer.write_aliased_open_generic({item}); - end - while obj.has_aliased_closed_generic() - item = obj.read_aliased_closed_generic(); - writer.write_aliased_closed_generic({item}); - end - while obj.has_aliased_optional() - item = obj.read_aliased_optional(); - writer.write_aliased_optional({item}); - end - while obj.has_aliased_generic_optional() - item = obj.read_aliased_generic_optional(); - writer.write_aliased_generic_optional({item}); - end - while obj.has_aliased_generic_union_2() - item = obj.read_aliased_generic_union_2(); - writer.write_aliased_generic_union_2({item}); - end - while obj.has_aliased_generic_vector() - item = obj.read_aliased_generic_vector(); - writer.write_aliased_generic_vector({item}); - end - while obj.has_aliased_generic_fixed_vector() - item = obj.read_aliased_generic_fixed_vector(); - writer.write_aliased_generic_fixed_vector({item}); - end + writer.write_aliased_string(obj.read_aliased_string()); + writer.write_aliased_enum(obj.read_aliased_enum()); + writer.write_aliased_open_generic(obj.read_aliased_open_generic()); + writer.write_aliased_closed_generic(obj.read_aliased_closed_generic()); + writer.write_aliased_optional(obj.read_aliased_optional()); + writer.write_aliased_generic_optional(obj.read_aliased_generic_optional()); + writer.write_aliased_generic_union_2(obj.read_aliased_generic_union_2()); + writer.write_aliased_generic_vector(obj.read_aliased_generic_vector()); + writer.write_aliased_generic_fixed_vector(obj.read_aliased_generic_fixed_vector()); while obj.has_stream_of_aliased_generic_union_2() item = obj.read_stream_of_aliased_generic_union_2(); writer.write_stream_of_aliased_generic_union_2({item}); end + writer.end_stream_of_aliased_generic_union_2(); end end @@ -209,23 +178,23 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_aliased_string'; - elseif state == 2 + elseif state == 1 name = 'read_aliased_enum'; - elseif state == 4 + elseif state == 2 name = 'read_aliased_open_generic'; - elseif state == 6 + elseif state == 3 name = 'read_aliased_closed_generic'; - elseif state == 8 + elseif state == 4 name = 'read_aliased_optional'; - elseif state == 10 + elseif state == 5 name = 'read_aliased_generic_optional'; - elseif state == 12 + elseif state == 6 name = 'read_aliased_generic_union_2'; - elseif state == 14 + elseif state == 7 name = 'read_aliased_generic_vector'; - elseif state == 16 + elseif state == 8 name = 'read_aliased_generic_fixed_vector'; - elseif state == 18 + elseif state == 9 name = 'read_stream_of_aliased_generic_union_2'; else name = ''; diff --git a/matlab/generated/+test_model/AliasesWriterBase.m b/matlab/generated/+test_model/AliasesWriterBase.m index ffb9831e..ca413e8d 100644 --- a/matlab/generated/+test_model/AliasesWriterBase.m +++ b/matlab/generated/+test_model/AliasesWriterBase.m @@ -12,13 +12,8 @@ end function close(obj) - if obj.state_ == 19 - obj.end_stream_(); - obj.close_(); - return - end obj.close_(); - if obj.state_ ~= 20 + if obj.state_ ~= 10 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -31,97 +26,105 @@ function write_aliased_string(obj, value) end obj.write_aliased_string_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_aliased_enum(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_aliased_enum_(value); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function write_aliased_open_generic(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_aliased_open_generic_(value); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function write_aliased_closed_generic(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end obj.write_aliased_closed_generic_(value); - obj.state_ = 8; + obj.state_ = 4; end % Ordinal 4 function write_aliased_optional(obj, value) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); end obj.write_aliased_optional_(value); - obj.state_ = 10; + obj.state_ = 5; end % Ordinal 5 function write_aliased_generic_optional(obj, value) - if obj.state_ ~= 10 - obj.raise_unexpected_state_(10); + if obj.state_ ~= 5 + obj.raise_unexpected_state_(5); end obj.write_aliased_generic_optional_(value); - obj.state_ = 12; + obj.state_ = 6; end % Ordinal 6 function write_aliased_generic_union_2(obj, value) - if obj.state_ ~= 12 - obj.raise_unexpected_state_(12); + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); end obj.write_aliased_generic_union_2_(value); - obj.state_ = 14; + obj.state_ = 7; end % Ordinal 7 function write_aliased_generic_vector(obj, value) - if obj.state_ ~= 14 - obj.raise_unexpected_state_(14); + if obj.state_ ~= 7 + obj.raise_unexpected_state_(7); end obj.write_aliased_generic_vector_(value); - obj.state_ = 16; + obj.state_ = 8; end % Ordinal 8 function write_aliased_generic_fixed_vector(obj, value) - if obj.state_ ~= 16 - obj.raise_unexpected_state_(16); + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); end obj.write_aliased_generic_fixed_vector_(value); - obj.state_ = 18; + obj.state_ = 9; end % Ordinal 9 function write_stream_of_aliased_generic_union_2(obj, value) - if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 18 - obj.raise_unexpected_state_(18); + if obj.state_ ~= 9 + obj.raise_unexpected_state_(9); end obj.write_stream_of_aliased_generic_union_2_(value); - obj.state_ = 19; + end + + function end_stream_of_aliased_generic_union_2(obj) + if obj.state_ ~= 9 + obj.raise_unexpected_state_(9); + end + + obj.end_stream_(); + obj.state_ = 10; end end @@ -157,24 +160,24 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_aliased_string'; - elseif state == 2 + elseif state == 1 name = 'write_aliased_enum'; - elseif state == 4 + elseif state == 2 name = 'write_aliased_open_generic'; - elseif state == 6 + elseif state == 3 name = 'write_aliased_closed_generic'; - elseif state == 8 + elseif state == 4 name = 'write_aliased_optional'; - elseif state == 10 + elseif state == 5 name = 'write_aliased_generic_optional'; - elseif state == 12 + elseif state == 6 name = 'write_aliased_generic_union_2'; - elseif state == 14 + elseif state == 7 name = 'write_aliased_generic_vector'; - elseif state == 16 + elseif state == 8 name = 'write_aliased_generic_fixed_vector'; - elseif state == 18 - name = 'write_stream_of_aliased_generic_union_2'; + elseif state == 9 + name = 'write_stream_of_aliased_generic_union_2 or end_stream_of_aliased_generic_union_2'; else name = ''; end diff --git a/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m b/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m index 6ebda383..5870df86 100644 --- a/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 2 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 1 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -31,7 +26,7 @@ function close(obj) more = obj.has_float256x256_(); if ~more - obj.state_ = 2; + obj.state_ = 1; end end @@ -48,6 +43,7 @@ function copy_to(obj, writer) item = obj.read_float256x256(); writer.write_float256x256({item}); end + writer.end_float256x256(); end end diff --git a/matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m b/matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m index e6c05531..3a430a90 100644 --- a/matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m +++ b/matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m @@ -12,13 +12,8 @@ end function close(obj) - if obj.state_ == 1 - obj.end_stream_(); - obj.close_(); - return - end obj.close_(); - if obj.state_ ~= 2 + if obj.state_ ~= 1 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,11 +21,19 @@ function close(obj) % Ordinal 0 function write_float256x256(obj, value) - if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end obj.write_float256x256_(value); + end + + function end_float256x256(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.end_stream_(); obj.state_ = 1; end end @@ -57,7 +60,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 - name = 'write_float256x256'; + name = 'write_float256x256 or end_float256x256'; else name = ''; end diff --git a/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m b/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m index 0d1e7363..f5d77caa 100644 --- a/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 2 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 1 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -31,7 +26,7 @@ function close(obj) more = obj.has_float_array_(); if ~more - obj.state_ = 2; + obj.state_ = 1; end end @@ -48,6 +43,7 @@ function copy_to(obj, writer) item = obj.read_float_array(); writer.write_float_array({item}); end + writer.end_float_array(); end end diff --git a/matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m b/matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m index 288ed5fe..de021dea 100644 --- a/matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m +++ b/matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m @@ -12,13 +12,8 @@ end function close(obj) - if obj.state_ == 1 - obj.end_stream_(); - obj.close_(); - return - end obj.close_(); - if obj.state_ ~= 2 + if obj.state_ ~= 1 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,11 +21,19 @@ function close(obj) % Ordinal 0 function write_float_array(obj, value) - if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end obj.write_float_array_(value); + end + + function end_float_array(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.end_stream_(); obj.state_ = 1; end end @@ -57,7 +60,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 - name = 'write_float_array'; + name = 'write_float_array or end_float_array'; else name = ''; end diff --git a/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m b/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m index d536eefa..7f707c47 100644 --- a/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 2 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 1 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -31,7 +26,7 @@ function close(obj) more = obj.has_int256x256_(); if ~more - obj.state_ = 2; + obj.state_ = 1; end end @@ -48,6 +43,7 @@ function copy_to(obj, writer) item = obj.read_int256x256(); writer.write_int256x256({item}); end + writer.end_int256x256(); end end diff --git a/matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m b/matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m index 09a0f68d..ea3a988d 100644 --- a/matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m +++ b/matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m @@ -12,13 +12,8 @@ end function close(obj) - if obj.state_ == 1 - obj.end_stream_(); - obj.close_(); - return - end obj.close_(); - if obj.state_ ~= 2 + if obj.state_ ~= 1 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,11 +21,19 @@ function close(obj) % Ordinal 0 function write_int256x256(obj, value) - if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end obj.write_int256x256_(value); + end + + function end_int256x256(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.end_stream_(); obj.state_ = 1; end end @@ -57,7 +60,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 - name = 'write_int256x256'; + name = 'write_int256x256 or end_int256x256'; else name = ''; end diff --git a/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m b/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m index 17e65407..e97413e5 100644 --- a/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 2 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 1 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -31,7 +26,7 @@ function close(obj) more = obj.has_data_(); if ~more - obj.state_ = 2; + obj.state_ = 1; end end @@ -48,6 +43,7 @@ function copy_to(obj, writer) item = obj.read_data(); writer.write_data({item}); end + writer.end_data(); end end diff --git a/matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m b/matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m index b84e788c..63f1a7de 100644 --- a/matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m +++ b/matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m @@ -12,13 +12,8 @@ end function close(obj) - if obj.state_ == 1 - obj.end_stream_(); - obj.close_(); - return - end obj.close_(); - if obj.state_ ~= 2 + if obj.state_ ~= 1 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,11 +21,19 @@ function close(obj) % Ordinal 0 function write_data(obj, value) - if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end obj.write_data_(value); + end + + function end_data(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.end_stream_(); obj.state_ = 1; end end @@ -57,7 +60,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 - name = 'write_data'; + name = 'write_data or end_data'; else name = ''; end diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m index 40573f4b..fc1260d4 100644 --- a/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 2 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 1 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -31,7 +26,7 @@ function close(obj) more = obj.has_small_record_(); if ~more - obj.state_ = 2; + obj.state_ = 1; end end @@ -48,6 +43,7 @@ function copy_to(obj, writer) item = obj.read_small_record(); writer.write_small_record({item}); end + writer.end_small_record(); end end diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m index 4af9afa9..e44d05d8 100644 --- a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 2 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 1 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -31,7 +26,7 @@ function close(obj) more = obj.has_small_record_(); if ~more - obj.state_ = 2; + obj.state_ = 1; end end @@ -48,6 +43,7 @@ function copy_to(obj, writer) item = obj.read_small_record(); writer.write_small_record({item}); end + writer.end_small_record(); end end diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m index 9f076622..a9b8a9f8 100644 --- a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m +++ b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m @@ -12,13 +12,8 @@ end function close(obj) - if obj.state_ == 1 - obj.end_stream_(); - obj.close_(); - return - end obj.close_(); - if obj.state_ ~= 2 + if obj.state_ ~= 1 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,11 +21,19 @@ function close(obj) % Ordinal 0 function write_small_record(obj, value) - if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end obj.write_small_record_(value); + end + + function end_small_record(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.end_stream_(); obj.state_ = 1; end end @@ -57,7 +60,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 - name = 'write_small_record'; + name = 'write_small_record or end_small_record'; else name = ''; end diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m index c9a6cbc5..24844c3e 100644 --- a/matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m +++ b/matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m @@ -12,13 +12,8 @@ end function close(obj) - if obj.state_ == 1 - obj.end_stream_(); - obj.close_(); - return - end obj.close_(); - if obj.state_ ~= 2 + if obj.state_ ~= 1 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,11 +21,19 @@ function close(obj) % Ordinal 0 function write_small_record(obj, value) - if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end obj.write_small_record_(value); + end + + function end_small_record(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.end_stream_(); obj.state_ = 1; end end @@ -57,7 +60,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 - name = 'write_small_record'; + name = 'write_small_record or end_small_record'; else name = ''; end diff --git a/matlab/generated/+test_model/DynamicNDArraysReaderBase.m b/matlab/generated/+test_model/DynamicNDArraysReaderBase.m index 35f7bcd8..496272d5 100644 --- a/matlab/generated/+test_model/DynamicNDArraysReaderBase.m +++ b/matlab/generated/+test_model/DynamicNDArraysReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 8 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 4 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,56 +25,44 @@ function close(obj) end value = obj.read_ints_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_simple_record_array(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_simple_record_array_(); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function value = read_record_with_vlens_array(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_record_with_vlens_array_(); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function value = read_record_with_dynamic_nd_arrays(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end value = obj.read_record_with_dynamic_nd_arrays_(); - obj.state_ = 8; + obj.state_ = 4; end function copy_to(obj, writer) - while obj.has_ints() - item = obj.read_ints(); - writer.write_ints({item}); - end - while obj.has_simple_record_array() - item = obj.read_simple_record_array(); - writer.write_simple_record_array({item}); - end - while obj.has_record_with_vlens_array() - item = obj.read_record_with_vlens_array(); - writer.write_record_with_vlens_array({item}); - end - while obj.has_record_with_dynamic_nd_arrays() - item = obj.read_record_with_dynamic_nd_arrays(); - writer.write_record_with_dynamic_nd_arrays({item}); - end + writer.write_ints(obj.read_ints()); + writer.write_simple_record_array(obj.read_simple_record_array()); + writer.write_record_with_vlens_array(obj.read_record_with_vlens_array()); + writer.write_record_with_dynamic_nd_arrays(obj.read_record_with_dynamic_nd_arrays()); end end @@ -108,11 +91,11 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_ints'; - elseif state == 2 + elseif state == 1 name = 'read_simple_record_array'; - elseif state == 4 + elseif state == 2 name = 'read_record_with_vlens_array'; - elseif state == 6 + elseif state == 3 name = 'read_record_with_dynamic_nd_arrays'; else name = ''; diff --git a/matlab/generated/+test_model/DynamicNDArraysWriterBase.m b/matlab/generated/+test_model/DynamicNDArraysWriterBase.m index a70096da..0962508a 100644 --- a/matlab/generated/+test_model/DynamicNDArraysWriterBase.m +++ b/matlab/generated/+test_model/DynamicNDArraysWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 8 + if obj.state_ ~= 4 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,37 +26,37 @@ function write_ints(obj, value) end obj.write_ints_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_simple_record_array(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_simple_record_array_(value); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function write_record_with_vlens_array(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_record_with_vlens_array_(value); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function write_record_with_dynamic_nd_arrays(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end obj.write_record_with_dynamic_nd_arrays_(value); - obj.state_ = 8; + obj.state_ = 4; end end @@ -86,11 +86,11 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_ints'; - elseif state == 2 + elseif state == 1 name = 'write_simple_record_array'; - elseif state == 4 + elseif state == 2 name = 'write_record_with_vlens_array'; - elseif state == 6 + elseif state == 3 name = 'write_record_with_dynamic_nd_arrays'; else name = ''; diff --git a/matlab/generated/+test_model/EnumsReaderBase.m b/matlab/generated/+test_model/EnumsReaderBase.m index 67464952..b42a931c 100644 --- a/matlab/generated/+test_model/EnumsReaderBase.m +++ b/matlab/generated/+test_model/EnumsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 6 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 3 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,42 +25,33 @@ function close(obj) end value = obj.read_single_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_vec(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_vec_(); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function value = read_size(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_size_(); - obj.state_ = 6; + obj.state_ = 3; end function copy_to(obj, writer) - while obj.has_single() - item = obj.read_single(); - writer.write_single({item}); - end - while obj.has_vec() - item = obj.read_vec(); - writer.write_vec({item}); - end - while obj.has_size() - item = obj.read_size(); - writer.write_size({item}); - end + writer.write_single(obj.read_single()); + writer.write_vec(obj.read_vec()); + writer.write_size(obj.read_size()); end end @@ -93,9 +79,9 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_single'; - elseif state == 2 + elseif state == 1 name = 'read_vec'; - elseif state == 4 + elseif state == 2 name = 'read_size'; else name = ''; diff --git a/matlab/generated/+test_model/EnumsWriterBase.m b/matlab/generated/+test_model/EnumsWriterBase.m index f5e331a5..88b13d86 100644 --- a/matlab/generated/+test_model/EnumsWriterBase.m +++ b/matlab/generated/+test_model/EnumsWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 6 + if obj.state_ ~= 3 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,27 +26,27 @@ function write_single(obj, value) end obj.write_single_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_vec(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_vec_(value); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function write_size(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_size_(value); - obj.state_ = 6; + obj.state_ = 3; end end @@ -75,9 +75,9 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_single'; - elseif state == 2 + elseif state == 1 name = 'write_vec'; - elseif state == 4 + elseif state == 2 name = 'write_size'; else name = ''; diff --git a/matlab/generated/+test_model/FixedArraysReaderBase.m b/matlab/generated/+test_model/FixedArraysReaderBase.m index 8401e78c..c1f53772 100644 --- a/matlab/generated/+test_model/FixedArraysReaderBase.m +++ b/matlab/generated/+test_model/FixedArraysReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 10 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 5 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,70 +25,55 @@ function close(obj) end value = obj.read_ints_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_fixed_simple_record_array(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_fixed_simple_record_array_(); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function value = read_fixed_record_with_vlens_array(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_fixed_record_with_vlens_array_(); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function value = read_record_with_fixed_arrays(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end value = obj.read_record_with_fixed_arrays_(); - obj.state_ = 8; + obj.state_ = 4; end % Ordinal 4 function value = read_named_array(obj) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); end value = obj.read_named_array_(); - obj.state_ = 10; + obj.state_ = 5; end function copy_to(obj, writer) - while obj.has_ints() - item = obj.read_ints(); - writer.write_ints({item}); - end - while obj.has_fixed_simple_record_array() - item = obj.read_fixed_simple_record_array(); - writer.write_fixed_simple_record_array({item}); - end - while obj.has_fixed_record_with_vlens_array() - item = obj.read_fixed_record_with_vlens_array(); - writer.write_fixed_record_with_vlens_array({item}); - end - while obj.has_record_with_fixed_arrays() - item = obj.read_record_with_fixed_arrays(); - writer.write_record_with_fixed_arrays({item}); - end - while obj.has_named_array() - item = obj.read_named_array(); - writer.write_named_array({item}); - end + writer.write_ints(obj.read_ints()); + writer.write_fixed_simple_record_array(obj.read_fixed_simple_record_array()); + writer.write_fixed_record_with_vlens_array(obj.read_fixed_record_with_vlens_array()); + writer.write_record_with_fixed_arrays(obj.read_record_with_fixed_arrays()); + writer.write_named_array(obj.read_named_array()); end end @@ -123,13 +103,13 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_ints'; - elseif state == 2 + elseif state == 1 name = 'read_fixed_simple_record_array'; - elseif state == 4 + elseif state == 2 name = 'read_fixed_record_with_vlens_array'; - elseif state == 6 + elseif state == 3 name = 'read_record_with_fixed_arrays'; - elseif state == 8 + elseif state == 4 name = 'read_named_array'; else name = ''; diff --git a/matlab/generated/+test_model/FixedArraysWriterBase.m b/matlab/generated/+test_model/FixedArraysWriterBase.m index 38dca966..d17e24a6 100644 --- a/matlab/generated/+test_model/FixedArraysWriterBase.m +++ b/matlab/generated/+test_model/FixedArraysWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 10 + if obj.state_ ~= 5 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,47 +26,47 @@ function write_ints(obj, value) end obj.write_ints_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_fixed_simple_record_array(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_fixed_simple_record_array_(value); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function write_fixed_record_with_vlens_array(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_fixed_record_with_vlens_array_(value); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function write_record_with_fixed_arrays(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end obj.write_record_with_fixed_arrays_(value); - obj.state_ = 8; + obj.state_ = 4; end % Ordinal 4 function write_named_array(obj, value) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); end obj.write_named_array_(value); - obj.state_ = 10; + obj.state_ = 5; end end @@ -97,13 +97,13 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_ints'; - elseif state == 2 + elseif state == 1 name = 'write_fixed_simple_record_array'; - elseif state == 4 + elseif state == 2 name = 'write_fixed_record_with_vlens_array'; - elseif state == 6 + elseif state == 3 name = 'write_record_with_fixed_arrays'; - elseif state == 8 + elseif state == 4 name = 'write_named_array'; else name = ''; diff --git a/matlab/generated/+test_model/FixedVectorsReaderBase.m b/matlab/generated/+test_model/FixedVectorsReaderBase.m index 10d7d731..f70fe945 100644 --- a/matlab/generated/+test_model/FixedVectorsReaderBase.m +++ b/matlab/generated/+test_model/FixedVectorsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 8 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 4 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,56 +25,44 @@ function close(obj) end value = obj.read_fixed_int_vector_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_fixed_simple_record_vector(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_fixed_simple_record_vector_(); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function value = read_fixed_record_with_vlens_vector(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_fixed_record_with_vlens_vector_(); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function value = read_record_with_fixed_vectors(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end value = obj.read_record_with_fixed_vectors_(); - obj.state_ = 8; + obj.state_ = 4; end function copy_to(obj, writer) - while obj.has_fixed_int_vector() - item = obj.read_fixed_int_vector(); - writer.write_fixed_int_vector({item}); - end - while obj.has_fixed_simple_record_vector() - item = obj.read_fixed_simple_record_vector(); - writer.write_fixed_simple_record_vector({item}); - end - while obj.has_fixed_record_with_vlens_vector() - item = obj.read_fixed_record_with_vlens_vector(); - writer.write_fixed_record_with_vlens_vector({item}); - end - while obj.has_record_with_fixed_vectors() - item = obj.read_record_with_fixed_vectors(); - writer.write_record_with_fixed_vectors({item}); - end + writer.write_fixed_int_vector(obj.read_fixed_int_vector()); + writer.write_fixed_simple_record_vector(obj.read_fixed_simple_record_vector()); + writer.write_fixed_record_with_vlens_vector(obj.read_fixed_record_with_vlens_vector()); + writer.write_record_with_fixed_vectors(obj.read_record_with_fixed_vectors()); end end @@ -108,11 +91,11 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_fixed_int_vector'; - elseif state == 2 + elseif state == 1 name = 'read_fixed_simple_record_vector'; - elseif state == 4 + elseif state == 2 name = 'read_fixed_record_with_vlens_vector'; - elseif state == 6 + elseif state == 3 name = 'read_record_with_fixed_vectors'; else name = ''; diff --git a/matlab/generated/+test_model/FixedVectorsWriterBase.m b/matlab/generated/+test_model/FixedVectorsWriterBase.m index 4a4ef2f2..a6cfb043 100644 --- a/matlab/generated/+test_model/FixedVectorsWriterBase.m +++ b/matlab/generated/+test_model/FixedVectorsWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 8 + if obj.state_ ~= 4 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,37 +26,37 @@ function write_fixed_int_vector(obj, value) end obj.write_fixed_int_vector_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_fixed_simple_record_vector(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_fixed_simple_record_vector_(value); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function write_fixed_record_with_vlens_vector(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_fixed_record_with_vlens_vector_(value); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function write_record_with_fixed_vectors(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end obj.write_record_with_fixed_vectors_(value); - obj.state_ = 8; + obj.state_ = 4; end end @@ -86,11 +86,11 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_fixed_int_vector'; - elseif state == 2 + elseif state == 1 name = 'write_fixed_simple_record_vector'; - elseif state == 4 + elseif state == 2 name = 'write_fixed_record_with_vlens_vector'; - elseif state == 6 + elseif state == 3 name = 'write_record_with_fixed_vectors'; else name = ''; diff --git a/matlab/generated/+test_model/FlagsReaderBase.m b/matlab/generated/+test_model/FlagsReaderBase.m index 4d53ef02..89114613 100644 --- a/matlab/generated/+test_model/FlagsReaderBase.m +++ b/matlab/generated/+test_model/FlagsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 4 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -31,7 +26,7 @@ function close(obj) more = obj.has_days_(); if ~more - obj.state_ = 2; + obj.state_ = 1; end end @@ -45,19 +40,19 @@ function close(obj) % Ordinal 1 function more = has_formats(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end more = obj.has_formats_(); if ~more - obj.state_ = 4; + obj.state_ = 2; end end function value = read_formats(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_formats_(); @@ -68,10 +63,12 @@ function copy_to(obj, writer) item = obj.read_days(); writer.write_days({item}); end + writer.end_days(); while obj.has_formats() item = obj.read_formats(); writer.write_formats({item}); end + writer.end_formats(); end end @@ -100,7 +97,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_days'; - elseif state == 2 + elseif state == 1 name = 'read_formats'; else name = ''; diff --git a/matlab/generated/+test_model/FlagsWriterBase.m b/matlab/generated/+test_model/FlagsWriterBase.m index d3139421..b0d970cd 100644 --- a/matlab/generated/+test_model/FlagsWriterBase.m +++ b/matlab/generated/+test_model/FlagsWriterBase.m @@ -12,13 +12,8 @@ end function close(obj) - if obj.state_ == 3 - obj.end_stream_(); - obj.close_(); - return - end obj.close_(); - if obj.state_ ~= 4 + if obj.state_ ~= 2 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,25 +21,38 @@ function close(obj) % Ordinal 0 function write_days(obj, value) - if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end obj.write_days_(value); + end + + function end_days(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.end_stream_(); obj.state_ = 1; end % Ordinal 1 function write_formats(obj, value) - if obj.state_ == 1 - obj.end_stream_(); - obj.state_ = 2; - elseif bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_formats_(value); - obj.state_ = 3; + end + + function end_formats(obj) + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); + end + + obj.end_stream_(); + obj.state_ = 2; end end @@ -71,9 +79,9 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 - name = 'write_days'; - elseif state == 2 - name = 'write_formats'; + name = 'write_days or end_days'; + elseif state == 1 + name = 'write_formats or end_formats'; else name = ''; end diff --git a/matlab/generated/+test_model/MapsReaderBase.m b/matlab/generated/+test_model/MapsReaderBase.m index 27da4559..fe221b9e 100644 --- a/matlab/generated/+test_model/MapsReaderBase.m +++ b/matlab/generated/+test_model/MapsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 8 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 4 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,56 +25,44 @@ function close(obj) end value = obj.read_string_to_int_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_int_to_string(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_int_to_string_(); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function value = read_string_to_union(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_string_to_union_(); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function value = read_aliased_generic(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end value = obj.read_aliased_generic_(); - obj.state_ = 8; + obj.state_ = 4; end function copy_to(obj, writer) - while obj.has_string_to_int() - item = obj.read_string_to_int(); - writer.write_string_to_int({item}); - end - while obj.has_int_to_string() - item = obj.read_int_to_string(); - writer.write_int_to_string({item}); - end - while obj.has_string_to_union() - item = obj.read_string_to_union(); - writer.write_string_to_union({item}); - end - while obj.has_aliased_generic() - item = obj.read_aliased_generic(); - writer.write_aliased_generic({item}); - end + writer.write_string_to_int(obj.read_string_to_int()); + writer.write_int_to_string(obj.read_int_to_string()); + writer.write_string_to_union(obj.read_string_to_union()); + writer.write_aliased_generic(obj.read_aliased_generic()); end end @@ -108,11 +91,11 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_string_to_int'; - elseif state == 2 + elseif state == 1 name = 'read_int_to_string'; - elseif state == 4 + elseif state == 2 name = 'read_string_to_union'; - elseif state == 6 + elseif state == 3 name = 'read_aliased_generic'; else name = ''; diff --git a/matlab/generated/+test_model/MapsWriterBase.m b/matlab/generated/+test_model/MapsWriterBase.m index ec72c8d6..e1ba4b7f 100644 --- a/matlab/generated/+test_model/MapsWriterBase.m +++ b/matlab/generated/+test_model/MapsWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 8 + if obj.state_ ~= 4 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,37 +26,37 @@ function write_string_to_int(obj, value) end obj.write_string_to_int_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_int_to_string(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_int_to_string_(value); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function write_string_to_union(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_string_to_union_(value); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function write_aliased_generic(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end obj.write_aliased_generic_(value); - obj.state_ = 8; + obj.state_ = 4; end end @@ -86,11 +86,11 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_string_to_int'; - elseif state == 2 + elseif state == 1 name = 'write_int_to_string'; - elseif state == 4 + elseif state == 2 name = 'write_string_to_union'; - elseif state == 6 + elseif state == 3 name = 'write_aliased_generic'; else name = ''; diff --git a/matlab/generated/+test_model/NDArraysReaderBase.m b/matlab/generated/+test_model/NDArraysReaderBase.m index 11952889..cce25c5d 100644 --- a/matlab/generated/+test_model/NDArraysReaderBase.m +++ b/matlab/generated/+test_model/NDArraysReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 10 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 5 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,70 +25,55 @@ function close(obj) end value = obj.read_ints_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_simple_record_array(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_simple_record_array_(); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function value = read_record_with_vlens_array(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_record_with_vlens_array_(); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function value = read_record_with_nd_arrays(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end value = obj.read_record_with_nd_arrays_(); - obj.state_ = 8; + obj.state_ = 4; end % Ordinal 4 function value = read_named_array(obj) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); end value = obj.read_named_array_(); - obj.state_ = 10; + obj.state_ = 5; end function copy_to(obj, writer) - while obj.has_ints() - item = obj.read_ints(); - writer.write_ints({item}); - end - while obj.has_simple_record_array() - item = obj.read_simple_record_array(); - writer.write_simple_record_array({item}); - end - while obj.has_record_with_vlens_array() - item = obj.read_record_with_vlens_array(); - writer.write_record_with_vlens_array({item}); - end - while obj.has_record_with_nd_arrays() - item = obj.read_record_with_nd_arrays(); - writer.write_record_with_nd_arrays({item}); - end - while obj.has_named_array() - item = obj.read_named_array(); - writer.write_named_array({item}); - end + writer.write_ints(obj.read_ints()); + writer.write_simple_record_array(obj.read_simple_record_array()); + writer.write_record_with_vlens_array(obj.read_record_with_vlens_array()); + writer.write_record_with_nd_arrays(obj.read_record_with_nd_arrays()); + writer.write_named_array(obj.read_named_array()); end end @@ -123,13 +103,13 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_ints'; - elseif state == 2 + elseif state == 1 name = 'read_simple_record_array'; - elseif state == 4 + elseif state == 2 name = 'read_record_with_vlens_array'; - elseif state == 6 + elseif state == 3 name = 'read_record_with_nd_arrays'; - elseif state == 8 + elseif state == 4 name = 'read_named_array'; else name = ''; diff --git a/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m b/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m index 97d4b218..038416f0 100644 --- a/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m +++ b/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 8 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 4 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,56 +25,44 @@ function close(obj) end value = obj.read_ints_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_simple_record_array(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_simple_record_array_(); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function value = read_record_with_vlens_array(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_record_with_vlens_array_(); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function value = read_record_with_nd_arrays(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end value = obj.read_record_with_nd_arrays_(); - obj.state_ = 8; + obj.state_ = 4; end function copy_to(obj, writer) - while obj.has_ints() - item = obj.read_ints(); - writer.write_ints({item}); - end - while obj.has_simple_record_array() - item = obj.read_simple_record_array(); - writer.write_simple_record_array({item}); - end - while obj.has_record_with_vlens_array() - item = obj.read_record_with_vlens_array(); - writer.write_record_with_vlens_array({item}); - end - while obj.has_record_with_nd_arrays() - item = obj.read_record_with_nd_arrays(); - writer.write_record_with_nd_arrays({item}); - end + writer.write_ints(obj.read_ints()); + writer.write_simple_record_array(obj.read_simple_record_array()); + writer.write_record_with_vlens_array(obj.read_record_with_vlens_array()); + writer.write_record_with_nd_arrays(obj.read_record_with_nd_arrays()); end end @@ -108,11 +91,11 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_ints'; - elseif state == 2 + elseif state == 1 name = 'read_simple_record_array'; - elseif state == 4 + elseif state == 2 name = 'read_record_with_vlens_array'; - elseif state == 6 + elseif state == 3 name = 'read_record_with_nd_arrays'; else name = ''; diff --git a/matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m b/matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m index 878c6efa..0a60a963 100644 --- a/matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m +++ b/matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 8 + if obj.state_ ~= 4 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,37 +26,37 @@ function write_ints(obj, value) end obj.write_ints_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_simple_record_array(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_simple_record_array_(value); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function write_record_with_vlens_array(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_record_with_vlens_array_(value); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function write_record_with_nd_arrays(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end obj.write_record_with_nd_arrays_(value); - obj.state_ = 8; + obj.state_ = 4; end end @@ -86,11 +86,11 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_ints'; - elseif state == 2 + elseif state == 1 name = 'write_simple_record_array'; - elseif state == 4 + elseif state == 2 name = 'write_record_with_vlens_array'; - elseif state == 6 + elseif state == 3 name = 'write_record_with_nd_arrays'; else name = ''; diff --git a/matlab/generated/+test_model/NDArraysWriterBase.m b/matlab/generated/+test_model/NDArraysWriterBase.m index 54248412..7b03daa2 100644 --- a/matlab/generated/+test_model/NDArraysWriterBase.m +++ b/matlab/generated/+test_model/NDArraysWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 10 + if obj.state_ ~= 5 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,47 +26,47 @@ function write_ints(obj, value) end obj.write_ints_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_simple_record_array(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_simple_record_array_(value); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function write_record_with_vlens_array(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_record_with_vlens_array_(value); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function write_record_with_nd_arrays(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end obj.write_record_with_nd_arrays_(value); - obj.state_ = 8; + obj.state_ = 4; end % Ordinal 4 function write_named_array(obj, value) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); end obj.write_named_array_(value); - obj.state_ = 10; + obj.state_ = 5; end end @@ -97,13 +97,13 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_ints'; - elseif state == 2 + elseif state == 1 name = 'write_simple_record_array'; - elseif state == 4 + elseif state == 2 name = 'write_record_with_vlens_array'; - elseif state == 6 + elseif state == 3 name = 'write_record_with_nd_arrays'; - elseif state == 8 + elseif state == 4 name = 'write_named_array'; else name = ''; diff --git a/matlab/generated/+test_model/NestedRecordsReaderBase.m b/matlab/generated/+test_model/NestedRecordsReaderBase.m index 3ed687cb..1923a281 100644 --- a/matlab/generated/+test_model/NestedRecordsReaderBase.m +++ b/matlab/generated/+test_model/NestedRecordsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 2 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 1 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,14 +25,11 @@ function close(obj) end value = obj.read_tuple_with_records_(); - obj.state_ = 2; + obj.state_ = 1; end function copy_to(obj, writer) - while obj.has_tuple_with_records() - item = obj.read_tuple_with_records(); - writer.write_tuple_with_records({item}); - end + writer.write_tuple_with_records(obj.read_tuple_with_records()); end end diff --git a/matlab/generated/+test_model/NestedRecordsWriterBase.m b/matlab/generated/+test_model/NestedRecordsWriterBase.m index 3deb5535..1957b9e5 100644 --- a/matlab/generated/+test_model/NestedRecordsWriterBase.m +++ b/matlab/generated/+test_model/NestedRecordsWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 2 + if obj.state_ ~= 1 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,7 +26,7 @@ function write_tuple_with_records(obj, value) end obj.write_tuple_with_records_(value); - obj.state_ = 2; + obj.state_ = 1; end end diff --git a/matlab/generated/+test_model/OptionalVectorsReaderBase.m b/matlab/generated/+test_model/OptionalVectorsReaderBase.m index 7e502ca5..bfdb8b87 100644 --- a/matlab/generated/+test_model/OptionalVectorsReaderBase.m +++ b/matlab/generated/+test_model/OptionalVectorsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 2 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 1 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,14 +25,11 @@ function close(obj) end value = obj.read_record_with_optional_vector_(); - obj.state_ = 2; + obj.state_ = 1; end function copy_to(obj, writer) - while obj.has_record_with_optional_vector() - item = obj.read_record_with_optional_vector(); - writer.write_record_with_optional_vector({item}); - end + writer.write_record_with_optional_vector(obj.read_record_with_optional_vector()); end end diff --git a/matlab/generated/+test_model/OptionalVectorsWriterBase.m b/matlab/generated/+test_model/OptionalVectorsWriterBase.m index 64bc1f6d..51bde231 100644 --- a/matlab/generated/+test_model/OptionalVectorsWriterBase.m +++ b/matlab/generated/+test_model/OptionalVectorsWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 2 + if obj.state_ ~= 1 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,7 +26,7 @@ function write_record_with_optional_vector(obj, value) end obj.write_record_with_optional_vector_(value); - obj.state_ = 2; + obj.state_ = 1; end end diff --git a/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m b/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m index 020d3e7e..7cfa5f28 100644 --- a/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m +++ b/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 2 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 1 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,14 +25,11 @@ function close(obj) end value = obj.read_record_with_computed_fields_(); - obj.state_ = 2; + obj.state_ = 1; end function copy_to(obj, writer) - while obj.has_record_with_computed_fields() - item = obj.read_record_with_computed_fields(); - writer.write_record_with_computed_fields({item}); - end + writer.write_record_with_computed_fields(obj.read_record_with_computed_fields()); end end diff --git a/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m b/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m index 1e98e674..6975e1b9 100644 --- a/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m +++ b/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 2 + if obj.state_ ~= 1 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,7 +26,7 @@ function write_record_with_computed_fields(obj, value) end obj.write_record_with_computed_fields_(value); - obj.state_ = 2; + obj.state_ = 1; end end diff --git a/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m b/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m index 8d3af52f..64c18c81 100644 --- a/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m +++ b/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 4 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -31,7 +26,7 @@ function close(obj) more = obj.has_int_(); if ~more - obj.state_ = 2; + obj.state_ = 1; end end @@ -45,12 +40,12 @@ function close(obj) % Ordinal 1 function value = read_float(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_float_(); - obj.state_ = 4; + obj.state_ = 2; end function copy_to(obj, writer) @@ -58,10 +53,8 @@ function copy_to(obj, writer) item = obj.read_int(); writer.write_int({item}); end - while obj.has_float() - item = obj.read_float(); - writer.write_float({item}); - end + writer.end_int(); + writer.write_float(obj.read_float()); end end @@ -89,7 +82,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_int'; - elseif state == 2 + elseif state == 1 name = 'read_float'; else name = ''; diff --git a/matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m b/matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m index df87b91f..d9f68586 100644 --- a/matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m +++ b/matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 4 + if obj.state_ ~= 2 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -21,25 +21,30 @@ function close(obj) % Ordinal 0 function write_int(obj, value) - if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end obj.write_int_(value); + end + + function end_int(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.end_stream_(); obj.state_ = 1; end % Ordinal 1 function write_float(obj, value) - if obj.state_ == 1 - obj.end_stream_(); - obj.state_ = 2; - elseif obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_float_(value); - obj.state_ = 4; + obj.state_ = 2; end end @@ -66,8 +71,8 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 - name = 'write_int'; - elseif state == 2 + name = 'write_int or end_int'; + elseif state == 1 name = 'write_float'; else name = ''; diff --git a/matlab/generated/+test_model/ScalarOptionalsReaderBase.m b/matlab/generated/+test_model/ScalarOptionalsReaderBase.m index 10eecb58..025be340 100644 --- a/matlab/generated/+test_model/ScalarOptionalsReaderBase.m +++ b/matlab/generated/+test_model/ScalarOptionalsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 8 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 4 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,56 +25,44 @@ function close(obj) end value = obj.read_optional_int_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_optional_record(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_optional_record_(); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function value = read_record_with_optional_fields(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_record_with_optional_fields_(); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function value = read_optional_record_with_optional_fields(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end value = obj.read_optional_record_with_optional_fields_(); - obj.state_ = 8; + obj.state_ = 4; end function copy_to(obj, writer) - while obj.has_optional_int() - item = obj.read_optional_int(); - writer.write_optional_int({item}); - end - while obj.has_optional_record() - item = obj.read_optional_record(); - writer.write_optional_record({item}); - end - while obj.has_record_with_optional_fields() - item = obj.read_record_with_optional_fields(); - writer.write_record_with_optional_fields({item}); - end - while obj.has_optional_record_with_optional_fields() - item = obj.read_optional_record_with_optional_fields(); - writer.write_optional_record_with_optional_fields({item}); - end + writer.write_optional_int(obj.read_optional_int()); + writer.write_optional_record(obj.read_optional_record()); + writer.write_record_with_optional_fields(obj.read_record_with_optional_fields()); + writer.write_optional_record_with_optional_fields(obj.read_optional_record_with_optional_fields()); end end @@ -108,11 +91,11 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_optional_int'; - elseif state == 2 + elseif state == 1 name = 'read_optional_record'; - elseif state == 4 + elseif state == 2 name = 'read_record_with_optional_fields'; - elseif state == 6 + elseif state == 3 name = 'read_optional_record_with_optional_fields'; else name = ''; diff --git a/matlab/generated/+test_model/ScalarOptionalsWriterBase.m b/matlab/generated/+test_model/ScalarOptionalsWriterBase.m index d4c7b4ef..31f97826 100644 --- a/matlab/generated/+test_model/ScalarOptionalsWriterBase.m +++ b/matlab/generated/+test_model/ScalarOptionalsWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 8 + if obj.state_ ~= 4 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,37 +26,37 @@ function write_optional_int(obj, value) end obj.write_optional_int_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_optional_record(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_optional_record_(value); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function write_record_with_optional_fields(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_record_with_optional_fields_(value); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function write_optional_record_with_optional_fields(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end obj.write_optional_record_with_optional_fields_(value); - obj.state_ = 8; + obj.state_ = 4; end end @@ -86,11 +86,11 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_optional_int'; - elseif state == 2 + elseif state == 1 name = 'write_optional_record'; - elseif state == 4 + elseif state == 2 name = 'write_record_with_optional_fields'; - elseif state == 6 + elseif state == 3 name = 'write_optional_record_with_optional_fields'; else name = ''; diff --git a/matlab/generated/+test_model/ScalarsReaderBase.m b/matlab/generated/+test_model/ScalarsReaderBase.m index 5dafbee9..fb963c40 100644 --- a/matlab/generated/+test_model/ScalarsReaderBase.m +++ b/matlab/generated/+test_model/ScalarsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 4 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,28 +25,22 @@ function close(obj) end value = obj.read_int32_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_record(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_record_(); - obj.state_ = 4; + obj.state_ = 2; end function copy_to(obj, writer) - while obj.has_int32() - item = obj.read_int32(); - writer.write_int32({item}); - end - while obj.has_record() - item = obj.read_record(); - writer.write_record({item}); - end + writer.write_int32(obj.read_int32()); + writer.write_record(obj.read_record()); end end @@ -78,7 +67,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_int32'; - elseif state == 2 + elseif state == 1 name = 'read_record'; else name = ''; diff --git a/matlab/generated/+test_model/ScalarsWriterBase.m b/matlab/generated/+test_model/ScalarsWriterBase.m index 01145216..82682635 100644 --- a/matlab/generated/+test_model/ScalarsWriterBase.m +++ b/matlab/generated/+test_model/ScalarsWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 4 + if obj.state_ ~= 2 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,17 +26,17 @@ function write_int32(obj, value) end obj.write_int32_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_record(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_record_(value); - obj.state_ = 4; + obj.state_ = 2; end end @@ -64,7 +64,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_int32'; - elseif state == 2 + elseif state == 1 name = 'write_record'; else name = ''; diff --git a/matlab/generated/+test_model/SimpleGenericsReaderBase.m b/matlab/generated/+test_model/SimpleGenericsReaderBase.m index 7ca4bbed..1f8741fa 100644 --- a/matlab/generated/+test_model/SimpleGenericsReaderBase.m +++ b/matlab/generated/+test_model/SimpleGenericsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 18 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 9 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,136 +25,113 @@ function close(obj) end value = obj.read_float_image_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_int_image(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_int_image_(); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function value = read_int_image_alternate_syntax(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_int_image_alternate_syntax_(); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function value = read_string_image(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end value = obj.read_string_image_(); - obj.state_ = 8; + obj.state_ = 4; end % Ordinal 4 function value = read_int_float_tuple(obj) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); end value = obj.read_int_float_tuple_(); - obj.state_ = 10; + obj.state_ = 5; end % Ordinal 5 function value = read_float_float_tuple(obj) - if obj.state_ ~= 10 - obj.raise_unexpected_state_(10); + if obj.state_ ~= 5 + obj.raise_unexpected_state_(5); end value = obj.read_float_float_tuple_(); - obj.state_ = 12; + obj.state_ = 6; end % Ordinal 6 function value = read_int_float_tuple_alternate_syntax(obj) - if obj.state_ ~= 12 - obj.raise_unexpected_state_(12); + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); end value = obj.read_int_float_tuple_alternate_syntax_(); - obj.state_ = 14; + obj.state_ = 7; end % Ordinal 7 function value = read_int_string_tuple(obj) - if obj.state_ ~= 14 - obj.raise_unexpected_state_(14); + if obj.state_ ~= 7 + obj.raise_unexpected_state_(7); end value = obj.read_int_string_tuple_(); - obj.state_ = 16; + obj.state_ = 8; end % Ordinal 8 function more = has_stream_of_type_variants(obj) - if obj.state_ ~= 16 - obj.raise_unexpected_state_(16); + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); end more = obj.has_stream_of_type_variants_(); if ~more - obj.state_ = 18; + obj.state_ = 9; end end function value = read_stream_of_type_variants(obj) - if obj.state_ ~= 16 - obj.raise_unexpected_state_(16); + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); end value = obj.read_stream_of_type_variants_(); end function copy_to(obj, writer) - while obj.has_float_image() - item = obj.read_float_image(); - writer.write_float_image({item}); - end - while obj.has_int_image() - item = obj.read_int_image(); - writer.write_int_image({item}); - end - while obj.has_int_image_alternate_syntax() - item = obj.read_int_image_alternate_syntax(); - writer.write_int_image_alternate_syntax({item}); - end - while obj.has_string_image() - item = obj.read_string_image(); - writer.write_string_image({item}); - end - while obj.has_int_float_tuple() - item = obj.read_int_float_tuple(); - writer.write_int_float_tuple({item}); - end - while obj.has_float_float_tuple() - item = obj.read_float_float_tuple(); - writer.write_float_float_tuple({item}); - end - while obj.has_int_float_tuple_alternate_syntax() - item = obj.read_int_float_tuple_alternate_syntax(); - writer.write_int_float_tuple_alternate_syntax({item}); - end - while obj.has_int_string_tuple() - item = obj.read_int_string_tuple(); - writer.write_int_string_tuple({item}); - end + writer.write_float_image(obj.read_float_image()); + writer.write_int_image(obj.read_int_image()); + writer.write_int_image_alternate_syntax(obj.read_int_image_alternate_syntax()); + writer.write_string_image(obj.read_string_image()); + writer.write_int_float_tuple(obj.read_int_float_tuple()); + writer.write_float_float_tuple(obj.read_float_float_tuple()); + writer.write_int_float_tuple_alternate_syntax(obj.read_int_float_tuple_alternate_syntax()); + writer.write_int_string_tuple(obj.read_int_string_tuple()); while obj.has_stream_of_type_variants() item = obj.read_stream_of_type_variants(); writer.write_stream_of_type_variants({item}); end + writer.end_stream_of_type_variants(); end end @@ -194,21 +166,21 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_float_image'; - elseif state == 2 + elseif state == 1 name = 'read_int_image'; - elseif state == 4 + elseif state == 2 name = 'read_int_image_alternate_syntax'; - elseif state == 6 + elseif state == 3 name = 'read_string_image'; - elseif state == 8 + elseif state == 4 name = 'read_int_float_tuple'; - elseif state == 10 + elseif state == 5 name = 'read_float_float_tuple'; - elseif state == 12 + elseif state == 6 name = 'read_int_float_tuple_alternate_syntax'; - elseif state == 14 + elseif state == 7 name = 'read_int_string_tuple'; - elseif state == 16 + elseif state == 8 name = 'read_stream_of_type_variants'; else name = ''; diff --git a/matlab/generated/+test_model/SimpleGenericsWriterBase.m b/matlab/generated/+test_model/SimpleGenericsWriterBase.m index aa7a8610..f79af39f 100644 --- a/matlab/generated/+test_model/SimpleGenericsWriterBase.m +++ b/matlab/generated/+test_model/SimpleGenericsWriterBase.m @@ -12,13 +12,8 @@ end function close(obj) - if obj.state_ == 17 - obj.end_stream_(); - obj.close_(); - return - end obj.close_(); - if obj.state_ ~= 18 + if obj.state_ ~= 9 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -31,87 +26,95 @@ function write_float_image(obj, value) end obj.write_float_image_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_int_image(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_int_image_(value); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function write_int_image_alternate_syntax(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_int_image_alternate_syntax_(value); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function write_string_image(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end obj.write_string_image_(value); - obj.state_ = 8; + obj.state_ = 4; end % Ordinal 4 function write_int_float_tuple(obj, value) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); end obj.write_int_float_tuple_(value); - obj.state_ = 10; + obj.state_ = 5; end % Ordinal 5 function write_float_float_tuple(obj, value) - if obj.state_ ~= 10 - obj.raise_unexpected_state_(10); + if obj.state_ ~= 5 + obj.raise_unexpected_state_(5); end obj.write_float_float_tuple_(value); - obj.state_ = 12; + obj.state_ = 6; end % Ordinal 6 function write_int_float_tuple_alternate_syntax(obj, value) - if obj.state_ ~= 12 - obj.raise_unexpected_state_(12); + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); end obj.write_int_float_tuple_alternate_syntax_(value); - obj.state_ = 14; + obj.state_ = 7; end % Ordinal 7 function write_int_string_tuple(obj, value) - if obj.state_ ~= 14 - obj.raise_unexpected_state_(14); + if obj.state_ ~= 7 + obj.raise_unexpected_state_(7); end obj.write_int_string_tuple_(value); - obj.state_ = 16; + obj.state_ = 8; end % Ordinal 8 function write_stream_of_type_variants(obj, value) - if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 16 - obj.raise_unexpected_state_(16); + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); end obj.write_stream_of_type_variants_(value); - obj.state_ = 17; + end + + function end_stream_of_type_variants(obj) + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); + end + + obj.end_stream_(); + obj.state_ = 9; end end @@ -146,22 +149,22 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_float_image'; - elseif state == 2 + elseif state == 1 name = 'write_int_image'; - elseif state == 4 + elseif state == 2 name = 'write_int_image_alternate_syntax'; - elseif state == 6 + elseif state == 3 name = 'write_string_image'; - elseif state == 8 + elseif state == 4 name = 'write_int_float_tuple'; - elseif state == 10 + elseif state == 5 name = 'write_float_float_tuple'; - elseif state == 12 + elseif state == 6 name = 'write_int_float_tuple_alternate_syntax'; - elseif state == 14 + elseif state == 7 name = 'write_int_string_tuple'; - elseif state == 16 - name = 'write_stream_of_type_variants'; + elseif state == 8 + name = 'write_stream_of_type_variants or end_stream_of_type_variants'; else name = ''; end diff --git a/matlab/generated/+test_model/StateTestReaderBase.m b/matlab/generated/+test_model/StateTestReaderBase.m index 31d2fbdd..e1e61f1a 100644 --- a/matlab/generated/+test_model/StateTestReaderBase.m +++ b/matlab/generated/+test_model/StateTestReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 6 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 3 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,24 +25,24 @@ function close(obj) end value = obj.read_an_int_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function more = has_a_stream(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end more = obj.has_a_stream_(); if ~more - obj.state_ = 4; + obj.state_ = 2; end end function value = read_a_stream(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_a_stream_(); @@ -55,27 +50,22 @@ function close(obj) % Ordinal 2 function value = read_another_int(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_another_int_(); - obj.state_ = 6; + obj.state_ = 3; end function copy_to(obj, writer) - while obj.has_an_int() - item = obj.read_an_int(); - writer.write_an_int({item}); - end + writer.write_an_int(obj.read_an_int()); while obj.has_a_stream() item = obj.read_a_stream(); writer.write_a_stream({item}); end - while obj.has_another_int() - item = obj.read_another_int(); - writer.write_another_int({item}); - end + writer.end_a_stream(); + writer.write_another_int(obj.read_another_int()); end end @@ -104,9 +94,9 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_an_int'; - elseif state == 2 + elseif state == 1 name = 'read_a_stream'; - elseif state == 4 + elseif state == 2 name = 'read_another_int'; else name = ''; diff --git a/matlab/generated/+test_model/StateTestWriterBase.m b/matlab/generated/+test_model/StateTestWriterBase.m index d5d0f8a4..1e588e01 100644 --- a/matlab/generated/+test_model/StateTestWriterBase.m +++ b/matlab/generated/+test_model/StateTestWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 6 + if obj.state_ ~= 3 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,30 +26,35 @@ function write_an_int(obj, value) end obj.write_an_int_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_a_stream(obj, value) - if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_a_stream_(value); - obj.state_ = 3; + end + + function end_a_stream(obj) + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); + end + + obj.end_stream_(); + obj.state_ = 2; end % Ordinal 2 function write_another_int(obj, value) - if obj.state_ == 3 - obj.end_stream_(); - obj.state_ = 4; - elseif obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_another_int_(value); - obj.state_ = 6; + obj.state_ = 3; end end @@ -78,9 +83,9 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_an_int'; + elseif state == 1 + name = 'write_a_stream or end_a_stream'; elseif state == 2 - name = 'write_a_stream'; - elseif state == 4 name = 'write_another_int'; else name = ''; diff --git a/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m b/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m index bd362229..7880f2df 100644 --- a/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m +++ b/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 4 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -31,7 +26,7 @@ function close(obj) more = obj.has_int_or_simple_record_(); if ~more - obj.state_ = 2; + obj.state_ = 1; end end @@ -45,19 +40,19 @@ function close(obj) % Ordinal 1 function more = has_nullable_int_or_simple_record(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end more = obj.has_nullable_int_or_simple_record_(); if ~more - obj.state_ = 4; + obj.state_ = 2; end end function value = read_nullable_int_or_simple_record(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_nullable_int_or_simple_record_(); @@ -68,10 +63,12 @@ function copy_to(obj, writer) item = obj.read_int_or_simple_record(); writer.write_int_or_simple_record({item}); end + writer.end_int_or_simple_record(); while obj.has_nullable_int_or_simple_record() item = obj.read_nullable_int_or_simple_record(); writer.write_nullable_int_or_simple_record({item}); end + writer.end_nullable_int_or_simple_record(); end end @@ -100,7 +97,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_int_or_simple_record'; - elseif state == 2 + elseif state == 1 name = 'read_nullable_int_or_simple_record'; else name = ''; diff --git a/matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m b/matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m index 77592477..5a5d347b 100644 --- a/matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m +++ b/matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m @@ -12,13 +12,8 @@ end function close(obj) - if obj.state_ == 3 - obj.end_stream_(); - obj.close_(); - return - end obj.close_(); - if obj.state_ ~= 4 + if obj.state_ ~= 2 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,25 +21,38 @@ function close(obj) % Ordinal 0 function write_int_or_simple_record(obj, value) - if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end obj.write_int_or_simple_record_(value); + end + + function end_int_or_simple_record(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.end_stream_(); obj.state_ = 1; end % Ordinal 1 function write_nullable_int_or_simple_record(obj, value) - if obj.state_ == 1 - obj.end_stream_(); - obj.state_ = 2; - elseif bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_nullable_int_or_simple_record_(value); - obj.state_ = 3; + end + + function end_nullable_int_or_simple_record(obj) + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); + end + + obj.end_stream_(); + obj.state_ = 2; end end @@ -71,9 +79,9 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 - name = 'write_int_or_simple_record'; - elseif state == 2 - name = 'write_nullable_int_or_simple_record'; + name = 'write_int_or_simple_record or end_int_or_simple_record'; + elseif state == 1 + name = 'write_nullable_int_or_simple_record or end_nullable_int_or_simple_record'; else name = ''; end diff --git a/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m b/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m index df9e217a..56e3c674 100644 --- a/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m +++ b/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 4 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -31,7 +26,7 @@ function close(obj) more = obj.has_int_or_simple_record_(); if ~more - obj.state_ = 2; + obj.state_ = 1; end end @@ -45,19 +40,19 @@ function close(obj) % Ordinal 1 function more = has_nullable_int_or_simple_record(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end more = obj.has_nullable_int_or_simple_record_(); if ~more - obj.state_ = 4; + obj.state_ = 2; end end function value = read_nullable_int_or_simple_record(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_nullable_int_or_simple_record_(); @@ -68,10 +63,12 @@ function copy_to(obj, writer) item = obj.read_int_or_simple_record(); writer.write_int_or_simple_record({item}); end + writer.end_int_or_simple_record(); while obj.has_nullable_int_or_simple_record() item = obj.read_nullable_int_or_simple_record(); writer.write_nullable_int_or_simple_record({item}); end + writer.end_nullable_int_or_simple_record(); end end @@ -100,7 +97,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_int_or_simple_record'; - elseif state == 2 + elseif state == 1 name = 'read_nullable_int_or_simple_record'; else name = ''; diff --git a/matlab/generated/+test_model/StreamsOfUnionsWriterBase.m b/matlab/generated/+test_model/StreamsOfUnionsWriterBase.m index 7988ed15..cb21be23 100644 --- a/matlab/generated/+test_model/StreamsOfUnionsWriterBase.m +++ b/matlab/generated/+test_model/StreamsOfUnionsWriterBase.m @@ -12,13 +12,8 @@ end function close(obj) - if obj.state_ == 3 - obj.end_stream_(); - obj.close_(); - return - end obj.close_(); - if obj.state_ ~= 4 + if obj.state_ ~= 2 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,25 +21,38 @@ function close(obj) % Ordinal 0 function write_int_or_simple_record(obj, value) - if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end obj.write_int_or_simple_record_(value); + end + + function end_int_or_simple_record(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.end_stream_(); obj.state_ = 1; end % Ordinal 1 function write_nullable_int_or_simple_record(obj, value) - if obj.state_ == 1 - obj.end_stream_(); - obj.state_ = 2; - elseif bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_nullable_int_or_simple_record_(value); - obj.state_ = 3; + end + + function end_nullable_int_or_simple_record(obj) + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); + end + + obj.end_stream_(); + obj.state_ = 2; end end @@ -71,9 +79,9 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 - name = 'write_int_or_simple_record'; - elseif state == 2 - name = 'write_nullable_int_or_simple_record'; + name = 'write_int_or_simple_record or end_int_or_simple_record'; + elseif state == 1 + name = 'write_nullable_int_or_simple_record or end_nullable_int_or_simple_record'; else name = ''; end diff --git a/matlab/generated/+test_model/StreamsReaderBase.m b/matlab/generated/+test_model/StreamsReaderBase.m index 8f1d3455..26a17394 100644 --- a/matlab/generated/+test_model/StreamsReaderBase.m +++ b/matlab/generated/+test_model/StreamsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 8 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 4 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -31,7 +26,7 @@ function close(obj) more = obj.has_int_data_(); if ~more - obj.state_ = 2; + obj.state_ = 1; end end @@ -45,19 +40,19 @@ function close(obj) % Ordinal 1 function more = has_optional_int_data(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end more = obj.has_optional_int_data_(); if ~more - obj.state_ = 4; + obj.state_ = 2; end end function value = read_optional_int_data(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_optional_int_data_(); @@ -65,19 +60,19 @@ function close(obj) % Ordinal 2 function more = has_record_with_optional_vector_data(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end more = obj.has_record_with_optional_vector_data_(); if ~more - obj.state_ = 6; + obj.state_ = 3; end end function value = read_record_with_optional_vector_data(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_record_with_optional_vector_data_(); @@ -85,19 +80,19 @@ function close(obj) % Ordinal 3 function more = has_fixed_vector(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end more = obj.has_fixed_vector_(); if ~more - obj.state_ = 8; + obj.state_ = 4; end end function value = read_fixed_vector(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end value = obj.read_fixed_vector_(); @@ -108,18 +103,22 @@ function copy_to(obj, writer) item = obj.read_int_data(); writer.write_int_data({item}); end + writer.end_int_data(); while obj.has_optional_int_data() item = obj.read_optional_int_data(); writer.write_optional_int_data({item}); end + writer.end_optional_int_data(); while obj.has_record_with_optional_vector_data() item = obj.read_record_with_optional_vector_data(); writer.write_record_with_optional_vector_data({item}); end + writer.end_record_with_optional_vector_data(); while obj.has_fixed_vector() item = obj.read_fixed_vector(); writer.write_fixed_vector({item}); end + writer.end_fixed_vector(); end end @@ -152,11 +151,11 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_int_data'; - elseif state == 2 + elseif state == 1 name = 'read_optional_int_data'; - elseif state == 4 + elseif state == 2 name = 'read_record_with_optional_vector_data'; - elseif state == 6 + elseif state == 3 name = 'read_fixed_vector'; else name = ''; diff --git a/matlab/generated/+test_model/StreamsWriterBase.m b/matlab/generated/+test_model/StreamsWriterBase.m index fdeb2f34..62ec15cb 100644 --- a/matlab/generated/+test_model/StreamsWriterBase.m +++ b/matlab/generated/+test_model/StreamsWriterBase.m @@ -12,13 +12,8 @@ end function close(obj) - if obj.state_ == 7 - obj.end_stream_(); - obj.close_(); - return - end obj.close_(); - if obj.state_ ~= 8 + if obj.state_ ~= 4 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,51 +21,74 @@ function close(obj) % Ordinal 0 function write_int_data(obj, value) - if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 0 + if obj.state_ ~= 0 obj.raise_unexpected_state_(0); end obj.write_int_data_(value); + end + + function end_int_data(obj) + if obj.state_ ~= 0 + obj.raise_unexpected_state_(0); + end + + obj.end_stream_(); obj.state_ = 1; end % Ordinal 1 function write_optional_int_data(obj, value) - if obj.state_ == 1 - obj.end_stream_(); - obj.state_ = 2; - elseif bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_optional_int_data_(value); - obj.state_ = 3; + end + + function end_optional_int_data(obj) + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); + end + + obj.end_stream_(); + obj.state_ = 2; end % Ordinal 2 function write_record_with_optional_vector_data(obj, value) - if obj.state_ == 3 - obj.end_stream_(); - obj.state_ = 4; - elseif bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_record_with_optional_vector_data_(value); - obj.state_ = 5; + end + + function end_record_with_optional_vector_data(obj) + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); + end + + obj.end_stream_(); + obj.state_ = 3; end % Ordinal 3 function write_fixed_vector(obj, value) - if obj.state_ == 5 - obj.end_stream_(); - obj.state_ = 6; - elseif bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end obj.write_fixed_vector_(value); - obj.state_ = 7; + end + + function end_fixed_vector(obj) + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); + end + + obj.end_stream_(); + obj.state_ = 4; end end @@ -99,13 +117,13 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 - name = 'write_int_data'; + name = 'write_int_data or end_int_data'; + elseif state == 1 + name = 'write_optional_int_data or end_optional_int_data'; elseif state == 2 - name = 'write_optional_int_data'; - elseif state == 4 - name = 'write_record_with_optional_vector_data'; - elseif state == 6 - name = 'write_fixed_vector'; + name = 'write_record_with_optional_vector_data or end_record_with_optional_vector_data'; + elseif state == 3 + name = 'write_fixed_vector or end_fixed_vector'; else name = ''; end diff --git a/matlab/generated/+test_model/StringsReaderBase.m b/matlab/generated/+test_model/StringsReaderBase.m index 61739ef0..f816cf1c 100644 --- a/matlab/generated/+test_model/StringsReaderBase.m +++ b/matlab/generated/+test_model/StringsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 4 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,28 +25,22 @@ function close(obj) end value = obj.read_single_string_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_rec_with_string(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_rec_with_string_(); - obj.state_ = 4; + obj.state_ = 2; end function copy_to(obj, writer) - while obj.has_single_string() - item = obj.read_single_string(); - writer.write_single_string({item}); - end - while obj.has_rec_with_string() - item = obj.read_rec_with_string(); - writer.write_rec_with_string({item}); - end + writer.write_single_string(obj.read_single_string()); + writer.write_rec_with_string(obj.read_rec_with_string()); end end @@ -78,7 +67,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_single_string'; - elseif state == 2 + elseif state == 1 name = 'read_rec_with_string'; else name = ''; diff --git a/matlab/generated/+test_model/StringsWriterBase.m b/matlab/generated/+test_model/StringsWriterBase.m index d83c49ef..6d6945c4 100644 --- a/matlab/generated/+test_model/StringsWriterBase.m +++ b/matlab/generated/+test_model/StringsWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 4 + if obj.state_ ~= 2 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,17 +26,17 @@ function write_single_string(obj, value) end obj.write_single_string_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_rec_with_string(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_rec_with_string_(value); - obj.state_ = 4; + obj.state_ = 2; end end @@ -64,7 +64,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_single_string'; - elseif state == 2 + elseif state == 1 name = 'write_rec_with_string'; else name = ''; diff --git a/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m b/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m index f04dbefb..ba161677 100644 --- a/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m +++ b/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 4 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 2 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,28 +25,22 @@ function close(obj) end value = obj.read_with_fixed_subarrays_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_with_vlen_subarrays(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_with_vlen_subarrays_(); - obj.state_ = 4; + obj.state_ = 2; end function copy_to(obj, writer) - while obj.has_with_fixed_subarrays() - item = obj.read_with_fixed_subarrays(); - writer.write_with_fixed_subarrays({item}); - end - while obj.has_with_vlen_subarrays() - item = obj.read_with_vlen_subarrays(); - writer.write_with_vlen_subarrays({item}); - end + writer.write_with_fixed_subarrays(obj.read_with_fixed_subarrays()); + writer.write_with_vlen_subarrays(obj.read_with_vlen_subarrays()); end end @@ -78,7 +67,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_with_fixed_subarrays'; - elseif state == 2 + elseif state == 1 name = 'read_with_vlen_subarrays'; else name = ''; diff --git a/matlab/generated/+test_model/SubarraysInRecordsWriterBase.m b/matlab/generated/+test_model/SubarraysInRecordsWriterBase.m index 08cca492..b92097f9 100644 --- a/matlab/generated/+test_model/SubarraysInRecordsWriterBase.m +++ b/matlab/generated/+test_model/SubarraysInRecordsWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 4 + if obj.state_ ~= 2 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,17 +26,17 @@ function write_with_fixed_subarrays(obj, value) end obj.write_with_fixed_subarrays_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_with_vlen_subarrays(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_with_vlen_subarrays_(value); - obj.state_ = 4; + obj.state_ = 2; end end @@ -64,7 +64,7 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_with_fixed_subarrays'; - elseif state == 2 + elseif state == 1 name = 'write_with_vlen_subarrays'; else name = ''; diff --git a/matlab/generated/+test_model/SubarraysReaderBase.m b/matlab/generated/+test_model/SubarraysReaderBase.m index 2263cb3c..368edd59 100644 --- a/matlab/generated/+test_model/SubarraysReaderBase.m +++ b/matlab/generated/+test_model/SubarraysReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 18 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 9 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,126 +25,99 @@ function close(obj) end value = obj.read_dynamic_with_fixed_int_subarray_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_dynamic_with_fixed_float_subarray(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_dynamic_with_fixed_float_subarray_(); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function value = read_known_dim_count_with_fixed_int_subarray(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_known_dim_count_with_fixed_int_subarray_(); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function value = read_known_dim_count_with_fixed_float_subarray(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end value = obj.read_known_dim_count_with_fixed_float_subarray_(); - obj.state_ = 8; + obj.state_ = 4; end % Ordinal 4 function value = read_fixed_with_fixed_int_subarray(obj) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); end value = obj.read_fixed_with_fixed_int_subarray_(); - obj.state_ = 10; + obj.state_ = 5; end % Ordinal 5 function value = read_fixed_with_fixed_float_subarray(obj) - if obj.state_ ~= 10 - obj.raise_unexpected_state_(10); + if obj.state_ ~= 5 + obj.raise_unexpected_state_(5); end value = obj.read_fixed_with_fixed_float_subarray_(); - obj.state_ = 12; + obj.state_ = 6; end % Ordinal 6 function value = read_nested_subarray(obj) - if obj.state_ ~= 12 - obj.raise_unexpected_state_(12); + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); end value = obj.read_nested_subarray_(); - obj.state_ = 14; + obj.state_ = 7; end % Ordinal 7 function value = read_dynamic_with_fixed_vector_subarray(obj) - if obj.state_ ~= 14 - obj.raise_unexpected_state_(14); + if obj.state_ ~= 7 + obj.raise_unexpected_state_(7); end value = obj.read_dynamic_with_fixed_vector_subarray_(); - obj.state_ = 16; + obj.state_ = 8; end % Ordinal 8 function value = read_generic_subarray(obj) - if obj.state_ ~= 16 - obj.raise_unexpected_state_(16); + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); end value = obj.read_generic_subarray_(); - obj.state_ = 18; + obj.state_ = 9; end function copy_to(obj, writer) - while obj.has_dynamic_with_fixed_int_subarray() - item = obj.read_dynamic_with_fixed_int_subarray(); - writer.write_dynamic_with_fixed_int_subarray({item}); - end - while obj.has_dynamic_with_fixed_float_subarray() - item = obj.read_dynamic_with_fixed_float_subarray(); - writer.write_dynamic_with_fixed_float_subarray({item}); - end - while obj.has_known_dim_count_with_fixed_int_subarray() - item = obj.read_known_dim_count_with_fixed_int_subarray(); - writer.write_known_dim_count_with_fixed_int_subarray({item}); - end - while obj.has_known_dim_count_with_fixed_float_subarray() - item = obj.read_known_dim_count_with_fixed_float_subarray(); - writer.write_known_dim_count_with_fixed_float_subarray({item}); - end - while obj.has_fixed_with_fixed_int_subarray() - item = obj.read_fixed_with_fixed_int_subarray(); - writer.write_fixed_with_fixed_int_subarray({item}); - end - while obj.has_fixed_with_fixed_float_subarray() - item = obj.read_fixed_with_fixed_float_subarray(); - writer.write_fixed_with_fixed_float_subarray({item}); - end - while obj.has_nested_subarray() - item = obj.read_nested_subarray(); - writer.write_nested_subarray({item}); - end - while obj.has_dynamic_with_fixed_vector_subarray() - item = obj.read_dynamic_with_fixed_vector_subarray(); - writer.write_dynamic_with_fixed_vector_subarray({item}); - end - while obj.has_generic_subarray() - item = obj.read_generic_subarray(); - writer.write_generic_subarray({item}); - end + writer.write_dynamic_with_fixed_int_subarray(obj.read_dynamic_with_fixed_int_subarray()); + writer.write_dynamic_with_fixed_float_subarray(obj.read_dynamic_with_fixed_float_subarray()); + writer.write_known_dim_count_with_fixed_int_subarray(obj.read_known_dim_count_with_fixed_int_subarray()); + writer.write_known_dim_count_with_fixed_float_subarray(obj.read_known_dim_count_with_fixed_float_subarray()); + writer.write_fixed_with_fixed_int_subarray(obj.read_fixed_with_fixed_int_subarray()); + writer.write_fixed_with_fixed_float_subarray(obj.read_fixed_with_fixed_float_subarray()); + writer.write_nested_subarray(obj.read_nested_subarray()); + writer.write_dynamic_with_fixed_vector_subarray(obj.read_dynamic_with_fixed_vector_subarray()); + writer.write_generic_subarray(obj.read_generic_subarray()); end end @@ -183,21 +151,21 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_dynamic_with_fixed_int_subarray'; - elseif state == 2 + elseif state == 1 name = 'read_dynamic_with_fixed_float_subarray'; - elseif state == 4 + elseif state == 2 name = 'read_known_dim_count_with_fixed_int_subarray'; - elseif state == 6 + elseif state == 3 name = 'read_known_dim_count_with_fixed_float_subarray'; - elseif state == 8 + elseif state == 4 name = 'read_fixed_with_fixed_int_subarray'; - elseif state == 10 + elseif state == 5 name = 'read_fixed_with_fixed_float_subarray'; - elseif state == 12 + elseif state == 6 name = 'read_nested_subarray'; - elseif state == 14 + elseif state == 7 name = 'read_dynamic_with_fixed_vector_subarray'; - elseif state == 16 + elseif state == 8 name = 'read_generic_subarray'; else name = ''; diff --git a/matlab/generated/+test_model/SubarraysWriterBase.m b/matlab/generated/+test_model/SubarraysWriterBase.m index 2ec2cb0e..c250c9aa 100644 --- a/matlab/generated/+test_model/SubarraysWriterBase.m +++ b/matlab/generated/+test_model/SubarraysWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 18 + if obj.state_ ~= 9 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,87 +26,87 @@ function write_dynamic_with_fixed_int_subarray(obj, value) end obj.write_dynamic_with_fixed_int_subarray_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_dynamic_with_fixed_float_subarray(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_dynamic_with_fixed_float_subarray_(value); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function write_known_dim_count_with_fixed_int_subarray(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_known_dim_count_with_fixed_int_subarray_(value); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function write_known_dim_count_with_fixed_float_subarray(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end obj.write_known_dim_count_with_fixed_float_subarray_(value); - obj.state_ = 8; + obj.state_ = 4; end % Ordinal 4 function write_fixed_with_fixed_int_subarray(obj, value) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + if obj.state_ ~= 4 + obj.raise_unexpected_state_(4); end obj.write_fixed_with_fixed_int_subarray_(value); - obj.state_ = 10; + obj.state_ = 5; end % Ordinal 5 function write_fixed_with_fixed_float_subarray(obj, value) - if obj.state_ ~= 10 - obj.raise_unexpected_state_(10); + if obj.state_ ~= 5 + obj.raise_unexpected_state_(5); end obj.write_fixed_with_fixed_float_subarray_(value); - obj.state_ = 12; + obj.state_ = 6; end % Ordinal 6 function write_nested_subarray(obj, value) - if obj.state_ ~= 12 - obj.raise_unexpected_state_(12); + if obj.state_ ~= 6 + obj.raise_unexpected_state_(6); end obj.write_nested_subarray_(value); - obj.state_ = 14; + obj.state_ = 7; end % Ordinal 7 function write_dynamic_with_fixed_vector_subarray(obj, value) - if obj.state_ ~= 14 - obj.raise_unexpected_state_(14); + if obj.state_ ~= 7 + obj.raise_unexpected_state_(7); end obj.write_dynamic_with_fixed_vector_subarray_(value); - obj.state_ = 16; + obj.state_ = 8; end % Ordinal 8 function write_generic_subarray(obj, value) - if obj.state_ ~= 16 - obj.raise_unexpected_state_(16); + if obj.state_ ~= 8 + obj.raise_unexpected_state_(8); end obj.write_generic_subarray_(value); - obj.state_ = 18; + obj.state_ = 9; end end @@ -141,21 +141,21 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_dynamic_with_fixed_int_subarray'; - elseif state == 2 + elseif state == 1 name = 'write_dynamic_with_fixed_float_subarray'; - elseif state == 4 + elseif state == 2 name = 'write_known_dim_count_with_fixed_int_subarray'; - elseif state == 6 + elseif state == 3 name = 'write_known_dim_count_with_fixed_float_subarray'; - elseif state == 8 + elseif state == 4 name = 'write_fixed_with_fixed_int_subarray'; - elseif state == 10 + elseif state == 5 name = 'write_fixed_with_fixed_float_subarray'; - elseif state == 12 + elseif state == 6 name = 'write_nested_subarray'; - elseif state == 14 + elseif state == 7 name = 'write_dynamic_with_fixed_vector_subarray'; - elseif state == 16 + elseif state == 8 name = 'write_generic_subarray'; else name = ''; diff --git a/matlab/generated/+test_model/UnionsReaderBase.m b/matlab/generated/+test_model/UnionsReaderBase.m index 0f1e4877..9e378df0 100644 --- a/matlab/generated/+test_model/UnionsReaderBase.m +++ b/matlab/generated/+test_model/UnionsReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 8 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 4 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,56 +25,44 @@ function close(obj) end value = obj.read_int_or_simple_record_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_int_or_record_with_vlens(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_int_or_record_with_vlens_(); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function value = read_monosotate_or_int_or_simple_record(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_monosotate_or_int_or_simple_record_(); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function value = read_record_with_unions(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end value = obj.read_record_with_unions_(); - obj.state_ = 8; + obj.state_ = 4; end function copy_to(obj, writer) - while obj.has_int_or_simple_record() - item = obj.read_int_or_simple_record(); - writer.write_int_or_simple_record({item}); - end - while obj.has_int_or_record_with_vlens() - item = obj.read_int_or_record_with_vlens(); - writer.write_int_or_record_with_vlens({item}); - end - while obj.has_monosotate_or_int_or_simple_record() - item = obj.read_monosotate_or_int_or_simple_record(); - writer.write_monosotate_or_int_or_simple_record({item}); - end - while obj.has_record_with_unions() - item = obj.read_record_with_unions(); - writer.write_record_with_unions({item}); - end + writer.write_int_or_simple_record(obj.read_int_or_simple_record()); + writer.write_int_or_record_with_vlens(obj.read_int_or_record_with_vlens()); + writer.write_monosotate_or_int_or_simple_record(obj.read_monosotate_or_int_or_simple_record()); + writer.write_record_with_unions(obj.read_record_with_unions()); end end @@ -108,11 +91,11 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_int_or_simple_record'; - elseif state == 2 + elseif state == 1 name = 'read_int_or_record_with_vlens'; - elseif state == 4 + elseif state == 2 name = 'read_monosotate_or_int_or_simple_record'; - elseif state == 6 + elseif state == 3 name = 'read_record_with_unions'; else name = ''; diff --git a/matlab/generated/+test_model/UnionsWriterBase.m b/matlab/generated/+test_model/UnionsWriterBase.m index d334b128..c8fa38c0 100644 --- a/matlab/generated/+test_model/UnionsWriterBase.m +++ b/matlab/generated/+test_model/UnionsWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 8 + if obj.state_ ~= 4 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,37 +26,37 @@ function write_int_or_simple_record(obj, value) end obj.write_int_or_simple_record_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_int_or_record_with_vlens(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_int_or_record_with_vlens_(value); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function write_monosotate_or_int_or_simple_record(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_monosotate_or_int_or_simple_record_(value); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function write_record_with_unions(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end obj.write_record_with_unions_(value); - obj.state_ = 8; + obj.state_ = 4; end end @@ -86,11 +86,11 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_int_or_simple_record'; - elseif state == 2 + elseif state == 1 name = 'write_int_or_record_with_vlens'; - elseif state == 4 + elseif state == 2 name = 'write_monosotate_or_int_or_simple_record'; - elseif state == 6 + elseif state == 3 name = 'write_record_with_unions'; else name = ''; diff --git a/matlab/generated/+test_model/VlensReaderBase.m b/matlab/generated/+test_model/VlensReaderBase.m index aa3fb81c..fb95f40f 100644 --- a/matlab/generated/+test_model/VlensReaderBase.m +++ b/matlab/generated/+test_model/VlensReaderBase.m @@ -12,14 +12,9 @@ function close(obj) obj.close_(); - if obj.state_ ~= 8 - if mod(obj.state_, 2) == 1 - previous_method = obj.state_to_method_name_(obj.state_ - 1); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method)); - else - expected_method = obj.state_to_method_name_(obj.state_); - throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); - end + if obj.state_ ~= 4 + expected_method = obj.state_to_method_name_(obj.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end @@ -30,56 +25,44 @@ function close(obj) end value = obj.read_int_vector_(); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function value = read_complex_vector(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end value = obj.read_complex_vector_(); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function value = read_record_with_vlens(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end value = obj.read_record_with_vlens_(); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function value = read_vlen_of_record_with_vlens(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end value = obj.read_vlen_of_record_with_vlens_(); - obj.state_ = 8; + obj.state_ = 4; end function copy_to(obj, writer) - while obj.has_int_vector() - item = obj.read_int_vector(); - writer.write_int_vector({item}); - end - while obj.has_complex_vector() - item = obj.read_complex_vector(); - writer.write_complex_vector({item}); - end - while obj.has_record_with_vlens() - item = obj.read_record_with_vlens(); - writer.write_record_with_vlens({item}); - end - while obj.has_vlen_of_record_with_vlens() - item = obj.read_vlen_of_record_with_vlens(); - writer.write_vlen_of_record_with_vlens({item}); - end + writer.write_int_vector(obj.read_int_vector()); + writer.write_complex_vector(obj.read_complex_vector()); + writer.write_record_with_vlens(obj.read_record_with_vlens()); + writer.write_vlen_of_record_with_vlens(obj.read_vlen_of_record_with_vlens()); end end @@ -108,11 +91,11 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'read_int_vector'; - elseif state == 2 + elseif state == 1 name = 'read_complex_vector'; - elseif state == 4 + elseif state == 2 name = 'read_record_with_vlens'; - elseif state == 6 + elseif state == 3 name = 'read_vlen_of_record_with_vlens'; else name = ''; diff --git a/matlab/generated/+test_model/VlensWriterBase.m b/matlab/generated/+test_model/VlensWriterBase.m index ff2ecf02..2bcb2eac 100644 --- a/matlab/generated/+test_model/VlensWriterBase.m +++ b/matlab/generated/+test_model/VlensWriterBase.m @@ -13,7 +13,7 @@ function close(obj) obj.close_(); - if obj.state_ ~= 8 + if obj.state_ ~= 4 expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end @@ -26,37 +26,37 @@ function write_int_vector(obj, value) end obj.write_int_vector_(value); - obj.state_ = 2; + obj.state_ = 1; end % Ordinal 1 function write_complex_vector(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + if obj.state_ ~= 1 + obj.raise_unexpected_state_(1); end obj.write_complex_vector_(value); - obj.state_ = 4; + obj.state_ = 2; end % Ordinal 2 function write_record_with_vlens(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + if obj.state_ ~= 2 + obj.raise_unexpected_state_(2); end obj.write_record_with_vlens_(value); - obj.state_ = 6; + obj.state_ = 3; end % Ordinal 3 function write_vlen_of_record_with_vlens(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + if obj.state_ ~= 3 + obj.raise_unexpected_state_(3); end obj.write_vlen_of_record_with_vlens_(value); - obj.state_ = 8; + obj.state_ = 4; end end @@ -86,11 +86,11 @@ function raise_unexpected_state_(obj, actual) function name = state_to_method_name_(obj, state) if state == 0 name = 'write_int_vector'; - elseif state == 2 + elseif state == 1 name = 'write_complex_vector'; - elseif state == 4 + elseif state == 2 name = 'write_record_with_vlens'; - elseif state == 6 + elseif state == 3 name = 'write_vlen_of_record_with_vlens'; else name = ''; diff --git a/matlab/test/ProtocolStateTest.m b/matlab/test/ProtocolStateTest.m index 9ab35db6..4b248001 100644 --- a/matlab/test/ProtocolStateTest.m +++ b/matlab/test/ProtocolStateTest.m @@ -8,6 +8,7 @@ function testProperSequenceWrite(testCase) w = ProtocolStateTestWriter(); w.write_an_int(1); w.write_a_stream([1, 2, 3]); + w.end_a_stream(); w.write_another_int(3); w.close(); end @@ -16,6 +17,7 @@ function testProperSequenceWriteEmptyStream(testCase) w = ProtocolStateTestWriter(); w.write_an_int(1); w.write_a_stream([]); + w.end_a_stream(); w.write_another_int(3); w.close(); end @@ -25,6 +27,7 @@ function testProperSequenceWriteMultipleStreams(testCase) w.write_an_int(1); w.write_a_stream([1, 2, 3]); w.write_a_stream([4, 5, 6]); + w.end_a_stream(); w.write_another_int(3); w.close(); end @@ -34,6 +37,13 @@ function testSequenceWriteMissingFirstStep(testCase) testCase.verifyError(@() w.write_a_stream([1, 2, 3]), 'yardl:ProtocolError'); end + function testSequenceWriteMissingEndStream(testCase) + w = ProtocolStateTestWriter(); + w.write_an_int(1); + w.write_a_stream([1, 2, 3]); + testCase.verifyError(@() w.write_another_int(4), 'yardl:ProtocolError'); + end + function testSequenceWritePrematureClose(testCase) w = ProtocolStateTestWriter(); w.write_an_int(1); diff --git a/matlab/test/RoundTripTest.m b/matlab/test/RoundTripTest.m index 006f8591..ee9d1d6e 100644 --- a/matlab/test/RoundTripTest.m +++ b/matlab/test/RoundTripTest.m @@ -318,6 +318,7 @@ function testFlags(testCase, format) test_model.DaysOfWeek(282839), ... test_model.DaysOfWeek(234532) ... ]); + w.end_days(); w.write_formats([... test_model.TextFormat.BOLD, ... @@ -325,46 +326,64 @@ function testFlags(testCase, format) test_model.TextFormat.REGULAR, ... test_model.TextFormat(232932) ... ]); + w.end_formats(); w.close(); end function testSimpleStreams(testCase, format) - w = create_validating_writer(testCase, format, 'Streams'); - % Non-empty streams + w = create_validating_writer(testCase, format, 'Streams'); w.write_int_data(int32(1:10)); - w.write_int_data(42); + w.write_int_data(int32(42)); w.write_int_data(int32(1:20)); + w.end_int_data(); w.write_optional_int_data([1, 2, yardl.None, 4, 5, yardl.None, 7, 8, 9, 10]); + w.end_optional_int_data(); w.write_record_with_optional_vector_data([... test_model.RecordWithOptionalVector(), ... test_model.RecordWithOptionalVector(int32([1, 2, 3])), ... test_model.RecordWithOptionalVector(int32(1:10)) ... ]); + w.end_record_with_optional_vector_data(); w.write_fixed_vector(... - transpose(int32([... - [1, 2, 3]; [1, 2, 3]; [1, 2, 3]; [1, 2, 3]; - ]))... + repelem({int32([1, 2, 3])}, 4)... ); + w.end_fixed_vector(); w.close(); % Mixed empty/non-empty streams w = create_validating_writer(testCase, format, 'Streams'); w.write_int_data(int32(1:10)) w.write_int_data([]); + w.end_int_data(); w.write_optional_int_data([]); w.write_optional_int_data([1, 2, yardl.None, 4, 5, yardl.None, 7, 8, 9, 10]); + w.end_optional_int_data(); w.write_record_with_optional_vector_data([]); - w.write_fixed_vector(int32(repmat([1;2;3], 1,4))); + w.end_record_with_optional_vector_data(); + % w.write_fixed_vector(int32(repmat([1;2;3], 1,4))); + w.write_fixed_vector(repelem({int32([1, 2, 3])}, 4)); + w.end_fixed_vector(); w.close(); - % All empty streams + % % All empty streams w = create_validating_writer(testCase, format, 'Streams'); w.write_int_data([]); + w.end_int_data(); w.write_optional_int_data([]); + w.end_optional_int_data(); w.write_record_with_optional_vector_data([]); + w.end_record_with_optional_vector_data(); w.write_fixed_vector([]); + w.end_fixed_vector(); + w.close(); + + w = create_validating_writer(testCase, format, 'Streams'); + w.end_int_data(); + w.end_optional_int_data(); + w.end_record_with_optional_vector_data(); + w.end_fixed_vector(); w.close(); end @@ -375,6 +394,7 @@ function testStreamsOfUnions(testCase, format) test_model.Int32OrSimpleRecord.SimpleRecord(test_model.SimpleRecord(1, 2, 3)), ... test_model.Int32OrSimpleRecord.Int32(2) ... ]); + w.end_int_or_simple_record(); w.write_nullable_int_or_simple_record([... yardl.None, ... test_model.Int32OrSimpleRecord.Int32(1), ... @@ -383,6 +403,7 @@ function testStreamsOfUnions(testCase, format) test_model.Int32OrSimpleRecord.Int32(2), ... yardl.None ... ]); + w.end_nullable_int_or_simple_record(); w.close(); end @@ -393,6 +414,7 @@ function testStreamsOfAliasedUnions(testCase, format) test_model.AliasedIntOrSimpleRecord.SimpleRecord(test_model.SimpleRecord(1, 2, 3)), ... test_model.AliasedIntOrSimpleRecord.Int32(2) ... ]); + w.end_int_or_simple_record(); w.write_nullable_int_or_simple_record([... yardl.None, ... test_model.AliasedNullableIntSimpleRecord.Int32(1), ... @@ -401,6 +423,7 @@ function testStreamsOfAliasedUnions(testCase, format) test_model.AliasedNullableIntSimpleRecord.Int32(2), ... yardl.None ... ]); + w.end_nullable_int_or_simple_record(); w.close(); end @@ -419,6 +442,7 @@ function testSimpleGenerics(testCase, format) test_model.ImageFloatOrImageDouble.ImageFloat(transpose(single([[1, 2]; [3, 4]]))), ... test_model.ImageFloatOrImageDouble.ImageDouble(transpose([[1, 2]; [3, 4]])) ... ]); + w.end_stream_of_type_variants(); w.close(); end @@ -465,6 +489,7 @@ function testAliases(testCase, format) test_model.AliasedGenericUnion2.T1("hello"), ... test_model.AliasedGenericUnion2.T2(test_model.Fruits.APPLE) ... ]); + w.end_stream_of_aliased_generic_union_2(); w.close(); end end diff --git a/matlab/test/benchmark.m b/matlab/test/benchmark.m index 76a79229..5214017e 100644 --- a/matlab/test/benchmark.m +++ b/matlab/test/benchmark.m @@ -119,6 +119,7 @@ function write() for r = 1:repetitions w.write_float256x256({a}); end + w.end_float256x256(); w.close(); end @@ -154,6 +155,7 @@ function write() for r = 1:repetitions w.write_float_array({a}); end + w.end_float_array(); w.close(); end @@ -189,6 +191,7 @@ function write() for r = 1:repetitions w.write_int256x256({a}); end + w.end_int256x256(); w.close(); end @@ -221,6 +224,7 @@ function write() for r = 1:repetitions w.write_small_record({record}); end + w.end_small_record(); w.close(); end @@ -267,6 +271,7 @@ function write() for r = 1:repetitions w.write_data({value}); end + w.end_data(); w.close(); end diff --git a/tooling/internal/matlab/common/common.go b/tooling/internal/matlab/common/common.go index a5066795..658e2831 100644 --- a/tooling/internal/matlab/common/common.go +++ b/tooling/internal/matlab/common/common.go @@ -203,6 +203,10 @@ func ProtocolWriteImplMethodName(s *dsl.ProtocolStep) string { return fmt.Sprintf("write_%s_", formatting.ToSnakeCase(s.Name)) } +func ProtocolEndMethodName(s *dsl.ProtocolStep) string { + return fmt.Sprintf("end_%s", formatting.ToSnakeCase(s.Name)) +} + func ProtocolReadMethodName(s *dsl.ProtocolStep) string { return fmt.Sprintf("read_%s", formatting.ToSnakeCase(s.Name)) } diff --git a/tooling/internal/matlab/mocks/mocks.go b/tooling/internal/matlab/mocks/mocks.go index 8192120f..a6084979 100644 --- a/tooling/internal/matlab/mocks/mocks.go +++ b/tooling/internal/matlab/mocks/mocks.go @@ -24,6 +24,9 @@ func WriteMocks(fw *common.MatlabFileWriter, ns *dsl.Namespace) error { } func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) error { + expectedName := func(step *dsl.ProtocolStep) string { + return fmt.Sprintf("expected_%s", formatting.ToSnakeCase(step.Name)) + } return fw.WriteFile(mockWriterName(p), func(w *formatting.IndentedWriter) { abstractWriterName := fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(p.Namespace), common.AbstractWriterName(p)) fmt.Fprintf(w, "classdef %s < matlab.mixin.Copyable & %s\n", mockWriterName(p), abstractWriterName) @@ -32,7 +35,7 @@ func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) e common.WriteBlockBody(w, func() { w.WriteStringln("testCase_") for _, step := range p.Sequence { - fmt.Fprintf(w, "%swritten\n", common.ProtocolWriteImplMethodName(step)) + w.WriteStringln(expectedName(step)) } }) w.WriteStringln("") @@ -43,7 +46,11 @@ func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) e common.WriteBlockBody(w, func() { w.WriteStringln("obj.testCase_ = testCase;") for _, step := range p.Sequence { - fmt.Fprintf(w, "obj.%swritten = yardl.None;\n", common.ProtocolWriteImplMethodName(step)) + if step.IsStream() { + fmt.Fprintf(w, "obj.%s = {};\n", expectedName(step)) + } else { + fmt.Fprintf(w, "obj.%s = yardl.None;\n", expectedName(step)) + } } }) w.WriteStringln("") @@ -51,15 +58,27 @@ func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) e for _, step := range p.Sequence { fmt.Fprintf(w, "function expect_%s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "if obj.%swritten.has_value()\n", common.ProtocolWriteImplMethodName(step)) - w.Indented(func() { - fmt.Fprintf(w, "last_dim = ndims(value);\n") - fmt.Fprintf(w, "obj.%swritten = yardl.Optional(cat(last_dim, obj.%swritten.value, value));\n", common.ProtocolWriteImplMethodName(step), common.ProtocolWriteImplMethodName(step)) - }) - w.WriteStringln("else") - common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.%swritten = yardl.Optional(value);\n", common.ProtocolWriteImplMethodName(step)) - }) + if step.IsStream() { + w.WriteStringln("if iscell(value)") + common.WriteBlockBody(w, func() { + w.WriteStringln("for n = 1:numel(value)") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "obj.%s{end+1} = value{n};\n", expectedName(step)) + }) + w.WriteStringln("return;") + }) + + w.WriteStringln("shape = size(value);") + w.WriteStringln("lastDim = ndims(value);") + w.WriteStringln("count = shape(lastDim);") + w.WriteStringln("index = repelem({':'}, lastDim-1);") + w.WriteStringln("for n = 1:count") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "obj.%s{end+1} = value(index{:}, n);\n", expectedName(step)) + }) + } else { + fmt.Fprintf(w, "obj.%s = yardl.Optional(value);\n", expectedName(step)) + } }) w.WriteStringln("") } @@ -68,7 +87,11 @@ func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) e common.WriteBlockBody(w, func() { for _, step := range p.Sequence { diagnostic := fmt.Sprintf("Expected call to %s was not received", common.ProtocolWriteImplMethodName(step)) - fmt.Fprintf(w, "obj.testCase_.verifyEqual(obj.%swritten, yardl.None, \"%s\");\n", common.ProtocolWriteImplMethodName(step), diagnostic) + if step.IsStream() { + fmt.Fprintf(w, "obj.testCase_.verifyTrue(isempty(obj.%s), \"%s\");\n", expectedName(step), diagnostic) + } else { + fmt.Fprintf(w, "obj.testCase_.verifyEqual(obj.%s, yardl.None, \"%s\");\n", expectedName(step), diagnostic) + } } }) }) @@ -79,10 +102,17 @@ func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) e for _, step := range p.Sequence { fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.testCase_.verifyTrue(obj.%swritten.has_value(), \"Unexpected call to %s\");\n", common.ProtocolWriteImplMethodName(step), common.ProtocolWriteImplMethodName(step)) - fmt.Fprintf(w, "expected = obj.%swritten.value;\n", common.ProtocolWriteImplMethodName(step)) - fmt.Fprintf(w, "obj.testCase_.verifyEqual(value, expected, \"Unexpected argument value for call to %s\");\n", common.ProtocolWriteImplMethodName(step)) - fmt.Fprintf(w, "obj.%swritten = yardl.None;\n", common.ProtocolWriteImplMethodName(step)) + if step.IsStream() { + w.WriteStringln("assert(iscell(value));") + w.WriteStringln("assert(isscalar(value));") + fmt.Fprintf(w, "obj.testCase_.verifyFalse(isempty(obj.%s), \"Unexpected call to %s\");\n", expectedName(step), common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "obj.testCase_.verifyEqual(value{1}, obj.%s{1}, \"Unexpected argument value for call to %s\");\n", expectedName(step), common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "obj.%s = obj.%s(2:end);\n", expectedName(step), expectedName(step)) + } else { + fmt.Fprintf(w, "obj.testCase_.verifyTrue(obj.%s.has_value(), \"Unexpected call to %s\");\n", expectedName(step), common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "obj.testCase_.verifyEqual(value, obj.%s.value, \"Unexpected argument value for call to %s\");\n", expectedName(step), common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "obj.%s = yardl.None;\n", expectedName(step)) + } }) w.WriteStringln("") } @@ -136,6 +166,17 @@ func writeProtocolTestWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinit fmt.Fprintf(w, "throw(yardl.RuntimeError(\"Close() must be called on '%s' to verify mocks\"));\n", testWriterName(p)) }) }) + + for _, step := range p.Sequence { + if step.IsStream() { + fmt.Fprintf(w, "function %s(obj)\n", common.ProtocolEndMethodName(step)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "%s@%s(obj);\n", common.ProtocolEndMethodName(step), abstractWriterName) + fmt.Fprintf(w, "obj.writer_.%s();\n", common.ProtocolEndMethodName(step)) + }) + w.WriteStringln("") + } + } }) w.WriteStringln("") diff --git a/tooling/internal/matlab/protocols/protocols.go b/tooling/internal/matlab/protocols/protocols.go index e16413a4..b251a11a 100644 --- a/tooling/internal/matlab/protocols/protocols.go +++ b/tooling/internal/matlab/protocols/protocols.go @@ -46,16 +46,8 @@ func writeAbstractWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, // Close method w.WriteStringln("function close(obj)") common.WriteBlockBody(w, func() { - if len(p.Sequence) > 0 && p.Sequence[len(p.Sequence)-1].IsStream() { - fmt.Fprintf(w, "if obj.state_ == %d\n", len(p.Sequence)*2-1) - common.WriteBlockBody(w, func() { - w.WriteStringln("obj.end_stream_();") - w.WriteStringln("obj.close_();") - w.WriteStringln("return") - }) - } w.WriteStringln("obj.close_();") - fmt.Fprintf(w, "if obj.state_ ~= %d\n", len(p.Sequence)*2) + fmt.Fprintf(w, "if obj.state_ ~= %d\n", len(p.Sequence)) common.WriteBlockBody(w, func() { w.WriteStringln("expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8')));") w.WriteStringln(`throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method));`) @@ -69,33 +61,31 @@ func writeAbstractWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, common.WriteComment(w, step.Comment) fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteMethodName(step)) common.WriteBlockBody(w, func() { - prevIsStream := i > 0 && p.Sequence[i-1].IsStream() - if prevIsStream { - fmt.Fprintf(w, "if obj.state_ == %d\n", i*2-1) - w.Indented(func() { - w.WriteStringln("obj.end_stream_();") - fmt.Fprintf(w, "obj.state_ = %d;\n", i*2) - }) - w.WriteString("else") - } - - if step.IsStream() { - fmt.Fprintf(w, "if bitand(int32(obj.state_), bitcmp(1, 'int8')) ~= %d\n", i*2) - } else { - fmt.Fprintf(w, "if obj.state_ ~= %d\n", i*2) - } + fmt.Fprintf(w, "if obj.state_ ~= %d\n", i) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i*2) + fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i) }) w.WriteStringln("") fmt.Fprintf(w, "obj.%s(value);\n", common.ProtocolWriteImplMethodName(step)) - if step.IsStream() { - fmt.Fprintf(w, "obj.state_ = %d;\n", i*2+1) - } else { - fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) + if !step.IsStream() { + fmt.Fprintf(w, "obj.state_ = %d;\n", i+1) } }) + if step.IsStream() { + w.WriteStringln("") + fmt.Fprintf(w, "function %s(obj)\n", common.ProtocolEndMethodName(step)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "if obj.state_ ~= %d\n", i) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i) + }) + w.WriteStringln("") + fmt.Fprintf(w, "obj.end_stream_();\n") + fmt.Fprintf(w, "obj.state_ = %d;\n", i+1) + }) + } + if i < len(p.Sequence)-1 { w.WriteStringln("") } @@ -130,7 +120,7 @@ func writeAbstractWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, // Private methods w.WriteStringln("methods (Access=private)") common.WriteBlockBody(w, func() { - // _raise_unexpected_state method + // raise_unexpected_state method w.WriteStringln("function raise_unexpected_state_(obj, actual)") common.WriteBlockBody(w, func() { w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") @@ -142,9 +132,13 @@ func writeAbstractWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, w.WriteStringln("function name = state_to_method_name_(obj, state)") common.WriteBlockBody(w, func() { for i, step := range p.Sequence { - fmt.Fprintf(w, "if state == %d\n", i*2) + fmt.Fprintf(w, "if state == %d\n", i) w.Indented(func() { - fmt.Fprintf(w, "name = '%s';\n", common.ProtocolWriteMethodName(step)) + if step.IsStream() { + fmt.Fprintf(w, "name = '%s or %s';\n", common.ProtocolWriteMethodName(step), common.ProtocolEndMethodName(step)) + } else { + fmt.Fprintf(w, "name = '%s';\n", common.ProtocolWriteMethodName(step)) + } }) w.WriteString("else") } @@ -184,18 +178,10 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, w.WriteStringln("function close(obj)") common.WriteBlockBody(w, func() { w.WriteStringln("obj.close_();") - fmt.Fprintf(w, "if obj.state_ ~= %d\n", len(p.Sequence)*2) + fmt.Fprintf(w, "if obj.state_ ~= %d\n", len(p.Sequence)) common.WriteBlockBody(w, func() { - w.WriteStringln("if mod(obj.state_, 2) == 1") - w.Indented(func() { - w.WriteStringln("previous_method = obj.state_to_method_name_(obj.state_ - 1);") - w.WriteStringln(`throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. The iterable returned by '%s' was not fully consumed.", previous_method));`) - }) - w.WriteStringln("else") - common.WriteBlockBody(w, func() { - w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") - w.WriteStringln(`throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method));`) - }) + w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") + w.WriteStringln(`throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method));`) }) }) w.WriteStringln("") @@ -206,16 +192,16 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, if step.IsStream() { fmt.Fprintf(w, "function more = %s(obj)\n", common.ProtocolHasMoreMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "if obj.state_ ~= %d\n", i*2) + fmt.Fprintf(w, "if obj.state_ ~= %d\n", i) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i*2) + fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i) }) w.WriteStringln("") fmt.Fprintf(w, "more = obj.%s();\n", common.ProtocolHasMoreImplMethodName(step)) w.WriteStringln("if ~more") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) + fmt.Fprintf(w, "obj.state_ = %d;\n", i+1) }) }) w.WriteStringln("") @@ -223,15 +209,15 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, common.WriteComment(w, step.Comment) fmt.Fprintf(w, "function value = %s(obj)\n", common.ProtocolReadMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "if obj.state_ ~= %d\n", i*2) + fmt.Fprintf(w, "if obj.state_ ~= %d\n", i) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i*2) + fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i) }) w.WriteStringln("") fmt.Fprintf(w, "value = obj.%s();\n", common.ProtocolReadImplMethodName(step)) if !step.IsStream() { - fmt.Fprintf(w, "obj.state_ = %d;\n", (i+1)*2) + fmt.Fprintf(w, "obj.state_ = %d;\n", i+1) } }) w.WriteStringln("") @@ -241,11 +227,16 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, fmt.Fprintf(w, "function copy_to(obj, writer)\n") common.WriteBlockBody(w, func() { for _, step := range p.Sequence { - fmt.Fprintf(w, "while obj.%s()\n", common.ProtocolHasMoreMethodName(step)) - common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "item = obj.%s();\n", common.ProtocolReadMethodName(step)) - fmt.Fprintf(w, "writer.%s({item});\n", common.ProtocolWriteMethodName(step)) - }) + if step.IsStream() { + fmt.Fprintf(w, "while obj.%s()\n", common.ProtocolHasMoreMethodName(step)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "item = obj.%s();\n", common.ProtocolReadMethodName(step)) + fmt.Fprintf(w, "writer.%s({item});\n", common.ProtocolWriteMethodName(step)) + }) + fmt.Fprintf(w, "writer.%s();\n", common.ProtocolEndMethodName(step)) + } else { + fmt.Fprintf(w, "writer.%s(obj.%s());\n", common.ProtocolWriteMethodName(step), common.ProtocolReadMethodName(step)) + } } }) }) @@ -290,7 +281,7 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, w.WriteStringln("function name = state_to_method_name_(obj, state)") common.WriteBlockBody(w, func() { for i, step := range p.Sequence { - fmt.Fprintf(w, "if state == %d\n", i*2) + fmt.Fprintf(w, "if state == %d\n", i) w.Indented(func() { fmt.Fprintf(w, "name = '%s';\n", common.ProtocolReadMethodName(step)) }) From bc6cc7d81d7ec72adbeb8585eb69f66425896549 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Mon, 15 Apr 2024 15:41:18 +0000 Subject: [PATCH 18/32] Add Matlab documentation Also clean up Matlab code and improve serializer input validation. --- docs/.vitepress/config.mts | 29 + docs/cpp/language.md | 4 +- docs/cpp/packages.md | 5 + docs/index.md | 5 +- docs/matlab/evolution.md | 1 + docs/matlab/introduction.md | 68 ++ docs/matlab/language.md | 718 ++++++++++++++++++ docs/matlab/packages.md | 1 + docs/matlab/quickstart.md | 205 +++++ docs/parts/intro-core.md | 5 +- docs/python/language.md | 4 +- ...enericRecordWithComputedFieldsSerializer.m | 18 +- .../+binary/RecordWithUnionsSerializer.m | 18 +- .../+basic_types/GenericNullableUnion2.m | 8 + .../GenericRecordWithComputedFields.m | 12 +- matlab/generated/+basic_types/GenericUnion2.m | 8 + matlab/generated/+basic_types/Int32OrString.m | 8 + .../generated/+basic_types/RecordWithUnions.m | 26 +- matlab/generated/+basic_types/T0OrT1.m | 8 + .../generated/+basic_types/TimeOrDatetime.m | 8 + matlab/generated/+image/FloatImage.m | 4 +- matlab/generated/+image/IntImage.m | 4 +- .../+binary/AdvancedGenericsReader.m | 36 +- .../+binary/AdvancedGenericsWriter.m | 36 +- .../+test_model/+binary/AliasesReader.m | 70 +- .../+test_model/+binary/AliasesWriter.m | 66 +- .../+binary/BenchmarkFloat256x256Reader.m | 16 +- .../+binary/BenchmarkFloat256x256Writer.m | 12 +- .../+binary/BenchmarkFloatVlenReader.m | 16 +- .../+binary/BenchmarkFloatVlenWriter.m | 12 +- .../+binary/BenchmarkInt256x256Reader.m | 16 +- .../+binary/BenchmarkInt256x256Writer.m | 12 +- .../+binary/BenchmarkSimpleMrdReader.m | 16 +- .../+binary/BenchmarkSimpleMrdWriter.m | 12 +- .../+binary/BenchmarkSmallRecordReader.m | 16 +- .../BenchmarkSmallRecordWithOptionalsReader.m | 16 +- .../BenchmarkSmallRecordWithOptionalsWriter.m | 12 +- .../+binary/BenchmarkSmallRecordWriter.m | 12 +- .../+binary/DynamicNDArraysReader.m | 30 +- .../+binary/DynamicNDArraysWriter.m | 30 +- .../+test_model/+binary/EnumsReader.m | 24 +- .../+test_model/+binary/EnumsWriter.m | 24 +- .../+test_model/+binary/FixedArraysReader.m | 36 +- .../+test_model/+binary/FixedArraysWriter.m | 36 +- .../+test_model/+binary/FixedVectorsReader.m | 30 +- .../+test_model/+binary/FixedVectorsWriter.m | 30 +- .../+test_model/+binary/FlagsReader.m | 26 +- .../+test_model/+binary/FlagsWriter.m | 18 +- .../+binary/GenericRecordSerializer.m | 18 +- .../+test_model/+binary/MapsReader.m | 30 +- .../+test_model/+binary/MapsWriter.m | 30 +- .../+test_model/+binary/NDArraysReader.m | 36 +- .../+binary/NDArraysSingleDimensionReader.m | 30 +- .../+binary/NDArraysSingleDimensionWriter.m | 30 +- .../+test_model/+binary/NDArraysWriter.m | 36 +- .../+test_model/+binary/NestedRecordsReader.m | 12 +- .../+test_model/+binary/NestedRecordsWriter.m | 12 +- .../+binary/OptionalVectorsReader.m | 12 +- .../+binary/OptionalVectorsWriter.m | 12 +- .../ProtocolWithComputedFieldsReader.m | 12 +- .../ProtocolWithComputedFieldsWriter.m | 12 +- .../+binary/ProtocolWithKeywordStepsReader.m | 22 +- .../+binary/ProtocolWithKeywordStepsWriter.m | 18 +- ...RecordContainingGenericRecordsSerializer.m | 18 +- ...ContainingNestedGenericRecordsSerializer.m | 18 +- .../RecordNotUsedInProtocolSerializer.m | 18 +- .../RecordWithAliasedGenericsSerializer.m | 18 +- ...ithAliasedOptionalGenericFieldSerializer.m | 18 +- ...iasedOptionalGenericUnionFieldSerializer.m | 18 +- .../+binary/RecordWithArraysSerializer.m | 18 +- .../RecordWithArraysSimpleSyntaxSerializer.m | 18 +- .../RecordWithComputedFieldsSerializer.m | 18 +- .../RecordWithDynamicNDArraysSerializer.m | 18 +- .../+binary/RecordWithEnumsSerializer.m | 18 +- .../+binary/RecordWithFixedArraysSerializer.m | 18 +- .../RecordWithFixedCollectionsSerializer.m | 18 +- .../RecordWithFixedVectorsSerializer.m | 18 +- .../RecordWithGenericArraysSerializer.m | 18 +- .../RecordWithGenericFixedVectorsSerializer.m | 18 +- .../+binary/RecordWithGenericMapsSerializer.m | 18 +- ...cordWithGenericVectorOfRecordsSerializer.m | 18 +- .../RecordWithGenericVectorsSerializer.m | 18 +- .../RecordWithKeywordFieldsSerializer.m | 18 +- .../+binary/RecordWithNDArraysSerializer.m | 18 +- ...ordWithNDArraysSingleDimensionSerializer.m | 18 +- .../RecordWithNamedFixedArraysSerializer.m | 18 +- .../RecordWithOptionalFieldsSerializer.m | 18 +- ...RecordWithOptionalGenericFieldSerializer.m | 18 +- ...dWithOptionalGenericUnionFieldSerializer.m | 18 +- .../RecordWithOptionalVectorSerializer.m | 18 +- .../RecordWithPrimitiveAliasesSerializer.m | 18 +- .../+binary/RecordWithPrimitivesSerializer.m | 18 +- .../+binary/RecordWithStringsSerializer.m | 18 +- .../RecordWithUnionsOfContainersSerializer.m | 18 +- .../RecordWithVectorOfTimesSerializer.m | 18 +- .../+binary/RecordWithVectorsSerializer.m | 18 +- .../RecordWithVlenCollectionsSerializer.m | 18 +- .../+binary/RecordWithVlensSerializer.m | 18 +- .../+binary/ScalarOptionalsReader.m | 30 +- .../+binary/ScalarOptionalsWriter.m | 30 +- .../+test_model/+binary/ScalarsReader.m | 18 +- .../+test_model/+binary/ScalarsWriter.m | 18 +- .../+binary/SimpleAcquisitionSerializer.m | 18 +- .../SimpleEncodingCountersSerializer.m | 18 +- .../+binary/SimpleGenericsReader.m | 64 +- .../+binary/SimpleGenericsWriter.m | 60 +- .../+binary/SimpleRecordSerializer.m | 18 +- .../+binary/SmallBenchmarkRecordSerializer.m | 18 +- .../+test_model/+binary/StateTestReader.m | 28 +- .../+test_model/+binary/StateTestWriter.m | 24 +- .../+binary/StreamsOfAliasedUnionsReader.m | 26 +- .../+binary/StreamsOfAliasedUnionsWriter.m | 18 +- .../+binary/StreamsOfUnionsReader.m | 26 +- .../+binary/StreamsOfUnionsWriter.m | 18 +- .../+test_model/+binary/StreamsReader.m | 46 +- .../+test_model/+binary/StreamsWriter.m | 30 +- .../+test_model/+binary/StringsReader.m | 18 +- .../+test_model/+binary/StringsWriter.m | 18 +- .../+binary/SubarraysInRecordsReader.m | 18 +- .../+binary/SubarraysInRecordsWriter.m | 18 +- .../+test_model/+binary/SubarraysReader.m | 60 +- .../+test_model/+binary/SubarraysWriter.m | 60 +- .../+binary/TupleWithRecordsSerializer.m | 18 +- .../+test_model/+binary/UnionsReader.m | 30 +- .../+test_model/+binary/UnionsWriter.m | 30 +- .../+test_model/+binary/VlensReader.m | 30 +- .../+test_model/+binary/VlensWriter.m | 30 +- .../+testing/MockAdvancedGenericsWriter.m | 90 +-- .../+test_model/+testing/MockAliasesWriter.m | 172 ++--- .../MockBenchmarkFloat256x256Writer.m | 28 +- .../+testing/MockBenchmarkFloatVlenWriter.m | 28 +- .../+testing/MockBenchmarkInt256x256Writer.m | 28 +- .../+testing/MockBenchmarkSimpleMrdWriter.m | 28 +- ...kBenchmarkSmallRecordWithOptionalsWriter.m | 28 +- .../+testing/MockBenchmarkSmallRecordWriter.m | 28 +- .../+testing/MockDynamicNDArraysWriter.m | 74 +- .../+test_model/+testing/MockEnumsWriter.m | 58 +- .../+testing/MockFixedArraysWriter.m | 90 +-- .../+testing/MockFixedVectorsWriter.m | 74 +- .../+test_model/+testing/MockFlagsWriter.m | 46 +- .../+test_model/+testing/MockMapsWriter.m | 74 +- .../MockNDArraysSingleDimensionWriter.m | 74 +- .../+test_model/+testing/MockNDArraysWriter.m | 90 +-- .../+testing/MockNestedRecordsWriter.m | 26 +- .../+testing/MockOptionalVectorsWriter.m | 26 +- .../MockProtocolWithComputedFieldsWriter.m | 26 +- .../MockProtocolWithKeywordStepsWriter.m | 44 +- .../+testing/MockScalarOptionalsWriter.m | 74 +- .../+test_model/+testing/MockScalarsWriter.m | 42 +- .../+testing/MockSimpleGenericsWriter.m | 156 ++-- .../+testing/MockStateTestWriter.m | 60 +- .../MockStreamsOfAliasedUnionsWriter.m | 46 +- .../+testing/MockStreamsOfUnionsWriter.m | 46 +- .../+test_model/+testing/MockStreamsWriter.m | 82 +- .../+test_model/+testing/MockStringsWriter.m | 42 +- .../+testing/MockSubarraysInRecordsWriter.m | 42 +- .../+testing/MockSubarraysWriter.m | 154 ++-- .../+test_model/+testing/MockUnionsWriter.m | 74 +- .../+test_model/+testing/MockVlensWriter.m | 74 +- .../+testing/TestAdvancedGenericsWriter.m | 72 +- .../+test_model/+testing/TestAliasesWriter.m | 108 +-- .../TestBenchmarkFloat256x256Writer.m | 54 +- .../+testing/TestBenchmarkFloatVlenWriter.m | 54 +- .../+testing/TestBenchmarkInt256x256Writer.m | 54 +- .../+testing/TestBenchmarkSimpleMrdWriter.m | 54 +- ...tBenchmarkSmallRecordWithOptionalsWriter.m | 54 +- .../+testing/TestBenchmarkSmallRecordWriter.m | 54 +- .../+testing/TestDynamicNDArraysWriter.m | 66 +- .../+test_model/+testing/TestEnumsWriter.m | 60 +- .../+testing/TestFixedArraysWriter.m | 72 +- .../+testing/TestFixedVectorsWriter.m | 66 +- .../+test_model/+testing/TestFlagsWriter.m | 66 +- .../+test_model/+testing/TestMapsWriter.m | 66 +- .../TestNDArraysSingleDimensionWriter.m | 66 +- .../+test_model/+testing/TestNDArraysWriter.m | 72 +- .../+testing/TestNestedRecordsWriter.m | 48 +- .../+testing/TestOptionalVectorsWriter.m | 48 +- .../TestProtocolWithComputedFieldsWriter.m | 48 +- .../TestProtocolWithKeywordStepsWriter.m | 60 +- .../+testing/TestScalarOptionalsWriter.m | 66 +- .../+test_model/+testing/TestScalarsWriter.m | 54 +- .../+testing/TestSimpleGenericsWriter.m | 102 +-- .../+testing/TestStateTestWriter.m | 66 +- .../TestStreamsOfAliasedUnionsWriter.m | 66 +- .../+testing/TestStreamsOfUnionsWriter.m | 66 +- .../+test_model/+testing/TestStreamsWriter.m | 90 +-- .../+test_model/+testing/TestStringsWriter.m | 54 +- .../+testing/TestSubarraysInRecordsWriter.m | 54 +- .../+testing/TestSubarraysWriter.m | 96 +-- .../+test_model/+testing/TestUnionsWriter.m | 66 +- .../+test_model/+testing/TestVlensWriter.m | 66 +- .../+test_model/AcquisitionOrImage.m | 8 + .../+test_model/AdvancedGenericsReaderBase.m | 106 +-- .../+test_model/AdvancedGenericsWriterBase.m | 96 +-- .../+test_model/AliasedIntOrSimpleRecord.m | 8 + .../+test_model/AliasedMultiGenericOptional.m | 8 + .../AliasedNullableIntSimpleRecord.m | 8 + .../generated/+test_model/AliasedOptional.m | 4 +- .../generated/+test_model/AliasesReaderBase.m | 204 ++--- .../generated/+test_model/AliasesWriterBase.m | 174 ++--- matlab/generated/+test_model/ArrayOrScalar.m | 8 + .../ArrayWithKeywordDimensionNames.m | 4 +- .../BenchmarkFloat256x256ReaderBase.m | 54 +- .../BenchmarkFloat256x256WriterBase.m | 46 +- .../BenchmarkFloatVlenReaderBase.m | 54 +- .../BenchmarkFloatVlenWriterBase.m | 46 +- .../BenchmarkInt256x256ReaderBase.m | 54 +- .../BenchmarkInt256x256WriterBase.m | 46 +- .../BenchmarkSimpleMrdReaderBase.m | 54 +- .../BenchmarkSimpleMrdWriterBase.m | 46 +- .../BenchmarkSmallRecordReaderBase.m | 54 +- ...chmarkSmallRecordWithOptionalsReaderBase.m | 54 +- ...chmarkSmallRecordWithOptionalsWriterBase.m | 46 +- .../BenchmarkSmallRecordWriterBase.m | 46 +- .../+test_model/DynamicNDArraysReaderBase.m | 90 +-- .../+test_model/DynamicNDArraysWriterBase.m | 80 +- .../generated/+test_model/EnumsReaderBase.m | 74 +- .../generated/+test_model/EnumsWriterBase.m | 66 +- .../+test_model/FixedArraysReaderBase.m | 106 +-- .../+test_model/FixedArraysWriterBase.m | 96 +-- .../+test_model/FixedVectorsReaderBase.m | 90 +-- .../+test_model/FixedVectorsWriterBase.m | 80 +- .../generated/+test_model/FlagsReaderBase.m | 82 +- .../generated/+test_model/FlagsWriterBase.m | 68 +- matlab/generated/+test_model/GenericRecord.m | 24 +- matlab/generated/+test_model/GenericUnion3.m | 12 + .../+test_model/GenericUnion3Alternate.m | 12 + .../GenericUnionWithRepeatedTypeParameters.m | 12 + .../+test_model/ImageFloatOrImageDouble.m | 8 + matlab/generated/+test_model/Int32OrFloat32.m | 8 + .../+test_model/Int32OrRecordWithVlens.m | 8 + .../+test_model/Int32OrSimpleRecord.m | 8 + matlab/generated/+test_model/IntArray.m | 4 +- matlab/generated/+test_model/IntFixedArray.m | 4 +- .../IntOrGenericRecordWithComputedFields.m | 8 + matlab/generated/+test_model/IntRank2Array.m | 4 +- matlab/generated/+test_model/MapOrScalar.m | 8 + matlab/generated/+test_model/MapsReaderBase.m | 90 +-- matlab/generated/+test_model/MapsWriterBase.m | 80 +- .../+test_model/NDArraysReaderBase.m | 106 +-- .../NDArraysSingleDimensionReaderBase.m | 90 +-- .../NDArraysSingleDimensionWriterBase.m | 80 +- .../+test_model/NDArraysWriterBase.m | 96 +-- .../generated/+test_model/NamedFixedNDArray.m | 4 +- matlab/generated/+test_model/NamedNDArray.m | 4 +- .../+test_model/NestedRecordsReaderBase.m | 42 +- .../+test_model/NestedRecordsWriterBase.m | 38 +- .../+test_model/OptionalVectorsReaderBase.m | 42 +- .../+test_model/OptionalVectorsWriterBase.m | 38 +- .../ProtocolWithComputedFieldsReaderBase.m | 42 +- .../ProtocolWithComputedFieldsWriterBase.m | 38 +- .../ProtocolWithKeywordStepsReaderBase.m | 70 +- .../ProtocolWithKeywordStepsWriterBase.m | 60 +- .../RecordContainingGenericRecords.m | 48 +- .../RecordContainingNestedGenericRecords.m | 38 +- .../+test_model/RecordNotUsedInProtocol.m | 20 +- .../+test_model/RecordWithAliasedGenerics.m | 20 +- .../RecordWithAliasedOptionalGenericField.m | 14 +- ...cordWithAliasedOptionalGenericUnionField.m | 14 +- .../generated/+test_model/RecordWithArrays.m | 62 +- .../RecordWithArraysSimpleSyntax.m | 62 +- .../+test_model/RecordWithComputedFields.m | 184 ++--- .../+test_model/RecordWithDynamicNDArrays.m | 26 +- .../generated/+test_model/RecordWithEnums.m | 26 +- .../+test_model/RecordWithFixedArrays.m | 26 +- .../+test_model/RecordWithFixedCollections.m | 20 +- .../+test_model/RecordWithFixedVectors.m | 26 +- .../+test_model/RecordWithGenericArrays.m | 32 +- .../RecordWithGenericFixedVectors.m | 16 +- .../+test_model/RecordWithGenericMaps.m | 20 +- .../RecordWithGenericVectorOfRecords.m | 12 +- .../+test_model/RecordWithGenericVectors.m | 16 +- .../+test_model/RecordWithKeywordFields.m | 20 +- .../+test_model/RecordWithNDArrays.m | 26 +- .../RecordWithNDArraysSingleDimension.m | 26 +- .../+test_model/RecordWithNamedFixedArrays.m | 26 +- .../+test_model/RecordWithOptionalFields.m | 26 +- .../RecordWithOptionalGenericField.m | 14 +- .../RecordWithOptionalGenericUnionField.m | 14 +- .../+test_model/RecordWithOptionalVector.m | 14 +- .../+test_model/RecordWithPrimitiveAliases.m | 62 +- .../+test_model/RecordWithPrimitives.m | 110 +-- .../generated/+test_model/RecordWithStrings.m | 20 +- .../RecordWithUnionsOfContainers.m | 26 +- .../+test_model/RecordWithVectorOfTimes.m | 14 +- .../generated/+test_model/RecordWithVectors.m | 26 +- .../+test_model/RecordWithVlenCollections.m | 20 +- .../generated/+test_model/RecordWithVlens.m | 26 +- .../+test_model/RecordWithVlensFixedArray.m | 4 +- .../+test_model/ScalarOptionalsReaderBase.m | 90 +-- .../+test_model/ScalarOptionalsWriterBase.m | 80 +- .../generated/+test_model/ScalarsReaderBase.m | 58 +- .../generated/+test_model/ScalarsWriterBase.m | 52 +- .../generated/+test_model/SimpleAcquisition.m | 32 +- .../+test_model/SimpleEncodingCounters.m | 32 +- .../+test_model/SimpleGenericsReaderBase.m | 184 ++--- .../+test_model/SimpleGenericsWriterBase.m | 160 ++-- matlab/generated/+test_model/SimpleRecord.m | 26 +- .../+test_model/SimpleRecordFixedArray.m | 4 +- .../+test_model/SmallBenchmarkRecord.m | 26 +- .../+test_model/StateTestReaderBase.m | 86 +-- .../+test_model/StateTestWriterBase.m | 74 +- .../StreamsOfAliasedUnionsReaderBase.m | 82 +- .../StreamsOfAliasedUnionsWriterBase.m | 68 +- .../+test_model/StreamsOfUnionsReaderBase.m | 82 +- .../+test_model/StreamsOfUnionsWriterBase.m | 68 +- .../generated/+test_model/StreamsReaderBase.m | 140 ++-- .../generated/+test_model/StreamsWriterBase.m | 112 +-- matlab/generated/+test_model/StringOrInt32.m | 8 + .../generated/+test_model/StringsReaderBase.m | 58 +- .../generated/+test_model/StringsWriterBase.m | 52 +- .../SubarraysInRecordsReaderBase.m | 58 +- .../SubarraysInRecordsWriterBase.m | 52 +- .../+test_model/SubarraysReaderBase.m | 172 ++--- .../+test_model/SubarraysWriterBase.m | 152 ++-- .../generated/+test_model/TupleWithRecords.m | 20 +- matlab/generated/+test_model/UOrV.m | 8 + .../generated/+test_model/UnionsReaderBase.m | 90 +-- .../generated/+test_model/UnionsWriterBase.m | 80 +- matlab/generated/+test_model/VectorOrScalar.m | 8 + .../generated/+test_model/VlensReaderBase.m | 90 +-- .../generated/+test_model/VlensWriterBase.m | 80 +- .../+tuples/+binary/TupleSerializer.m | 18 +- matlab/generated/+tuples/Tuple.m | 16 +- matlab/test/CodedStreamTest.m | 112 ++- matlab/test/ComputedFieldsTest.m | 4 +- matlab/test/SerializerShapeTest.m | 60 +- tooling/internal/matlab/binary/binary.go | 49 +- tooling/internal/matlab/mocks/mocks.go | 94 +-- .../internal/matlab/protocols/protocols.go | 108 +-- .../+binary/BinaryProtocolReader.m | 16 +- .../+binary/BinaryProtocolWriter.m | 27 +- .../static_files/+binary/BoolSerializer.m | 13 +- .../static_files/+binary/CodedInputStream.m | 17 +- .../static_files/+binary/CodedOutputStream.m | 43 +- .../+binary/Complexfloat32Serializer.m | 28 +- .../+binary/Complexfloat64Serializer.m | 23 +- .../static_files/+binary/DateSerializer.m | 8 +- .../static_files/+binary/DatetimeSerializer.m | 8 +- .../+binary/DynamicNDArraySerializer.m | 6 +- .../static_files/+binary/EnumSerializer.m | 34 +- .../matlab/static_files/+binary/Error.m | 6 - .../+binary/FixedNDArraySerializer.m | 23 +- .../+binary/FixedVectorSerializer.m | 101 +-- .../static_files/+binary/Float32Serializer.m | 15 +- .../static_files/+binary/Float64Serializer.m | 13 +- .../static_files/+binary/Int16Serializer.m | 11 +- .../static_files/+binary/Int32Serializer.m | 11 +- .../static_files/+binary/Int64Serializer.m | 11 +- .../static_files/+binary/Int8Serializer.m | 16 +- .../static_files/+binary/MapSerializer.m | 28 +- .../static_files/+binary/NDArraySerializer.m | 2 - .../+binary/NDArraySerializerBase.m | 19 +- .../static_files/+binary/NoneSerializer.m | 8 +- .../static_files/+binary/OptionalSerializer.m | 26 +- .../static_files/+binary/RecordSerializer.m | 22 +- .../static_files/+binary/StreamSerializer.m | 40 +- .../static_files/+binary/StringSerializer.m | 10 +- .../static_files/+binary/TimeSerializer.m | 8 +- .../static_files/+binary/TypeSerializer.m | 26 +- .../static_files/+binary/Uint16Serializer.m | 11 +- .../static_files/+binary/Uint32Serializer.m | 11 +- .../static_files/+binary/Uint64Serializer.m | 11 +- .../static_files/+binary/Uint8Serializer.m | 14 +- .../static_files/+binary/UnionSerializer.m | 52 +- .../static_files/+binary/VectorSerializer.m | 82 +- .../+binary/VectorSerializerBase.m | 95 +++ tooling/internal/matlab/static_files/Date.m | 22 +- .../internal/matlab/static_files/DateTime.m | 26 +- .../internal/matlab/static_files/KeyError.m | 6 - .../internal/matlab/static_files/Optional.m | 16 +- tooling/internal/matlab/static_files/Time.m | 22 +- tooling/internal/matlab/static_files/Union.m | 14 +- tooling/internal/matlab/types/types.go | 41 +- .../internal/python/static_files/_binary.py | 16 +- 375 files changed, 8700 insertions(+), 7188 deletions(-) create mode 100644 docs/matlab/evolution.md create mode 100644 docs/matlab/introduction.md create mode 100644 docs/matlab/language.md create mode 100644 docs/matlab/packages.md create mode 100644 docs/matlab/quickstart.md delete mode 100755 tooling/internal/matlab/static_files/+binary/Error.m create mode 100644 tooling/internal/matlab/static_files/+binary/VectorSerializerBase.m delete mode 100644 tooling/internal/matlab/static_files/KeyError.m diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index c07405f3..054fcc9a 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -20,6 +20,11 @@ export default defineConfig({ link: "/cpp/introduction", activeMatch: "/cpp/", }, + { + text: "Matlab Documentation", + link: "/matlab/introduction", + activeMatch: "/matlab/", + }, { text: "Reference", link: "/reference/binary", @@ -70,6 +75,26 @@ export default defineConfig({ }, { text: "Reference", link: "/reference/binary" }, ], + "/matlab/": [ + { + text: "Getting Started (Matlab)", + collapsed: false, + items: [ + { text: "Introduction", link: "/matlab/introduction" }, + { text: "Quick Start", link: "/matlab/quickstart" }, + ], + }, + { + text: "Yardl Guide (Matlab)", + collapsed: false, + items: [ + { text: "Packages", link: "/matlab/packages" }, + { text: "The Yardl Language", link: "/matlab/language" }, + // { text: "Schema Evolution", link: "/matlab/evolution" }, + ], + }, + { text: "Reference", link: "/reference/binary" }, + ], "/reference/": [ { text: "Reference", @@ -116,6 +141,10 @@ export default defineConfig({ if (documentId.startsWith("/yardl/python")) { return ["Python"].concat(fieldValue); } + + if (documentId.startsWith("/yardl/matlab")) { + return ["Matlab"].concat(fieldValue); + } } return fieldValue; diff --git a/docs/cpp/language.md b/docs/cpp/language.md index 2e848eda..6ec50b3e 100644 --- a/docs/cpp/language.md +++ b/docs/cpp/language.md @@ -95,7 +95,7 @@ Yardl has the following primitive types: | `int32` | | | `int` | Alias of `int32` | | `uint32` | | -| `uint` | Alias of `unit32` | +| `uint` | Alias of `uint32` | | `int64` | | | `long` | Alias of `int64` | | `uint64` | | @@ -249,7 +249,7 @@ Or with explicit values and an optional base type: ```yaml Permissions: !flags - base: unit8 + base: uint8 values: read: 1 write: 2 diff --git a/docs/cpp/packages.md b/docs/cpp/packages.md index 9410fb27..0bc07733 100644 --- a/docs/cpp/packages.md +++ b/docs/cpp/packages.md @@ -45,6 +45,11 @@ cpp: python: # The directory where the generated Python package will be written outputDir: ../path/relative/to/this/file + +# Settings for Matlab code generation (optional) +matlab: + # The directory where the generated Matlab packages will be written + outputDir: ../path/relative/to/this/file ``` In the future, this file will be able to reference previous versions of diff --git a/docs/index.md b/docs/index.md index 905344ad..9ad87d7b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -15,13 +15,16 @@ hero: - theme: brand text: Get Started With C++ link: /cpp/installation + - theme: brand + text: Get Started With Matlab + link: /matlab/quickstart - theme: alt text: View on GitHub link: https://github.com/microsoft/yardl features: - title: Multiple Languages - details: Define your model in a simple YAML syntax and generate clean Python and C++. + details: Define your model in a simple YAML syntax and generate clean Python, C++, and Matlab. - title: Multiple Formats details: Supports writing to a compact binary format, NDJSON, or HDF5. - title: Stream-Oriented diff --git a/docs/matlab/evolution.md b/docs/matlab/evolution.md new file mode 100644 index 00000000..47f3bb5c --- /dev/null +++ b/docs/matlab/evolution.md @@ -0,0 +1 @@ + diff --git a/docs/matlab/introduction.md b/docs/matlab/introduction.md new file mode 100644 index 00000000..3b31ecd2 --- /dev/null +++ b/docs/matlab/introduction.md @@ -0,0 +1,68 @@ +# Introduction + +Yardl is a simple schema language and command-line tool that generates domain +types and serialization code. + +:::details Simple Example +Given a Yardl definition like this: + +```yaml +# This is an example protocol, which is defined as a Header value +# followed by a stream of zero or more Sample values +MyProtocol: !protocol + sequence: + header: Header + samples: !stream + items: Sample + +# Header is a record with a single string field +Header: !record + fields: + subject: string + +# Sample is a record made up of a datetime and +# a vector of integers +Sample: !record + fields: + timestamp: datetime + data: int* +``` + +After running `yardl generate`, you can write code like the following to write +data to a file in a compact binary format: + +```matlab +addpath("./matlab/"); + +Sample = @sandbox.Sample; +samples = [Sample(yardl.DateTime.now(), [1, 2, 3]), Sample(yardl.DateTime.now(), [4, 5, 6])]; + +outfile = "sandbox.bin"; + +w = sandbox.binary.MyProtocolWriter(outfile); +w.write_header(sandbox.Header("Me")); +w.write_samples(samples); +w.end_samples(); +w.close(); +``` + +And then another script can read it in from the file: + +```matlab +addpath("./matlab/"); + +infile = "sandbox.bin"; + +r = sandbox.binary.MyProtocolReader(infile); +disp(r.read_header()); +while r.has_samples() + sample = r.read_samples(); + disp(sample.timestamp.to_datetime()); + disp(sample.data); +end +r.close(); +``` + +::: + + diff --git a/docs/matlab/language.md b/docs/matlab/language.md new file mode 100644 index 00000000..3adc466a --- /dev/null +++ b/docs/matlab/language.md @@ -0,0 +1,718 @@ +# The Yardl Language + +:::info Note + +The Matlab implementation supports the binary format, but does not +currently support HDF5 or NDJSON. + +::: + +Yardl model files use YAML syntax and are required to have either a `.yml` or +`.yaml` file extension. + +To efficiently work with Yardl, we recommend that you run the following from the +yardl package (model) directory: + +```bash +yardl generate --watch +``` + +This watches the directory for changes and generates code whenever a file is +saved. This allows you to get rapid feedback as you experiment. + +Comments placed above top-level types and their fields are captured and added to +the generated code as docstrings. + +`yardl generate` only generates code once the model files in the package have +been validated. It will write out any validation errors to standard error. + +## Protocols + +As explained in the [quick start](quickstart), protocols define a sequence of +values, called "steps", that are required to be transmitted, in order. They are +defined like this: + +```yaml +MyProtocol: !protocol + sequence: + a: int + b: !stream + items: float + c: !stream + items: string +``` + +In the example, the first step is a single integer named `a`. Following that +will be a stream (named `b`) of zero or more floating-point numbers, and a +stream (named `c`) of strings. + +You can write to this protocol like this: + +```matlab +w = sandbox.binary.MyProtocolWriter("sandbox.bin"); + +w.write_a(1); % Write single protocol step + +w.write_b(1:10); % Write stream items +w.end_b(); % Call stream end method to signal that it is complete + +w.write_c(["a", "b"]); % Write stream items +w.write_c(["c", "d"]); % Write more stream items +w.end_c(); % Signal that the 'c' stream is complete + +w.close(); % Must close the Writer +``` + +And read the data back like this: + +```matlab +r = sandbox.binary.MyProtocolReader("sandbox.bin"); + +disp(r.read_a()); % Read single protocol step + +while r.has_b() % Check whether stream has ended + disp(r.read_b()); % Read stream items in a loop +end + +while r.has_c() % Check whether stream has ended + disp(r.read_c()); % Read stream items in a loop +end + +r.close(); % Must close the reader +``` + +It is an error to attempt to read or write a protocol's steps out of order or to +close a reader or writer without having written or read all steps. + +```matlab +w = sandbox.binary.MyProtocolWriter("sandbox.bin"); +w.write_b(1:10); % Error: Expected to call to 'write_a' but received call to 'write_b' // [!code error] +``` + +Generated protocol readers have a `copy_to()` method that allows you to copy the +contents of the protocol to another protocol writer. This makes is easy to, say, +read from an NDJSON file and send the data in the binary format over a network +connection. + +## Records + +Records have fields and, optionally, [computed fields](#computed-fields). In +generated Matlab code, they map to class definitions. + +Fields have a name and can be of any primitive or compound type. For example: + +```yaml +MyRecord: !record + fields: + myIntField: int + myStringField: string +``` + +Records must be declared at the top level and cannot be inlined. For example, +this is not supported: + +```yaml +RecordA: !record + fields: + recA: !record # NOT SUPPORTED! // [!code error] + fields: // [!code error] + a: int // [!code error] + recB: RecordB # But this is fine. + +RecordB: !record + fields: + c: int +``` + +Note that Yardl does not support type inheritance. + +The generated class constructors take arguments for each field and +in most cases they are optional. They are only required when the field type is +[generic](#generics). + +## Primitive Types + +Yardl has the following primitive types: + +| Yardl Type | Comment | Matlab Type | +| ---------------- | ----------------------------------------------------------------------- | -------------------| +| `bool` | | `logical` | +| `int8` | | `int8` | +| `uint8` | | `uint8` | +| `byte` | Alias of `uint8` | | +| `int16` | | `int16` | +| `uint16` | | `uint16` | +| `int32` | | `int32` | +| `int` | Alias of `int32` | | +| `uint32` | | `uint32` | +| `uint` | Alias of `unit32` | | +| `int64` | | `int64` | +| `long` | Alias of `int64` | | +| `uint64` | | `uint64` | +| `ulong` | Alias of `uint64` | | +| `size` | Equivalent to `uint64` | | +| `float32` | | `single` | +| `float` | Alias of `float32` | | +| `float64` | | `double` | +| `double` | Alias of `float64` | | +| `complexfloat32` | A complex number where each component is a 32-bit floating-point number | `complex(single)` | +| `complexfloat` | Alias of `complexfloat32` | | +| `complexfloat64` | A complex number where each component is a 64-bit floating-point number | `complex(double)` | +| `complexdouble` | Alias of `complexfloat64` | | +| `string` | | `string` | +| `date` | A number of days since the epoch | `yardl.Date` | +| `time` | A number of nanoseconds after midnight | `yardl.Time` | +| `datetime` | A number of nanoseconds since the epoch | `yardl.DateTime` | + +`yardl.Date`, `yardl.Time`, and `yardl.DateTime` are custom classes because +Yardl uses nanosecond precision and Matlab's `datetime` has only microsecond precision. +Each of them can be easily converted to a Matlab `datetime` by calling its static `to_datetime()` method. + +## Optional Types + +If a value is optional, its type has a `?` suffix. + +```yaml +Rec: !record + fields: + optionalInt: int? +``` + +They can also be expressed as a YAML array of length two, with `null` in the +first position: + +```yaml +Rec: !record + fields: + optionalInt: [null, int] # equivalent to the example above +``` + +In Matlab, optional values can be instantiated using `yardl.Optional(value)`, and have the value `yardl.None` when not set. + +## Unions + +Optional types are a special case of unions, which are used when a value can be +one of several types: + +```yaml +Rec: !record + fields: + intOrFloat: [int, float] + intOrFloatExpandedForm: + - int + - float + nullableIntOrFloat: + - null + - int + - float +``` + +The `null` type in the example above means that no value (`yardl.None` in Matlab) is +also a possibility. + +### Generated Union Types + +For the Matlab codegen, we represent unions as a [tagged +union](https://en.wikipedia.org/wiki/Tagged_union) and we generate a class for +each union in a model. In the example above, the union `[int, float]` would have +a class named `Int32OrFloat32`. Each union case then has a corresponding static +constructor method in the union class. + +This union class can be used like this: + +```matlab +function process_my_union(u) + if u.isInt32() + fprintf("%d is an int32\n", u.value); + elseif u.isFloat32() + fprintf("%f is a float\n", u.value); + else + error("Unrecognized union type"); + end +end + +process_my_union(sandbox.Int32OrFloat32.Int32(2)) +process_my_union(sandbox.Int32OrFloat32.Float32(7.9)) +``` + +### Union Tag Names + +The type case name used in union classes (`Int32` and `Float32` in the example +above) is derived from the name of the type of each case. This means that you +will get an error when attempting to use a type in a union that is made up of +symbols that are not valid in an identifier. For example: + +```yaml +Rec: !record + fields: + floatArrayOrDoubleArray: + - float[] # Error! // [!code error] + - double[] # Error! // [!code error] +``` + +There are two simple solutions to this problem. The first is to give explicit +tag names to each union case using the expanded `!union` syntax: + +```yaml +Rec: !record + fields: + floatArrayOrDoubleArray: !union + floatArray: float[] + doubleArray: double[] +``` + +The second option is to create [aliases](#type-aliases) for the types: + +```yaml + +FloatArray: float[] +DoubleArray: double[] + +Rec: !record + fields: + floatArrayOrDoubleArray: + - FloatArray + - DoubleArray +``` + +The first option is usually preferred, unless the type alias is going to be used +elsewhere. In both cases, the union type will be `FloatArrayOrDoubleArray` and +the cases `FloatArray` and `DoubleArray`. + +If you don't like the generated name you can give the union an +[alias](#type-aliases): + +```yaml +ArrayUnion: !union + floatArray: float[] + doubleArray: double[] + +Rec: !record + fields: + arrayUnion: ArrayUnion +``` + +Now the union class is `ArrayUnion` with case types `FloatArray` and `DoubleArray`. + +## Enums + +Enums can be defined as a list of values: + +```yaml +Fruits: !enum + values: + - apple + - banana + - pear +``` + +Enums are generated as custom Matlab class definitions, *not* using Matlab's `enumeration` support, which doesn't allow integer values that are not explicitly defined in the enum definition. + +In Matlab, use the enum constructor to create new values, or the generated static methods for predefined values: + +```matlab +fruit1 = sandbox.Fruits.APPLE; +fruit2 = sandbox.Fruits.BANANA; +newFruit = sandbox.Fruits(42); +``` + +You can optionally specify the underlying type of the enum and give each symbol +an integer value: + +```yaml +UInt64Enum: !enum + base: uint64 + values: + a: 0x1 + b: 0x2 + c: 20 +``` + +Any integer values that are left blank will be: + +- 0 if the first value +- 1 greater than the previous value if positive +- 1 less that the previous value if negative. + +## Flags + +Flags are similar to enums but are meant to represent a bit field, meaning +multiple values can be set at once. + +They can be defined with automatic values: + +```yaml +Permissions: !flags + values: + - read + - write + - execute +``` + +Or with explicit values and an optional base type: + +```yaml +Permissions: !flags + base: uint8 + values: + read: 1 + write: 2 + execute: +``` + +Any value without an integer value will have the next power of two bit set that +is greater than the previous value. In the example above, `execute` would have +the value 4. + +Like Enums, Flags are generated as custom Matlab class definitions. + +Example usage: + +```matlab +permissions = bitor(sandbox.Permissions.READ, sandbox.Permissions.EXECUTE); +# ... +if bitand(sandbox.Permissions.READ, permissions) + # ... +end +``` + +## Maps + +Maps, also known as dictionaries or associative arrays, are an unordered +collection of key-value pairs. + +They can be declared like this: + +```yaml +MyMap: string->int +``` + +Or declared with the expanded syntax: + +```yaml +MyMap: !map + keys: string + values: int +``` + +Keys are required to be scalar primitive types. + +These map to the Matlab `dictionary` type. + +:::info Note + +Matlab's `dictionary` type was introduced in Matlab r2022b, effectively replacing +the `containers.Map` type. The `containers.Map` does not provide sufficient +support for yardl types (including primitive strings) as keys or values. + +::: + + +## Vectors + +Vectors are one-dimensional lists. They can optionally have a fixed length. The +simple syntax for vectors is `*[length]`. + +For example: + +```yaml +MyRec: !record + fields: + vec1: int* + vec2: int*10 +``` + +In the example above, `vec1` is a vector of integers of unknown length and +`vec2` has length 10. The expanded syntax for vectors is: + +```yaml +MyRec: !record + fields: + vec1: !vector + items: int + vec2: !vector + items: int + length: 10 +``` + +Both flavors of vectors are generated as Matlab arrays. +The generated protocol readers/writers also support cell arrays as vectors. +When working with vectors of vectors, the last dimension represents the outer vector: + +```matlab +% Create a vector of integers +vs = [1, 2, 3, 4]; + +% Create a vector of 3 vectors, each of length 4 +vs = [[1; 2; 3; 4], [5; 6; 7; 8], [9; 10; 11; 12]]; + +% Create a vector of 3 vectors, each of varying length +vs = { [1, 2, 3], [4, 5], [7] }; +``` + +## Arrays + +Arrays are multidimensional and map to Matlab arrays. Like vectors, there is a simple +syntax and an expanded syntax for declaring them. Both syntaxes are shown in the +examples below. + +There are three kinds of arrays. They can be of a fixed size: + +```yaml +MyRec: !record + fields: + fixedNdArray: float[3, 4] + fixedNdArrayExpandedSyntax: !array + items: float + dimensions: [3, 4] +``` + +Or the size might not be fixed but the number of dimensions is known: + +```yaml +MyRec: !record + fields: + ndArray: float[,] + ndArrayExpandedSyntax: !array + items: float + dimensions: 2 +``` + +Or finally, the number of dimensions may be unknown as well: + +```yaml +MyRec: !record + fields: + dynamicNdArray: float[] + dynamicNdArrayExpandedSyntax: !array + items: float +``` + +Dimensions can be given names, which can be used in [computed +field](#computed-fields) expressions. + +```yaml +MyRec: !record + fields: + fixedNdArray: float[x:3, y:4] + fixedNdArrayExpandedSyntax: !array + items: float + dimensions: + x: 3 + y: 4 + ndArray: !array + items: float + dimensions: [x, y] + ndArrayExpandedSyntax: !array + items: float + dimensions: [x, y] + ndArrayExpandedSyntaxAlternate: !array + items: float + dimensions: + x: + y: +``` + +In the simple syntax, `int[]` means an int array with an unknown number of +dimensions, and `int[,]` means an int array with two dimensions. To declare an +array with 1 dimension of unknown length, you can either give the dimension a +name (`int[x]`) or use parentheses to disambiguate from an empty set of +dimensions: `int[()]`. + +### Matlab Arrays + +In Matlab, arrays are always created with dimensions reversed with respect to the model definition. +This means that an array defined as `Image: double[x, y, z]` has the shape `[z, y, x]` in Matlab. + +This convention maintains consistency across yardl with respect to indexing +multi-dimensional arrays, and provides the best serialization performance, since +Yardl currently supports only C-order when serializing multi-dimensional arrays. +Matlab, however, uses Fortran-order to store and serialize multi-dimensional arrays. + +As a side effect, if you define a *matrix* in yardl as `matrix: double[row, col]`, +you will need to transpose the array in Matlab. + +Example: + +```yaml +MyProtocol: !protocol + sequence: + fixedArray: double[x:2, y:4] +``` + +```matlab +>> r = sandbox.binary.MyProtocolReader(filename); +>> image = r.read_image(); +>> size(image) + +ans = + + 4 2 + +>> r.close(); +``` + +To create an array with more than two dimensions, use Matlab pages: + +```yaml +ndarray: double[2, 3, 4] +``` + +```matlab +>> ndarray(:, :, 1) = [[ 1; 2; 3; 4], [ 5; 6; 7; 8], [ 9; 10; 11; 12]]; +>> ndarray(:, :, 2) = [[13; 14; 15; 16], [17; 18; 19; 20], [21; 22; 23; 24]]; +>> size(ndarray) + +ans = + + 4 3 2 + +``` + +## Type Aliases + +Any type can be given one or more aliases: + +```yaml +FloatArray: float[] + +SignedInteger: [int8, int16, int32, int64] + +Id: string +Name: string +``` + +This simply gives another name to a type, so the `Name` type above is no +different from the `string` type. + +In Matlab, aliases are generated in one of three forms: +1. Union class definition for union types +2. Function wrapper for optionals/vectors/arrays +3. Subclass definitions for all other types + +In all cases, you can use the generated syntax to construct the aliased type. + +## Computed Fields + +In addition to fields, records can contain computed fields. These are simple expressions +over the record's other (computed) fields. + +```yaml +MyRec: !record + fields: + arrayField: int[x,y] + computedFields: + accessArray: arrayField + accessArrayElement: arrayField[0, 1] + accessArrayElementByName: arrayField[x:0, y:1] + accessArrayElementAndConvert: arrayField[0, 1] as int + sizeOfArrayField: size(arrayField) + sizeOfFirstDimension: size(arrayField, 0) + sizeOfXDimension: size(arrayField, 'x') + basicArithmentic: arrayField[0, 1] * 2 +``` + +The following expression types are supported: +- Numeric literals, such as `1`, `-1`, `0xF`, `3.4`, and `-2e-3`. +- String literals, such as `"abc"` and `'abc'`. +- Simple arithmethic expresions, such as `1 + 2`, `2.0 * 3`, and `2 ** 3` (`**` + is the power operator and yields a `float64`). +- Type conversions using the `as` operator, such as `1 as float64`. +- Field accesses, such as `myField`. You can access a field on another field + using the `.` operator, such as `myField.anotherField`. +- Array and vector element access, such as `arrayField[0, 1]` or + `arrayField[x:0, y:1]` to identify the dimensions by name. +- Function calls: + - `size(vector)`: returns the size (length) of the vector. + - `size(array)`: returns the total size of the array. + - `size(array, integer)`: returns the size of the array's dimension at the given + index. + - `size(array, string)`: returns the size of the array's dimension with the + given name. + - `dimensionIndex(array, string)` returns the index of the dimension with the + given name. + - `dimensionCount(array)` returns the dimension count of the array. + +To work with union or optional types, you need to use a switch expression with type pattern +matching: + +```yaml +NamedArray: int[x, y] + +MyRec: !record + fields: + myUnion: [null, int, NamedArray] + computedFields: + myUnionSize: + !switch myUnion: + int: 1 # if the union holds an int + NamedArray arr: size(arr) # if it's a NamedArray. Note the variable declaration. + _: 0 # all other cases (here it's just null) +``` + +Computed fields become parameterless methods on the generated Python class. Here +is an example of invoking the field from the preceding Yardl definition: + +```matlab +>>> rec = sandbox.MyRec(sandbox.Int32OrNamedArray.Int32(4)); +>>> rec.my_union_size() + + ans = + + 1 +``` + +## Generics + +Yardl supports generic types. + +```yaml +Point: !record + fields: + x: T + y: T + +MyProtocol: !protocol + sequence: + point: Point +``` + +Here `Point` is a generic type with one type parameter `T`, while `MyProtocol` +references `Point` with `int` as its type argument. + +Records and type aliases can be generic, but enums, flags, and protocols cannot. + +In Matlab, generics are treated as open types. +Type validation occurs when values are written using a ProtocolWriter. + +```matlab +p = sandbox.Point(1, 2); + +w = sandbox.binary.MyProtocolWriter("sandbox.bin"); +w.write_point(p); +w.close(); + +p = sandbox.Point("a", "b"); +w = sandbox.binary.MyProtocolWriter("sandbox.bin"); +w.write_point(p); % Error: ...Value must be of type int32 or be convertible to int32. // [!code error] +w.close(); +``` + +## Imported Types + +Types can be imported from other packages (see [Packages](packages)) and referenced +through their respective yardl namespace: + +```yaml +MyTuple: BasicTypes.Tuple +``` + +Imported types are likewise namespaced in Matlab packages: + +```matlab +t1 = basic_types.Tuple("John Smith", 42); +t2 = sandbox.MyTuple("John Smith", 42); +assert(t1 == t2); +``` + +Note that yardl ignores protocols defined in imported packages. diff --git a/docs/matlab/packages.md b/docs/matlab/packages.md new file mode 100644 index 00000000..ee39bceb --- /dev/null +++ b/docs/matlab/packages.md @@ -0,0 +1 @@ + diff --git a/docs/matlab/quickstart.md b/docs/matlab/quickstart.md new file mode 100644 index 00000000..b01d4db9 --- /dev/null +++ b/docs/matlab/quickstart.md @@ -0,0 +1,205 @@ +# Quick Start + +## Installation + + + +### Dependencies + +The generated Matlab code requires Matlab R2022b or newer. + +## Getting our Feet Wet + +::: info Note +Yardl is currently based on YAML. If you are new to YAML, you can get an +overview [here](https://learnxinyminutes.com/docs/yaml/). +::: + +To get started, create a new empty directory and `cd` into it. Then run: + +``` bash +yardl init playground +``` + +This creates the initial structure and files for our project: + +```txt +$ tree . +. +└── model + ├── model.yml + └── _package.yml +``` + +The Yardl model package is in the `model` directory. + +`_package.yml` is the package's manifest. + +``` yaml +namespace: Playground + +cpp: + sourcesOutputDir: ../cpp/generated + +python: + outputDir: ../python + +matlab: + outputDir: ../matlab +``` + +It specifies the package's namespace along with code generation settings. The +`matlab.outputDir` property specifies where the generated Matlab package should +go. If you are not interested in generating Python or C++ code, you can remove +the corresponding property from the file: + +``` yaml +namespace: Playground + +cpp: // [!code --] + sourcesOutputDir: ../cpp/generated // [!code --] + +python: // [!code --] + outputDir: ../python // [!code --] + +matlab: + outputDir: ../matlab +``` + +All other `.yml` and `.yaml` files in the directory are assumed to be yardl +model files. The contents of `model.yml` look like this: + +```yaml +# This is an example protocol, which is defined as a Header value +# followed by a stream of zero or more Sample values +MyProtocol: !protocol + sequence: + + # A Header value + header: Header + + # A stream of Samples + samples: !stream + items: Sample + +# Header is a record with a single string field +Header: !record + fields: + subject: string + +# Sample is a record made up of a datetime and +# a vector of integers +Sample: !record + fields: + + # The time the sample was taken + timestamp: datetime + + # A vector of integers + data: int* +``` + +`!protocol`, `!stream` and `!record` are custom YAML tags, which describe the +type of the YAML node that follows. + +`MyProtocol` is a protocol, which is a defined sequence of values that can be +written to or read from a file or binary stream (e.g. over a network +connection). This example protocol says that there will be one `Header` value +followed by an unknown number of `Sample`s. `Header` and `Sample` are records. + +To generate Matlab code for this model, `cd` into the `model` directory and run: + +```bash +yardl generate +``` + +This will generate a Matlab package in the `outputDir` directory: + +```txt +$ tree . +. +├── +playground +│ ├── +binary +│ │ ├── HeaderSerializer.m +│ │ ├── MyProtocolReader.m +│ │ ├── MyProtocolWriter.m +│ │ └── SampleSerializer.m +│ ├── Header.m +│ ├── MyProtocolReaderBase.m +│ ├── MyProtocolWriterBase.m +│ └── Sample.m +└── +yardl + ├── +binary + │ └── ... + └── ... +``` + +The top-level package, e.g. `+playground`, contains the class definitions for (1) the non-protocol types defined in our model (in this case, `Header.m` and `Sample.m`), and (2) the abstract protocol reader and writer classes, from which concrete implementations inherit from (e.g. in the `+binary` subpackage). + +The adjacent `+yardl` package contains definitions for primitive types, error handling, and serializers. + +To use these packages from outside of the `matlab` directory, use Matlab's `addpath` function, e.g. `addpath("../path/to/parent/directory");`. + +Ok, let's write some code! In our `matlab` directory (containing the generated +`+playground` package), create `run_playground.m` that looks like this: + +```matlab +Sample = @playground.Sample; +samples = [Sample(yardl.DateTime.now(), [1, 2, 3]), Sample(yardl.DateTime.now(), [4, 5, 6])]; + +path = "playground.bin"; + +w = playground.binary.MyProtocolWriter(path); +w.write_header(playground.Header("Me")); +w.write_samples(samples); +w.end_samples(); +w.close(); + +r = playground.binary.MyProtocolReader(path); +disp(r.read_header()); +while r.has_samples() + sample = r.read_samples(); + disp(sample.timestamp.to_datetime()); + disp(sample.data); +end +r.close(); +``` + +Run this directly in Matlab, e.g. `run_playground`, or on the command-line with `matlab -batch run_playground`. + +You can inspect the binary file our code produced with: + +```bash +hexdump -C playground.bin +``` + +Note that the binary file contains a JSON representation of the protocol's +schema. This allows code that was not previously aware of this protocol to +deserialize the contents. + + diff --git a/docs/parts/intro-core.md b/docs/parts/intro-core.md index be217adf..4d27d70d 100644 --- a/docs/parts/intro-core.md +++ b/docs/parts/intro-core.md @@ -33,9 +33,6 @@ expect to introduce breaking changes until the project reaches V1. We currently support C++ and Python codegen. Other planned features include: -- Reading data with a different schema version -- MATLAB support -- References between packages -- Validating schema evolution is non-breaking +- Python and Matlab support for reading data with a different schema version - Constraints - Improvements to the language and editing experience diff --git a/docs/python/language.md b/docs/python/language.md index cad6b1a1..33302c0e 100644 --- a/docs/python/language.md +++ b/docs/python/language.md @@ -133,7 +133,7 @@ Yardl has the following primitive types: | `int32` | | `yardl.Int32` | `int` | | `int` | Alias of `int32` | | | | `uint32` | | `yardl.UInt32` | `int` | -| `uint` | Alias of `unit32` | | | +| `uint` | Alias of `uint32` | | | | `int64` | | `yardl.Int64` | `int` | | `long` | Alias of `int64` | | | | `uint64` | | `yardl.UInt64` | `int` | @@ -391,7 +391,7 @@ Or with explicit values and an optional base type: ```yaml Permissions: !flags - base: unit8 + base: uint8 values: read: 1 write: 2 diff --git a/matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m b/matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m index 8225a1c8..680eeee0 100644 --- a/matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m +++ b/matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m @@ -2,18 +2,22 @@ classdef GenericRecordWithComputedFieldsSerializer < yardl.binary.RecordSerializer methods - function obj = GenericRecordWithComputedFieldsSerializer(t0_serializer, t1_serializer) + function self = GenericRecordWithComputedFieldsSerializer(t0_serializer, t1_serializer) field_serializers{1} = yardl.binary.UnionSerializer('basic_types.T0OrT1', {t0_serializer, t1_serializer}, {@basic_types.T0OrT1.T0, @basic_types.T0OrT1.T1}); - obj@yardl.binary.RecordSerializer('basic_types.GenericRecordWithComputedFields', field_serializers); + self@yardl.binary.RecordSerializer('basic_types.GenericRecordWithComputedFields', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'basic_types.GenericRecordWithComputedFields')); - obj.write_(outstream, value.f1) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) basic_types.GenericRecordWithComputedFields + end + self.write_(outstream, value.f1) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = basic_types.GenericRecordWithComputedFields(field_values{:}); end end diff --git a/matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m b/matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m index 3e51797c..e5088ca7 100644 --- a/matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m +++ b/matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m @@ -2,20 +2,24 @@ classdef RecordWithUnionsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithUnionsSerializer() + function self = RecordWithUnionsSerializer() field_serializers{1} = yardl.binary.UnionSerializer('basic_types.Int32OrString', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, yardl.binary.StringSerializer}, {yardl.None, @basic_types.Int32OrString.Int32, @basic_types.Int32OrString.String}); field_serializers{2} = yardl.binary.UnionSerializer('basic_types.TimeOrDatetime', {yardl.binary.TimeSerializer, yardl.binary.DatetimeSerializer}, {@basic_types.TimeOrDatetime.Time, @basic_types.TimeOrDatetime.Datetime}); field_serializers{3} = yardl.binary.UnionSerializer('basic_types.GenericNullableUnion2', {yardl.binary.NoneSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer), yardl.binary.EnumSerializer('basic_types.DaysOfWeek', @basic_types.DaysOfWeek, yardl.binary.Int32Serializer)}, {yardl.None, @basic_types.GenericNullableUnion2.T1, @basic_types.GenericNullableUnion2.T2}); - obj@yardl.binary.RecordSerializer('basic_types.RecordWithUnions', field_serializers); + self@yardl.binary.RecordSerializer('basic_types.RecordWithUnions', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'basic_types.RecordWithUnions')); - obj.write_(outstream, value.null_or_int_or_string, value.date_or_datetime, value.null_or_fruits_or_days_of_week) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) basic_types.RecordWithUnions + end + self.write_(outstream, value.null_or_int_or_string, value.date_or_datetime, value.null_or_fruits_or_days_of_week) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = basic_types.RecordWithUnions(field_values{:}); end end diff --git a/matlab/generated/+basic_types/GenericNullableUnion2.m b/matlab/generated/+basic_types/GenericNullableUnion2.m index 0409861e..a89ab11c 100644 --- a/matlab/generated/+basic_types/GenericNullableUnion2.m +++ b/matlab/generated/+basic_types/GenericNullableUnion2.m @@ -25,6 +25,14 @@ end methods + function res = isT1(self) + res = self.index == 1; + end + + function res = isT2(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'basic_types.GenericNullableUnion2') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+basic_types/GenericRecordWithComputedFields.m b/matlab/generated/+basic_types/GenericRecordWithComputedFields.m index 9e61f504..bd7af45b 100644 --- a/matlab/generated/+basic_types/GenericRecordWithComputedFields.m +++ b/matlab/generated/+basic_types/GenericRecordWithComputedFields.m @@ -6,8 +6,8 @@ end methods - function obj = GenericRecordWithComputedFields(f1) - obj.f1 = f1; + function self = GenericRecordWithComputedFields(f1) + self.f1 = f1; end function res = type_index(self) @@ -24,14 +24,14 @@ end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'basic_types.GenericRecordWithComputedFields') && ... - isequal(obj.f1, other.f1); + isequal(self.f1, other.f1); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+basic_types/GenericUnion2.m b/matlab/generated/+basic_types/GenericUnion2.m index 830be8e5..9261589c 100644 --- a/matlab/generated/+basic_types/GenericUnion2.m +++ b/matlab/generated/+basic_types/GenericUnion2.m @@ -25,6 +25,14 @@ end methods + function res = isT1(self) + res = self.index == 1; + end + + function res = isT2(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'basic_types.GenericUnion2') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+basic_types/Int32OrString.m b/matlab/generated/+basic_types/Int32OrString.m index 0a7b74d1..819da9e5 100644 --- a/matlab/generated/+basic_types/Int32OrString.m +++ b/matlab/generated/+basic_types/Int32OrString.m @@ -25,6 +25,14 @@ end methods + function res = isInt32(self) + res = self.index == 1; + end + + function res = isString(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'basic_types.Int32OrString') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+basic_types/RecordWithUnions.m b/matlab/generated/+basic_types/RecordWithUnions.m index edc67bdd..10b4d81b 100644 --- a/matlab/generated/+basic_types/RecordWithUnions.m +++ b/matlab/generated/+basic_types/RecordWithUnions.m @@ -8,28 +8,28 @@ end methods - function obj = RecordWithUnions(null_or_int_or_string, date_or_datetime, null_or_fruits_or_days_of_week) + function self = RecordWithUnions(null_or_int_or_string, date_or_datetime, null_or_fruits_or_days_of_week) if nargin > 0 - obj.null_or_int_or_string = null_or_int_or_string; - obj.date_or_datetime = date_or_datetime; - obj.null_or_fruits_or_days_of_week = null_or_fruits_or_days_of_week; + self.null_or_int_or_string = null_or_int_or_string; + self.date_or_datetime = date_or_datetime; + self.null_or_fruits_or_days_of_week = null_or_fruits_or_days_of_week; else - obj.null_or_int_or_string = yardl.None; - obj.date_or_datetime = basic_types.TimeOrDatetime.Time(yardl.Time()); - obj.null_or_fruits_or_days_of_week = yardl.None; + self.null_or_int_or_string = yardl.None; + self.date_or_datetime = basic_types.TimeOrDatetime.Time(yardl.Time()); + self.null_or_fruits_or_days_of_week = yardl.None; end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'basic_types.RecordWithUnions') && ... - all([obj.null_or_int_or_string] == [other.null_or_int_or_string]) && ... - all([obj.date_or_datetime] == [other.date_or_datetime]) && ... - all([obj.null_or_fruits_or_days_of_week] == [other.null_or_fruits_or_days_of_week]); + all([self.null_or_int_or_string] == [other.null_or_int_or_string]) && ... + all([self.date_or_datetime] == [other.date_or_datetime]) && ... + all([self.null_or_fruits_or_days_of_week] == [other.null_or_fruits_or_days_of_week]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+basic_types/T0OrT1.m b/matlab/generated/+basic_types/T0OrT1.m index c677eb94..3115edea 100644 --- a/matlab/generated/+basic_types/T0OrT1.m +++ b/matlab/generated/+basic_types/T0OrT1.m @@ -25,6 +25,14 @@ end methods + function res = isT0(self) + res = self.index == 1; + end + + function res = isT1(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'basic_types.T0OrT1') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+basic_types/TimeOrDatetime.m b/matlab/generated/+basic_types/TimeOrDatetime.m index f84f2d55..c1951beb 100644 --- a/matlab/generated/+basic_types/TimeOrDatetime.m +++ b/matlab/generated/+basic_types/TimeOrDatetime.m @@ -25,6 +25,14 @@ end methods + function res = isTime(self) + res = self.index == 1; + end + + function res = isDatetime(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'basic_types.TimeOrDatetime') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+image/FloatImage.m b/matlab/generated/+image/FloatImage.m index dcefa50e..f73dc355 100644 --- a/matlab/generated/+image/FloatImage.m +++ b/matlab/generated/+image/FloatImage.m @@ -1,6 +1,8 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. function a = FloatImage(array) - assert(isa(array, 'single')); + arguments + array single + end a = array; end diff --git a/matlab/generated/+image/IntImage.m b/matlab/generated/+image/IntImage.m index f419feb9..a6cd19c4 100644 --- a/matlab/generated/+image/IntImage.m +++ b/matlab/generated/+image/IntImage.m @@ -1,6 +1,8 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. function a = IntImage(array) - assert(isa(array, 'int32')); + arguments + array int32 + end a = array; end diff --git a/matlab/generated/+test_model/+binary/AdvancedGenericsReader.m b/matlab/generated/+test_model/+binary/AdvancedGenericsReader.m index f39d020b..ecc960ca 100644 --- a/matlab/generated/+test_model/+binary/AdvancedGenericsReader.m +++ b/matlab/generated/+test_model/+binary/AdvancedGenericsReader.m @@ -11,36 +11,36 @@ end methods - function obj = AdvancedGenericsReader(filename) - obj@test_model.AdvancedGenericsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.AdvancedGenericsReaderBase.schema); - obj.float_image_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), 2); - obj.generic_record_1_serializer = test_model.binary.GenericRecordSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); - obj.tuple_of_optionals_serializer = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); - obj.tuple_of_optionals_alternate_syntax_serializer = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); - obj.tuple_of_vectors_serializer = tuples.binary.TupleSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), yardl.binary.VectorSerializer(yardl.binary.Float32Serializer)); + function self = AdvancedGenericsReader(filename) + self@test_model.AdvancedGenericsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.AdvancedGenericsReaderBase.schema); + self.float_image_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), 2); + self.generic_record_1_serializer = test_model.binary.GenericRecordSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + self.tuple_of_optionals_serializer = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); + self.tuple_of_optionals_alternate_syntax_serializer = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); + self.tuple_of_vectors_serializer = tuples.binary.TupleSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), yardl.binary.VectorSerializer(yardl.binary.Float32Serializer)); end end methods (Access=protected) - function value = read_float_image_image_(obj) - value = obj.float_image_image_serializer.read(obj.stream_); + function value = read_float_image_image_(self) + value = self.float_image_image_serializer.read(self.stream_); end - function value = read_generic_record_1_(obj) - value = obj.generic_record_1_serializer.read(obj.stream_); + function value = read_generic_record_1_(self) + value = self.generic_record_1_serializer.read(self.stream_); end - function value = read_tuple_of_optionals_(obj) - value = obj.tuple_of_optionals_serializer.read(obj.stream_); + function value = read_tuple_of_optionals_(self) + value = self.tuple_of_optionals_serializer.read(self.stream_); end - function value = read_tuple_of_optionals_alternate_syntax_(obj) - value = obj.tuple_of_optionals_alternate_syntax_serializer.read(obj.stream_); + function value = read_tuple_of_optionals_alternate_syntax_(self) + value = self.tuple_of_optionals_alternate_syntax_serializer.read(self.stream_); end - function value = read_tuple_of_vectors_(obj) - value = obj.tuple_of_vectors_serializer.read(obj.stream_); + function value = read_tuple_of_vectors_(self) + value = self.tuple_of_vectors_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m b/matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m index 78686999..13d882ab 100644 --- a/matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m +++ b/matlab/generated/+test_model/+binary/AdvancedGenericsWriter.m @@ -11,36 +11,36 @@ end methods - function obj = AdvancedGenericsWriter(filename) - obj@test_model.AdvancedGenericsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.AdvancedGenericsWriterBase.schema); - obj.float_image_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), 2); - obj.generic_record_1_serializer = test_model.binary.GenericRecordSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); - obj.tuple_of_optionals_serializer = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); - obj.tuple_of_optionals_alternate_syntax_serializer = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); - obj.tuple_of_vectors_serializer = tuples.binary.TupleSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), yardl.binary.VectorSerializer(yardl.binary.Float32Serializer)); + function self = AdvancedGenericsWriter(filename) + self@test_model.AdvancedGenericsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.AdvancedGenericsWriterBase.schema); + self.float_image_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), 2); + self.generic_record_1_serializer = test_model.binary.GenericRecordSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + self.tuple_of_optionals_serializer = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); + self.tuple_of_optionals_alternate_syntax_serializer = tuples.binary.TupleSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer), yardl.binary.OptionalSerializer(yardl.binary.StringSerializer)); + self.tuple_of_vectors_serializer = tuples.binary.TupleSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), yardl.binary.VectorSerializer(yardl.binary.Float32Serializer)); end end methods (Access=protected) - function write_float_image_image_(obj, value) - obj.float_image_image_serializer.write(obj.stream_, value); + function write_float_image_image_(self, value) + self.float_image_image_serializer.write(self.stream_, value); end - function write_generic_record_1_(obj, value) - obj.generic_record_1_serializer.write(obj.stream_, value); + function write_generic_record_1_(self, value) + self.generic_record_1_serializer.write(self.stream_, value); end - function write_tuple_of_optionals_(obj, value) - obj.tuple_of_optionals_serializer.write(obj.stream_, value); + function write_tuple_of_optionals_(self, value) + self.tuple_of_optionals_serializer.write(self.stream_, value); end - function write_tuple_of_optionals_alternate_syntax_(obj, value) - obj.tuple_of_optionals_alternate_syntax_serializer.write(obj.stream_, value); + function write_tuple_of_optionals_alternate_syntax_(self, value) + self.tuple_of_optionals_alternate_syntax_serializer.write(self.stream_, value); end - function write_tuple_of_vectors_(obj, value) - obj.tuple_of_vectors_serializer.write(obj.stream_, value); + function write_tuple_of_vectors_(self, value) + self.tuple_of_vectors_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/AliasesReader.m b/matlab/generated/+test_model/+binary/AliasesReader.m index aef2cde1..2edb8961 100644 --- a/matlab/generated/+test_model/+binary/AliasesReader.m +++ b/matlab/generated/+test_model/+binary/AliasesReader.m @@ -16,65 +16,65 @@ end methods - function obj = AliasesReader(filename) - obj@test_model.AliasesReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.AliasesReaderBase.schema); - obj.aliased_string_serializer = yardl.binary.StringSerializer; - obj.aliased_enum_serializer = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); - obj.aliased_open_generic_serializer = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); - obj.aliased_closed_generic_serializer = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); - obj.aliased_optional_serializer = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); - obj.aliased_generic_optional_serializer = yardl.binary.OptionalSerializer(yardl.binary.Float32Serializer); - obj.aliased_generic_union_2_serializer = yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2}); - obj.aliased_generic_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Float32Serializer); - obj.aliased_generic_fixed_vector_serializer = yardl.binary.FixedVectorSerializer(yardl.binary.Float32Serializer, 3); - obj.stream_of_aliased_generic_union_2_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2})); + function self = AliasesReader(filename) + self@test_model.AliasesReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.AliasesReaderBase.schema); + self.aliased_string_serializer = yardl.binary.StringSerializer; + self.aliased_enum_serializer = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); + self.aliased_open_generic_serializer = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + self.aliased_closed_generic_serializer = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + self.aliased_optional_serializer = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); + self.aliased_generic_optional_serializer = yardl.binary.OptionalSerializer(yardl.binary.Float32Serializer); + self.aliased_generic_union_2_serializer = yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2}); + self.aliased_generic_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Float32Serializer); + self.aliased_generic_fixed_vector_serializer = yardl.binary.FixedVectorSerializer(yardl.binary.Float32Serializer, 3); + self.stream_of_aliased_generic_union_2_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2})); end end methods (Access=protected) - function value = read_aliased_string_(obj) - value = obj.aliased_string_serializer.read(obj.stream_); + function value = read_aliased_string_(self) + value = self.aliased_string_serializer.read(self.stream_); end - function value = read_aliased_enum_(obj) - value = obj.aliased_enum_serializer.read(obj.stream_); + function value = read_aliased_enum_(self) + value = self.aliased_enum_serializer.read(self.stream_); end - function value = read_aliased_open_generic_(obj) - value = obj.aliased_open_generic_serializer.read(obj.stream_); + function value = read_aliased_open_generic_(self) + value = self.aliased_open_generic_serializer.read(self.stream_); end - function value = read_aliased_closed_generic_(obj) - value = obj.aliased_closed_generic_serializer.read(obj.stream_); + function value = read_aliased_closed_generic_(self) + value = self.aliased_closed_generic_serializer.read(self.stream_); end - function value = read_aliased_optional_(obj) - value = obj.aliased_optional_serializer.read(obj.stream_); + function value = read_aliased_optional_(self) + value = self.aliased_optional_serializer.read(self.stream_); end - function value = read_aliased_generic_optional_(obj) - value = obj.aliased_generic_optional_serializer.read(obj.stream_); + function value = read_aliased_generic_optional_(self) + value = self.aliased_generic_optional_serializer.read(self.stream_); end - function value = read_aliased_generic_union_2_(obj) - value = obj.aliased_generic_union_2_serializer.read(obj.stream_); + function value = read_aliased_generic_union_2_(self) + value = self.aliased_generic_union_2_serializer.read(self.stream_); end - function value = read_aliased_generic_vector_(obj) - value = obj.aliased_generic_vector_serializer.read(obj.stream_); + function value = read_aliased_generic_vector_(self) + value = self.aliased_generic_vector_serializer.read(self.stream_); end - function value = read_aliased_generic_fixed_vector_(obj) - value = obj.aliased_generic_fixed_vector_serializer.read(obj.stream_); + function value = read_aliased_generic_fixed_vector_(self) + value = self.aliased_generic_fixed_vector_serializer.read(self.stream_); end - function more = has_stream_of_aliased_generic_union_2_(obj) - more = obj.stream_of_aliased_generic_union_2_serializer.hasnext(obj.stream_); + function more = has_stream_of_aliased_generic_union_2_(self) + more = self.stream_of_aliased_generic_union_2_serializer.hasnext(self.stream_); end - function value = read_stream_of_aliased_generic_union_2_(obj) - value = obj.stream_of_aliased_generic_union_2_serializer.read(obj.stream_); + function value = read_stream_of_aliased_generic_union_2_(self) + value = self.stream_of_aliased_generic_union_2_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/AliasesWriter.m b/matlab/generated/+test_model/+binary/AliasesWriter.m index 2982acc9..543dd046 100644 --- a/matlab/generated/+test_model/+binary/AliasesWriter.m +++ b/matlab/generated/+test_model/+binary/AliasesWriter.m @@ -16,61 +16,61 @@ end methods - function obj = AliasesWriter(filename) - obj@test_model.AliasesWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.AliasesWriterBase.schema); - obj.aliased_string_serializer = yardl.binary.StringSerializer; - obj.aliased_enum_serializer = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); - obj.aliased_open_generic_serializer = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); - obj.aliased_closed_generic_serializer = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); - obj.aliased_optional_serializer = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); - obj.aliased_generic_optional_serializer = yardl.binary.OptionalSerializer(yardl.binary.Float32Serializer); - obj.aliased_generic_union_2_serializer = yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2}); - obj.aliased_generic_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Float32Serializer); - obj.aliased_generic_fixed_vector_serializer = yardl.binary.FixedVectorSerializer(yardl.binary.Float32Serializer, 3); - obj.stream_of_aliased_generic_union_2_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2})); + function self = AliasesWriter(filename) + self@test_model.AliasesWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.AliasesWriterBase.schema); + self.aliased_string_serializer = yardl.binary.StringSerializer; + self.aliased_enum_serializer = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); + self.aliased_open_generic_serializer = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + self.aliased_closed_generic_serializer = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + self.aliased_optional_serializer = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); + self.aliased_generic_optional_serializer = yardl.binary.OptionalSerializer(yardl.binary.Float32Serializer); + self.aliased_generic_union_2_serializer = yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2}); + self.aliased_generic_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Float32Serializer); + self.aliased_generic_fixed_vector_serializer = yardl.binary.FixedVectorSerializer(yardl.binary.Float32Serializer, 3); + self.stream_of_aliased_generic_union_2_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('basic_types.GenericUnion2', {yardl.binary.StringSerializer, yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)}, {@basic_types.GenericUnion2.T1, @basic_types.GenericUnion2.T2})); end end methods (Access=protected) - function write_aliased_string_(obj, value) - obj.aliased_string_serializer.write(obj.stream_, value); + function write_aliased_string_(self, value) + self.aliased_string_serializer.write(self.stream_, value); end - function write_aliased_enum_(obj, value) - obj.aliased_enum_serializer.write(obj.stream_, value); + function write_aliased_enum_(self, value) + self.aliased_enum_serializer.write(self.stream_, value); end - function write_aliased_open_generic_(obj, value) - obj.aliased_open_generic_serializer.write(obj.stream_, value); + function write_aliased_open_generic_(self, value) + self.aliased_open_generic_serializer.write(self.stream_, value); end - function write_aliased_closed_generic_(obj, value) - obj.aliased_closed_generic_serializer.write(obj.stream_, value); + function write_aliased_closed_generic_(self, value) + self.aliased_closed_generic_serializer.write(self.stream_, value); end - function write_aliased_optional_(obj, value) - obj.aliased_optional_serializer.write(obj.stream_, value); + function write_aliased_optional_(self, value) + self.aliased_optional_serializer.write(self.stream_, value); end - function write_aliased_generic_optional_(obj, value) - obj.aliased_generic_optional_serializer.write(obj.stream_, value); + function write_aliased_generic_optional_(self, value) + self.aliased_generic_optional_serializer.write(self.stream_, value); end - function write_aliased_generic_union_2_(obj, value) - obj.aliased_generic_union_2_serializer.write(obj.stream_, value); + function write_aliased_generic_union_2_(self, value) + self.aliased_generic_union_2_serializer.write(self.stream_, value); end - function write_aliased_generic_vector_(obj, value) - obj.aliased_generic_vector_serializer.write(obj.stream_, value); + function write_aliased_generic_vector_(self, value) + self.aliased_generic_vector_serializer.write(self.stream_, value); end - function write_aliased_generic_fixed_vector_(obj, value) - obj.aliased_generic_fixed_vector_serializer.write(obj.stream_, value); + function write_aliased_generic_fixed_vector_(self, value) + self.aliased_generic_fixed_vector_serializer.write(self.stream_, value); end - function write_stream_of_aliased_generic_union_2_(obj, value) - obj.stream_of_aliased_generic_union_2_serializer.write(obj.stream_, value); + function write_stream_of_aliased_generic_union_2_(self, value) + self.stream_of_aliased_generic_union_2_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m index 3428aa88..ca6e86eb 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Reader.m @@ -7,20 +7,20 @@ end methods - function obj = BenchmarkFloat256x256Reader(filename) - obj@test_model.BenchmarkFloat256x256ReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkFloat256x256ReaderBase.schema); - obj.float256x256_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [256, 256])); + function self = BenchmarkFloat256x256Reader(filename) + self@test_model.BenchmarkFloat256x256ReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkFloat256x256ReaderBase.schema); + self.float256x256_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [256, 256])); end end methods (Access=protected) - function more = has_float256x256_(obj) - more = obj.float256x256_serializer.hasnext(obj.stream_); + function more = has_float256x256_(self) + more = self.float256x256_serializer.hasnext(self.stream_); end - function value = read_float256x256_(obj) - value = obj.float256x256_serializer.read(obj.stream_); + function value = read_float256x256_(self) + value = self.float256x256_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m index 967cb1fd..df30b7d2 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m +++ b/matlab/generated/+test_model/+binary/BenchmarkFloat256x256Writer.m @@ -7,16 +7,16 @@ end methods - function obj = BenchmarkFloat256x256Writer(filename) - obj@test_model.BenchmarkFloat256x256WriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkFloat256x256WriterBase.schema); - obj.float256x256_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [256, 256])); + function self = BenchmarkFloat256x256Writer(filename) + self@test_model.BenchmarkFloat256x256WriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkFloat256x256WriterBase.schema); + self.float256x256_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [256, 256])); end end methods (Access=protected) - function write_float256x256_(obj, value) - obj.float256x256_serializer.write(obj.stream_, value); + function write_float256x256_(self, value) + self.float256x256_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m index 93ccdff5..2dad1ad5 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenReader.m @@ -7,20 +7,20 @@ end methods - function obj = BenchmarkFloatVlenReader(filename) - obj@test_model.BenchmarkFloatVlenReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkFloatVlenReaderBase.schema); - obj.float_array_serializer = yardl.binary.StreamSerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)); + function self = BenchmarkFloatVlenReader(filename) + self@test_model.BenchmarkFloatVlenReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkFloatVlenReaderBase.schema); + self.float_array_serializer = yardl.binary.StreamSerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)); end end methods (Access=protected) - function more = has_float_array_(obj) - more = obj.float_array_serializer.hasnext(obj.stream_); + function more = has_float_array_(self) + more = self.float_array_serializer.hasnext(self.stream_); end - function value = read_float_array_(obj) - value = obj.float_array_serializer.read(obj.stream_); + function value = read_float_array_(self) + value = self.float_array_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m index de5aeb34..2c924fb5 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m +++ b/matlab/generated/+test_model/+binary/BenchmarkFloatVlenWriter.m @@ -7,16 +7,16 @@ end methods - function obj = BenchmarkFloatVlenWriter(filename) - obj@test_model.BenchmarkFloatVlenWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkFloatVlenWriterBase.schema); - obj.float_array_serializer = yardl.binary.StreamSerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)); + function self = BenchmarkFloatVlenWriter(filename) + self@test_model.BenchmarkFloatVlenWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkFloatVlenWriterBase.schema); + self.float_array_serializer = yardl.binary.StreamSerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)); end end methods (Access=protected) - function write_float_array_(obj, value) - obj.float_array_serializer.write(obj.stream_, value); + function write_float_array_(self, value) + self.float_array_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m index 7cf64038..37b47ebb 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Reader.m @@ -7,20 +7,20 @@ end methods - function obj = BenchmarkInt256x256Reader(filename) - obj@test_model.BenchmarkInt256x256ReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkInt256x256ReaderBase.schema); - obj.int256x256_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [256, 256])); + function self = BenchmarkInt256x256Reader(filename) + self@test_model.BenchmarkInt256x256ReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkInt256x256ReaderBase.schema); + self.int256x256_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [256, 256])); end end methods (Access=protected) - function more = has_int256x256_(obj) - more = obj.int256x256_serializer.hasnext(obj.stream_); + function more = has_int256x256_(self) + more = self.int256x256_serializer.hasnext(self.stream_); end - function value = read_int256x256_(obj) - value = obj.int256x256_serializer.read(obj.stream_); + function value = read_int256x256_(self) + value = self.int256x256_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m index 7f3dc1d5..1d32f216 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m +++ b/matlab/generated/+test_model/+binary/BenchmarkInt256x256Writer.m @@ -7,16 +7,16 @@ end methods - function obj = BenchmarkInt256x256Writer(filename) - obj@test_model.BenchmarkInt256x256WriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkInt256x256WriterBase.schema); - obj.int256x256_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [256, 256])); + function self = BenchmarkInt256x256Writer(filename) + self@test_model.BenchmarkInt256x256WriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkInt256x256WriterBase.schema); + self.int256x256_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [256, 256])); end end methods (Access=protected) - function write_int256x256_(obj, value) - obj.int256x256_serializer.write(obj.stream_, value); + function write_int256x256_(self, value) + self.int256x256_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m index fef78270..51d36e82 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdReader.m @@ -7,20 +7,20 @@ end methods - function obj = BenchmarkSimpleMrdReader(filename) - obj@test_model.BenchmarkSimpleMrdReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkSimpleMrdReaderBase.schema); - obj.data_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AcquisitionOrImage', {test_model.binary.SimpleAcquisitionSerializer(), yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)}, {@test_model.AcquisitionOrImage.Acquisition, @test_model.AcquisitionOrImage.Image})); + function self = BenchmarkSimpleMrdReader(filename) + self@test_model.BenchmarkSimpleMrdReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkSimpleMrdReaderBase.schema); + self.data_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AcquisitionOrImage', {test_model.binary.SimpleAcquisitionSerializer(), yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)}, {@test_model.AcquisitionOrImage.Acquisition, @test_model.AcquisitionOrImage.Image})); end end methods (Access=protected) - function more = has_data_(obj) - more = obj.data_serializer.hasnext(obj.stream_); + function more = has_data_(self) + more = self.data_serializer.hasnext(self.stream_); end - function value = read_data_(obj) - value = obj.data_serializer.read(obj.stream_); + function value = read_data_(self) + value = self.data_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m index eaf98e79..04bafb53 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSimpleMrdWriter.m @@ -7,16 +7,16 @@ end methods - function obj = BenchmarkSimpleMrdWriter(filename) - obj@test_model.BenchmarkSimpleMrdWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkSimpleMrdWriterBase.schema); - obj.data_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AcquisitionOrImage', {test_model.binary.SimpleAcquisitionSerializer(), yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)}, {@test_model.AcquisitionOrImage.Acquisition, @test_model.AcquisitionOrImage.Image})); + function self = BenchmarkSimpleMrdWriter(filename) + self@test_model.BenchmarkSimpleMrdWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkSimpleMrdWriterBase.schema); + self.data_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AcquisitionOrImage', {test_model.binary.SimpleAcquisitionSerializer(), yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2)}, {@test_model.AcquisitionOrImage.Acquisition, @test_model.AcquisitionOrImage.Image})); end end methods (Access=protected) - function write_data_(obj, value) - obj.data_serializer.write(obj.stream_, value); + function write_data_(self, value) + self.data_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m index 0a0bc5b0..64114ba3 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordReader.m @@ -7,20 +7,20 @@ end methods - function obj = BenchmarkSmallRecordReader(filename) - obj@test_model.BenchmarkSmallRecordReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkSmallRecordReaderBase.schema); - obj.small_record_serializer = yardl.binary.StreamSerializer(test_model.binary.SmallBenchmarkRecordSerializer()); + function self = BenchmarkSmallRecordReader(filename) + self@test_model.BenchmarkSmallRecordReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkSmallRecordReaderBase.schema); + self.small_record_serializer = yardl.binary.StreamSerializer(test_model.binary.SmallBenchmarkRecordSerializer()); end end methods (Access=protected) - function more = has_small_record_(obj) - more = obj.small_record_serializer.hasnext(obj.stream_); + function more = has_small_record_(self) + more = self.small_record_serializer.hasnext(self.stream_); end - function value = read_small_record_(obj) - value = obj.small_record_serializer.read(obj.stream_); + function value = read_small_record_(self) + value = self.small_record_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m index 745f8266..cccf0c7d 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsReader.m @@ -7,20 +7,20 @@ end methods - function obj = BenchmarkSmallRecordWithOptionalsReader(filename) - obj@test_model.BenchmarkSmallRecordWithOptionalsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkSmallRecordWithOptionalsReaderBase.schema); - obj.small_record_serializer = yardl.binary.StreamSerializer(test_model.binary.SimpleEncodingCountersSerializer()); + function self = BenchmarkSmallRecordWithOptionalsReader(filename) + self@test_model.BenchmarkSmallRecordWithOptionalsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.BenchmarkSmallRecordWithOptionalsReaderBase.schema); + self.small_record_serializer = yardl.binary.StreamSerializer(test_model.binary.SimpleEncodingCountersSerializer()); end end methods (Access=protected) - function more = has_small_record_(obj) - more = obj.small_record_serializer.hasnext(obj.stream_); + function more = has_small_record_(self) + more = self.small_record_serializer.hasnext(self.stream_); end - function value = read_small_record_(obj) - value = obj.small_record_serializer.read(obj.stream_); + function value = read_small_record_(self) + value = self.small_record_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m index c2040860..f01d0dfd 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWithOptionalsWriter.m @@ -7,16 +7,16 @@ end methods - function obj = BenchmarkSmallRecordWithOptionalsWriter(filename) - obj@test_model.BenchmarkSmallRecordWithOptionalsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkSmallRecordWithOptionalsWriterBase.schema); - obj.small_record_serializer = yardl.binary.StreamSerializer(test_model.binary.SimpleEncodingCountersSerializer()); + function self = BenchmarkSmallRecordWithOptionalsWriter(filename) + self@test_model.BenchmarkSmallRecordWithOptionalsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkSmallRecordWithOptionalsWriterBase.schema); + self.small_record_serializer = yardl.binary.StreamSerializer(test_model.binary.SimpleEncodingCountersSerializer()); end end methods (Access=protected) - function write_small_record_(obj, value) - obj.small_record_serializer.write(obj.stream_, value); + function write_small_record_(self, value) + self.small_record_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m index e07730e0..f315e263 100644 --- a/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m +++ b/matlab/generated/+test_model/+binary/BenchmarkSmallRecordWriter.m @@ -7,16 +7,16 @@ end methods - function obj = BenchmarkSmallRecordWriter(filename) - obj@test_model.BenchmarkSmallRecordWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkSmallRecordWriterBase.schema); - obj.small_record_serializer = yardl.binary.StreamSerializer(test_model.binary.SmallBenchmarkRecordSerializer()); + function self = BenchmarkSmallRecordWriter(filename) + self@test_model.BenchmarkSmallRecordWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.BenchmarkSmallRecordWriterBase.schema); + self.small_record_serializer = yardl.binary.StreamSerializer(test_model.binary.SmallBenchmarkRecordSerializer()); end end methods (Access=protected) - function write_small_record_(obj, value) - obj.small_record_serializer.write(obj.stream_, value); + function write_small_record_(self, value) + self.small_record_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/DynamicNDArraysReader.m b/matlab/generated/+test_model/+binary/DynamicNDArraysReader.m index 8e840f65..b3ce728c 100644 --- a/matlab/generated/+test_model/+binary/DynamicNDArraysReader.m +++ b/matlab/generated/+test_model/+binary/DynamicNDArraysReader.m @@ -10,31 +10,31 @@ end methods - function obj = DynamicNDArraysReader(filename) - obj@test_model.DynamicNDArraysReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.DynamicNDArraysReaderBase.schema); - obj.ints_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); - obj.simple_record_array_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.SimpleRecordSerializer()); - obj.record_with_vlens_array_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlensSerializer()); - obj.record_with_dynamic_nd_arrays_serializer = test_model.binary.RecordWithDynamicNDArraysSerializer(); + function self = DynamicNDArraysReader(filename) + self@test_model.DynamicNDArraysReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.DynamicNDArraysReaderBase.schema); + self.ints_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); + self.simple_record_array_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.SimpleRecordSerializer()); + self.record_with_vlens_array_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlensSerializer()); + self.record_with_dynamic_nd_arrays_serializer = test_model.binary.RecordWithDynamicNDArraysSerializer(); end end methods (Access=protected) - function value = read_ints_(obj) - value = obj.ints_serializer.read(obj.stream_); + function value = read_ints_(self) + value = self.ints_serializer.read(self.stream_); end - function value = read_simple_record_array_(obj) - value = obj.simple_record_array_serializer.read(obj.stream_); + function value = read_simple_record_array_(self) + value = self.simple_record_array_serializer.read(self.stream_); end - function value = read_record_with_vlens_array_(obj) - value = obj.record_with_vlens_array_serializer.read(obj.stream_); + function value = read_record_with_vlens_array_(self) + value = self.record_with_vlens_array_serializer.read(self.stream_); end - function value = read_record_with_dynamic_nd_arrays_(obj) - value = obj.record_with_dynamic_nd_arrays_serializer.read(obj.stream_); + function value = read_record_with_dynamic_nd_arrays_(self) + value = self.record_with_dynamic_nd_arrays_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m b/matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m index f4d6ee7f..b50763f2 100644 --- a/matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m +++ b/matlab/generated/+test_model/+binary/DynamicNDArraysWriter.m @@ -10,31 +10,31 @@ end methods - function obj = DynamicNDArraysWriter(filename) - obj@test_model.DynamicNDArraysWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.DynamicNDArraysWriterBase.schema); - obj.ints_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); - obj.simple_record_array_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.SimpleRecordSerializer()); - obj.record_with_vlens_array_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlensSerializer()); - obj.record_with_dynamic_nd_arrays_serializer = test_model.binary.RecordWithDynamicNDArraysSerializer(); + function self = DynamicNDArraysWriter(filename) + self@test_model.DynamicNDArraysWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.DynamicNDArraysWriterBase.schema); + self.ints_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); + self.simple_record_array_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.SimpleRecordSerializer()); + self.record_with_vlens_array_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlensSerializer()); + self.record_with_dynamic_nd_arrays_serializer = test_model.binary.RecordWithDynamicNDArraysSerializer(); end end methods (Access=protected) - function write_ints_(obj, value) - obj.ints_serializer.write(obj.stream_, value); + function write_ints_(self, value) + self.ints_serializer.write(self.stream_, value); end - function write_simple_record_array_(obj, value) - obj.simple_record_array_serializer.write(obj.stream_, value); + function write_simple_record_array_(self, value) + self.simple_record_array_serializer.write(self.stream_, value); end - function write_record_with_vlens_array_(obj, value) - obj.record_with_vlens_array_serializer.write(obj.stream_, value); + function write_record_with_vlens_array_(self, value) + self.record_with_vlens_array_serializer.write(self.stream_, value); end - function write_record_with_dynamic_nd_arrays_(obj, value) - obj.record_with_dynamic_nd_arrays_serializer.write(obj.stream_, value); + function write_record_with_dynamic_nd_arrays_(self, value) + self.record_with_dynamic_nd_arrays_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/EnumsReader.m b/matlab/generated/+test_model/+binary/EnumsReader.m index d22e52ab..fd458581 100644 --- a/matlab/generated/+test_model/+binary/EnumsReader.m +++ b/matlab/generated/+test_model/+binary/EnumsReader.m @@ -9,26 +9,26 @@ end methods - function obj = EnumsReader(filename) - obj@test_model.EnumsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.EnumsReaderBase.schema); - obj.single_serializer = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); - obj.vec_serializer = yardl.binary.VectorSerializer(yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); - obj.size_serializer = yardl.binary.EnumSerializer('test_model.SizeBasedEnum', @test_model.SizeBasedEnum, yardl.binary.SizeSerializer); + function self = EnumsReader(filename) + self@test_model.EnumsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.EnumsReaderBase.schema); + self.single_serializer = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); + self.vec_serializer = yardl.binary.VectorSerializer(yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + self.size_serializer = yardl.binary.EnumSerializer('test_model.SizeBasedEnum', @test_model.SizeBasedEnum, yardl.binary.SizeSerializer); end end methods (Access=protected) - function value = read_single_(obj) - value = obj.single_serializer.read(obj.stream_); + function value = read_single_(self) + value = self.single_serializer.read(self.stream_); end - function value = read_vec_(obj) - value = obj.vec_serializer.read(obj.stream_); + function value = read_vec_(self) + value = self.vec_serializer.read(self.stream_); end - function value = read_size_(obj) - value = obj.size_serializer.read(obj.stream_); + function value = read_size_(self) + value = self.size_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/EnumsWriter.m b/matlab/generated/+test_model/+binary/EnumsWriter.m index ce0ef72c..1cd61c9f 100644 --- a/matlab/generated/+test_model/+binary/EnumsWriter.m +++ b/matlab/generated/+test_model/+binary/EnumsWriter.m @@ -9,26 +9,26 @@ end methods - function obj = EnumsWriter(filename) - obj@test_model.EnumsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.EnumsWriterBase.schema); - obj.single_serializer = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); - obj.vec_serializer = yardl.binary.VectorSerializer(yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); - obj.size_serializer = yardl.binary.EnumSerializer('test_model.SizeBasedEnum', @test_model.SizeBasedEnum, yardl.binary.SizeSerializer); + function self = EnumsWriter(filename) + self@test_model.EnumsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.EnumsWriterBase.schema); + self.single_serializer = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); + self.vec_serializer = yardl.binary.VectorSerializer(yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer)); + self.size_serializer = yardl.binary.EnumSerializer('test_model.SizeBasedEnum', @test_model.SizeBasedEnum, yardl.binary.SizeSerializer); end end methods (Access=protected) - function write_single_(obj, value) - obj.single_serializer.write(obj.stream_, value); + function write_single_(self, value) + self.single_serializer.write(self.stream_, value); end - function write_vec_(obj, value) - obj.vec_serializer.write(obj.stream_, value); + function write_vec_(self, value) + self.vec_serializer.write(self.stream_, value); end - function write_size_(obj, value) - obj.size_serializer.write(obj.stream_, value); + function write_size_(self, value) + self.size_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/FixedArraysReader.m b/matlab/generated/+test_model/+binary/FixedArraysReader.m index 21f7294a..5e265d3c 100644 --- a/matlab/generated/+test_model/+binary/FixedArraysReader.m +++ b/matlab/generated/+test_model/+binary/FixedArraysReader.m @@ -11,36 +11,36 @@ end methods - function obj = FixedArraysReader(filename) - obj@test_model.FixedArraysReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.FixedArraysReaderBase.schema); - obj.ints_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); - obj.fixed_simple_record_array_serializer = yardl.binary.FixedNDArraySerializer(test_model.binary.SimpleRecordSerializer(), [2, 3]); - obj.fixed_record_with_vlens_array_serializer = yardl.binary.FixedNDArraySerializer(test_model.binary.RecordWithVlensSerializer(), [2, 2]); - obj.record_with_fixed_arrays_serializer = test_model.binary.RecordWithFixedArraysSerializer(); - obj.named_array_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 2]); + function self = FixedArraysReader(filename) + self@test_model.FixedArraysReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.FixedArraysReaderBase.schema); + self.ints_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); + self.fixed_simple_record_array_serializer = yardl.binary.FixedNDArraySerializer(test_model.binary.SimpleRecordSerializer(), [2, 3]); + self.fixed_record_with_vlens_array_serializer = yardl.binary.FixedNDArraySerializer(test_model.binary.RecordWithVlensSerializer(), [2, 2]); + self.record_with_fixed_arrays_serializer = test_model.binary.RecordWithFixedArraysSerializer(); + self.named_array_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 2]); end end methods (Access=protected) - function value = read_ints_(obj) - value = obj.ints_serializer.read(obj.stream_); + function value = read_ints_(self) + value = self.ints_serializer.read(self.stream_); end - function value = read_fixed_simple_record_array_(obj) - value = obj.fixed_simple_record_array_serializer.read(obj.stream_); + function value = read_fixed_simple_record_array_(self) + value = self.fixed_simple_record_array_serializer.read(self.stream_); end - function value = read_fixed_record_with_vlens_array_(obj) - value = obj.fixed_record_with_vlens_array_serializer.read(obj.stream_); + function value = read_fixed_record_with_vlens_array_(self) + value = self.fixed_record_with_vlens_array_serializer.read(self.stream_); end - function value = read_record_with_fixed_arrays_(obj) - value = obj.record_with_fixed_arrays_serializer.read(obj.stream_); + function value = read_record_with_fixed_arrays_(self) + value = self.record_with_fixed_arrays_serializer.read(self.stream_); end - function value = read_named_array_(obj) - value = obj.named_array_serializer.read(obj.stream_); + function value = read_named_array_(self) + value = self.named_array_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/FixedArraysWriter.m b/matlab/generated/+test_model/+binary/FixedArraysWriter.m index 68f820b0..65831e55 100644 --- a/matlab/generated/+test_model/+binary/FixedArraysWriter.m +++ b/matlab/generated/+test_model/+binary/FixedArraysWriter.m @@ -11,36 +11,36 @@ end methods - function obj = FixedArraysWriter(filename) - obj@test_model.FixedArraysWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.FixedArraysWriterBase.schema); - obj.ints_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); - obj.fixed_simple_record_array_serializer = yardl.binary.FixedNDArraySerializer(test_model.binary.SimpleRecordSerializer(), [2, 3]); - obj.fixed_record_with_vlens_array_serializer = yardl.binary.FixedNDArraySerializer(test_model.binary.RecordWithVlensSerializer(), [2, 2]); - obj.record_with_fixed_arrays_serializer = test_model.binary.RecordWithFixedArraysSerializer(); - obj.named_array_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 2]); + function self = FixedArraysWriter(filename) + self@test_model.FixedArraysWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.FixedArraysWriterBase.schema); + self.ints_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); + self.fixed_simple_record_array_serializer = yardl.binary.FixedNDArraySerializer(test_model.binary.SimpleRecordSerializer(), [2, 3]); + self.fixed_record_with_vlens_array_serializer = yardl.binary.FixedNDArraySerializer(test_model.binary.RecordWithVlensSerializer(), [2, 2]); + self.record_with_fixed_arrays_serializer = test_model.binary.RecordWithFixedArraysSerializer(); + self.named_array_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 2]); end end methods (Access=protected) - function write_ints_(obj, value) - obj.ints_serializer.write(obj.stream_, value); + function write_ints_(self, value) + self.ints_serializer.write(self.stream_, value); end - function write_fixed_simple_record_array_(obj, value) - obj.fixed_simple_record_array_serializer.write(obj.stream_, value); + function write_fixed_simple_record_array_(self, value) + self.fixed_simple_record_array_serializer.write(self.stream_, value); end - function write_fixed_record_with_vlens_array_(obj, value) - obj.fixed_record_with_vlens_array_serializer.write(obj.stream_, value); + function write_fixed_record_with_vlens_array_(self, value) + self.fixed_record_with_vlens_array_serializer.write(self.stream_, value); end - function write_record_with_fixed_arrays_(obj, value) - obj.record_with_fixed_arrays_serializer.write(obj.stream_, value); + function write_record_with_fixed_arrays_(self, value) + self.record_with_fixed_arrays_serializer.write(self.stream_, value); end - function write_named_array_(obj, value) - obj.named_array_serializer.write(obj.stream_, value); + function write_named_array_(self, value) + self.named_array_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/FixedVectorsReader.m b/matlab/generated/+test_model/+binary/FixedVectorsReader.m index 25b5eebf..8584d603 100644 --- a/matlab/generated/+test_model/+binary/FixedVectorsReader.m +++ b/matlab/generated/+test_model/+binary/FixedVectorsReader.m @@ -10,31 +10,31 @@ end methods - function obj = FixedVectorsReader(filename) - obj@test_model.FixedVectorsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.FixedVectorsReaderBase.schema); - obj.fixed_int_vector_serializer = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 5); - obj.fixed_simple_record_vector_serializer = yardl.binary.FixedVectorSerializer(test_model.binary.SimpleRecordSerializer(), 3); - obj.fixed_record_with_vlens_vector_serializer = yardl.binary.FixedVectorSerializer(test_model.binary.RecordWithVlensSerializer(), 2); - obj.record_with_fixed_vectors_serializer = test_model.binary.RecordWithFixedVectorsSerializer(); + function self = FixedVectorsReader(filename) + self@test_model.FixedVectorsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.FixedVectorsReaderBase.schema); + self.fixed_int_vector_serializer = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 5); + self.fixed_simple_record_vector_serializer = yardl.binary.FixedVectorSerializer(test_model.binary.SimpleRecordSerializer(), 3); + self.fixed_record_with_vlens_vector_serializer = yardl.binary.FixedVectorSerializer(test_model.binary.RecordWithVlensSerializer(), 2); + self.record_with_fixed_vectors_serializer = test_model.binary.RecordWithFixedVectorsSerializer(); end end methods (Access=protected) - function value = read_fixed_int_vector_(obj) - value = obj.fixed_int_vector_serializer.read(obj.stream_); + function value = read_fixed_int_vector_(self) + value = self.fixed_int_vector_serializer.read(self.stream_); end - function value = read_fixed_simple_record_vector_(obj) - value = obj.fixed_simple_record_vector_serializer.read(obj.stream_); + function value = read_fixed_simple_record_vector_(self) + value = self.fixed_simple_record_vector_serializer.read(self.stream_); end - function value = read_fixed_record_with_vlens_vector_(obj) - value = obj.fixed_record_with_vlens_vector_serializer.read(obj.stream_); + function value = read_fixed_record_with_vlens_vector_(self) + value = self.fixed_record_with_vlens_vector_serializer.read(self.stream_); end - function value = read_record_with_fixed_vectors_(obj) - value = obj.record_with_fixed_vectors_serializer.read(obj.stream_); + function value = read_record_with_fixed_vectors_(self) + value = self.record_with_fixed_vectors_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/FixedVectorsWriter.m b/matlab/generated/+test_model/+binary/FixedVectorsWriter.m index cd852da1..bd569036 100644 --- a/matlab/generated/+test_model/+binary/FixedVectorsWriter.m +++ b/matlab/generated/+test_model/+binary/FixedVectorsWriter.m @@ -10,31 +10,31 @@ end methods - function obj = FixedVectorsWriter(filename) - obj@test_model.FixedVectorsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.FixedVectorsWriterBase.schema); - obj.fixed_int_vector_serializer = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 5); - obj.fixed_simple_record_vector_serializer = yardl.binary.FixedVectorSerializer(test_model.binary.SimpleRecordSerializer(), 3); - obj.fixed_record_with_vlens_vector_serializer = yardl.binary.FixedVectorSerializer(test_model.binary.RecordWithVlensSerializer(), 2); - obj.record_with_fixed_vectors_serializer = test_model.binary.RecordWithFixedVectorsSerializer(); + function self = FixedVectorsWriter(filename) + self@test_model.FixedVectorsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.FixedVectorsWriterBase.schema); + self.fixed_int_vector_serializer = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 5); + self.fixed_simple_record_vector_serializer = yardl.binary.FixedVectorSerializer(test_model.binary.SimpleRecordSerializer(), 3); + self.fixed_record_with_vlens_vector_serializer = yardl.binary.FixedVectorSerializer(test_model.binary.RecordWithVlensSerializer(), 2); + self.record_with_fixed_vectors_serializer = test_model.binary.RecordWithFixedVectorsSerializer(); end end methods (Access=protected) - function write_fixed_int_vector_(obj, value) - obj.fixed_int_vector_serializer.write(obj.stream_, value); + function write_fixed_int_vector_(self, value) + self.fixed_int_vector_serializer.write(self.stream_, value); end - function write_fixed_simple_record_vector_(obj, value) - obj.fixed_simple_record_vector_serializer.write(obj.stream_, value); + function write_fixed_simple_record_vector_(self, value) + self.fixed_simple_record_vector_serializer.write(self.stream_, value); end - function write_fixed_record_with_vlens_vector_(obj, value) - obj.fixed_record_with_vlens_vector_serializer.write(obj.stream_, value); + function write_fixed_record_with_vlens_vector_(self, value) + self.fixed_record_with_vlens_vector_serializer.write(self.stream_, value); end - function write_record_with_fixed_vectors_(obj, value) - obj.record_with_fixed_vectors_serializer.write(obj.stream_, value); + function write_record_with_fixed_vectors_(self, value) + self.record_with_fixed_vectors_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/FlagsReader.m b/matlab/generated/+test_model/+binary/FlagsReader.m index 697dbf35..3afa6e20 100644 --- a/matlab/generated/+test_model/+binary/FlagsReader.m +++ b/matlab/generated/+test_model/+binary/FlagsReader.m @@ -8,29 +8,29 @@ end methods - function obj = FlagsReader(filename) - obj@test_model.FlagsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.FlagsReaderBase.schema); - obj.days_serializer = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.DaysOfWeek', @basic_types.DaysOfWeek, yardl.binary.Int32Serializer)); - obj.formats_serializer = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.TextFormat', @basic_types.TextFormat, yardl.binary.Uint64Serializer)); + function self = FlagsReader(filename) + self@test_model.FlagsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.FlagsReaderBase.schema); + self.days_serializer = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.DaysOfWeek', @basic_types.DaysOfWeek, yardl.binary.Int32Serializer)); + self.formats_serializer = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.TextFormat', @basic_types.TextFormat, yardl.binary.Uint64Serializer)); end end methods (Access=protected) - function more = has_days_(obj) - more = obj.days_serializer.hasnext(obj.stream_); + function more = has_days_(self) + more = self.days_serializer.hasnext(self.stream_); end - function value = read_days_(obj) - value = obj.days_serializer.read(obj.stream_); + function value = read_days_(self) + value = self.days_serializer.read(self.stream_); end - function more = has_formats_(obj) - more = obj.formats_serializer.hasnext(obj.stream_); + function more = has_formats_(self) + more = self.formats_serializer.hasnext(self.stream_); end - function value = read_formats_(obj) - value = obj.formats_serializer.read(obj.stream_); + function value = read_formats_(self) + value = self.formats_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/FlagsWriter.m b/matlab/generated/+test_model/+binary/FlagsWriter.m index 9a378e7b..887d0d3c 100644 --- a/matlab/generated/+test_model/+binary/FlagsWriter.m +++ b/matlab/generated/+test_model/+binary/FlagsWriter.m @@ -8,21 +8,21 @@ end methods - function obj = FlagsWriter(filename) - obj@test_model.FlagsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.FlagsWriterBase.schema); - obj.days_serializer = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.DaysOfWeek', @basic_types.DaysOfWeek, yardl.binary.Int32Serializer)); - obj.formats_serializer = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.TextFormat', @basic_types.TextFormat, yardl.binary.Uint64Serializer)); + function self = FlagsWriter(filename) + self@test_model.FlagsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.FlagsWriterBase.schema); + self.days_serializer = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.DaysOfWeek', @basic_types.DaysOfWeek, yardl.binary.Int32Serializer)); + self.formats_serializer = yardl.binary.StreamSerializer(yardl.binary.EnumSerializer('basic_types.TextFormat', @basic_types.TextFormat, yardl.binary.Uint64Serializer)); end end methods (Access=protected) - function write_days_(obj, value) - obj.days_serializer.write(obj.stream_, value); + function write_days_(self, value) + self.days_serializer.write(self.stream_, value); end - function write_formats_(obj, value) - obj.formats_serializer.write(obj.stream_, value); + function write_formats_(self, value) + self.formats_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/GenericRecordSerializer.m b/matlab/generated/+test_model/+binary/GenericRecordSerializer.m index 4a52a8dd..c24491bf 100644 --- a/matlab/generated/+test_model/+binary/GenericRecordSerializer.m +++ b/matlab/generated/+test_model/+binary/GenericRecordSerializer.m @@ -2,21 +2,25 @@ classdef GenericRecordSerializer < yardl.binary.RecordSerializer methods - function obj = GenericRecordSerializer(t1_serializer, t2_serializer) + function self = GenericRecordSerializer(t1_serializer, t2_serializer) field_serializers{1} = t1_serializer; field_serializers{2} = t2_serializer; field_serializers{3} = yardl.binary.VectorSerializer(t1_serializer); field_serializers{4} = yardl.binary.NDArraySerializer(t2_serializer, 2); - obj@yardl.binary.RecordSerializer('test_model.GenericRecord', field_serializers); + self@yardl.binary.RecordSerializer('test_model.GenericRecord', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.GenericRecord')); - obj.write_(outstream, value.scalar_1, value.scalar_2, value.vector_1, value.image_2) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.GenericRecord + end + self.write_(outstream, value.scalar_1, value.scalar_2, value.vector_1, value.image_2) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.GenericRecord(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/MapsReader.m b/matlab/generated/+test_model/+binary/MapsReader.m index 48ebad45..b702f3db 100644 --- a/matlab/generated/+test_model/+binary/MapsReader.m +++ b/matlab/generated/+test_model/+binary/MapsReader.m @@ -10,31 +10,31 @@ end methods - function obj = MapsReader(filename) - obj@test_model.MapsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.MapsReaderBase.schema); - obj.string_to_int_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); - obj.int_to_string_serializer = yardl.binary.MapSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); - obj.string_to_union_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.UnionSerializer('test_model.StringOrInt32', {yardl.binary.StringSerializer, yardl.binary.Int32Serializer}, {@test_model.StringOrInt32.String, @test_model.StringOrInt32.Int32})); - obj.aliased_generic_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); + function self = MapsReader(filename) + self@test_model.MapsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.MapsReaderBase.schema); + self.string_to_int_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); + self.int_to_string_serializer = yardl.binary.MapSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + self.string_to_union_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.UnionSerializer('test_model.StringOrInt32', {yardl.binary.StringSerializer, yardl.binary.Int32Serializer}, {@test_model.StringOrInt32.String, @test_model.StringOrInt32.Int32})); + self.aliased_generic_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); end end methods (Access=protected) - function value = read_string_to_int_(obj) - value = obj.string_to_int_serializer.read(obj.stream_); + function value = read_string_to_int_(self) + value = self.string_to_int_serializer.read(self.stream_); end - function value = read_int_to_string_(obj) - value = obj.int_to_string_serializer.read(obj.stream_); + function value = read_int_to_string_(self) + value = self.int_to_string_serializer.read(self.stream_); end - function value = read_string_to_union_(obj) - value = obj.string_to_union_serializer.read(obj.stream_); + function value = read_string_to_union_(self) + value = self.string_to_union_serializer.read(self.stream_); end - function value = read_aliased_generic_(obj) - value = obj.aliased_generic_serializer.read(obj.stream_); + function value = read_aliased_generic_(self) + value = self.aliased_generic_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/MapsWriter.m b/matlab/generated/+test_model/+binary/MapsWriter.m index e522badc..eaff4c19 100644 --- a/matlab/generated/+test_model/+binary/MapsWriter.m +++ b/matlab/generated/+test_model/+binary/MapsWriter.m @@ -10,31 +10,31 @@ end methods - function obj = MapsWriter(filename) - obj@test_model.MapsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.MapsWriterBase.schema); - obj.string_to_int_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); - obj.int_to_string_serializer = yardl.binary.MapSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); - obj.string_to_union_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.UnionSerializer('test_model.StringOrInt32', {yardl.binary.StringSerializer, yardl.binary.Int32Serializer}, {@test_model.StringOrInt32.String, @test_model.StringOrInt32.Int32})); - obj.aliased_generic_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); + function self = MapsWriter(filename) + self@test_model.MapsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.MapsWriterBase.schema); + self.string_to_int_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); + self.int_to_string_serializer = yardl.binary.MapSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + self.string_to_union_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.UnionSerializer('test_model.StringOrInt32', {yardl.binary.StringSerializer, yardl.binary.Int32Serializer}, {@test_model.StringOrInt32.String, @test_model.StringOrInt32.Int32})); + self.aliased_generic_serializer = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); end end methods (Access=protected) - function write_string_to_int_(obj, value) - obj.string_to_int_serializer.write(obj.stream_, value); + function write_string_to_int_(self, value) + self.string_to_int_serializer.write(self.stream_, value); end - function write_int_to_string_(obj, value) - obj.int_to_string_serializer.write(obj.stream_, value); + function write_int_to_string_(self, value) + self.int_to_string_serializer.write(self.stream_, value); end - function write_string_to_union_(obj, value) - obj.string_to_union_serializer.write(obj.stream_, value); + function write_string_to_union_(self, value) + self.string_to_union_serializer.write(self.stream_, value); end - function write_aliased_generic_(obj, value) - obj.aliased_generic_serializer.write(obj.stream_, value); + function write_aliased_generic_(self, value) + self.aliased_generic_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/NDArraysReader.m b/matlab/generated/+test_model/+binary/NDArraysReader.m index 7d829228..8314be45 100644 --- a/matlab/generated/+test_model/+binary/NDArraysReader.m +++ b/matlab/generated/+test_model/+binary/NDArraysReader.m @@ -11,36 +11,36 @@ end methods - function obj = NDArraysReader(filename) - obj@test_model.NDArraysReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.NDArraysReaderBase.schema); - obj.ints_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - obj.simple_record_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 2); - obj.record_with_vlens_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 2); - obj.record_with_nd_arrays_serializer = test_model.binary.RecordWithNDArraysSerializer(); - obj.named_array_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + function self = NDArraysReader(filename) + self@test_model.NDArraysReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.NDArraysReaderBase.schema); + self.ints_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + self.simple_record_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 2); + self.record_with_vlens_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 2); + self.record_with_nd_arrays_serializer = test_model.binary.RecordWithNDArraysSerializer(); + self.named_array_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); end end methods (Access=protected) - function value = read_ints_(obj) - value = obj.ints_serializer.read(obj.stream_); + function value = read_ints_(self) + value = self.ints_serializer.read(self.stream_); end - function value = read_simple_record_array_(obj) - value = obj.simple_record_array_serializer.read(obj.stream_); + function value = read_simple_record_array_(self) + value = self.simple_record_array_serializer.read(self.stream_); end - function value = read_record_with_vlens_array_(obj) - value = obj.record_with_vlens_array_serializer.read(obj.stream_); + function value = read_record_with_vlens_array_(self) + value = self.record_with_vlens_array_serializer.read(self.stream_); end - function value = read_record_with_nd_arrays_(obj) - value = obj.record_with_nd_arrays_serializer.read(obj.stream_); + function value = read_record_with_nd_arrays_(self) + value = self.record_with_nd_arrays_serializer.read(self.stream_); end - function value = read_named_array_(obj) - value = obj.named_array_serializer.read(obj.stream_); + function value = read_named_array_(self) + value = self.named_array_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m index 7be072b4..6073b3c5 100644 --- a/matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m +++ b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionReader.m @@ -10,31 +10,31 @@ end methods - function obj = NDArraysSingleDimensionReader(filename) - obj@test_model.NDArraysSingleDimensionReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.NDArraysSingleDimensionReaderBase.schema); - obj.ints_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); - obj.simple_record_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 1); - obj.record_with_vlens_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 1); - obj.record_with_nd_arrays_serializer = test_model.binary.RecordWithNDArraysSingleDimensionSerializer(); + function self = NDArraysSingleDimensionReader(filename) + self@test_model.NDArraysSingleDimensionReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.NDArraysSingleDimensionReaderBase.schema); + self.ints_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); + self.simple_record_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 1); + self.record_with_vlens_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 1); + self.record_with_nd_arrays_serializer = test_model.binary.RecordWithNDArraysSingleDimensionSerializer(); end end methods (Access=protected) - function value = read_ints_(obj) - value = obj.ints_serializer.read(obj.stream_); + function value = read_ints_(self) + value = self.ints_serializer.read(self.stream_); end - function value = read_simple_record_array_(obj) - value = obj.simple_record_array_serializer.read(obj.stream_); + function value = read_simple_record_array_(self) + value = self.simple_record_array_serializer.read(self.stream_); end - function value = read_record_with_vlens_array_(obj) - value = obj.record_with_vlens_array_serializer.read(obj.stream_); + function value = read_record_with_vlens_array_(self) + value = self.record_with_vlens_array_serializer.read(self.stream_); end - function value = read_record_with_nd_arrays_(obj) - value = obj.record_with_nd_arrays_serializer.read(obj.stream_); + function value = read_record_with_nd_arrays_(self) + value = self.record_with_nd_arrays_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m index 71664529..092ff0a5 100644 --- a/matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m +++ b/matlab/generated/+test_model/+binary/NDArraysSingleDimensionWriter.m @@ -10,31 +10,31 @@ end methods - function obj = NDArraysSingleDimensionWriter(filename) - obj@test_model.NDArraysSingleDimensionWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.NDArraysSingleDimensionWriterBase.schema); - obj.ints_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); - obj.simple_record_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 1); - obj.record_with_vlens_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 1); - obj.record_with_nd_arrays_serializer = test_model.binary.RecordWithNDArraysSingleDimensionSerializer(); + function self = NDArraysSingleDimensionWriter(filename) + self@test_model.NDArraysSingleDimensionWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.NDArraysSingleDimensionWriterBase.schema); + self.ints_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); + self.simple_record_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 1); + self.record_with_vlens_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 1); + self.record_with_nd_arrays_serializer = test_model.binary.RecordWithNDArraysSingleDimensionSerializer(); end end methods (Access=protected) - function write_ints_(obj, value) - obj.ints_serializer.write(obj.stream_, value); + function write_ints_(self, value) + self.ints_serializer.write(self.stream_, value); end - function write_simple_record_array_(obj, value) - obj.simple_record_array_serializer.write(obj.stream_, value); + function write_simple_record_array_(self, value) + self.simple_record_array_serializer.write(self.stream_, value); end - function write_record_with_vlens_array_(obj, value) - obj.record_with_vlens_array_serializer.write(obj.stream_, value); + function write_record_with_vlens_array_(self, value) + self.record_with_vlens_array_serializer.write(self.stream_, value); end - function write_record_with_nd_arrays_(obj, value) - obj.record_with_nd_arrays_serializer.write(obj.stream_, value); + function write_record_with_nd_arrays_(self, value) + self.record_with_nd_arrays_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/NDArraysWriter.m b/matlab/generated/+test_model/+binary/NDArraysWriter.m index 2468160b..fa2014ea 100644 --- a/matlab/generated/+test_model/+binary/NDArraysWriter.m +++ b/matlab/generated/+test_model/+binary/NDArraysWriter.m @@ -11,36 +11,36 @@ end methods - function obj = NDArraysWriter(filename) - obj@test_model.NDArraysWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.NDArraysWriterBase.schema); - obj.ints_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - obj.simple_record_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 2); - obj.record_with_vlens_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 2); - obj.record_with_nd_arrays_serializer = test_model.binary.RecordWithNDArraysSerializer(); - obj.named_array_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + function self = NDArraysWriter(filename) + self@test_model.NDArraysWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.NDArraysWriterBase.schema); + self.ints_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + self.simple_record_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 2); + self.record_with_vlens_array_serializer = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 2); + self.record_with_nd_arrays_serializer = test_model.binary.RecordWithNDArraysSerializer(); + self.named_array_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); end end methods (Access=protected) - function write_ints_(obj, value) - obj.ints_serializer.write(obj.stream_, value); + function write_ints_(self, value) + self.ints_serializer.write(self.stream_, value); end - function write_simple_record_array_(obj, value) - obj.simple_record_array_serializer.write(obj.stream_, value); + function write_simple_record_array_(self, value) + self.simple_record_array_serializer.write(self.stream_, value); end - function write_record_with_vlens_array_(obj, value) - obj.record_with_vlens_array_serializer.write(obj.stream_, value); + function write_record_with_vlens_array_(self, value) + self.record_with_vlens_array_serializer.write(self.stream_, value); end - function write_record_with_nd_arrays_(obj, value) - obj.record_with_nd_arrays_serializer.write(obj.stream_, value); + function write_record_with_nd_arrays_(self, value) + self.record_with_nd_arrays_serializer.write(self.stream_, value); end - function write_named_array_(obj, value) - obj.named_array_serializer.write(obj.stream_, value); + function write_named_array_(self, value) + self.named_array_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/NestedRecordsReader.m b/matlab/generated/+test_model/+binary/NestedRecordsReader.m index 4538d286..6663bc64 100644 --- a/matlab/generated/+test_model/+binary/NestedRecordsReader.m +++ b/matlab/generated/+test_model/+binary/NestedRecordsReader.m @@ -7,16 +7,16 @@ end methods - function obj = NestedRecordsReader(filename) - obj@test_model.NestedRecordsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.NestedRecordsReaderBase.schema); - obj.tuple_with_records_serializer = test_model.binary.TupleWithRecordsSerializer(); + function self = NestedRecordsReader(filename) + self@test_model.NestedRecordsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.NestedRecordsReaderBase.schema); + self.tuple_with_records_serializer = test_model.binary.TupleWithRecordsSerializer(); end end methods (Access=protected) - function value = read_tuple_with_records_(obj) - value = obj.tuple_with_records_serializer.read(obj.stream_); + function value = read_tuple_with_records_(self) + value = self.tuple_with_records_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/NestedRecordsWriter.m b/matlab/generated/+test_model/+binary/NestedRecordsWriter.m index 9882039b..f40653db 100644 --- a/matlab/generated/+test_model/+binary/NestedRecordsWriter.m +++ b/matlab/generated/+test_model/+binary/NestedRecordsWriter.m @@ -7,16 +7,16 @@ end methods - function obj = NestedRecordsWriter(filename) - obj@test_model.NestedRecordsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.NestedRecordsWriterBase.schema); - obj.tuple_with_records_serializer = test_model.binary.TupleWithRecordsSerializer(); + function self = NestedRecordsWriter(filename) + self@test_model.NestedRecordsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.NestedRecordsWriterBase.schema); + self.tuple_with_records_serializer = test_model.binary.TupleWithRecordsSerializer(); end end methods (Access=protected) - function write_tuple_with_records_(obj, value) - obj.tuple_with_records_serializer.write(obj.stream_, value); + function write_tuple_with_records_(self, value) + self.tuple_with_records_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/OptionalVectorsReader.m b/matlab/generated/+test_model/+binary/OptionalVectorsReader.m index 3268b291..463e4196 100644 --- a/matlab/generated/+test_model/+binary/OptionalVectorsReader.m +++ b/matlab/generated/+test_model/+binary/OptionalVectorsReader.m @@ -7,16 +7,16 @@ end methods - function obj = OptionalVectorsReader(filename) - obj@test_model.OptionalVectorsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.OptionalVectorsReaderBase.schema); - obj.record_with_optional_vector_serializer = test_model.binary.RecordWithOptionalVectorSerializer(); + function self = OptionalVectorsReader(filename) + self@test_model.OptionalVectorsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.OptionalVectorsReaderBase.schema); + self.record_with_optional_vector_serializer = test_model.binary.RecordWithOptionalVectorSerializer(); end end methods (Access=protected) - function value = read_record_with_optional_vector_(obj) - value = obj.record_with_optional_vector_serializer.read(obj.stream_); + function value = read_record_with_optional_vector_(self) + value = self.record_with_optional_vector_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/OptionalVectorsWriter.m b/matlab/generated/+test_model/+binary/OptionalVectorsWriter.m index e939008f..a30085b0 100644 --- a/matlab/generated/+test_model/+binary/OptionalVectorsWriter.m +++ b/matlab/generated/+test_model/+binary/OptionalVectorsWriter.m @@ -7,16 +7,16 @@ end methods - function obj = OptionalVectorsWriter(filename) - obj@test_model.OptionalVectorsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.OptionalVectorsWriterBase.schema); - obj.record_with_optional_vector_serializer = test_model.binary.RecordWithOptionalVectorSerializer(); + function self = OptionalVectorsWriter(filename) + self@test_model.OptionalVectorsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.OptionalVectorsWriterBase.schema); + self.record_with_optional_vector_serializer = test_model.binary.RecordWithOptionalVectorSerializer(); end end methods (Access=protected) - function write_record_with_optional_vector_(obj, value) - obj.record_with_optional_vector_serializer.write(obj.stream_, value); + function write_record_with_optional_vector_(self, value) + self.record_with_optional_vector_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m index 90c8d3fa..f79b4299 100644 --- a/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m +++ b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsReader.m @@ -7,16 +7,16 @@ end methods - function obj = ProtocolWithComputedFieldsReader(filename) - obj@test_model.ProtocolWithComputedFieldsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.ProtocolWithComputedFieldsReaderBase.schema); - obj.record_with_computed_fields_serializer = test_model.binary.RecordWithComputedFieldsSerializer(); + function self = ProtocolWithComputedFieldsReader(filename) + self@test_model.ProtocolWithComputedFieldsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.ProtocolWithComputedFieldsReaderBase.schema); + self.record_with_computed_fields_serializer = test_model.binary.RecordWithComputedFieldsSerializer(); end end methods (Access=protected) - function value = read_record_with_computed_fields_(obj) - value = obj.record_with_computed_fields_serializer.read(obj.stream_); + function value = read_record_with_computed_fields_(self) + value = self.record_with_computed_fields_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m index 5753fe27..494a6d78 100644 --- a/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m +++ b/matlab/generated/+test_model/+binary/ProtocolWithComputedFieldsWriter.m @@ -7,16 +7,16 @@ end methods - function obj = ProtocolWithComputedFieldsWriter(filename) - obj@test_model.ProtocolWithComputedFieldsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.ProtocolWithComputedFieldsWriterBase.schema); - obj.record_with_computed_fields_serializer = test_model.binary.RecordWithComputedFieldsSerializer(); + function self = ProtocolWithComputedFieldsWriter(filename) + self@test_model.ProtocolWithComputedFieldsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.ProtocolWithComputedFieldsWriterBase.schema); + self.record_with_computed_fields_serializer = test_model.binary.RecordWithComputedFieldsSerializer(); end end methods (Access=protected) - function write_record_with_computed_fields_(obj, value) - obj.record_with_computed_fields_serializer.write(obj.stream_, value); + function write_record_with_computed_fields_(self, value) + self.record_with_computed_fields_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m index b9258b44..b6fc429e 100644 --- a/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m +++ b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsReader.m @@ -8,25 +8,25 @@ end methods - function obj = ProtocolWithKeywordStepsReader(filename) - obj@test_model.ProtocolWithKeywordStepsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.ProtocolWithKeywordStepsReaderBase.schema); - obj.int_serializer = yardl.binary.StreamSerializer(test_model.binary.RecordWithKeywordFieldsSerializer()); - obj.float_serializer = yardl.binary.EnumSerializer('test_model.EnumWithKeywordSymbols', @test_model.EnumWithKeywordSymbols, yardl.binary.Int32Serializer); + function self = ProtocolWithKeywordStepsReader(filename) + self@test_model.ProtocolWithKeywordStepsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.ProtocolWithKeywordStepsReaderBase.schema); + self.int_serializer = yardl.binary.StreamSerializer(test_model.binary.RecordWithKeywordFieldsSerializer()); + self.float_serializer = yardl.binary.EnumSerializer('test_model.EnumWithKeywordSymbols', @test_model.EnumWithKeywordSymbols, yardl.binary.Int32Serializer); end end methods (Access=protected) - function more = has_int_(obj) - more = obj.int_serializer.hasnext(obj.stream_); + function more = has_int_(self) + more = self.int_serializer.hasnext(self.stream_); end - function value = read_int_(obj) - value = obj.int_serializer.read(obj.stream_); + function value = read_int_(self) + value = self.int_serializer.read(self.stream_); end - function value = read_float_(obj) - value = obj.float_serializer.read(obj.stream_); + function value = read_float_(self) + value = self.float_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m index 2b5a9906..706de0bf 100644 --- a/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m +++ b/matlab/generated/+test_model/+binary/ProtocolWithKeywordStepsWriter.m @@ -8,21 +8,21 @@ end methods - function obj = ProtocolWithKeywordStepsWriter(filename) - obj@test_model.ProtocolWithKeywordStepsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.ProtocolWithKeywordStepsWriterBase.schema); - obj.int_serializer = yardl.binary.StreamSerializer(test_model.binary.RecordWithKeywordFieldsSerializer()); - obj.float_serializer = yardl.binary.EnumSerializer('test_model.EnumWithKeywordSymbols', @test_model.EnumWithKeywordSymbols, yardl.binary.Int32Serializer); + function self = ProtocolWithKeywordStepsWriter(filename) + self@test_model.ProtocolWithKeywordStepsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.ProtocolWithKeywordStepsWriterBase.schema); + self.int_serializer = yardl.binary.StreamSerializer(test_model.binary.RecordWithKeywordFieldsSerializer()); + self.float_serializer = yardl.binary.EnumSerializer('test_model.EnumWithKeywordSymbols', @test_model.EnumWithKeywordSymbols, yardl.binary.Int32Serializer); end end methods (Access=protected) - function write_int_(obj, value) - obj.int_serializer.write(obj.stream_, value); + function write_int_(self, value) + self.int_serializer.write(self.stream_, value); end - function write_float_(obj, value) - obj.float_serializer.write(obj.stream_, value); + function write_float_(self, value) + self.float_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m b/matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m index de878e5f..60ec2301 100644 --- a/matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m @@ -2,7 +2,7 @@ classdef RecordContainingGenericRecordsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordContainingGenericRecordsSerializer(a_serializer, b_serializer) + function self = RecordContainingGenericRecordsSerializer(a_serializer, b_serializer) field_serializers{1} = test_model.binary.RecordWithOptionalGenericFieldSerializer(a_serializer); field_serializers{2} = test_model.binary.RecordWithAliasedOptionalGenericFieldSerializer(a_serializer); field_serializers{3} = test_model.binary.RecordWithOptionalGenericUnionFieldSerializer(a_serializer, b_serializer); @@ -13,16 +13,20 @@ field_serializers{8} = test_model.binary.RecordWithGenericFixedVectorsSerializer(b_serializer); field_serializers{9} = test_model.binary.RecordWithGenericArraysSerializer(b_serializer); field_serializers{10} = test_model.binary.RecordWithGenericMapsSerializer(a_serializer, b_serializer); - obj@yardl.binary.RecordSerializer('test_model.RecordContainingGenericRecords', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordContainingGenericRecords', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordContainingGenericRecords')); - obj.write_(outstream, value.g1, value.g1a, value.g2, value.g2a, value.g3, value.g3a, value.g4, value.g5, value.g6, value.g7) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordContainingGenericRecords + end + self.write_(outstream, value.g1, value.g1a, value.g2, value.g2a, value.g3, value.g3a, value.g4, value.g5, value.g6, value.g7) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordContainingGenericRecords(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m b/matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m index cf6844ac..3bb78a34 100644 --- a/matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m @@ -2,22 +2,26 @@ classdef RecordContainingNestedGenericRecordsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordContainingNestedGenericRecordsSerializer() + function self = RecordContainingNestedGenericRecordsSerializer() field_serializers{1} = test_model.binary.RecordWithOptionalGenericFieldSerializer(yardl.binary.StringSerializer); field_serializers{2} = test_model.binary.RecordWithAliasedOptionalGenericFieldSerializer(yardl.binary.StringSerializer); field_serializers{3} = test_model.binary.RecordWithOptionalGenericUnionFieldSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); field_serializers{4} = test_model.binary.RecordWithAliasedOptionalGenericUnionFieldSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); field_serializers{5} = test_model.binary.RecordContainingGenericRecordsSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer); - obj@yardl.binary.RecordSerializer('test_model.RecordContainingNestedGenericRecords', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordContainingNestedGenericRecords', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordContainingNestedGenericRecords')); - obj.write_(outstream, value.f1, value.f1a, value.f2, value.f2a, value.nested) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordContainingNestedGenericRecords + end + self.write_(outstream, value.f1, value.f1a, value.f2, value.f2a, value.nested) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordContainingNestedGenericRecords(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m b/matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m index e2413269..5b3f4b4b 100644 --- a/matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m @@ -2,19 +2,23 @@ classdef RecordNotUsedInProtocolSerializer < yardl.binary.RecordSerializer methods - function obj = RecordNotUsedInProtocolSerializer() + function self = RecordNotUsedInProtocolSerializer() field_serializers{1} = yardl.binary.UnionSerializer('test_model.GenericUnion3', {yardl.binary.Int32Serializer, yardl.binary.Float32Serializer, yardl.binary.StringSerializer}, {@test_model.GenericUnion3.T, @test_model.GenericUnion3.U, @test_model.GenericUnion3.V}); field_serializers{2} = yardl.binary.UnionSerializer('test_model.GenericUnion3Alternate', {yardl.binary.Int32Serializer, yardl.binary.Float32Serializer, yardl.binary.StringSerializer}, {@test_model.GenericUnion3Alternate.U, @test_model.GenericUnion3Alternate.V, @test_model.GenericUnion3Alternate.W}); - obj@yardl.binary.RecordSerializer('test_model.RecordNotUsedInProtocol', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordNotUsedInProtocol', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordNotUsedInProtocol')); - obj.write_(outstream, value.u1, value.u2) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordNotUsedInProtocol + end + self.write_(outstream, value.u1, value.u2) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordNotUsedInProtocol(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m index e050b084..7a3ee385 100644 --- a/matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m @@ -2,19 +2,23 @@ classdef RecordWithAliasedGenericsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithAliasedGenericsSerializer() + function self = RecordWithAliasedGenericsSerializer() field_serializers{1} = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.StringSerializer); field_serializers{2} = tuples.binary.TupleSerializer(yardl.binary.StringSerializer, yardl.binary.StringSerializer); - obj@yardl.binary.RecordSerializer('test_model.RecordWithAliasedGenerics', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithAliasedGenerics', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithAliasedGenerics')); - obj.write_(outstream, value.my_strings, value.aliased_strings) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithAliasedGenerics + end + self.write_(outstream, value.my_strings, value.aliased_strings) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithAliasedGenerics(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m index 87895f56..7fe3f9f0 100644 --- a/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m @@ -2,18 +2,22 @@ classdef RecordWithAliasedOptionalGenericFieldSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithAliasedOptionalGenericFieldSerializer(t_serializer) + function self = RecordWithAliasedOptionalGenericFieldSerializer(t_serializer) field_serializers{1} = yardl.binary.OptionalSerializer(t_serializer); - obj@yardl.binary.RecordSerializer('test_model.RecordWithAliasedOptionalGenericField', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithAliasedOptionalGenericField', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithAliasedOptionalGenericField')); - obj.write_(outstream, value.v) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithAliasedOptionalGenericField + end + self.write_(outstream, value.v) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithAliasedOptionalGenericField(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m index 4d9da421..91febc81 100644 --- a/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m @@ -2,18 +2,22 @@ classdef RecordWithAliasedOptionalGenericUnionFieldSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithAliasedOptionalGenericUnionFieldSerializer(u_serializer, v_serializer) + function self = RecordWithAliasedOptionalGenericUnionFieldSerializer(u_serializer, v_serializer) field_serializers{1} = yardl.binary.UnionSerializer('test_model.AliasedMultiGenericOptional', {yardl.binary.NoneSerializer, u_serializer, v_serializer}, {yardl.None, @test_model.AliasedMultiGenericOptional.T, @test_model.AliasedMultiGenericOptional.U}); - obj@yardl.binary.RecordSerializer('test_model.RecordWithAliasedOptionalGenericUnionField', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithAliasedOptionalGenericUnionField', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithAliasedOptionalGenericUnionField')); - obj.write_(outstream, value.v) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithAliasedOptionalGenericUnionField + end + self.write_(outstream, value.v) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithAliasedOptionalGenericUnionField(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m index 8cc58c8e..45aa8f10 100644 --- a/matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m @@ -2,7 +2,7 @@ classdef RecordWithArraysSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithArraysSerializer() + function self = RecordWithArraysSerializer() field_serializers{1} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); field_serializers{2} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); field_serializers{3} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); @@ -12,16 +12,20 @@ field_serializers{7} = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 3]); field_serializers{8} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); field_serializers{9} = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 4), [5]); - obj@yardl.binary.RecordSerializer('test_model.RecordWithArrays', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithArrays', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithArrays')); - obj.write_(outstream, value.default_array, value.default_array_with_empty_dimension, value.rank_1_array, value.rank_2_array, value.rank_2_array_with_named_dimensions, value.rank_2_fixed_array, value.rank_2_fixed_array_with_named_dimensions, value.dynamic_array, value.array_of_vectors) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithArrays + end + self.write_(outstream, value.default_array, value.default_array_with_empty_dimension, value.rank_1_array, value.rank_2_array, value.rank_2_array_with_named_dimensions, value.rank_2_fixed_array, value.rank_2_fixed_array_with_named_dimensions, value.dynamic_array, value.array_of_vectors) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithArrays(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m b/matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m index d089a19e..2a226ad3 100644 --- a/matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m @@ -2,7 +2,7 @@ classdef RecordWithArraysSimpleSyntaxSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithArraysSimpleSyntaxSerializer() + function self = RecordWithArraysSimpleSyntaxSerializer() field_serializers{1} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); field_serializers{2} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); field_serializers{3} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); @@ -12,16 +12,20 @@ field_serializers{7} = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [4, 3]); field_serializers{8} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); field_serializers{9} = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 4), [5]); - obj@yardl.binary.RecordSerializer('test_model.RecordWithArraysSimpleSyntax', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithArraysSimpleSyntax', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithArraysSimpleSyntax')); - obj.write_(outstream, value.default_array, value.default_array_with_empty_dimension, value.rank_1_array, value.rank_2_array, value.rank_2_array_with_named_dimensions, value.rank_2_fixed_array, value.rank_2_fixed_array_with_named_dimensions, value.dynamic_array, value.array_of_vectors) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithArraysSimpleSyntax + end + self.write_(outstream, value.default_array, value.default_array_with_empty_dimension, value.rank_1_array, value.rank_2_array, value.rank_2_array_with_named_dimensions, value.rank_2_fixed_array, value.rank_2_fixed_array_with_named_dimensions, value.dynamic_array, value.array_of_vectors) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithArraysSimpleSyntax(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m index b7a91bb1..91b64963 100644 --- a/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m @@ -2,7 +2,7 @@ classdef RecordWithComputedFieldsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithComputedFieldsSerializer() + function self = RecordWithComputedFieldsSerializer() field_serializers{1} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); field_serializers{2} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); field_serializers{3} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); @@ -31,16 +31,20 @@ field_serializers{26} = yardl.binary.UnionSerializer('test_model.Int32OrFloat32', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, yardl.binary.Float32Serializer}, {yardl.None, @test_model.Int32OrFloat32.Int32, @test_model.Int32OrFloat32.Float32}); field_serializers{27} = yardl.binary.UnionSerializer('test_model.IntOrGenericRecordWithComputedFields', {yardl.binary.Int32Serializer, basic_types.binary.GenericRecordWithComputedFieldsSerializer(yardl.binary.StringSerializer, yardl.binary.Float32Serializer)}, {@test_model.IntOrGenericRecordWithComputedFields.Int, @test_model.IntOrGenericRecordWithComputedFields.GenericRecordWithComputedFields}); field_serializers{28} = yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.StringSerializer); - obj@yardl.binary.RecordSerializer('test_model.RecordWithComputedFields', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithComputedFields', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithComputedFields')); - obj.write_(outstream, value.array_field, value.array_field_map_dimensions, value.dynamic_array_field, value.fixed_array_field, value.int_field, value.int8_field, value.uint8_field, value.int16_field, value.uint16_field, value.uint32_field, value.int64_field, value.uint64_field, value.size_field, value.float32_field, value.float64_field, value.complexfloat32_field, value.complexfloat64_field, value.string_field, value.tuple_field, value.vector_field, value.vector_of_vectors_field, value.fixed_vector_field, value.fixed_vector_of_vectors_field, value.optional_named_array, value.int_float_union, value.nullable_int_float_union, value.union_with_nested_generic_union, value.map_field) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithComputedFields + end + self.write_(outstream, value.array_field, value.array_field_map_dimensions, value.dynamic_array_field, value.fixed_array_field, value.int_field, value.int8_field, value.uint8_field, value.int16_field, value.uint16_field, value.uint32_field, value.int64_field, value.uint64_field, value.size_field, value.float32_field, value.float64_field, value.complexfloat32_field, value.complexfloat64_field, value.string_field, value.tuple_field, value.vector_field, value.vector_of_vectors_field, value.fixed_vector_field, value.fixed_vector_of_vectors_field, value.optional_named_array, value.int_float_union, value.nullable_int_float_union, value.union_with_nested_generic_union, value.map_field) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithComputedFields(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m index b34a2c3d..7272e4d3 100644 --- a/matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m @@ -2,20 +2,24 @@ classdef RecordWithDynamicNDArraysSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithDynamicNDArraysSerializer() + function self = RecordWithDynamicNDArraysSerializer() field_serializers{1} = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); field_serializers{2} = yardl.binary.DynamicNDArraySerializer(test_model.binary.SimpleRecordSerializer()); field_serializers{3} = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlensSerializer()); - obj@yardl.binary.RecordSerializer('test_model.RecordWithDynamicNDArrays', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithDynamicNDArrays', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithDynamicNDArrays')); - obj.write_(outstream, value.ints, value.simple_record_array, value.record_with_vlens_array) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithDynamicNDArrays + end + self.write_(outstream, value.ints, value.simple_record_array, value.record_with_vlens_array) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithDynamicNDArrays(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m index ddcc2310..45f53afe 100644 --- a/matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m @@ -2,20 +2,24 @@ classdef RecordWithEnumsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithEnumsSerializer() + function self = RecordWithEnumsSerializer() field_serializers{1} = yardl.binary.EnumSerializer('basic_types.Fruits', @basic_types.Fruits, yardl.binary.Int32Serializer); field_serializers{2} = yardl.binary.EnumSerializer('basic_types.DaysOfWeek', @basic_types.DaysOfWeek, yardl.binary.Int32Serializer); field_serializers{3} = yardl.binary.EnumSerializer('basic_types.TextFormat', @basic_types.TextFormat, yardl.binary.Uint64Serializer); - obj@yardl.binary.RecordSerializer('test_model.RecordWithEnums', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithEnums', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithEnums')); - obj.write_(outstream, value.enum, value.flags, value.flags_2) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithEnums + end + self.write_(outstream, value.enum, value.flags, value.flags_2) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithEnums(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m index 0dce817c..851c1556 100644 --- a/matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m @@ -2,20 +2,24 @@ classdef RecordWithFixedArraysSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithFixedArraysSerializer() + function self = RecordWithFixedArraysSerializer() field_serializers{1} = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); field_serializers{2} = yardl.binary.FixedNDArraySerializer(test_model.binary.SimpleRecordSerializer(), [2, 3]); field_serializers{3} = yardl.binary.FixedNDArraySerializer(test_model.binary.RecordWithVlensSerializer(), [2, 2]); - obj@yardl.binary.RecordSerializer('test_model.RecordWithFixedArrays', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithFixedArrays', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithFixedArrays')); - obj.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithFixedArrays + end + self.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithFixedArrays(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m index ac3cd3cb..2f426c83 100644 --- a/matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m @@ -2,19 +2,23 @@ classdef RecordWithFixedCollectionsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithFixedCollectionsSerializer() + function self = RecordWithFixedCollectionsSerializer() field_serializers{1} = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3); field_serializers{2} = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); - obj@yardl.binary.RecordSerializer('test_model.RecordWithFixedCollections', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithFixedCollections', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithFixedCollections')); - obj.write_(outstream, value.fixed_vector, value.fixed_array) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithFixedCollections + end + self.write_(outstream, value.fixed_vector, value.fixed_array) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithFixedCollections(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m index 9c2a5df3..e5c9634f 100644 --- a/matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m @@ -2,20 +2,24 @@ classdef RecordWithFixedVectorsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithFixedVectorsSerializer() + function self = RecordWithFixedVectorsSerializer() field_serializers{1} = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 5); field_serializers{2} = yardl.binary.FixedVectorSerializer(test_model.binary.SimpleRecordSerializer(), 3); field_serializers{3} = yardl.binary.FixedVectorSerializer(test_model.binary.RecordWithVlensSerializer(), 2); - obj@yardl.binary.RecordSerializer('test_model.RecordWithFixedVectors', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithFixedVectors', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithFixedVectors')); - obj.write_(outstream, value.fixed_int_vector, value.fixed_simple_record_vector, value.fixed_record_with_vlens_vector) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithFixedVectors + end + self.write_(outstream, value.fixed_int_vector, value.fixed_simple_record_vector, value.fixed_record_with_vlens_vector) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithFixedVectors(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m index 06924402..c4c0546c 100644 --- a/matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m @@ -2,23 +2,27 @@ classdef RecordWithGenericArraysSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithGenericArraysSerializer(t_serializer) + function self = RecordWithGenericArraysSerializer(t_serializer) field_serializers{1} = yardl.binary.NDArraySerializer(t_serializer, 2); field_serializers{2} = yardl.binary.FixedNDArraySerializer(t_serializer, [8, 16]); field_serializers{3} = yardl.binary.DynamicNDArraySerializer(t_serializer); field_serializers{4} = yardl.binary.NDArraySerializer(t_serializer, 2); field_serializers{5} = yardl.binary.FixedNDArraySerializer(t_serializer, [8, 16]); field_serializers{6} = yardl.binary.DynamicNDArraySerializer(t_serializer); - obj@yardl.binary.RecordSerializer('test_model.RecordWithGenericArrays', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithGenericArrays', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithGenericArrays')); - obj.write_(outstream, value.nd, value.fixed_nd, value.dynamic_nd, value.aliased_nd, value.aliased_fixed_nd, value.aliased_dynamic_nd) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithGenericArrays + end + self.write_(outstream, value.nd, value.fixed_nd, value.dynamic_nd, value.aliased_nd, value.aliased_fixed_nd, value.aliased_dynamic_nd) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithGenericArrays(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m index 49b75fa9..841eb30a 100644 --- a/matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m @@ -2,19 +2,23 @@ classdef RecordWithGenericFixedVectorsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithGenericFixedVectorsSerializer(t_serializer) + function self = RecordWithGenericFixedVectorsSerializer(t_serializer) field_serializers{1} = yardl.binary.FixedVectorSerializer(t_serializer, 3); field_serializers{2} = yardl.binary.FixedVectorSerializer(t_serializer, 3); - obj@yardl.binary.RecordSerializer('test_model.RecordWithGenericFixedVectors', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithGenericFixedVectors', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithGenericFixedVectors')); - obj.write_(outstream, value.fv, value.afv) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithGenericFixedVectors + end + self.write_(outstream, value.fv, value.afv) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithGenericFixedVectors(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m index 039d2100..015eda54 100644 --- a/matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m @@ -2,19 +2,23 @@ classdef RecordWithGenericMapsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithGenericMapsSerializer(t_serializer, u_serializer) + function self = RecordWithGenericMapsSerializer(t_serializer, u_serializer) field_serializers{1} = yardl.binary.MapSerializer(t_serializer, u_serializer); field_serializers{2} = yardl.binary.MapSerializer(t_serializer, u_serializer); - obj@yardl.binary.RecordSerializer('test_model.RecordWithGenericMaps', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithGenericMaps', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithGenericMaps')); - obj.write_(outstream, value.m, value.am) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithGenericMaps + end + self.write_(outstream, value.m, value.am) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithGenericMaps(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m index bdbff197..7c3d1250 100644 --- a/matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m @@ -2,18 +2,22 @@ classdef RecordWithGenericVectorOfRecordsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithGenericVectorOfRecordsSerializer(t_serializer, u_serializer) + function self = RecordWithGenericVectorOfRecordsSerializer(t_serializer, u_serializer) field_serializers{1} = yardl.binary.VectorSerializer(yardl.binary.VectorSerializer(test_model.binary.GenericRecordSerializer(t_serializer, u_serializer))); - obj@yardl.binary.RecordSerializer('test_model.RecordWithGenericVectorOfRecords', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithGenericVectorOfRecords', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithGenericVectorOfRecords')); - obj.write_(outstream, value.v) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithGenericVectorOfRecords + end + self.write_(outstream, value.v) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithGenericVectorOfRecords(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m index 1518b49f..c5b54317 100644 --- a/matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m @@ -2,19 +2,23 @@ classdef RecordWithGenericVectorsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithGenericVectorsSerializer(t_serializer) + function self = RecordWithGenericVectorsSerializer(t_serializer) field_serializers{1} = yardl.binary.VectorSerializer(t_serializer); field_serializers{2} = yardl.binary.VectorSerializer(t_serializer); - obj@yardl.binary.RecordSerializer('test_model.RecordWithGenericVectors', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithGenericVectors', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithGenericVectors')); - obj.write_(outstream, value.v, value.av) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithGenericVectors + end + self.write_(outstream, value.v, value.av) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithGenericVectors(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m index 263820e1..a8dbaede 100644 --- a/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m @@ -2,20 +2,24 @@ classdef RecordWithKeywordFieldsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithKeywordFieldsSerializer() + function self = RecordWithKeywordFieldsSerializer() field_serializers{1} = yardl.binary.StringSerializer; field_serializers{2} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); field_serializers{3} = yardl.binary.EnumSerializer('test_model.EnumWithKeywordSymbols', @test_model.EnumWithKeywordSymbols, yardl.binary.Int32Serializer); - obj@yardl.binary.RecordSerializer('test_model.RecordWithKeywordFields', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithKeywordFields', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithKeywordFields')); - obj.write_(outstream, value.int, value.sizeof, value.if_) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithKeywordFields + end + self.write_(outstream, value.int, value.sizeof, value.if_) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithKeywordFields(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m index a277561e..522f03cc 100644 --- a/matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m @@ -2,20 +2,24 @@ classdef RecordWithNDArraysSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithNDArraysSerializer() + function self = RecordWithNDArraysSerializer() field_serializers{1} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); field_serializers{2} = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 2); field_serializers{3} = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 2); - obj@yardl.binary.RecordSerializer('test_model.RecordWithNDArrays', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithNDArrays', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithNDArrays')); - obj.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithNDArrays + end + self.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithNDArrays(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m b/matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m index eea1ee3c..8ae7e35e 100644 --- a/matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m @@ -2,20 +2,24 @@ classdef RecordWithNDArraysSingleDimensionSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithNDArraysSingleDimensionSerializer() + function self = RecordWithNDArraysSingleDimensionSerializer() field_serializers{1} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 1); field_serializers{2} = yardl.binary.NDArraySerializer(test_model.binary.SimpleRecordSerializer(), 1); field_serializers{3} = yardl.binary.NDArraySerializer(test_model.binary.RecordWithVlensSerializer(), 1); - obj@yardl.binary.RecordSerializer('test_model.RecordWithNDArraysSingleDimension', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithNDArraysSingleDimension', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithNDArraysSingleDimension')); - obj.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithNDArraysSingleDimension + end + self.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithNDArraysSingleDimension(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m index 3e1c4545..d818c778 100644 --- a/matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m @@ -2,20 +2,24 @@ classdef RecordWithNamedFixedArraysSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithNamedFixedArraysSerializer() + function self = RecordWithNamedFixedArraysSerializer() field_serializers{1} = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 2]); field_serializers{2} = yardl.binary.FixedNDArraySerializer(test_model.binary.SimpleRecordSerializer(), [2, 3]); field_serializers{3} = yardl.binary.FixedNDArraySerializer(test_model.binary.RecordWithVlensSerializer(), [2, 2]); - obj@yardl.binary.RecordSerializer('test_model.RecordWithNamedFixedArrays', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithNamedFixedArrays', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithNamedFixedArrays')); - obj.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithNamedFixedArrays + end + self.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithNamedFixedArrays(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m index a9e54c59..aea1d258 100644 --- a/matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m @@ -2,20 +2,24 @@ classdef RecordWithOptionalFieldsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithOptionalFieldsSerializer() + function self = RecordWithOptionalFieldsSerializer() field_serializers{1} = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); field_serializers{2} = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); field_serializers{3} = yardl.binary.OptionalSerializer(yardl.binary.TimeSerializer); - obj@yardl.binary.RecordSerializer('test_model.RecordWithOptionalFields', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithOptionalFields', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithOptionalFields')); - obj.write_(outstream, value.optional_int, value.optional_int_alternate_syntax, value.optional_time) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithOptionalFields + end + self.write_(outstream, value.optional_int, value.optional_int_alternate_syntax, value.optional_time) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithOptionalFields(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m index 83e94bec..092b6039 100644 --- a/matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m @@ -2,18 +2,22 @@ classdef RecordWithOptionalGenericFieldSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithOptionalGenericFieldSerializer(t_serializer) + function self = RecordWithOptionalGenericFieldSerializer(t_serializer) field_serializers{1} = yardl.binary.OptionalSerializer(t_serializer); - obj@yardl.binary.RecordSerializer('test_model.RecordWithOptionalGenericField', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithOptionalGenericField', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithOptionalGenericField')); - obj.write_(outstream, value.v) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithOptionalGenericField + end + self.write_(outstream, value.v) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithOptionalGenericField(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m index 7fe2dbd2..84fd5485 100644 --- a/matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m @@ -2,18 +2,22 @@ classdef RecordWithOptionalGenericUnionFieldSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithOptionalGenericUnionFieldSerializer(u_serializer, v_serializer) + function self = RecordWithOptionalGenericUnionFieldSerializer(u_serializer, v_serializer) field_serializers{1} = yardl.binary.UnionSerializer('test_model.UOrV', {yardl.binary.NoneSerializer, u_serializer, v_serializer}, {yardl.None, @test_model.UOrV.U, @test_model.UOrV.V}); - obj@yardl.binary.RecordSerializer('test_model.RecordWithOptionalGenericUnionField', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithOptionalGenericUnionField', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithOptionalGenericUnionField')); - obj.write_(outstream, value.v) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithOptionalGenericUnionField + end + self.write_(outstream, value.v) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithOptionalGenericUnionField(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m index d0db2bd6..e058ccb1 100644 --- a/matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m @@ -2,18 +2,22 @@ classdef RecordWithOptionalVectorSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithOptionalVectorSerializer() + function self = RecordWithOptionalVectorSerializer() field_serializers{1} = yardl.binary.OptionalSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer)); - obj@yardl.binary.RecordSerializer('test_model.RecordWithOptionalVector', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithOptionalVector', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithOptionalVector')); - obj.write_(outstream, value.optional_vector) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithOptionalVector + end + self.write_(outstream, value.optional_vector) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithOptionalVector(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m b/matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m index 36bc9cd2..bc473f80 100644 --- a/matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m @@ -2,7 +2,7 @@ classdef RecordWithPrimitiveAliasesSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithPrimitiveAliasesSerializer() + function self = RecordWithPrimitiveAliasesSerializer() field_serializers{1} = yardl.binary.Uint8Serializer; field_serializers{2} = yardl.binary.Int32Serializer; field_serializers{3} = yardl.binary.Uint32Serializer; @@ -12,16 +12,20 @@ field_serializers{7} = yardl.binary.Float64Serializer; field_serializers{8} = yardl.binary.Complexfloat32Serializer; field_serializers{9} = yardl.binary.Complexfloat64Serializer; - obj@yardl.binary.RecordSerializer('test_model.RecordWithPrimitiveAliases', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithPrimitiveAliases', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithPrimitiveAliases')); - obj.write_(outstream, value.byte_field, value.int_field, value.uint_field, value.long_field, value.ulong_field, value.float_field, value.double_field, value.complexfloat_field, value.complexdouble_field) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithPrimitiveAliases + end + self.write_(outstream, value.byte_field, value.int_field, value.uint_field, value.long_field, value.ulong_field, value.float_field, value.double_field, value.complexfloat_field, value.complexdouble_field) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithPrimitiveAliases(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m b/matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m index 3a0d1d8e..733d9cd3 100644 --- a/matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m @@ -2,7 +2,7 @@ classdef RecordWithPrimitivesSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithPrimitivesSerializer() + function self = RecordWithPrimitivesSerializer() field_serializers{1} = yardl.binary.BoolSerializer; field_serializers{2} = yardl.binary.Int8Serializer; field_serializers{3} = yardl.binary.Uint8Serializer; @@ -20,16 +20,20 @@ field_serializers{15} = yardl.binary.DateSerializer; field_serializers{16} = yardl.binary.TimeSerializer; field_serializers{17} = yardl.binary.DatetimeSerializer; - obj@yardl.binary.RecordSerializer('test_model.RecordWithPrimitives', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithPrimitives', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithPrimitives')); - obj.write_(outstream, value.bool_field, value.int8_field, value.uint8_field, value.int16_field, value.uint16_field, value.int32_field, value.uint32_field, value.int64_field, value.uint64_field, value.size_field, value.float32_field, value.float64_field, value.complexfloat32_field, value.complexfloat64_field, value.date_field, value.time_field, value.datetime_field) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithPrimitives + end + self.write_(outstream, value.bool_field, value.int8_field, value.uint8_field, value.int16_field, value.uint16_field, value.int32_field, value.uint32_field, value.int64_field, value.uint64_field, value.size_field, value.float32_field, value.float64_field, value.complexfloat32_field, value.complexfloat64_field, value.date_field, value.time_field, value.datetime_field) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithPrimitives(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m index 7667d5e4..158f3f72 100644 --- a/matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m @@ -2,19 +2,23 @@ classdef RecordWithStringsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithStringsSerializer() + function self = RecordWithStringsSerializer() field_serializers{1} = yardl.binary.StringSerializer; field_serializers{2} = yardl.binary.StringSerializer; - obj@yardl.binary.RecordSerializer('test_model.RecordWithStrings', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithStrings', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithStrings')); - obj.write_(outstream, value.a, value.b) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithStrings + end + self.write_(outstream, value.a, value.b) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithStrings(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m b/matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m index a503a4a0..1817f6a9 100644 --- a/matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m @@ -2,20 +2,24 @@ classdef RecordWithUnionsOfContainersSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithUnionsOfContainersSerializer() + function self = RecordWithUnionsOfContainersSerializer() field_serializers{1} = yardl.binary.UnionSerializer('test_model.MapOrScalar', {yardl.binary.MapSerializer(yardl.binary.StringSerializer, yardl.binary.Int32Serializer), yardl.binary.Int32Serializer}, {@test_model.MapOrScalar.Map, @test_model.MapOrScalar.Scalar}); field_serializers{2} = yardl.binary.UnionSerializer('test_model.VectorOrScalar', {yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), yardl.binary.Int32Serializer}, {@test_model.VectorOrScalar.Vector, @test_model.VectorOrScalar.Scalar}); field_serializers{3} = yardl.binary.UnionSerializer('test_model.ArrayOrScalar', {yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer), yardl.binary.Int32Serializer}, {@test_model.ArrayOrScalar.Array, @test_model.ArrayOrScalar.Scalar}); - obj@yardl.binary.RecordSerializer('test_model.RecordWithUnionsOfContainers', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithUnionsOfContainers', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithUnionsOfContainers')); - obj.write_(outstream, value.map_or_scalar, value.vector_or_scalar, value.array_or_scalar) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithUnionsOfContainers + end + self.write_(outstream, value.map_or_scalar, value.vector_or_scalar, value.array_or_scalar) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithUnionsOfContainers(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m index d8bb776a..d72da3a2 100644 --- a/matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m @@ -2,18 +2,22 @@ classdef RecordWithVectorOfTimesSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithVectorOfTimesSerializer() + function self = RecordWithVectorOfTimesSerializer() field_serializers{1} = yardl.binary.VectorSerializer(yardl.binary.TimeSerializer); - obj@yardl.binary.RecordSerializer('test_model.RecordWithVectorOfTimes', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithVectorOfTimes', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithVectorOfTimes')); - obj.write_(outstream, value.times) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithVectorOfTimes + end + self.write_(outstream, value.times) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithVectorOfTimes(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m index b45cfc68..37b28575 100644 --- a/matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m @@ -2,20 +2,24 @@ classdef RecordWithVectorsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithVectorsSerializer() + function self = RecordWithVectorsSerializer() field_serializers{1} = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); field_serializers{2} = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3); field_serializers{3} = yardl.binary.VectorSerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 2)); - obj@yardl.binary.RecordSerializer('test_model.RecordWithVectors', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithVectors', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithVectors')); - obj.write_(outstream, value.default_vector, value.default_vector_fixed_length, value.vector_of_vectors) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithVectors + end + self.write_(outstream, value.default_vector, value.default_vector_fixed_length, value.vector_of_vectors) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithVectors(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m index 242db2f6..5a5304c3 100644 --- a/matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m @@ -2,19 +2,23 @@ classdef RecordWithVlenCollectionsSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithVlenCollectionsSerializer() + function self = RecordWithVlenCollectionsSerializer() field_serializers{1} = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); field_serializers{2} = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - obj@yardl.binary.RecordSerializer('test_model.RecordWithVlenCollections', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithVlenCollections', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithVlenCollections')); - obj.write_(outstream, value.vector, value.array) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithVlenCollections + end + self.write_(outstream, value.vector, value.array) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithVlenCollections(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m index a7cb28c0..17ec8a7e 100644 --- a/matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m @@ -2,20 +2,24 @@ classdef RecordWithVlensSerializer < yardl.binary.RecordSerializer methods - function obj = RecordWithVlensSerializer() + function self = RecordWithVlensSerializer() field_serializers{1} = yardl.binary.VectorSerializer(test_model.binary.SimpleRecordSerializer()); field_serializers{2} = yardl.binary.Int32Serializer; field_serializers{3} = yardl.binary.Int32Serializer; - obj@yardl.binary.RecordSerializer('test_model.RecordWithVlens', field_serializers); + self@yardl.binary.RecordSerializer('test_model.RecordWithVlens', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.RecordWithVlens')); - obj.write_(outstream, value.a, value.b, value.c) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.RecordWithVlens + end + self.write_(outstream, value.a, value.b, value.c) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.RecordWithVlens(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/ScalarOptionalsReader.m b/matlab/generated/+test_model/+binary/ScalarOptionalsReader.m index 1a70eccc..ff820061 100644 --- a/matlab/generated/+test_model/+binary/ScalarOptionalsReader.m +++ b/matlab/generated/+test_model/+binary/ScalarOptionalsReader.m @@ -10,31 +10,31 @@ end methods - function obj = ScalarOptionalsReader(filename) - obj@test_model.ScalarOptionalsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.ScalarOptionalsReaderBase.schema); - obj.optional_int_serializer = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); - obj.optional_record_serializer = yardl.binary.OptionalSerializer(test_model.binary.SimpleRecordSerializer()); - obj.record_with_optional_fields_serializer = test_model.binary.RecordWithOptionalFieldsSerializer(); - obj.optional_record_with_optional_fields_serializer = yardl.binary.OptionalSerializer(test_model.binary.RecordWithOptionalFieldsSerializer()); + function self = ScalarOptionalsReader(filename) + self@test_model.ScalarOptionalsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.ScalarOptionalsReaderBase.schema); + self.optional_int_serializer = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); + self.optional_record_serializer = yardl.binary.OptionalSerializer(test_model.binary.SimpleRecordSerializer()); + self.record_with_optional_fields_serializer = test_model.binary.RecordWithOptionalFieldsSerializer(); + self.optional_record_with_optional_fields_serializer = yardl.binary.OptionalSerializer(test_model.binary.RecordWithOptionalFieldsSerializer()); end end methods (Access=protected) - function value = read_optional_int_(obj) - value = obj.optional_int_serializer.read(obj.stream_); + function value = read_optional_int_(self) + value = self.optional_int_serializer.read(self.stream_); end - function value = read_optional_record_(obj) - value = obj.optional_record_serializer.read(obj.stream_); + function value = read_optional_record_(self) + value = self.optional_record_serializer.read(self.stream_); end - function value = read_record_with_optional_fields_(obj) - value = obj.record_with_optional_fields_serializer.read(obj.stream_); + function value = read_record_with_optional_fields_(self) + value = self.record_with_optional_fields_serializer.read(self.stream_); end - function value = read_optional_record_with_optional_fields_(obj) - value = obj.optional_record_with_optional_fields_serializer.read(obj.stream_); + function value = read_optional_record_with_optional_fields_(self) + value = self.optional_record_with_optional_fields_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m b/matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m index eb5f307d..592059c7 100644 --- a/matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m +++ b/matlab/generated/+test_model/+binary/ScalarOptionalsWriter.m @@ -10,31 +10,31 @@ end methods - function obj = ScalarOptionalsWriter(filename) - obj@test_model.ScalarOptionalsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.ScalarOptionalsWriterBase.schema); - obj.optional_int_serializer = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); - obj.optional_record_serializer = yardl.binary.OptionalSerializer(test_model.binary.SimpleRecordSerializer()); - obj.record_with_optional_fields_serializer = test_model.binary.RecordWithOptionalFieldsSerializer(); - obj.optional_record_with_optional_fields_serializer = yardl.binary.OptionalSerializer(test_model.binary.RecordWithOptionalFieldsSerializer()); + function self = ScalarOptionalsWriter(filename) + self@test_model.ScalarOptionalsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.ScalarOptionalsWriterBase.schema); + self.optional_int_serializer = yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer); + self.optional_record_serializer = yardl.binary.OptionalSerializer(test_model.binary.SimpleRecordSerializer()); + self.record_with_optional_fields_serializer = test_model.binary.RecordWithOptionalFieldsSerializer(); + self.optional_record_with_optional_fields_serializer = yardl.binary.OptionalSerializer(test_model.binary.RecordWithOptionalFieldsSerializer()); end end methods (Access=protected) - function write_optional_int_(obj, value) - obj.optional_int_serializer.write(obj.stream_, value); + function write_optional_int_(self, value) + self.optional_int_serializer.write(self.stream_, value); end - function write_optional_record_(obj, value) - obj.optional_record_serializer.write(obj.stream_, value); + function write_optional_record_(self, value) + self.optional_record_serializer.write(self.stream_, value); end - function write_record_with_optional_fields_(obj, value) - obj.record_with_optional_fields_serializer.write(obj.stream_, value); + function write_record_with_optional_fields_(self, value) + self.record_with_optional_fields_serializer.write(self.stream_, value); end - function write_optional_record_with_optional_fields_(obj, value) - obj.optional_record_with_optional_fields_serializer.write(obj.stream_, value); + function write_optional_record_with_optional_fields_(self, value) + self.optional_record_with_optional_fields_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/ScalarsReader.m b/matlab/generated/+test_model/+binary/ScalarsReader.m index a58b12ef..b8f893d3 100644 --- a/matlab/generated/+test_model/+binary/ScalarsReader.m +++ b/matlab/generated/+test_model/+binary/ScalarsReader.m @@ -8,21 +8,21 @@ end methods - function obj = ScalarsReader(filename) - obj@test_model.ScalarsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.ScalarsReaderBase.schema); - obj.int32_serializer = yardl.binary.Int32Serializer; - obj.record_serializer = test_model.binary.RecordWithPrimitivesSerializer(); + function self = ScalarsReader(filename) + self@test_model.ScalarsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.ScalarsReaderBase.schema); + self.int32_serializer = yardl.binary.Int32Serializer; + self.record_serializer = test_model.binary.RecordWithPrimitivesSerializer(); end end methods (Access=protected) - function value = read_int32_(obj) - value = obj.int32_serializer.read(obj.stream_); + function value = read_int32_(self) + value = self.int32_serializer.read(self.stream_); end - function value = read_record_(obj) - value = obj.record_serializer.read(obj.stream_); + function value = read_record_(self) + value = self.record_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/ScalarsWriter.m b/matlab/generated/+test_model/+binary/ScalarsWriter.m index 0ac9ea93..7701f0a7 100644 --- a/matlab/generated/+test_model/+binary/ScalarsWriter.m +++ b/matlab/generated/+test_model/+binary/ScalarsWriter.m @@ -8,21 +8,21 @@ end methods - function obj = ScalarsWriter(filename) - obj@test_model.ScalarsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.ScalarsWriterBase.schema); - obj.int32_serializer = yardl.binary.Int32Serializer; - obj.record_serializer = test_model.binary.RecordWithPrimitivesSerializer(); + function self = ScalarsWriter(filename) + self@test_model.ScalarsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.ScalarsWriterBase.schema); + self.int32_serializer = yardl.binary.Int32Serializer; + self.record_serializer = test_model.binary.RecordWithPrimitivesSerializer(); end end methods (Access=protected) - function write_int32_(obj, value) - obj.int32_serializer.write(obj.stream_, value); + function write_int32_(self, value) + self.int32_serializer.write(self.stream_, value); end - function write_record_(obj, value) - obj.record_serializer.write(obj.stream_, value); + function write_record_(self, value) + self.record_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m b/matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m index 3de76a44..03e7db4d 100644 --- a/matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m +++ b/matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m @@ -2,21 +2,25 @@ classdef SimpleAcquisitionSerializer < yardl.binary.RecordSerializer methods - function obj = SimpleAcquisitionSerializer() + function self = SimpleAcquisitionSerializer() field_serializers{1} = yardl.binary.Uint64Serializer; field_serializers{2} = test_model.binary.SimpleEncodingCountersSerializer(); field_serializers{3} = yardl.binary.NDArraySerializer(yardl.binary.Complexfloat32Serializer, 2); field_serializers{4} = yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2); - obj@yardl.binary.RecordSerializer('test_model.SimpleAcquisition', field_serializers); + self@yardl.binary.RecordSerializer('test_model.SimpleAcquisition', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.SimpleAcquisition')); - obj.write_(outstream, value.flags, value.idx, value.data, value.trajectory) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.SimpleAcquisition + end + self.write_(outstream, value.flags, value.idx, value.data, value.trajectory) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.SimpleAcquisition(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m b/matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m index 19847e48..7d7dab74 100644 --- a/matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m +++ b/matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m @@ -2,21 +2,25 @@ classdef SimpleEncodingCountersSerializer < yardl.binary.RecordSerializer methods - function obj = SimpleEncodingCountersSerializer() + function self = SimpleEncodingCountersSerializer() field_serializers{1} = yardl.binary.OptionalSerializer(yardl.binary.Uint32Serializer); field_serializers{2} = yardl.binary.OptionalSerializer(yardl.binary.Uint32Serializer); field_serializers{3} = yardl.binary.OptionalSerializer(yardl.binary.Uint32Serializer); field_serializers{4} = yardl.binary.OptionalSerializer(yardl.binary.Uint32Serializer); - obj@yardl.binary.RecordSerializer('test_model.SimpleEncodingCounters', field_serializers); + self@yardl.binary.RecordSerializer('test_model.SimpleEncodingCounters', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.SimpleEncodingCounters')); - obj.write_(outstream, value.e1, value.e2, value.slice, value.repetition) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.SimpleEncodingCounters + end + self.write_(outstream, value.e1, value.e2, value.slice, value.repetition) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.SimpleEncodingCounters(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/SimpleGenericsReader.m b/matlab/generated/+test_model/+binary/SimpleGenericsReader.m index b700ca37..80bc066c 100644 --- a/matlab/generated/+test_model/+binary/SimpleGenericsReader.m +++ b/matlab/generated/+test_model/+binary/SimpleGenericsReader.m @@ -15,60 +15,60 @@ end methods - function obj = SimpleGenericsReader(filename) - obj@test_model.SimpleGenericsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.SimpleGenericsReaderBase.schema); - obj.float_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2); - obj.int_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - obj.int_image_alternate_syntax_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - obj.string_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.StringSerializer, 2); - obj.int_float_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); - obj.float_float_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Float32Serializer, yardl.binary.Float32Serializer); - obj.int_float_tuple_alternate_syntax_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); - obj.int_string_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); - obj.stream_of_type_variants_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.ImageFloatOrImageDouble', {yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), yardl.binary.NDArraySerializer(yardl.binary.Float64Serializer, 2)}, {@test_model.ImageFloatOrImageDouble.ImageFloat, @test_model.ImageFloatOrImageDouble.ImageDouble})); + function self = SimpleGenericsReader(filename) + self@test_model.SimpleGenericsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.SimpleGenericsReaderBase.schema); + self.float_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2); + self.int_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + self.int_image_alternate_syntax_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + self.string_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.StringSerializer, 2); + self.int_float_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); + self.float_float_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Float32Serializer, yardl.binary.Float32Serializer); + self.int_float_tuple_alternate_syntax_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); + self.int_string_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + self.stream_of_type_variants_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.ImageFloatOrImageDouble', {yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), yardl.binary.NDArraySerializer(yardl.binary.Float64Serializer, 2)}, {@test_model.ImageFloatOrImageDouble.ImageFloat, @test_model.ImageFloatOrImageDouble.ImageDouble})); end end methods (Access=protected) - function value = read_float_image_(obj) - value = obj.float_image_serializer.read(obj.stream_); + function value = read_float_image_(self) + value = self.float_image_serializer.read(self.stream_); end - function value = read_int_image_(obj) - value = obj.int_image_serializer.read(obj.stream_); + function value = read_int_image_(self) + value = self.int_image_serializer.read(self.stream_); end - function value = read_int_image_alternate_syntax_(obj) - value = obj.int_image_alternate_syntax_serializer.read(obj.stream_); + function value = read_int_image_alternate_syntax_(self) + value = self.int_image_alternate_syntax_serializer.read(self.stream_); end - function value = read_string_image_(obj) - value = obj.string_image_serializer.read(obj.stream_); + function value = read_string_image_(self) + value = self.string_image_serializer.read(self.stream_); end - function value = read_int_float_tuple_(obj) - value = obj.int_float_tuple_serializer.read(obj.stream_); + function value = read_int_float_tuple_(self) + value = self.int_float_tuple_serializer.read(self.stream_); end - function value = read_float_float_tuple_(obj) - value = obj.float_float_tuple_serializer.read(obj.stream_); + function value = read_float_float_tuple_(self) + value = self.float_float_tuple_serializer.read(self.stream_); end - function value = read_int_float_tuple_alternate_syntax_(obj) - value = obj.int_float_tuple_alternate_syntax_serializer.read(obj.stream_); + function value = read_int_float_tuple_alternate_syntax_(self) + value = self.int_float_tuple_alternate_syntax_serializer.read(self.stream_); end - function value = read_int_string_tuple_(obj) - value = obj.int_string_tuple_serializer.read(obj.stream_); + function value = read_int_string_tuple_(self) + value = self.int_string_tuple_serializer.read(self.stream_); end - function more = has_stream_of_type_variants_(obj) - more = obj.stream_of_type_variants_serializer.hasnext(obj.stream_); + function more = has_stream_of_type_variants_(self) + more = self.stream_of_type_variants_serializer.hasnext(self.stream_); end - function value = read_stream_of_type_variants_(obj) - value = obj.stream_of_type_variants_serializer.read(obj.stream_); + function value = read_stream_of_type_variants_(self) + value = self.stream_of_type_variants_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/SimpleGenericsWriter.m b/matlab/generated/+test_model/+binary/SimpleGenericsWriter.m index 58addc43..d5faf313 100644 --- a/matlab/generated/+test_model/+binary/SimpleGenericsWriter.m +++ b/matlab/generated/+test_model/+binary/SimpleGenericsWriter.m @@ -15,56 +15,56 @@ end methods - function obj = SimpleGenericsWriter(filename) - obj@test_model.SimpleGenericsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.SimpleGenericsWriterBase.schema); - obj.float_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2); - obj.int_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - obj.int_image_alternate_syntax_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - obj.string_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.StringSerializer, 2); - obj.int_float_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); - obj.float_float_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Float32Serializer, yardl.binary.Float32Serializer); - obj.int_float_tuple_alternate_syntax_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); - obj.int_string_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); - obj.stream_of_type_variants_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.ImageFloatOrImageDouble', {yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), yardl.binary.NDArraySerializer(yardl.binary.Float64Serializer, 2)}, {@test_model.ImageFloatOrImageDouble.ImageFloat, @test_model.ImageFloatOrImageDouble.ImageDouble})); + function self = SimpleGenericsWriter(filename) + self@test_model.SimpleGenericsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.SimpleGenericsWriterBase.schema); + self.float_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2); + self.int_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + self.int_image_alternate_syntax_serializer = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); + self.string_image_serializer = yardl.binary.NDArraySerializer(yardl.binary.StringSerializer, 2); + self.int_float_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); + self.float_float_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Float32Serializer, yardl.binary.Float32Serializer); + self.int_float_tuple_alternate_syntax_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.Float32Serializer); + self.int_string_tuple_serializer = tuples.binary.TupleSerializer(yardl.binary.Int32Serializer, yardl.binary.StringSerializer); + self.stream_of_type_variants_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.ImageFloatOrImageDouble', {yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 2), yardl.binary.NDArraySerializer(yardl.binary.Float64Serializer, 2)}, {@test_model.ImageFloatOrImageDouble.ImageFloat, @test_model.ImageFloatOrImageDouble.ImageDouble})); end end methods (Access=protected) - function write_float_image_(obj, value) - obj.float_image_serializer.write(obj.stream_, value); + function write_float_image_(self, value) + self.float_image_serializer.write(self.stream_, value); end - function write_int_image_(obj, value) - obj.int_image_serializer.write(obj.stream_, value); + function write_int_image_(self, value) + self.int_image_serializer.write(self.stream_, value); end - function write_int_image_alternate_syntax_(obj, value) - obj.int_image_alternate_syntax_serializer.write(obj.stream_, value); + function write_int_image_alternate_syntax_(self, value) + self.int_image_alternate_syntax_serializer.write(self.stream_, value); end - function write_string_image_(obj, value) - obj.string_image_serializer.write(obj.stream_, value); + function write_string_image_(self, value) + self.string_image_serializer.write(self.stream_, value); end - function write_int_float_tuple_(obj, value) - obj.int_float_tuple_serializer.write(obj.stream_, value); + function write_int_float_tuple_(self, value) + self.int_float_tuple_serializer.write(self.stream_, value); end - function write_float_float_tuple_(obj, value) - obj.float_float_tuple_serializer.write(obj.stream_, value); + function write_float_float_tuple_(self, value) + self.float_float_tuple_serializer.write(self.stream_, value); end - function write_int_float_tuple_alternate_syntax_(obj, value) - obj.int_float_tuple_alternate_syntax_serializer.write(obj.stream_, value); + function write_int_float_tuple_alternate_syntax_(self, value) + self.int_float_tuple_alternate_syntax_serializer.write(self.stream_, value); end - function write_int_string_tuple_(obj, value) - obj.int_string_tuple_serializer.write(obj.stream_, value); + function write_int_string_tuple_(self, value) + self.int_string_tuple_serializer.write(self.stream_, value); end - function write_stream_of_type_variants_(obj, value) - obj.stream_of_type_variants_serializer.write(obj.stream_, value); + function write_stream_of_type_variants_(self, value) + self.stream_of_type_variants_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/SimpleRecordSerializer.m b/matlab/generated/+test_model/+binary/SimpleRecordSerializer.m index 3822533d..f48ca5f0 100644 --- a/matlab/generated/+test_model/+binary/SimpleRecordSerializer.m +++ b/matlab/generated/+test_model/+binary/SimpleRecordSerializer.m @@ -2,20 +2,24 @@ classdef SimpleRecordSerializer < yardl.binary.RecordSerializer methods - function obj = SimpleRecordSerializer() + function self = SimpleRecordSerializer() field_serializers{1} = yardl.binary.Int32Serializer; field_serializers{2} = yardl.binary.Int32Serializer; field_serializers{3} = yardl.binary.Int32Serializer; - obj@yardl.binary.RecordSerializer('test_model.SimpleRecord', field_serializers); + self@yardl.binary.RecordSerializer('test_model.SimpleRecord', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.SimpleRecord')); - obj.write_(outstream, value.x, value.y, value.z) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.SimpleRecord + end + self.write_(outstream, value.x, value.y, value.z) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.SimpleRecord(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m b/matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m index 5845e7be..9c89994c 100644 --- a/matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m +++ b/matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m @@ -2,20 +2,24 @@ classdef SmallBenchmarkRecordSerializer < yardl.binary.RecordSerializer methods - function obj = SmallBenchmarkRecordSerializer() + function self = SmallBenchmarkRecordSerializer() field_serializers{1} = yardl.binary.Float64Serializer; field_serializers{2} = yardl.binary.Float32Serializer; field_serializers{3} = yardl.binary.Float32Serializer; - obj@yardl.binary.RecordSerializer('test_model.SmallBenchmarkRecord', field_serializers); + self@yardl.binary.RecordSerializer('test_model.SmallBenchmarkRecord', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.SmallBenchmarkRecord')); - obj.write_(outstream, value.a, value.b, value.c) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.SmallBenchmarkRecord + end + self.write_(outstream, value.a, value.b, value.c) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.SmallBenchmarkRecord(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/StateTestReader.m b/matlab/generated/+test_model/+binary/StateTestReader.m index 232b2457..df5b39e3 100644 --- a/matlab/generated/+test_model/+binary/StateTestReader.m +++ b/matlab/generated/+test_model/+binary/StateTestReader.m @@ -9,30 +9,30 @@ end methods - function obj = StateTestReader(filename) - obj@test_model.StateTestReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.StateTestReaderBase.schema); - obj.an_int_serializer = yardl.binary.Int32Serializer; - obj.a_stream_serializer = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); - obj.another_int_serializer = yardl.binary.Int32Serializer; + function self = StateTestReader(filename) + self@test_model.StateTestReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.StateTestReaderBase.schema); + self.an_int_serializer = yardl.binary.Int32Serializer; + self.a_stream_serializer = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); + self.another_int_serializer = yardl.binary.Int32Serializer; end end methods (Access=protected) - function value = read_an_int_(obj) - value = obj.an_int_serializer.read(obj.stream_); + function value = read_an_int_(self) + value = self.an_int_serializer.read(self.stream_); end - function more = has_a_stream_(obj) - more = obj.a_stream_serializer.hasnext(obj.stream_); + function more = has_a_stream_(self) + more = self.a_stream_serializer.hasnext(self.stream_); end - function value = read_a_stream_(obj) - value = obj.a_stream_serializer.read(obj.stream_); + function value = read_a_stream_(self) + value = self.a_stream_serializer.read(self.stream_); end - function value = read_another_int_(obj) - value = obj.another_int_serializer.read(obj.stream_); + function value = read_another_int_(self) + value = self.another_int_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/StateTestWriter.m b/matlab/generated/+test_model/+binary/StateTestWriter.m index 4d4dc965..065d5487 100644 --- a/matlab/generated/+test_model/+binary/StateTestWriter.m +++ b/matlab/generated/+test_model/+binary/StateTestWriter.m @@ -9,26 +9,26 @@ end methods - function obj = StateTestWriter(filename) - obj@test_model.StateTestWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.StateTestWriterBase.schema); - obj.an_int_serializer = yardl.binary.Int32Serializer; - obj.a_stream_serializer = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); - obj.another_int_serializer = yardl.binary.Int32Serializer; + function self = StateTestWriter(filename) + self@test_model.StateTestWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.StateTestWriterBase.schema); + self.an_int_serializer = yardl.binary.Int32Serializer; + self.a_stream_serializer = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); + self.another_int_serializer = yardl.binary.Int32Serializer; end end methods (Access=protected) - function write_an_int_(obj, value) - obj.an_int_serializer.write(obj.stream_, value); + function write_an_int_(self, value) + self.an_int_serializer.write(self.stream_, value); end - function write_a_stream_(obj, value) - obj.a_stream_serializer.write(obj.stream_, value); + function write_a_stream_(self, value) + self.a_stream_serializer.write(self.stream_, value); end - function write_another_int_(obj, value) - obj.another_int_serializer.write(obj.stream_, value); + function write_another_int_(self, value) + self.another_int_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m index 08da91f5..eaf865b8 100644 --- a/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m +++ b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsReader.m @@ -8,29 +8,29 @@ end methods - function obj = StreamsOfAliasedUnionsReader(filename) - obj@test_model.StreamsOfAliasedUnionsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.StreamsOfAliasedUnionsReaderBase.schema); - obj.int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedIntOrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.AliasedIntOrSimpleRecord.Int32, @test_model.AliasedIntOrSimpleRecord.SimpleRecord})); - obj.nullable_int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedNullableIntSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.AliasedNullableIntSimpleRecord.Int32, @test_model.AliasedNullableIntSimpleRecord.SimpleRecord})); + function self = StreamsOfAliasedUnionsReader(filename) + self@test_model.StreamsOfAliasedUnionsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.StreamsOfAliasedUnionsReaderBase.schema); + self.int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedIntOrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.AliasedIntOrSimpleRecord.Int32, @test_model.AliasedIntOrSimpleRecord.SimpleRecord})); + self.nullable_int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedNullableIntSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.AliasedNullableIntSimpleRecord.Int32, @test_model.AliasedNullableIntSimpleRecord.SimpleRecord})); end end methods (Access=protected) - function more = has_int_or_simple_record_(obj) - more = obj.int_or_simple_record_serializer.hasnext(obj.stream_); + function more = has_int_or_simple_record_(self) + more = self.int_or_simple_record_serializer.hasnext(self.stream_); end - function value = read_int_or_simple_record_(obj) - value = obj.int_or_simple_record_serializer.read(obj.stream_); + function value = read_int_or_simple_record_(self) + value = self.int_or_simple_record_serializer.read(self.stream_); end - function more = has_nullable_int_or_simple_record_(obj) - more = obj.nullable_int_or_simple_record_serializer.hasnext(obj.stream_); + function more = has_nullable_int_or_simple_record_(self) + more = self.nullable_int_or_simple_record_serializer.hasnext(self.stream_); end - function value = read_nullable_int_or_simple_record_(obj) - value = obj.nullable_int_or_simple_record_serializer.read(obj.stream_); + function value = read_nullable_int_or_simple_record_(self) + value = self.nullable_int_or_simple_record_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m index 80463839..2766971d 100644 --- a/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m +++ b/matlab/generated/+test_model/+binary/StreamsOfAliasedUnionsWriter.m @@ -8,21 +8,21 @@ end methods - function obj = StreamsOfAliasedUnionsWriter(filename) - obj@test_model.StreamsOfAliasedUnionsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.StreamsOfAliasedUnionsWriterBase.schema); - obj.int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedIntOrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.AliasedIntOrSimpleRecord.Int32, @test_model.AliasedIntOrSimpleRecord.SimpleRecord})); - obj.nullable_int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedNullableIntSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.AliasedNullableIntSimpleRecord.Int32, @test_model.AliasedNullableIntSimpleRecord.SimpleRecord})); + function self = StreamsOfAliasedUnionsWriter(filename) + self@test_model.StreamsOfAliasedUnionsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.StreamsOfAliasedUnionsWriterBase.schema); + self.int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedIntOrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.AliasedIntOrSimpleRecord.Int32, @test_model.AliasedIntOrSimpleRecord.SimpleRecord})); + self.nullable_int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.AliasedNullableIntSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.AliasedNullableIntSimpleRecord.Int32, @test_model.AliasedNullableIntSimpleRecord.SimpleRecord})); end end methods (Access=protected) - function write_int_or_simple_record_(obj, value) - obj.int_or_simple_record_serializer.write(obj.stream_, value); + function write_int_or_simple_record_(self, value) + self.int_or_simple_record_serializer.write(self.stream_, value); end - function write_nullable_int_or_simple_record_(obj, value) - obj.nullable_int_or_simple_record_serializer.write(obj.stream_, value); + function write_nullable_int_or_simple_record_(self, value) + self.nullable_int_or_simple_record_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m b/matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m index 75ec590c..98cea845 100644 --- a/matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m +++ b/matlab/generated/+test_model/+binary/StreamsOfUnionsReader.m @@ -8,29 +8,29 @@ end methods - function obj = StreamsOfUnionsReader(filename) - obj@test_model.StreamsOfUnionsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.StreamsOfUnionsReaderBase.schema); - obj.int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); - obj.nullable_int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); + function self = StreamsOfUnionsReader(filename) + self@test_model.StreamsOfUnionsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.StreamsOfUnionsReaderBase.schema); + self.int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); + self.nullable_int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); end end methods (Access=protected) - function more = has_int_or_simple_record_(obj) - more = obj.int_or_simple_record_serializer.hasnext(obj.stream_); + function more = has_int_or_simple_record_(self) + more = self.int_or_simple_record_serializer.hasnext(self.stream_); end - function value = read_int_or_simple_record_(obj) - value = obj.int_or_simple_record_serializer.read(obj.stream_); + function value = read_int_or_simple_record_(self) + value = self.int_or_simple_record_serializer.read(self.stream_); end - function more = has_nullable_int_or_simple_record_(obj) - more = obj.nullable_int_or_simple_record_serializer.hasnext(obj.stream_); + function more = has_nullable_int_or_simple_record_(self) + more = self.nullable_int_or_simple_record_serializer.hasnext(self.stream_); end - function value = read_nullable_int_or_simple_record_(obj) - value = obj.nullable_int_or_simple_record_serializer.read(obj.stream_); + function value = read_nullable_int_or_simple_record_(self) + value = self.nullable_int_or_simple_record_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m b/matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m index 89e2e3c5..a711c70d 100644 --- a/matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m +++ b/matlab/generated/+test_model/+binary/StreamsOfUnionsWriter.m @@ -8,21 +8,21 @@ end methods - function obj = StreamsOfUnionsWriter(filename) - obj@test_model.StreamsOfUnionsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.StreamsOfUnionsWriterBase.schema); - obj.int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); - obj.nullable_int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); + function self = StreamsOfUnionsWriter(filename) + self@test_model.StreamsOfUnionsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.StreamsOfUnionsWriterBase.schema); + self.int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); + self.nullable_int_or_simple_record_serializer = yardl.binary.StreamSerializer(yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord})); end end methods (Access=protected) - function write_int_or_simple_record_(obj, value) - obj.int_or_simple_record_serializer.write(obj.stream_, value); + function write_int_or_simple_record_(self, value) + self.int_or_simple_record_serializer.write(self.stream_, value); end - function write_nullable_int_or_simple_record_(obj, value) - obj.nullable_int_or_simple_record_serializer.write(obj.stream_, value); + function write_nullable_int_or_simple_record_(self, value) + self.nullable_int_or_simple_record_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/StreamsReader.m b/matlab/generated/+test_model/+binary/StreamsReader.m index fe83ca5b..088eef5c 100644 --- a/matlab/generated/+test_model/+binary/StreamsReader.m +++ b/matlab/generated/+test_model/+binary/StreamsReader.m @@ -10,47 +10,47 @@ end methods - function obj = StreamsReader(filename) - obj@test_model.StreamsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.StreamsReaderBase.schema); - obj.int_data_serializer = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); - obj.optional_int_data_serializer = yardl.binary.StreamSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer)); - obj.record_with_optional_vector_data_serializer = yardl.binary.StreamSerializer(test_model.binary.RecordWithOptionalVectorSerializer()); - obj.fixed_vector_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); + function self = StreamsReader(filename) + self@test_model.StreamsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.StreamsReaderBase.schema); + self.int_data_serializer = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); + self.optional_int_data_serializer = yardl.binary.StreamSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer)); + self.record_with_optional_vector_data_serializer = yardl.binary.StreamSerializer(test_model.binary.RecordWithOptionalVectorSerializer()); + self.fixed_vector_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); end end methods (Access=protected) - function more = has_int_data_(obj) - more = obj.int_data_serializer.hasnext(obj.stream_); + function more = has_int_data_(self) + more = self.int_data_serializer.hasnext(self.stream_); end - function value = read_int_data_(obj) - value = obj.int_data_serializer.read(obj.stream_); + function value = read_int_data_(self) + value = self.int_data_serializer.read(self.stream_); end - function more = has_optional_int_data_(obj) - more = obj.optional_int_data_serializer.hasnext(obj.stream_); + function more = has_optional_int_data_(self) + more = self.optional_int_data_serializer.hasnext(self.stream_); end - function value = read_optional_int_data_(obj) - value = obj.optional_int_data_serializer.read(obj.stream_); + function value = read_optional_int_data_(self) + value = self.optional_int_data_serializer.read(self.stream_); end - function more = has_record_with_optional_vector_data_(obj) - more = obj.record_with_optional_vector_data_serializer.hasnext(obj.stream_); + function more = has_record_with_optional_vector_data_(self) + more = self.record_with_optional_vector_data_serializer.hasnext(self.stream_); end - function value = read_record_with_optional_vector_data_(obj) - value = obj.record_with_optional_vector_data_serializer.read(obj.stream_); + function value = read_record_with_optional_vector_data_(self) + value = self.record_with_optional_vector_data_serializer.read(self.stream_); end - function more = has_fixed_vector_(obj) - more = obj.fixed_vector_serializer.hasnext(obj.stream_); + function more = has_fixed_vector_(self) + more = self.fixed_vector_serializer.hasnext(self.stream_); end - function value = read_fixed_vector_(obj) - value = obj.fixed_vector_serializer.read(obj.stream_); + function value = read_fixed_vector_(self) + value = self.fixed_vector_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/StreamsWriter.m b/matlab/generated/+test_model/+binary/StreamsWriter.m index 394f7d49..4f3240c1 100644 --- a/matlab/generated/+test_model/+binary/StreamsWriter.m +++ b/matlab/generated/+test_model/+binary/StreamsWriter.m @@ -10,31 +10,31 @@ end methods - function obj = StreamsWriter(filename) - obj@test_model.StreamsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.StreamsWriterBase.schema); - obj.int_data_serializer = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); - obj.optional_int_data_serializer = yardl.binary.StreamSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer)); - obj.record_with_optional_vector_data_serializer = yardl.binary.StreamSerializer(test_model.binary.RecordWithOptionalVectorSerializer()); - obj.fixed_vector_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); + function self = StreamsWriter(filename) + self@test_model.StreamsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.StreamsWriterBase.schema); + self.int_data_serializer = yardl.binary.StreamSerializer(yardl.binary.Int32Serializer); + self.optional_int_data_serializer = yardl.binary.StreamSerializer(yardl.binary.OptionalSerializer(yardl.binary.Int32Serializer)); + self.record_with_optional_vector_data_serializer = yardl.binary.StreamSerializer(test_model.binary.RecordWithOptionalVectorSerializer()); + self.fixed_vector_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); end end methods (Access=protected) - function write_int_data_(obj, value) - obj.int_data_serializer.write(obj.stream_, value); + function write_int_data_(self, value) + self.int_data_serializer.write(self.stream_, value); end - function write_optional_int_data_(obj, value) - obj.optional_int_data_serializer.write(obj.stream_, value); + function write_optional_int_data_(self, value) + self.optional_int_data_serializer.write(self.stream_, value); end - function write_record_with_optional_vector_data_(obj, value) - obj.record_with_optional_vector_data_serializer.write(obj.stream_, value); + function write_record_with_optional_vector_data_(self, value) + self.record_with_optional_vector_data_serializer.write(self.stream_, value); end - function write_fixed_vector_(obj, value) - obj.fixed_vector_serializer.write(obj.stream_, value); + function write_fixed_vector_(self, value) + self.fixed_vector_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/StringsReader.m b/matlab/generated/+test_model/+binary/StringsReader.m index 7524f5e8..c11c3c12 100644 --- a/matlab/generated/+test_model/+binary/StringsReader.m +++ b/matlab/generated/+test_model/+binary/StringsReader.m @@ -8,21 +8,21 @@ end methods - function obj = StringsReader(filename) - obj@test_model.StringsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.StringsReaderBase.schema); - obj.single_string_serializer = yardl.binary.StringSerializer; - obj.rec_with_string_serializer = test_model.binary.RecordWithStringsSerializer(); + function self = StringsReader(filename) + self@test_model.StringsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.StringsReaderBase.schema); + self.single_string_serializer = yardl.binary.StringSerializer; + self.rec_with_string_serializer = test_model.binary.RecordWithStringsSerializer(); end end methods (Access=protected) - function value = read_single_string_(obj) - value = obj.single_string_serializer.read(obj.stream_); + function value = read_single_string_(self) + value = self.single_string_serializer.read(self.stream_); end - function value = read_rec_with_string_(obj) - value = obj.rec_with_string_serializer.read(obj.stream_); + function value = read_rec_with_string_(self) + value = self.rec_with_string_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/StringsWriter.m b/matlab/generated/+test_model/+binary/StringsWriter.m index 3cdd3f9f..2c8bb7ef 100644 --- a/matlab/generated/+test_model/+binary/StringsWriter.m +++ b/matlab/generated/+test_model/+binary/StringsWriter.m @@ -8,21 +8,21 @@ end methods - function obj = StringsWriter(filename) - obj@test_model.StringsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.StringsWriterBase.schema); - obj.single_string_serializer = yardl.binary.StringSerializer; - obj.rec_with_string_serializer = test_model.binary.RecordWithStringsSerializer(); + function self = StringsWriter(filename) + self@test_model.StringsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.StringsWriterBase.schema); + self.single_string_serializer = yardl.binary.StringSerializer; + self.rec_with_string_serializer = test_model.binary.RecordWithStringsSerializer(); end end methods (Access=protected) - function write_single_string_(obj, value) - obj.single_string_serializer.write(obj.stream_, value); + function write_single_string_(self, value) + self.single_string_serializer.write(self.stream_, value); end - function write_rec_with_string_(obj, value) - obj.rec_with_string_serializer.write(obj.stream_, value); + function write_rec_with_string_(self, value) + self.rec_with_string_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m b/matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m index 637b882c..96a2eaf2 100644 --- a/matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m +++ b/matlab/generated/+test_model/+binary/SubarraysInRecordsReader.m @@ -8,21 +8,21 @@ end methods - function obj = SubarraysInRecordsReader(filename) - obj@test_model.SubarraysInRecordsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.SubarraysInRecordsReaderBase.schema); - obj.with_fixed_subarrays_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithFixedCollectionsSerializer()); - obj.with_vlen_subarrays_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlenCollectionsSerializer()); + function self = SubarraysInRecordsReader(filename) + self@test_model.SubarraysInRecordsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.SubarraysInRecordsReaderBase.schema); + self.with_fixed_subarrays_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithFixedCollectionsSerializer()); + self.with_vlen_subarrays_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlenCollectionsSerializer()); end end methods (Access=protected) - function value = read_with_fixed_subarrays_(obj) - value = obj.with_fixed_subarrays_serializer.read(obj.stream_); + function value = read_with_fixed_subarrays_(self) + value = self.with_fixed_subarrays_serializer.read(self.stream_); end - function value = read_with_vlen_subarrays_(obj) - value = obj.with_vlen_subarrays_serializer.read(obj.stream_); + function value = read_with_vlen_subarrays_(self) + value = self.with_vlen_subarrays_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m b/matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m index 5214ef6c..159bea93 100644 --- a/matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m +++ b/matlab/generated/+test_model/+binary/SubarraysInRecordsWriter.m @@ -8,21 +8,21 @@ end methods - function obj = SubarraysInRecordsWriter(filename) - obj@test_model.SubarraysInRecordsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.SubarraysInRecordsWriterBase.schema); - obj.with_fixed_subarrays_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithFixedCollectionsSerializer()); - obj.with_vlen_subarrays_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlenCollectionsSerializer()); + function self = SubarraysInRecordsWriter(filename) + self@test_model.SubarraysInRecordsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.SubarraysInRecordsWriterBase.schema); + self.with_fixed_subarrays_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithFixedCollectionsSerializer()); + self.with_vlen_subarrays_serializer = yardl.binary.DynamicNDArraySerializer(test_model.binary.RecordWithVlenCollectionsSerializer()); end end methods (Access=protected) - function write_with_fixed_subarrays_(obj, value) - obj.with_fixed_subarrays_serializer.write(obj.stream_, value); + function write_with_fixed_subarrays_(self, value) + self.with_fixed_subarrays_serializer.write(self.stream_, value); end - function write_with_vlen_subarrays_(obj, value) - obj.with_vlen_subarrays_serializer.write(obj.stream_, value); + function write_with_vlen_subarrays_(self, value) + self.with_vlen_subarrays_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/SubarraysReader.m b/matlab/generated/+test_model/+binary/SubarraysReader.m index b8cb7604..3b6bb7f7 100644 --- a/matlab/generated/+test_model/+binary/SubarraysReader.m +++ b/matlab/generated/+test_model/+binary/SubarraysReader.m @@ -15,56 +15,56 @@ end methods - function obj = SubarraysReader(filename) - obj@test_model.SubarraysReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.SubarraysReaderBase.schema); - obj.dynamic_with_fixed_int_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3])); - obj.dynamic_with_fixed_float_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3])); - obj.known_dim_count_with_fixed_int_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 1); - obj.known_dim_count_with_fixed_float_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), 1); - obj.fixed_with_fixed_int_subarray_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2]); - obj.fixed_with_fixed_float_subarray_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), [2]); - obj.nested_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2])); - obj.dynamic_with_fixed_vector_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); - obj.generic_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 2); + function self = SubarraysReader(filename) + self@test_model.SubarraysReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.SubarraysReaderBase.schema); + self.dynamic_with_fixed_int_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3])); + self.dynamic_with_fixed_float_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3])); + self.known_dim_count_with_fixed_int_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 1); + self.known_dim_count_with_fixed_float_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), 1); + self.fixed_with_fixed_int_subarray_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2]); + self.fixed_with_fixed_float_subarray_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), [2]); + self.nested_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2])); + self.dynamic_with_fixed_vector_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); + self.generic_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 2); end end methods (Access=protected) - function value = read_dynamic_with_fixed_int_subarray_(obj) - value = obj.dynamic_with_fixed_int_subarray_serializer.read(obj.stream_); + function value = read_dynamic_with_fixed_int_subarray_(self) + value = self.dynamic_with_fixed_int_subarray_serializer.read(self.stream_); end - function value = read_dynamic_with_fixed_float_subarray_(obj) - value = obj.dynamic_with_fixed_float_subarray_serializer.read(obj.stream_); + function value = read_dynamic_with_fixed_float_subarray_(self) + value = self.dynamic_with_fixed_float_subarray_serializer.read(self.stream_); end - function value = read_known_dim_count_with_fixed_int_subarray_(obj) - value = obj.known_dim_count_with_fixed_int_subarray_serializer.read(obj.stream_); + function value = read_known_dim_count_with_fixed_int_subarray_(self) + value = self.known_dim_count_with_fixed_int_subarray_serializer.read(self.stream_); end - function value = read_known_dim_count_with_fixed_float_subarray_(obj) - value = obj.known_dim_count_with_fixed_float_subarray_serializer.read(obj.stream_); + function value = read_known_dim_count_with_fixed_float_subarray_(self) + value = self.known_dim_count_with_fixed_float_subarray_serializer.read(self.stream_); end - function value = read_fixed_with_fixed_int_subarray_(obj) - value = obj.fixed_with_fixed_int_subarray_serializer.read(obj.stream_); + function value = read_fixed_with_fixed_int_subarray_(self) + value = self.fixed_with_fixed_int_subarray_serializer.read(self.stream_); end - function value = read_fixed_with_fixed_float_subarray_(obj) - value = obj.fixed_with_fixed_float_subarray_serializer.read(obj.stream_); + function value = read_fixed_with_fixed_float_subarray_(self) + value = self.fixed_with_fixed_float_subarray_serializer.read(self.stream_); end - function value = read_nested_subarray_(obj) - value = obj.nested_subarray_serializer.read(obj.stream_); + function value = read_nested_subarray_(self) + value = self.nested_subarray_serializer.read(self.stream_); end - function value = read_dynamic_with_fixed_vector_subarray_(obj) - value = obj.dynamic_with_fixed_vector_subarray_serializer.read(obj.stream_); + function value = read_dynamic_with_fixed_vector_subarray_(self) + value = self.dynamic_with_fixed_vector_subarray_serializer.read(self.stream_); end - function value = read_generic_subarray_(obj) - value = obj.generic_subarray_serializer.read(obj.stream_); + function value = read_generic_subarray_(self) + value = self.generic_subarray_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/SubarraysWriter.m b/matlab/generated/+test_model/+binary/SubarraysWriter.m index 3bf59340..c5a64290 100644 --- a/matlab/generated/+test_model/+binary/SubarraysWriter.m +++ b/matlab/generated/+test_model/+binary/SubarraysWriter.m @@ -15,56 +15,56 @@ end methods - function obj = SubarraysWriter(filename) - obj@test_model.SubarraysWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.SubarraysWriterBase.schema); - obj.dynamic_with_fixed_int_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3])); - obj.dynamic_with_fixed_float_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3])); - obj.known_dim_count_with_fixed_int_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 1); - obj.known_dim_count_with_fixed_float_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), 1); - obj.fixed_with_fixed_int_subarray_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2]); - obj.fixed_with_fixed_float_subarray_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), [2]); - obj.nested_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2])); - obj.dynamic_with_fixed_vector_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); - obj.generic_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 2); + function self = SubarraysWriter(filename) + self@test_model.SubarraysWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.SubarraysWriterBase.schema); + self.dynamic_with_fixed_int_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3])); + self.dynamic_with_fixed_float_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3])); + self.known_dim_count_with_fixed_int_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 1); + self.known_dim_count_with_fixed_float_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), 1); + self.fixed_with_fixed_int_subarray_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2]); + self.fixed_with_fixed_float_subarray_serializer = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [3]), [2]); + self.nested_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), [2])); + self.dynamic_with_fixed_vector_subarray_serializer = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 3)); + self.generic_subarray_serializer = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3]), 2); end end methods (Access=protected) - function write_dynamic_with_fixed_int_subarray_(obj, value) - obj.dynamic_with_fixed_int_subarray_serializer.write(obj.stream_, value); + function write_dynamic_with_fixed_int_subarray_(self, value) + self.dynamic_with_fixed_int_subarray_serializer.write(self.stream_, value); end - function write_dynamic_with_fixed_float_subarray_(obj, value) - obj.dynamic_with_fixed_float_subarray_serializer.write(obj.stream_, value); + function write_dynamic_with_fixed_float_subarray_(self, value) + self.dynamic_with_fixed_float_subarray_serializer.write(self.stream_, value); end - function write_known_dim_count_with_fixed_int_subarray_(obj, value) - obj.known_dim_count_with_fixed_int_subarray_serializer.write(obj.stream_, value); + function write_known_dim_count_with_fixed_int_subarray_(self, value) + self.known_dim_count_with_fixed_int_subarray_serializer.write(self.stream_, value); end - function write_known_dim_count_with_fixed_float_subarray_(obj, value) - obj.known_dim_count_with_fixed_float_subarray_serializer.write(obj.stream_, value); + function write_known_dim_count_with_fixed_float_subarray_(self, value) + self.known_dim_count_with_fixed_float_subarray_serializer.write(self.stream_, value); end - function write_fixed_with_fixed_int_subarray_(obj, value) - obj.fixed_with_fixed_int_subarray_serializer.write(obj.stream_, value); + function write_fixed_with_fixed_int_subarray_(self, value) + self.fixed_with_fixed_int_subarray_serializer.write(self.stream_, value); end - function write_fixed_with_fixed_float_subarray_(obj, value) - obj.fixed_with_fixed_float_subarray_serializer.write(obj.stream_, value); + function write_fixed_with_fixed_float_subarray_(self, value) + self.fixed_with_fixed_float_subarray_serializer.write(self.stream_, value); end - function write_nested_subarray_(obj, value) - obj.nested_subarray_serializer.write(obj.stream_, value); + function write_nested_subarray_(self, value) + self.nested_subarray_serializer.write(self.stream_, value); end - function write_dynamic_with_fixed_vector_subarray_(obj, value) - obj.dynamic_with_fixed_vector_subarray_serializer.write(obj.stream_, value); + function write_dynamic_with_fixed_vector_subarray_(self, value) + self.dynamic_with_fixed_vector_subarray_serializer.write(self.stream_, value); end - function write_generic_subarray_(obj, value) - obj.generic_subarray_serializer.write(obj.stream_, value); + function write_generic_subarray_(self, value) + self.generic_subarray_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m b/matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m index 9f9c47cd..3f7d2c20 100644 --- a/matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m +++ b/matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m @@ -2,19 +2,23 @@ classdef TupleWithRecordsSerializer < yardl.binary.RecordSerializer methods - function obj = TupleWithRecordsSerializer() + function self = TupleWithRecordsSerializer() field_serializers{1} = test_model.binary.SimpleRecordSerializer(); field_serializers{2} = test_model.binary.SimpleRecordSerializer(); - obj@yardl.binary.RecordSerializer('test_model.TupleWithRecords', field_serializers); + self@yardl.binary.RecordSerializer('test_model.TupleWithRecords', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'test_model.TupleWithRecords')); - obj.write_(outstream, value.a, value.b) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) test_model.TupleWithRecords + end + self.write_(outstream, value.a, value.b) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = test_model.TupleWithRecords(field_values{:}); end end diff --git a/matlab/generated/+test_model/+binary/UnionsReader.m b/matlab/generated/+test_model/+binary/UnionsReader.m index 5b64af4f..95614609 100644 --- a/matlab/generated/+test_model/+binary/UnionsReader.m +++ b/matlab/generated/+test_model/+binary/UnionsReader.m @@ -10,31 +10,31 @@ end methods - function obj = UnionsReader(filename) - obj@test_model.UnionsReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.UnionsReaderBase.schema); - obj.int_or_simple_record_serializer = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); - obj.int_or_record_with_vlens_serializer = yardl.binary.UnionSerializer('test_model.Int32OrRecordWithVlens', {yardl.binary.Int32Serializer, test_model.binary.RecordWithVlensSerializer()}, {@test_model.Int32OrRecordWithVlens.Int32, @test_model.Int32OrRecordWithVlens.RecordWithVlens}); - obj.monosotate_or_int_or_simple_record_serializer = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); - obj.record_with_unions_serializer = basic_types.binary.RecordWithUnionsSerializer(); + function self = UnionsReader(filename) + self@test_model.UnionsReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.UnionsReaderBase.schema); + self.int_or_simple_record_serializer = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); + self.int_or_record_with_vlens_serializer = yardl.binary.UnionSerializer('test_model.Int32OrRecordWithVlens', {yardl.binary.Int32Serializer, test_model.binary.RecordWithVlensSerializer()}, {@test_model.Int32OrRecordWithVlens.Int32, @test_model.Int32OrRecordWithVlens.RecordWithVlens}); + self.monosotate_or_int_or_simple_record_serializer = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); + self.record_with_unions_serializer = basic_types.binary.RecordWithUnionsSerializer(); end end methods (Access=protected) - function value = read_int_or_simple_record_(obj) - value = obj.int_or_simple_record_serializer.read(obj.stream_); + function value = read_int_or_simple_record_(self) + value = self.int_or_simple_record_serializer.read(self.stream_); end - function value = read_int_or_record_with_vlens_(obj) - value = obj.int_or_record_with_vlens_serializer.read(obj.stream_); + function value = read_int_or_record_with_vlens_(self) + value = self.int_or_record_with_vlens_serializer.read(self.stream_); end - function value = read_monosotate_or_int_or_simple_record_(obj) - value = obj.monosotate_or_int_or_simple_record_serializer.read(obj.stream_); + function value = read_monosotate_or_int_or_simple_record_(self) + value = self.monosotate_or_int_or_simple_record_serializer.read(self.stream_); end - function value = read_record_with_unions_(obj) - value = obj.record_with_unions_serializer.read(obj.stream_); + function value = read_record_with_unions_(self) + value = self.record_with_unions_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/UnionsWriter.m b/matlab/generated/+test_model/+binary/UnionsWriter.m index 5d711325..dc1addc0 100644 --- a/matlab/generated/+test_model/+binary/UnionsWriter.m +++ b/matlab/generated/+test_model/+binary/UnionsWriter.m @@ -10,31 +10,31 @@ end methods - function obj = UnionsWriter(filename) - obj@test_model.UnionsWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.UnionsWriterBase.schema); - obj.int_or_simple_record_serializer = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); - obj.int_or_record_with_vlens_serializer = yardl.binary.UnionSerializer('test_model.Int32OrRecordWithVlens', {yardl.binary.Int32Serializer, test_model.binary.RecordWithVlensSerializer()}, {@test_model.Int32OrRecordWithVlens.Int32, @test_model.Int32OrRecordWithVlens.RecordWithVlens}); - obj.monosotate_or_int_or_simple_record_serializer = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); - obj.record_with_unions_serializer = basic_types.binary.RecordWithUnionsSerializer(); + function self = UnionsWriter(filename) + self@test_model.UnionsWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.UnionsWriterBase.schema); + self.int_or_simple_record_serializer = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {@test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); + self.int_or_record_with_vlens_serializer = yardl.binary.UnionSerializer('test_model.Int32OrRecordWithVlens', {yardl.binary.Int32Serializer, test_model.binary.RecordWithVlensSerializer()}, {@test_model.Int32OrRecordWithVlens.Int32, @test_model.Int32OrRecordWithVlens.RecordWithVlens}); + self.monosotate_or_int_or_simple_record_serializer = yardl.binary.UnionSerializer('test_model.Int32OrSimpleRecord', {yardl.binary.NoneSerializer, yardl.binary.Int32Serializer, test_model.binary.SimpleRecordSerializer()}, {yardl.None, @test_model.Int32OrSimpleRecord.Int32, @test_model.Int32OrSimpleRecord.SimpleRecord}); + self.record_with_unions_serializer = basic_types.binary.RecordWithUnionsSerializer(); end end methods (Access=protected) - function write_int_or_simple_record_(obj, value) - obj.int_or_simple_record_serializer.write(obj.stream_, value); + function write_int_or_simple_record_(self, value) + self.int_or_simple_record_serializer.write(self.stream_, value); end - function write_int_or_record_with_vlens_(obj, value) - obj.int_or_record_with_vlens_serializer.write(obj.stream_, value); + function write_int_or_record_with_vlens_(self, value) + self.int_or_record_with_vlens_serializer.write(self.stream_, value); end - function write_monosotate_or_int_or_simple_record_(obj, value) - obj.monosotate_or_int_or_simple_record_serializer.write(obj.stream_, value); + function write_monosotate_or_int_or_simple_record_(self, value) + self.monosotate_or_int_or_simple_record_serializer.write(self.stream_, value); end - function write_record_with_unions_(obj, value) - obj.record_with_unions_serializer.write(obj.stream_, value); + function write_record_with_unions_(self, value) + self.record_with_unions_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+binary/VlensReader.m b/matlab/generated/+test_model/+binary/VlensReader.m index 6f2bb302..ee2886f5 100644 --- a/matlab/generated/+test_model/+binary/VlensReader.m +++ b/matlab/generated/+test_model/+binary/VlensReader.m @@ -10,31 +10,31 @@ end methods - function obj = VlensReader(filename) - obj@test_model.VlensReaderBase(); - obj@yardl.binary.BinaryProtocolReader(filename, test_model.VlensReaderBase.schema); - obj.int_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); - obj.complex_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Complexfloat32Serializer); - obj.record_with_vlens_serializer = test_model.binary.RecordWithVlensSerializer(); - obj.vlen_of_record_with_vlens_serializer = yardl.binary.VectorSerializer(test_model.binary.RecordWithVlensSerializer()); + function self = VlensReader(filename) + self@test_model.VlensReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.VlensReaderBase.schema); + self.int_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); + self.complex_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Complexfloat32Serializer); + self.record_with_vlens_serializer = test_model.binary.RecordWithVlensSerializer(); + self.vlen_of_record_with_vlens_serializer = yardl.binary.VectorSerializer(test_model.binary.RecordWithVlensSerializer()); end end methods (Access=protected) - function value = read_int_vector_(obj) - value = obj.int_vector_serializer.read(obj.stream_); + function value = read_int_vector_(self) + value = self.int_vector_serializer.read(self.stream_); end - function value = read_complex_vector_(obj) - value = obj.complex_vector_serializer.read(obj.stream_); + function value = read_complex_vector_(self) + value = self.complex_vector_serializer.read(self.stream_); end - function value = read_record_with_vlens_(obj) - value = obj.record_with_vlens_serializer.read(obj.stream_); + function value = read_record_with_vlens_(self) + value = self.record_with_vlens_serializer.read(self.stream_); end - function value = read_vlen_of_record_with_vlens_(obj) - value = obj.vlen_of_record_with_vlens_serializer.read(obj.stream_); + function value = read_vlen_of_record_with_vlens_(self) + value = self.vlen_of_record_with_vlens_serializer.read(self.stream_); end end end diff --git a/matlab/generated/+test_model/+binary/VlensWriter.m b/matlab/generated/+test_model/+binary/VlensWriter.m index 891676bf..f7a00243 100644 --- a/matlab/generated/+test_model/+binary/VlensWriter.m +++ b/matlab/generated/+test_model/+binary/VlensWriter.m @@ -10,31 +10,31 @@ end methods - function obj = VlensWriter(filename) - obj@test_model.VlensWriterBase(); - obj@yardl.binary.BinaryProtocolWriter(filename, test_model.VlensWriterBase.schema); - obj.int_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); - obj.complex_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Complexfloat32Serializer); - obj.record_with_vlens_serializer = test_model.binary.RecordWithVlensSerializer(); - obj.vlen_of_record_with_vlens_serializer = yardl.binary.VectorSerializer(test_model.binary.RecordWithVlensSerializer()); + function self = VlensWriter(filename) + self@test_model.VlensWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.VlensWriterBase.schema); + self.int_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); + self.complex_vector_serializer = yardl.binary.VectorSerializer(yardl.binary.Complexfloat32Serializer); + self.record_with_vlens_serializer = test_model.binary.RecordWithVlensSerializer(); + self.vlen_of_record_with_vlens_serializer = yardl.binary.VectorSerializer(test_model.binary.RecordWithVlensSerializer()); end end methods (Access=protected) - function write_int_vector_(obj, value) - obj.int_vector_serializer.write(obj.stream_, value); + function write_int_vector_(self, value) + self.int_vector_serializer.write(self.stream_, value); end - function write_complex_vector_(obj, value) - obj.complex_vector_serializer.write(obj.stream_, value); + function write_complex_vector_(self, value) + self.complex_vector_serializer.write(self.stream_, value); end - function write_record_with_vlens_(obj, value) - obj.record_with_vlens_serializer.write(obj.stream_, value); + function write_record_with_vlens_(self, value) + self.record_with_vlens_serializer.write(self.stream_, value); end - function write_vlen_of_record_with_vlens_(obj, value) - obj.vlen_of_record_with_vlens_serializer.write(obj.stream_, value); + function write_vlen_of_record_with_vlens_(self, value) + self.vlen_of_record_with_vlens_serializer.write(self.stream_, value); end end end diff --git a/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m b/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m index cfed485a..e005205c 100644 --- a/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/MockAdvancedGenericsWriter.m @@ -11,78 +11,78 @@ end methods - function obj = MockAdvancedGenericsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_float_image_image = yardl.None; - obj.expected_generic_record_1 = yardl.None; - obj.expected_tuple_of_optionals = yardl.None; - obj.expected_tuple_of_optionals_alternate_syntax = yardl.None; - obj.expected_tuple_of_vectors = yardl.None; + function self = MockAdvancedGenericsWriter(testCase) + self.testCase_ = testCase; + self.expected_float_image_image = yardl.None; + self.expected_generic_record_1 = yardl.None; + self.expected_tuple_of_optionals = yardl.None; + self.expected_tuple_of_optionals_alternate_syntax = yardl.None; + self.expected_tuple_of_vectors = yardl.None; end - function expect_write_float_image_image_(obj, value) - obj.expected_float_image_image = yardl.Optional(value); + function expect_write_float_image_image_(self, value) + self.expected_float_image_image = yardl.Optional(value); end - function expect_write_generic_record_1_(obj, value) - obj.expected_generic_record_1 = yardl.Optional(value); + function expect_write_generic_record_1_(self, value) + self.expected_generic_record_1 = yardl.Optional(value); end - function expect_write_tuple_of_optionals_(obj, value) - obj.expected_tuple_of_optionals = yardl.Optional(value); + function expect_write_tuple_of_optionals_(self, value) + self.expected_tuple_of_optionals = yardl.Optional(value); end - function expect_write_tuple_of_optionals_alternate_syntax_(obj, value) - obj.expected_tuple_of_optionals_alternate_syntax = yardl.Optional(value); + function expect_write_tuple_of_optionals_alternate_syntax_(self, value) + self.expected_tuple_of_optionals_alternate_syntax = yardl.Optional(value); end - function expect_write_tuple_of_vectors_(obj, value) - obj.expected_tuple_of_vectors = yardl.Optional(value); + function expect_write_tuple_of_vectors_(self, value) + self.expected_tuple_of_vectors = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_float_image_image, yardl.None, "Expected call to write_float_image_image_ was not received"); - obj.testCase_.verifyEqual(obj.expected_generic_record_1, yardl.None, "Expected call to write_generic_record_1_ was not received"); - obj.testCase_.verifyEqual(obj.expected_tuple_of_optionals, yardl.None, "Expected call to write_tuple_of_optionals_ was not received"); - obj.testCase_.verifyEqual(obj.expected_tuple_of_optionals_alternate_syntax, yardl.None, "Expected call to write_tuple_of_optionals_alternate_syntax_ was not received"); - obj.testCase_.verifyEqual(obj.expected_tuple_of_vectors, yardl.None, "Expected call to write_tuple_of_vectors_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_float_image_image, yardl.None, "Expected call to write_float_image_image_ was not received"); + self.testCase_.verifyEqual(self.expected_generic_record_1, yardl.None, "Expected call to write_generic_record_1_ was not received"); + self.testCase_.verifyEqual(self.expected_tuple_of_optionals, yardl.None, "Expected call to write_tuple_of_optionals_ was not received"); + self.testCase_.verifyEqual(self.expected_tuple_of_optionals_alternate_syntax, yardl.None, "Expected call to write_tuple_of_optionals_alternate_syntax_ was not received"); + self.testCase_.verifyEqual(self.expected_tuple_of_vectors, yardl.None, "Expected call to write_tuple_of_vectors_ was not received"); end end methods (Access=protected) - function write_float_image_image_(obj, value) - obj.testCase_.verifyTrue(obj.expected_float_image_image.has_value(), "Unexpected call to write_float_image_image_"); - obj.testCase_.verifyEqual(value, obj.expected_float_image_image.value, "Unexpected argument value for call to write_float_image_image_"); - obj.expected_float_image_image = yardl.None; + function write_float_image_image_(self, value) + self.testCase_.verifyTrue(self.expected_float_image_image.has_value(), "Unexpected call to write_float_image_image_"); + self.testCase_.verifyEqual(value, self.expected_float_image_image.value, "Unexpected argument value for call to write_float_image_image_"); + self.expected_float_image_image = yardl.None; end - function write_generic_record_1_(obj, value) - obj.testCase_.verifyTrue(obj.expected_generic_record_1.has_value(), "Unexpected call to write_generic_record_1_"); - obj.testCase_.verifyEqual(value, obj.expected_generic_record_1.value, "Unexpected argument value for call to write_generic_record_1_"); - obj.expected_generic_record_1 = yardl.None; + function write_generic_record_1_(self, value) + self.testCase_.verifyTrue(self.expected_generic_record_1.has_value(), "Unexpected call to write_generic_record_1_"); + self.testCase_.verifyEqual(value, self.expected_generic_record_1.value, "Unexpected argument value for call to write_generic_record_1_"); + self.expected_generic_record_1 = yardl.None; end - function write_tuple_of_optionals_(obj, value) - obj.testCase_.verifyTrue(obj.expected_tuple_of_optionals.has_value(), "Unexpected call to write_tuple_of_optionals_"); - obj.testCase_.verifyEqual(value, obj.expected_tuple_of_optionals.value, "Unexpected argument value for call to write_tuple_of_optionals_"); - obj.expected_tuple_of_optionals = yardl.None; + function write_tuple_of_optionals_(self, value) + self.testCase_.verifyTrue(self.expected_tuple_of_optionals.has_value(), "Unexpected call to write_tuple_of_optionals_"); + self.testCase_.verifyEqual(value, self.expected_tuple_of_optionals.value, "Unexpected argument value for call to write_tuple_of_optionals_"); + self.expected_tuple_of_optionals = yardl.None; end - function write_tuple_of_optionals_alternate_syntax_(obj, value) - obj.testCase_.verifyTrue(obj.expected_tuple_of_optionals_alternate_syntax.has_value(), "Unexpected call to write_tuple_of_optionals_alternate_syntax_"); - obj.testCase_.verifyEqual(value, obj.expected_tuple_of_optionals_alternate_syntax.value, "Unexpected argument value for call to write_tuple_of_optionals_alternate_syntax_"); - obj.expected_tuple_of_optionals_alternate_syntax = yardl.None; + function write_tuple_of_optionals_alternate_syntax_(self, value) + self.testCase_.verifyTrue(self.expected_tuple_of_optionals_alternate_syntax.has_value(), "Unexpected call to write_tuple_of_optionals_alternate_syntax_"); + self.testCase_.verifyEqual(value, self.expected_tuple_of_optionals_alternate_syntax.value, "Unexpected argument value for call to write_tuple_of_optionals_alternate_syntax_"); + self.expected_tuple_of_optionals_alternate_syntax = yardl.None; end - function write_tuple_of_vectors_(obj, value) - obj.testCase_.verifyTrue(obj.expected_tuple_of_vectors.has_value(), "Unexpected call to write_tuple_of_vectors_"); - obj.testCase_.verifyEqual(value, obj.expected_tuple_of_vectors.value, "Unexpected argument value for call to write_tuple_of_vectors_"); - obj.expected_tuple_of_vectors = yardl.None; + function write_tuple_of_vectors_(self, value) + self.testCase_.verifyTrue(self.expected_tuple_of_vectors.has_value(), "Unexpected call to write_tuple_of_vectors_"); + self.testCase_.verifyEqual(value, self.expected_tuple_of_vectors.value, "Unexpected argument value for call to write_tuple_of_vectors_"); + self.expected_tuple_of_vectors = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockAliasesWriter.m b/matlab/generated/+test_model/+testing/MockAliasesWriter.m index 43ab50f7..8a7590f5 100644 --- a/matlab/generated/+test_model/+testing/MockAliasesWriter.m +++ b/matlab/generated/+test_model/+testing/MockAliasesWriter.m @@ -16,60 +16,60 @@ end methods - function obj = MockAliasesWriter(testCase) - obj.testCase_ = testCase; - obj.expected_aliased_string = yardl.None; - obj.expected_aliased_enum = yardl.None; - obj.expected_aliased_open_generic = yardl.None; - obj.expected_aliased_closed_generic = yardl.None; - obj.expected_aliased_optional = yardl.None; - obj.expected_aliased_generic_optional = yardl.None; - obj.expected_aliased_generic_union_2 = yardl.None; - obj.expected_aliased_generic_vector = yardl.None; - obj.expected_aliased_generic_fixed_vector = yardl.None; - obj.expected_stream_of_aliased_generic_union_2 = {}; + function self = MockAliasesWriter(testCase) + self.testCase_ = testCase; + self.expected_aliased_string = yardl.None; + self.expected_aliased_enum = yardl.None; + self.expected_aliased_open_generic = yardl.None; + self.expected_aliased_closed_generic = yardl.None; + self.expected_aliased_optional = yardl.None; + self.expected_aliased_generic_optional = yardl.None; + self.expected_aliased_generic_union_2 = yardl.None; + self.expected_aliased_generic_vector = yardl.None; + self.expected_aliased_generic_fixed_vector = yardl.None; + self.expected_stream_of_aliased_generic_union_2 = {}; end - function expect_write_aliased_string_(obj, value) - obj.expected_aliased_string = yardl.Optional(value); + function expect_write_aliased_string_(self, value) + self.expected_aliased_string = yardl.Optional(value); end - function expect_write_aliased_enum_(obj, value) - obj.expected_aliased_enum = yardl.Optional(value); + function expect_write_aliased_enum_(self, value) + self.expected_aliased_enum = yardl.Optional(value); end - function expect_write_aliased_open_generic_(obj, value) - obj.expected_aliased_open_generic = yardl.Optional(value); + function expect_write_aliased_open_generic_(self, value) + self.expected_aliased_open_generic = yardl.Optional(value); end - function expect_write_aliased_closed_generic_(obj, value) - obj.expected_aliased_closed_generic = yardl.Optional(value); + function expect_write_aliased_closed_generic_(self, value) + self.expected_aliased_closed_generic = yardl.Optional(value); end - function expect_write_aliased_optional_(obj, value) - obj.expected_aliased_optional = yardl.Optional(value); + function expect_write_aliased_optional_(self, value) + self.expected_aliased_optional = yardl.Optional(value); end - function expect_write_aliased_generic_optional_(obj, value) - obj.expected_aliased_generic_optional = yardl.Optional(value); + function expect_write_aliased_generic_optional_(self, value) + self.expected_aliased_generic_optional = yardl.Optional(value); end - function expect_write_aliased_generic_union_2_(obj, value) - obj.expected_aliased_generic_union_2 = yardl.Optional(value); + function expect_write_aliased_generic_union_2_(self, value) + self.expected_aliased_generic_union_2 = yardl.Optional(value); end - function expect_write_aliased_generic_vector_(obj, value) - obj.expected_aliased_generic_vector = yardl.Optional(value); + function expect_write_aliased_generic_vector_(self, value) + self.expected_aliased_generic_vector = yardl.Optional(value); end - function expect_write_aliased_generic_fixed_vector_(obj, value) - obj.expected_aliased_generic_fixed_vector = yardl.Optional(value); + function expect_write_aliased_generic_fixed_vector_(self, value) + self.expected_aliased_generic_fixed_vector = yardl.Optional(value); end - function expect_write_stream_of_aliased_generic_union_2_(obj, value) + function expect_write_stream_of_aliased_generic_union_2_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_stream_of_aliased_generic_union_2{end+1} = value{n}; + self.expected_stream_of_aliased_generic_union_2{end+1} = value{n}; end return; end @@ -78,90 +78,90 @@ function expect_write_stream_of_aliased_generic_union_2_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_stream_of_aliased_generic_union_2{end+1} = value(index{:}, n); + self.expected_stream_of_aliased_generic_union_2{end+1} = value(index{:}, n); end end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_aliased_string, yardl.None, "Expected call to write_aliased_string_ was not received"); - obj.testCase_.verifyEqual(obj.expected_aliased_enum, yardl.None, "Expected call to write_aliased_enum_ was not received"); - obj.testCase_.verifyEqual(obj.expected_aliased_open_generic, yardl.None, "Expected call to write_aliased_open_generic_ was not received"); - obj.testCase_.verifyEqual(obj.expected_aliased_closed_generic, yardl.None, "Expected call to write_aliased_closed_generic_ was not received"); - obj.testCase_.verifyEqual(obj.expected_aliased_optional, yardl.None, "Expected call to write_aliased_optional_ was not received"); - obj.testCase_.verifyEqual(obj.expected_aliased_generic_optional, yardl.None, "Expected call to write_aliased_generic_optional_ was not received"); - obj.testCase_.verifyEqual(obj.expected_aliased_generic_union_2, yardl.None, "Expected call to write_aliased_generic_union_2_ was not received"); - obj.testCase_.verifyEqual(obj.expected_aliased_generic_vector, yardl.None, "Expected call to write_aliased_generic_vector_ was not received"); - obj.testCase_.verifyEqual(obj.expected_aliased_generic_fixed_vector, yardl.None, "Expected call to write_aliased_generic_fixed_vector_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.expected_stream_of_aliased_generic_union_2), "Expected call to write_stream_of_aliased_generic_union_2_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_aliased_string, yardl.None, "Expected call to write_aliased_string_ was not received"); + self.testCase_.verifyEqual(self.expected_aliased_enum, yardl.None, "Expected call to write_aliased_enum_ was not received"); + self.testCase_.verifyEqual(self.expected_aliased_open_generic, yardl.None, "Expected call to write_aliased_open_generic_ was not received"); + self.testCase_.verifyEqual(self.expected_aliased_closed_generic, yardl.None, "Expected call to write_aliased_closed_generic_ was not received"); + self.testCase_.verifyEqual(self.expected_aliased_optional, yardl.None, "Expected call to write_aliased_optional_ was not received"); + self.testCase_.verifyEqual(self.expected_aliased_generic_optional, yardl.None, "Expected call to write_aliased_generic_optional_ was not received"); + self.testCase_.verifyEqual(self.expected_aliased_generic_union_2, yardl.None, "Expected call to write_aliased_generic_union_2_ was not received"); + self.testCase_.verifyEqual(self.expected_aliased_generic_vector, yardl.None, "Expected call to write_aliased_generic_vector_ was not received"); + self.testCase_.verifyEqual(self.expected_aliased_generic_fixed_vector, yardl.None, "Expected call to write_aliased_generic_fixed_vector_ was not received"); + self.testCase_.verifyTrue(isempty(self.expected_stream_of_aliased_generic_union_2), "Expected call to write_stream_of_aliased_generic_union_2_ was not received"); end end methods (Access=protected) - function write_aliased_string_(obj, value) - obj.testCase_.verifyTrue(obj.expected_aliased_string.has_value(), "Unexpected call to write_aliased_string_"); - obj.testCase_.verifyEqual(value, obj.expected_aliased_string.value, "Unexpected argument value for call to write_aliased_string_"); - obj.expected_aliased_string = yardl.None; + function write_aliased_string_(self, value) + self.testCase_.verifyTrue(self.expected_aliased_string.has_value(), "Unexpected call to write_aliased_string_"); + self.testCase_.verifyEqual(value, self.expected_aliased_string.value, "Unexpected argument value for call to write_aliased_string_"); + self.expected_aliased_string = yardl.None; end - function write_aliased_enum_(obj, value) - obj.testCase_.verifyTrue(obj.expected_aliased_enum.has_value(), "Unexpected call to write_aliased_enum_"); - obj.testCase_.verifyEqual(value, obj.expected_aliased_enum.value, "Unexpected argument value for call to write_aliased_enum_"); - obj.expected_aliased_enum = yardl.None; + function write_aliased_enum_(self, value) + self.testCase_.verifyTrue(self.expected_aliased_enum.has_value(), "Unexpected call to write_aliased_enum_"); + self.testCase_.verifyEqual(value, self.expected_aliased_enum.value, "Unexpected argument value for call to write_aliased_enum_"); + self.expected_aliased_enum = yardl.None; end - function write_aliased_open_generic_(obj, value) - obj.testCase_.verifyTrue(obj.expected_aliased_open_generic.has_value(), "Unexpected call to write_aliased_open_generic_"); - obj.testCase_.verifyEqual(value, obj.expected_aliased_open_generic.value, "Unexpected argument value for call to write_aliased_open_generic_"); - obj.expected_aliased_open_generic = yardl.None; + function write_aliased_open_generic_(self, value) + self.testCase_.verifyTrue(self.expected_aliased_open_generic.has_value(), "Unexpected call to write_aliased_open_generic_"); + self.testCase_.verifyEqual(value, self.expected_aliased_open_generic.value, "Unexpected argument value for call to write_aliased_open_generic_"); + self.expected_aliased_open_generic = yardl.None; end - function write_aliased_closed_generic_(obj, value) - obj.testCase_.verifyTrue(obj.expected_aliased_closed_generic.has_value(), "Unexpected call to write_aliased_closed_generic_"); - obj.testCase_.verifyEqual(value, obj.expected_aliased_closed_generic.value, "Unexpected argument value for call to write_aliased_closed_generic_"); - obj.expected_aliased_closed_generic = yardl.None; + function write_aliased_closed_generic_(self, value) + self.testCase_.verifyTrue(self.expected_aliased_closed_generic.has_value(), "Unexpected call to write_aliased_closed_generic_"); + self.testCase_.verifyEqual(value, self.expected_aliased_closed_generic.value, "Unexpected argument value for call to write_aliased_closed_generic_"); + self.expected_aliased_closed_generic = yardl.None; end - function write_aliased_optional_(obj, value) - obj.testCase_.verifyTrue(obj.expected_aliased_optional.has_value(), "Unexpected call to write_aliased_optional_"); - obj.testCase_.verifyEqual(value, obj.expected_aliased_optional.value, "Unexpected argument value for call to write_aliased_optional_"); - obj.expected_aliased_optional = yardl.None; + function write_aliased_optional_(self, value) + self.testCase_.verifyTrue(self.expected_aliased_optional.has_value(), "Unexpected call to write_aliased_optional_"); + self.testCase_.verifyEqual(value, self.expected_aliased_optional.value, "Unexpected argument value for call to write_aliased_optional_"); + self.expected_aliased_optional = yardl.None; end - function write_aliased_generic_optional_(obj, value) - obj.testCase_.verifyTrue(obj.expected_aliased_generic_optional.has_value(), "Unexpected call to write_aliased_generic_optional_"); - obj.testCase_.verifyEqual(value, obj.expected_aliased_generic_optional.value, "Unexpected argument value for call to write_aliased_generic_optional_"); - obj.expected_aliased_generic_optional = yardl.None; + function write_aliased_generic_optional_(self, value) + self.testCase_.verifyTrue(self.expected_aliased_generic_optional.has_value(), "Unexpected call to write_aliased_generic_optional_"); + self.testCase_.verifyEqual(value, self.expected_aliased_generic_optional.value, "Unexpected argument value for call to write_aliased_generic_optional_"); + self.expected_aliased_generic_optional = yardl.None; end - function write_aliased_generic_union_2_(obj, value) - obj.testCase_.verifyTrue(obj.expected_aliased_generic_union_2.has_value(), "Unexpected call to write_aliased_generic_union_2_"); - obj.testCase_.verifyEqual(value, obj.expected_aliased_generic_union_2.value, "Unexpected argument value for call to write_aliased_generic_union_2_"); - obj.expected_aliased_generic_union_2 = yardl.None; + function write_aliased_generic_union_2_(self, value) + self.testCase_.verifyTrue(self.expected_aliased_generic_union_2.has_value(), "Unexpected call to write_aliased_generic_union_2_"); + self.testCase_.verifyEqual(value, self.expected_aliased_generic_union_2.value, "Unexpected argument value for call to write_aliased_generic_union_2_"); + self.expected_aliased_generic_union_2 = yardl.None; end - function write_aliased_generic_vector_(obj, value) - obj.testCase_.verifyTrue(obj.expected_aliased_generic_vector.has_value(), "Unexpected call to write_aliased_generic_vector_"); - obj.testCase_.verifyEqual(value, obj.expected_aliased_generic_vector.value, "Unexpected argument value for call to write_aliased_generic_vector_"); - obj.expected_aliased_generic_vector = yardl.None; + function write_aliased_generic_vector_(self, value) + self.testCase_.verifyTrue(self.expected_aliased_generic_vector.has_value(), "Unexpected call to write_aliased_generic_vector_"); + self.testCase_.verifyEqual(value, self.expected_aliased_generic_vector.value, "Unexpected argument value for call to write_aliased_generic_vector_"); + self.expected_aliased_generic_vector = yardl.None; end - function write_aliased_generic_fixed_vector_(obj, value) - obj.testCase_.verifyTrue(obj.expected_aliased_generic_fixed_vector.has_value(), "Unexpected call to write_aliased_generic_fixed_vector_"); - obj.testCase_.verifyEqual(value, obj.expected_aliased_generic_fixed_vector.value, "Unexpected argument value for call to write_aliased_generic_fixed_vector_"); - obj.expected_aliased_generic_fixed_vector = yardl.None; + function write_aliased_generic_fixed_vector_(self, value) + self.testCase_.verifyTrue(self.expected_aliased_generic_fixed_vector.has_value(), "Unexpected call to write_aliased_generic_fixed_vector_"); + self.testCase_.verifyEqual(value, self.expected_aliased_generic_fixed_vector.value, "Unexpected argument value for call to write_aliased_generic_fixed_vector_"); + self.expected_aliased_generic_fixed_vector = yardl.None; end - function write_stream_of_aliased_generic_union_2_(obj, value) + function write_stream_of_aliased_generic_union_2_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_stream_of_aliased_generic_union_2), "Unexpected call to write_stream_of_aliased_generic_union_2_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_stream_of_aliased_generic_union_2{1}, "Unexpected argument value for call to write_stream_of_aliased_generic_union_2_"); - obj.expected_stream_of_aliased_generic_union_2 = obj.expected_stream_of_aliased_generic_union_2(2:end); + self.testCase_.verifyFalse(isempty(self.expected_stream_of_aliased_generic_union_2), "Unexpected call to write_stream_of_aliased_generic_union_2_"); + self.testCase_.verifyEqual(value{1}, self.expected_stream_of_aliased_generic_union_2{1}, "Unexpected argument value for call to write_stream_of_aliased_generic_union_2_"); + self.expected_stream_of_aliased_generic_union_2 = self.expected_stream_of_aliased_generic_union_2(2:end); end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m index f1b2fad3..133c5a3f 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkFloat256x256Writer.m @@ -7,15 +7,15 @@ end methods - function obj = MockBenchmarkFloat256x256Writer(testCase) - obj.testCase_ = testCase; - obj.expected_float256x256 = {}; + function self = MockBenchmarkFloat256x256Writer(testCase) + self.testCase_ = testCase; + self.expected_float256x256 = {}; end - function expect_write_float256x256_(obj, value) + function expect_write_float256x256_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_float256x256{end+1} = value{n}; + self.expected_float256x256{end+1} = value{n}; end return; end @@ -24,27 +24,27 @@ function expect_write_float256x256_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_float256x256{end+1} = value(index{:}, n); + self.expected_float256x256{end+1} = value(index{:}, n); end end - function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.expected_float256x256), "Expected call to write_float256x256_ was not received"); + function verify(self) + self.testCase_.verifyTrue(isempty(self.expected_float256x256), "Expected call to write_float256x256_ was not received"); end end methods (Access=protected) - function write_float256x256_(obj, value) + function write_float256x256_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_float256x256), "Unexpected call to write_float256x256_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_float256x256{1}, "Unexpected argument value for call to write_float256x256_"); - obj.expected_float256x256 = obj.expected_float256x256(2:end); + self.testCase_.verifyFalse(isempty(self.expected_float256x256), "Unexpected call to write_float256x256_"); + self.testCase_.verifyEqual(value{1}, self.expected_float256x256{1}, "Unexpected argument value for call to write_float256x256_"); + self.expected_float256x256 = self.expected_float256x256(2:end); end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m index a3c62c82..df217bfb 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkFloatVlenWriter.m @@ -7,15 +7,15 @@ end methods - function obj = MockBenchmarkFloatVlenWriter(testCase) - obj.testCase_ = testCase; - obj.expected_float_array = {}; + function self = MockBenchmarkFloatVlenWriter(testCase) + self.testCase_ = testCase; + self.expected_float_array = {}; end - function expect_write_float_array_(obj, value) + function expect_write_float_array_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_float_array{end+1} = value{n}; + self.expected_float_array{end+1} = value{n}; end return; end @@ -24,27 +24,27 @@ function expect_write_float_array_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_float_array{end+1} = value(index{:}, n); + self.expected_float_array{end+1} = value(index{:}, n); end end - function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.expected_float_array), "Expected call to write_float_array_ was not received"); + function verify(self) + self.testCase_.verifyTrue(isempty(self.expected_float_array), "Expected call to write_float_array_ was not received"); end end methods (Access=protected) - function write_float_array_(obj, value) + function write_float_array_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_float_array), "Unexpected call to write_float_array_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_float_array{1}, "Unexpected argument value for call to write_float_array_"); - obj.expected_float_array = obj.expected_float_array(2:end); + self.testCase_.verifyFalse(isempty(self.expected_float_array), "Unexpected call to write_float_array_"); + self.testCase_.verifyEqual(value{1}, self.expected_float_array{1}, "Unexpected argument value for call to write_float_array_"); + self.expected_float_array = self.expected_float_array(2:end); end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m index 9a578178..8c28f8d1 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkInt256x256Writer.m @@ -7,15 +7,15 @@ end methods - function obj = MockBenchmarkInt256x256Writer(testCase) - obj.testCase_ = testCase; - obj.expected_int256x256 = {}; + function self = MockBenchmarkInt256x256Writer(testCase) + self.testCase_ = testCase; + self.expected_int256x256 = {}; end - function expect_write_int256x256_(obj, value) + function expect_write_int256x256_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_int256x256{end+1} = value{n}; + self.expected_int256x256{end+1} = value{n}; end return; end @@ -24,27 +24,27 @@ function expect_write_int256x256_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_int256x256{end+1} = value(index{:}, n); + self.expected_int256x256{end+1} = value(index{:}, n); end end - function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.expected_int256x256), "Expected call to write_int256x256_ was not received"); + function verify(self) + self.testCase_.verifyTrue(isempty(self.expected_int256x256), "Expected call to write_int256x256_ was not received"); end end methods (Access=protected) - function write_int256x256_(obj, value) + function write_int256x256_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_int256x256), "Unexpected call to write_int256x256_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_int256x256{1}, "Unexpected argument value for call to write_int256x256_"); - obj.expected_int256x256 = obj.expected_int256x256(2:end); + self.testCase_.verifyFalse(isempty(self.expected_int256x256), "Unexpected call to write_int256x256_"); + self.testCase_.verifyEqual(value{1}, self.expected_int256x256{1}, "Unexpected argument value for call to write_int256x256_"); + self.expected_int256x256 = self.expected_int256x256(2:end); end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m index 8db1d155..0fc522f9 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSimpleMrdWriter.m @@ -7,15 +7,15 @@ end methods - function obj = MockBenchmarkSimpleMrdWriter(testCase) - obj.testCase_ = testCase; - obj.expected_data = {}; + function self = MockBenchmarkSimpleMrdWriter(testCase) + self.testCase_ = testCase; + self.expected_data = {}; end - function expect_write_data_(obj, value) + function expect_write_data_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_data{end+1} = value{n}; + self.expected_data{end+1} = value{n}; end return; end @@ -24,27 +24,27 @@ function expect_write_data_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_data{end+1} = value(index{:}, n); + self.expected_data{end+1} = value(index{:}, n); end end - function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.expected_data), "Expected call to write_data_ was not received"); + function verify(self) + self.testCase_.verifyTrue(isempty(self.expected_data), "Expected call to write_data_ was not received"); end end methods (Access=protected) - function write_data_(obj, value) + function write_data_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_data), "Unexpected call to write_data_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_data{1}, "Unexpected argument value for call to write_data_"); - obj.expected_data = obj.expected_data(2:end); + self.testCase_.verifyFalse(isempty(self.expected_data), "Unexpected call to write_data_"); + self.testCase_.verifyEqual(value{1}, self.expected_data{1}, "Unexpected argument value for call to write_data_"); + self.expected_data = self.expected_data(2:end); end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m index ccd19ad5..299bb4ed 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWithOptionalsWriter.m @@ -7,15 +7,15 @@ end methods - function obj = MockBenchmarkSmallRecordWithOptionalsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_small_record = {}; + function self = MockBenchmarkSmallRecordWithOptionalsWriter(testCase) + self.testCase_ = testCase; + self.expected_small_record = {}; end - function expect_write_small_record_(obj, value) + function expect_write_small_record_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_small_record{end+1} = value{n}; + self.expected_small_record{end+1} = value{n}; end return; end @@ -24,27 +24,27 @@ function expect_write_small_record_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_small_record{end+1} = value(index{:}, n); + self.expected_small_record{end+1} = value(index{:}, n); end end - function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.expected_small_record), "Expected call to write_small_record_ was not received"); + function verify(self) + self.testCase_.verifyTrue(isempty(self.expected_small_record), "Expected call to write_small_record_ was not received"); end end methods (Access=protected) - function write_small_record_(obj, value) + function write_small_record_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_small_record), "Unexpected call to write_small_record_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_small_record{1}, "Unexpected argument value for call to write_small_record_"); - obj.expected_small_record = obj.expected_small_record(2:end); + self.testCase_.verifyFalse(isempty(self.expected_small_record), "Unexpected call to write_small_record_"); + self.testCase_.verifyEqual(value{1}, self.expected_small_record{1}, "Unexpected argument value for call to write_small_record_"); + self.expected_small_record = self.expected_small_record(2:end); end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m index 1cf45503..ca14a7c7 100644 --- a/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m +++ b/matlab/generated/+test_model/+testing/MockBenchmarkSmallRecordWriter.m @@ -7,15 +7,15 @@ end methods - function obj = MockBenchmarkSmallRecordWriter(testCase) - obj.testCase_ = testCase; - obj.expected_small_record = {}; + function self = MockBenchmarkSmallRecordWriter(testCase) + self.testCase_ = testCase; + self.expected_small_record = {}; end - function expect_write_small_record_(obj, value) + function expect_write_small_record_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_small_record{end+1} = value{n}; + self.expected_small_record{end+1} = value{n}; end return; end @@ -24,27 +24,27 @@ function expect_write_small_record_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_small_record{end+1} = value(index{:}, n); + self.expected_small_record{end+1} = value(index{:}, n); end end - function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.expected_small_record), "Expected call to write_small_record_ was not received"); + function verify(self) + self.testCase_.verifyTrue(isempty(self.expected_small_record), "Expected call to write_small_record_ was not received"); end end methods (Access=protected) - function write_small_record_(obj, value) + function write_small_record_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_small_record), "Unexpected call to write_small_record_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_small_record{1}, "Unexpected argument value for call to write_small_record_"); - obj.expected_small_record = obj.expected_small_record(2:end); + self.testCase_.verifyFalse(isempty(self.expected_small_record), "Unexpected call to write_small_record_"); + self.testCase_.verifyEqual(value{1}, self.expected_small_record{1}, "Unexpected argument value for call to write_small_record_"); + self.expected_small_record = self.expected_small_record(2:end); end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m b/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m index 74e1a7ca..764e3629 100644 --- a/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockDynamicNDArraysWriter.m @@ -10,66 +10,66 @@ end methods - function obj = MockDynamicNDArraysWriter(testCase) - obj.testCase_ = testCase; - obj.expected_ints = yardl.None; - obj.expected_simple_record_array = yardl.None; - obj.expected_record_with_vlens_array = yardl.None; - obj.expected_record_with_dynamic_nd_arrays = yardl.None; + function self = MockDynamicNDArraysWriter(testCase) + self.testCase_ = testCase; + self.expected_ints = yardl.None; + self.expected_simple_record_array = yardl.None; + self.expected_record_with_vlens_array = yardl.None; + self.expected_record_with_dynamic_nd_arrays = yardl.None; end - function expect_write_ints_(obj, value) - obj.expected_ints = yardl.Optional(value); + function expect_write_ints_(self, value) + self.expected_ints = yardl.Optional(value); end - function expect_write_simple_record_array_(obj, value) - obj.expected_simple_record_array = yardl.Optional(value); + function expect_write_simple_record_array_(self, value) + self.expected_simple_record_array = yardl.Optional(value); end - function expect_write_record_with_vlens_array_(obj, value) - obj.expected_record_with_vlens_array = yardl.Optional(value); + function expect_write_record_with_vlens_array_(self, value) + self.expected_record_with_vlens_array = yardl.Optional(value); end - function expect_write_record_with_dynamic_nd_arrays_(obj, value) - obj.expected_record_with_dynamic_nd_arrays = yardl.Optional(value); + function expect_write_record_with_dynamic_nd_arrays_(self, value) + self.expected_record_with_dynamic_nd_arrays = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_ints, yardl.None, "Expected call to write_ints_ was not received"); - obj.testCase_.verifyEqual(obj.expected_simple_record_array, yardl.None, "Expected call to write_simple_record_array_ was not received"); - obj.testCase_.verifyEqual(obj.expected_record_with_vlens_array, yardl.None, "Expected call to write_record_with_vlens_array_ was not received"); - obj.testCase_.verifyEqual(obj.expected_record_with_dynamic_nd_arrays, yardl.None, "Expected call to write_record_with_dynamic_nd_arrays_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_ints, yardl.None, "Expected call to write_ints_ was not received"); + self.testCase_.verifyEqual(self.expected_simple_record_array, yardl.None, "Expected call to write_simple_record_array_ was not received"); + self.testCase_.verifyEqual(self.expected_record_with_vlens_array, yardl.None, "Expected call to write_record_with_vlens_array_ was not received"); + self.testCase_.verifyEqual(self.expected_record_with_dynamic_nd_arrays, yardl.None, "Expected call to write_record_with_dynamic_nd_arrays_ was not received"); end end methods (Access=protected) - function write_ints_(obj, value) - obj.testCase_.verifyTrue(obj.expected_ints.has_value(), "Unexpected call to write_ints_"); - obj.testCase_.verifyEqual(value, obj.expected_ints.value, "Unexpected argument value for call to write_ints_"); - obj.expected_ints = yardl.None; + function write_ints_(self, value) + self.testCase_.verifyTrue(self.expected_ints.has_value(), "Unexpected call to write_ints_"); + self.testCase_.verifyEqual(value, self.expected_ints.value, "Unexpected argument value for call to write_ints_"); + self.expected_ints = yardl.None; end - function write_simple_record_array_(obj, value) - obj.testCase_.verifyTrue(obj.expected_simple_record_array.has_value(), "Unexpected call to write_simple_record_array_"); - obj.testCase_.verifyEqual(value, obj.expected_simple_record_array.value, "Unexpected argument value for call to write_simple_record_array_"); - obj.expected_simple_record_array = yardl.None; + function write_simple_record_array_(self, value) + self.testCase_.verifyTrue(self.expected_simple_record_array.has_value(), "Unexpected call to write_simple_record_array_"); + self.testCase_.verifyEqual(value, self.expected_simple_record_array.value, "Unexpected argument value for call to write_simple_record_array_"); + self.expected_simple_record_array = yardl.None; end - function write_record_with_vlens_array_(obj, value) - obj.testCase_.verifyTrue(obj.expected_record_with_vlens_array.has_value(), "Unexpected call to write_record_with_vlens_array_"); - obj.testCase_.verifyEqual(value, obj.expected_record_with_vlens_array.value, "Unexpected argument value for call to write_record_with_vlens_array_"); - obj.expected_record_with_vlens_array = yardl.None; + function write_record_with_vlens_array_(self, value) + self.testCase_.verifyTrue(self.expected_record_with_vlens_array.has_value(), "Unexpected call to write_record_with_vlens_array_"); + self.testCase_.verifyEqual(value, self.expected_record_with_vlens_array.value, "Unexpected argument value for call to write_record_with_vlens_array_"); + self.expected_record_with_vlens_array = yardl.None; end - function write_record_with_dynamic_nd_arrays_(obj, value) - obj.testCase_.verifyTrue(obj.expected_record_with_dynamic_nd_arrays.has_value(), "Unexpected call to write_record_with_dynamic_nd_arrays_"); - obj.testCase_.verifyEqual(value, obj.expected_record_with_dynamic_nd_arrays.value, "Unexpected argument value for call to write_record_with_dynamic_nd_arrays_"); - obj.expected_record_with_dynamic_nd_arrays = yardl.None; + function write_record_with_dynamic_nd_arrays_(self, value) + self.testCase_.verifyTrue(self.expected_record_with_dynamic_nd_arrays.has_value(), "Unexpected call to write_record_with_dynamic_nd_arrays_"); + self.testCase_.verifyEqual(value, self.expected_record_with_dynamic_nd_arrays.value, "Unexpected argument value for call to write_record_with_dynamic_nd_arrays_"); + self.expected_record_with_dynamic_nd_arrays = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockEnumsWriter.m b/matlab/generated/+test_model/+testing/MockEnumsWriter.m index 14cd6e97..adafd431 100644 --- a/matlab/generated/+test_model/+testing/MockEnumsWriter.m +++ b/matlab/generated/+test_model/+testing/MockEnumsWriter.m @@ -9,54 +9,54 @@ end methods - function obj = MockEnumsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_single = yardl.None; - obj.expected_vec = yardl.None; - obj.expected_size = yardl.None; + function self = MockEnumsWriter(testCase) + self.testCase_ = testCase; + self.expected_single = yardl.None; + self.expected_vec = yardl.None; + self.expected_size = yardl.None; end - function expect_write_single_(obj, value) - obj.expected_single = yardl.Optional(value); + function expect_write_single_(self, value) + self.expected_single = yardl.Optional(value); end - function expect_write_vec_(obj, value) - obj.expected_vec = yardl.Optional(value); + function expect_write_vec_(self, value) + self.expected_vec = yardl.Optional(value); end - function expect_write_size_(obj, value) - obj.expected_size = yardl.Optional(value); + function expect_write_size_(self, value) + self.expected_size = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_single, yardl.None, "Expected call to write_single_ was not received"); - obj.testCase_.verifyEqual(obj.expected_vec, yardl.None, "Expected call to write_vec_ was not received"); - obj.testCase_.verifyEqual(obj.expected_size, yardl.None, "Expected call to write_size_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_single, yardl.None, "Expected call to write_single_ was not received"); + self.testCase_.verifyEqual(self.expected_vec, yardl.None, "Expected call to write_vec_ was not received"); + self.testCase_.verifyEqual(self.expected_size, yardl.None, "Expected call to write_size_ was not received"); end end methods (Access=protected) - function write_single_(obj, value) - obj.testCase_.verifyTrue(obj.expected_single.has_value(), "Unexpected call to write_single_"); - obj.testCase_.verifyEqual(value, obj.expected_single.value, "Unexpected argument value for call to write_single_"); - obj.expected_single = yardl.None; + function write_single_(self, value) + self.testCase_.verifyTrue(self.expected_single.has_value(), "Unexpected call to write_single_"); + self.testCase_.verifyEqual(value, self.expected_single.value, "Unexpected argument value for call to write_single_"); + self.expected_single = yardl.None; end - function write_vec_(obj, value) - obj.testCase_.verifyTrue(obj.expected_vec.has_value(), "Unexpected call to write_vec_"); - obj.testCase_.verifyEqual(value, obj.expected_vec.value, "Unexpected argument value for call to write_vec_"); - obj.expected_vec = yardl.None; + function write_vec_(self, value) + self.testCase_.verifyTrue(self.expected_vec.has_value(), "Unexpected call to write_vec_"); + self.testCase_.verifyEqual(value, self.expected_vec.value, "Unexpected argument value for call to write_vec_"); + self.expected_vec = yardl.None; end - function write_size_(obj, value) - obj.testCase_.verifyTrue(obj.expected_size.has_value(), "Unexpected call to write_size_"); - obj.testCase_.verifyEqual(value, obj.expected_size.value, "Unexpected argument value for call to write_size_"); - obj.expected_size = yardl.None; + function write_size_(self, value) + self.testCase_.verifyTrue(self.expected_size.has_value(), "Unexpected call to write_size_"); + self.testCase_.verifyEqual(value, self.expected_size.value, "Unexpected argument value for call to write_size_"); + self.expected_size = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m b/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m index 472ddde3..5efac74a 100644 --- a/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockFixedArraysWriter.m @@ -11,78 +11,78 @@ end methods - function obj = MockFixedArraysWriter(testCase) - obj.testCase_ = testCase; - obj.expected_ints = yardl.None; - obj.expected_fixed_simple_record_array = yardl.None; - obj.expected_fixed_record_with_vlens_array = yardl.None; - obj.expected_record_with_fixed_arrays = yardl.None; - obj.expected_named_array = yardl.None; + function self = MockFixedArraysWriter(testCase) + self.testCase_ = testCase; + self.expected_ints = yardl.None; + self.expected_fixed_simple_record_array = yardl.None; + self.expected_fixed_record_with_vlens_array = yardl.None; + self.expected_record_with_fixed_arrays = yardl.None; + self.expected_named_array = yardl.None; end - function expect_write_ints_(obj, value) - obj.expected_ints = yardl.Optional(value); + function expect_write_ints_(self, value) + self.expected_ints = yardl.Optional(value); end - function expect_write_fixed_simple_record_array_(obj, value) - obj.expected_fixed_simple_record_array = yardl.Optional(value); + function expect_write_fixed_simple_record_array_(self, value) + self.expected_fixed_simple_record_array = yardl.Optional(value); end - function expect_write_fixed_record_with_vlens_array_(obj, value) - obj.expected_fixed_record_with_vlens_array = yardl.Optional(value); + function expect_write_fixed_record_with_vlens_array_(self, value) + self.expected_fixed_record_with_vlens_array = yardl.Optional(value); end - function expect_write_record_with_fixed_arrays_(obj, value) - obj.expected_record_with_fixed_arrays = yardl.Optional(value); + function expect_write_record_with_fixed_arrays_(self, value) + self.expected_record_with_fixed_arrays = yardl.Optional(value); end - function expect_write_named_array_(obj, value) - obj.expected_named_array = yardl.Optional(value); + function expect_write_named_array_(self, value) + self.expected_named_array = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_ints, yardl.None, "Expected call to write_ints_ was not received"); - obj.testCase_.verifyEqual(obj.expected_fixed_simple_record_array, yardl.None, "Expected call to write_fixed_simple_record_array_ was not received"); - obj.testCase_.verifyEqual(obj.expected_fixed_record_with_vlens_array, yardl.None, "Expected call to write_fixed_record_with_vlens_array_ was not received"); - obj.testCase_.verifyEqual(obj.expected_record_with_fixed_arrays, yardl.None, "Expected call to write_record_with_fixed_arrays_ was not received"); - obj.testCase_.verifyEqual(obj.expected_named_array, yardl.None, "Expected call to write_named_array_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_ints, yardl.None, "Expected call to write_ints_ was not received"); + self.testCase_.verifyEqual(self.expected_fixed_simple_record_array, yardl.None, "Expected call to write_fixed_simple_record_array_ was not received"); + self.testCase_.verifyEqual(self.expected_fixed_record_with_vlens_array, yardl.None, "Expected call to write_fixed_record_with_vlens_array_ was not received"); + self.testCase_.verifyEqual(self.expected_record_with_fixed_arrays, yardl.None, "Expected call to write_record_with_fixed_arrays_ was not received"); + self.testCase_.verifyEqual(self.expected_named_array, yardl.None, "Expected call to write_named_array_ was not received"); end end methods (Access=protected) - function write_ints_(obj, value) - obj.testCase_.verifyTrue(obj.expected_ints.has_value(), "Unexpected call to write_ints_"); - obj.testCase_.verifyEqual(value, obj.expected_ints.value, "Unexpected argument value for call to write_ints_"); - obj.expected_ints = yardl.None; + function write_ints_(self, value) + self.testCase_.verifyTrue(self.expected_ints.has_value(), "Unexpected call to write_ints_"); + self.testCase_.verifyEqual(value, self.expected_ints.value, "Unexpected argument value for call to write_ints_"); + self.expected_ints = yardl.None; end - function write_fixed_simple_record_array_(obj, value) - obj.testCase_.verifyTrue(obj.expected_fixed_simple_record_array.has_value(), "Unexpected call to write_fixed_simple_record_array_"); - obj.testCase_.verifyEqual(value, obj.expected_fixed_simple_record_array.value, "Unexpected argument value for call to write_fixed_simple_record_array_"); - obj.expected_fixed_simple_record_array = yardl.None; + function write_fixed_simple_record_array_(self, value) + self.testCase_.verifyTrue(self.expected_fixed_simple_record_array.has_value(), "Unexpected call to write_fixed_simple_record_array_"); + self.testCase_.verifyEqual(value, self.expected_fixed_simple_record_array.value, "Unexpected argument value for call to write_fixed_simple_record_array_"); + self.expected_fixed_simple_record_array = yardl.None; end - function write_fixed_record_with_vlens_array_(obj, value) - obj.testCase_.verifyTrue(obj.expected_fixed_record_with_vlens_array.has_value(), "Unexpected call to write_fixed_record_with_vlens_array_"); - obj.testCase_.verifyEqual(value, obj.expected_fixed_record_with_vlens_array.value, "Unexpected argument value for call to write_fixed_record_with_vlens_array_"); - obj.expected_fixed_record_with_vlens_array = yardl.None; + function write_fixed_record_with_vlens_array_(self, value) + self.testCase_.verifyTrue(self.expected_fixed_record_with_vlens_array.has_value(), "Unexpected call to write_fixed_record_with_vlens_array_"); + self.testCase_.verifyEqual(value, self.expected_fixed_record_with_vlens_array.value, "Unexpected argument value for call to write_fixed_record_with_vlens_array_"); + self.expected_fixed_record_with_vlens_array = yardl.None; end - function write_record_with_fixed_arrays_(obj, value) - obj.testCase_.verifyTrue(obj.expected_record_with_fixed_arrays.has_value(), "Unexpected call to write_record_with_fixed_arrays_"); - obj.testCase_.verifyEqual(value, obj.expected_record_with_fixed_arrays.value, "Unexpected argument value for call to write_record_with_fixed_arrays_"); - obj.expected_record_with_fixed_arrays = yardl.None; + function write_record_with_fixed_arrays_(self, value) + self.testCase_.verifyTrue(self.expected_record_with_fixed_arrays.has_value(), "Unexpected call to write_record_with_fixed_arrays_"); + self.testCase_.verifyEqual(value, self.expected_record_with_fixed_arrays.value, "Unexpected argument value for call to write_record_with_fixed_arrays_"); + self.expected_record_with_fixed_arrays = yardl.None; end - function write_named_array_(obj, value) - obj.testCase_.verifyTrue(obj.expected_named_array.has_value(), "Unexpected call to write_named_array_"); - obj.testCase_.verifyEqual(value, obj.expected_named_array.value, "Unexpected argument value for call to write_named_array_"); - obj.expected_named_array = yardl.None; + function write_named_array_(self, value) + self.testCase_.verifyTrue(self.expected_named_array.has_value(), "Unexpected call to write_named_array_"); + self.testCase_.verifyEqual(value, self.expected_named_array.value, "Unexpected argument value for call to write_named_array_"); + self.expected_named_array = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m b/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m index 354c107e..89bccca2 100644 --- a/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/MockFixedVectorsWriter.m @@ -10,66 +10,66 @@ end methods - function obj = MockFixedVectorsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_fixed_int_vector = yardl.None; - obj.expected_fixed_simple_record_vector = yardl.None; - obj.expected_fixed_record_with_vlens_vector = yardl.None; - obj.expected_record_with_fixed_vectors = yardl.None; + function self = MockFixedVectorsWriter(testCase) + self.testCase_ = testCase; + self.expected_fixed_int_vector = yardl.None; + self.expected_fixed_simple_record_vector = yardl.None; + self.expected_fixed_record_with_vlens_vector = yardl.None; + self.expected_record_with_fixed_vectors = yardl.None; end - function expect_write_fixed_int_vector_(obj, value) - obj.expected_fixed_int_vector = yardl.Optional(value); + function expect_write_fixed_int_vector_(self, value) + self.expected_fixed_int_vector = yardl.Optional(value); end - function expect_write_fixed_simple_record_vector_(obj, value) - obj.expected_fixed_simple_record_vector = yardl.Optional(value); + function expect_write_fixed_simple_record_vector_(self, value) + self.expected_fixed_simple_record_vector = yardl.Optional(value); end - function expect_write_fixed_record_with_vlens_vector_(obj, value) - obj.expected_fixed_record_with_vlens_vector = yardl.Optional(value); + function expect_write_fixed_record_with_vlens_vector_(self, value) + self.expected_fixed_record_with_vlens_vector = yardl.Optional(value); end - function expect_write_record_with_fixed_vectors_(obj, value) - obj.expected_record_with_fixed_vectors = yardl.Optional(value); + function expect_write_record_with_fixed_vectors_(self, value) + self.expected_record_with_fixed_vectors = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_fixed_int_vector, yardl.None, "Expected call to write_fixed_int_vector_ was not received"); - obj.testCase_.verifyEqual(obj.expected_fixed_simple_record_vector, yardl.None, "Expected call to write_fixed_simple_record_vector_ was not received"); - obj.testCase_.verifyEqual(obj.expected_fixed_record_with_vlens_vector, yardl.None, "Expected call to write_fixed_record_with_vlens_vector_ was not received"); - obj.testCase_.verifyEqual(obj.expected_record_with_fixed_vectors, yardl.None, "Expected call to write_record_with_fixed_vectors_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_fixed_int_vector, yardl.None, "Expected call to write_fixed_int_vector_ was not received"); + self.testCase_.verifyEqual(self.expected_fixed_simple_record_vector, yardl.None, "Expected call to write_fixed_simple_record_vector_ was not received"); + self.testCase_.verifyEqual(self.expected_fixed_record_with_vlens_vector, yardl.None, "Expected call to write_fixed_record_with_vlens_vector_ was not received"); + self.testCase_.verifyEqual(self.expected_record_with_fixed_vectors, yardl.None, "Expected call to write_record_with_fixed_vectors_ was not received"); end end methods (Access=protected) - function write_fixed_int_vector_(obj, value) - obj.testCase_.verifyTrue(obj.expected_fixed_int_vector.has_value(), "Unexpected call to write_fixed_int_vector_"); - obj.testCase_.verifyEqual(value, obj.expected_fixed_int_vector.value, "Unexpected argument value for call to write_fixed_int_vector_"); - obj.expected_fixed_int_vector = yardl.None; + function write_fixed_int_vector_(self, value) + self.testCase_.verifyTrue(self.expected_fixed_int_vector.has_value(), "Unexpected call to write_fixed_int_vector_"); + self.testCase_.verifyEqual(value, self.expected_fixed_int_vector.value, "Unexpected argument value for call to write_fixed_int_vector_"); + self.expected_fixed_int_vector = yardl.None; end - function write_fixed_simple_record_vector_(obj, value) - obj.testCase_.verifyTrue(obj.expected_fixed_simple_record_vector.has_value(), "Unexpected call to write_fixed_simple_record_vector_"); - obj.testCase_.verifyEqual(value, obj.expected_fixed_simple_record_vector.value, "Unexpected argument value for call to write_fixed_simple_record_vector_"); - obj.expected_fixed_simple_record_vector = yardl.None; + function write_fixed_simple_record_vector_(self, value) + self.testCase_.verifyTrue(self.expected_fixed_simple_record_vector.has_value(), "Unexpected call to write_fixed_simple_record_vector_"); + self.testCase_.verifyEqual(value, self.expected_fixed_simple_record_vector.value, "Unexpected argument value for call to write_fixed_simple_record_vector_"); + self.expected_fixed_simple_record_vector = yardl.None; end - function write_fixed_record_with_vlens_vector_(obj, value) - obj.testCase_.verifyTrue(obj.expected_fixed_record_with_vlens_vector.has_value(), "Unexpected call to write_fixed_record_with_vlens_vector_"); - obj.testCase_.verifyEqual(value, obj.expected_fixed_record_with_vlens_vector.value, "Unexpected argument value for call to write_fixed_record_with_vlens_vector_"); - obj.expected_fixed_record_with_vlens_vector = yardl.None; + function write_fixed_record_with_vlens_vector_(self, value) + self.testCase_.verifyTrue(self.expected_fixed_record_with_vlens_vector.has_value(), "Unexpected call to write_fixed_record_with_vlens_vector_"); + self.testCase_.verifyEqual(value, self.expected_fixed_record_with_vlens_vector.value, "Unexpected argument value for call to write_fixed_record_with_vlens_vector_"); + self.expected_fixed_record_with_vlens_vector = yardl.None; end - function write_record_with_fixed_vectors_(obj, value) - obj.testCase_.verifyTrue(obj.expected_record_with_fixed_vectors.has_value(), "Unexpected call to write_record_with_fixed_vectors_"); - obj.testCase_.verifyEqual(value, obj.expected_record_with_fixed_vectors.value, "Unexpected argument value for call to write_record_with_fixed_vectors_"); - obj.expected_record_with_fixed_vectors = yardl.None; + function write_record_with_fixed_vectors_(self, value) + self.testCase_.verifyTrue(self.expected_record_with_fixed_vectors.has_value(), "Unexpected call to write_record_with_fixed_vectors_"); + self.testCase_.verifyEqual(value, self.expected_record_with_fixed_vectors.value, "Unexpected argument value for call to write_record_with_fixed_vectors_"); + self.expected_record_with_fixed_vectors = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockFlagsWriter.m b/matlab/generated/+test_model/+testing/MockFlagsWriter.m index eddb4be0..31992a45 100644 --- a/matlab/generated/+test_model/+testing/MockFlagsWriter.m +++ b/matlab/generated/+test_model/+testing/MockFlagsWriter.m @@ -8,16 +8,16 @@ end methods - function obj = MockFlagsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_days = {}; - obj.expected_formats = {}; + function self = MockFlagsWriter(testCase) + self.testCase_ = testCase; + self.expected_days = {}; + self.expected_formats = {}; end - function expect_write_days_(obj, value) + function expect_write_days_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_days{end+1} = value{n}; + self.expected_days{end+1} = value{n}; end return; end @@ -26,14 +26,14 @@ function expect_write_days_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_days{end+1} = value(index{:}, n); + self.expected_days{end+1} = value(index{:}, n); end end - function expect_write_formats_(obj, value) + function expect_write_formats_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_formats{end+1} = value{n}; + self.expected_formats{end+1} = value{n}; end return; end @@ -42,36 +42,36 @@ function expect_write_formats_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_formats{end+1} = value(index{:}, n); + self.expected_formats{end+1} = value(index{:}, n); end end - function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.expected_days), "Expected call to write_days_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.expected_formats), "Expected call to write_formats_ was not received"); + function verify(self) + self.testCase_.verifyTrue(isempty(self.expected_days), "Expected call to write_days_ was not received"); + self.testCase_.verifyTrue(isempty(self.expected_formats), "Expected call to write_formats_ was not received"); end end methods (Access=protected) - function write_days_(obj, value) + function write_days_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_days), "Unexpected call to write_days_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_days{1}, "Unexpected argument value for call to write_days_"); - obj.expected_days = obj.expected_days(2:end); + self.testCase_.verifyFalse(isempty(self.expected_days), "Unexpected call to write_days_"); + self.testCase_.verifyEqual(value{1}, self.expected_days{1}, "Unexpected argument value for call to write_days_"); + self.expected_days = self.expected_days(2:end); end - function write_formats_(obj, value) + function write_formats_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_formats), "Unexpected call to write_formats_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_formats{1}, "Unexpected argument value for call to write_formats_"); - obj.expected_formats = obj.expected_formats(2:end); + self.testCase_.verifyFalse(isempty(self.expected_formats), "Unexpected call to write_formats_"); + self.testCase_.verifyEqual(value{1}, self.expected_formats{1}, "Unexpected argument value for call to write_formats_"); + self.expected_formats = self.expected_formats(2:end); end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockMapsWriter.m b/matlab/generated/+test_model/+testing/MockMapsWriter.m index a83d4f03..a1e34ef1 100644 --- a/matlab/generated/+test_model/+testing/MockMapsWriter.m +++ b/matlab/generated/+test_model/+testing/MockMapsWriter.m @@ -10,66 +10,66 @@ end methods - function obj = MockMapsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_string_to_int = yardl.None; - obj.expected_int_to_string = yardl.None; - obj.expected_string_to_union = yardl.None; - obj.expected_aliased_generic = yardl.None; + function self = MockMapsWriter(testCase) + self.testCase_ = testCase; + self.expected_string_to_int = yardl.None; + self.expected_int_to_string = yardl.None; + self.expected_string_to_union = yardl.None; + self.expected_aliased_generic = yardl.None; end - function expect_write_string_to_int_(obj, value) - obj.expected_string_to_int = yardl.Optional(value); + function expect_write_string_to_int_(self, value) + self.expected_string_to_int = yardl.Optional(value); end - function expect_write_int_to_string_(obj, value) - obj.expected_int_to_string = yardl.Optional(value); + function expect_write_int_to_string_(self, value) + self.expected_int_to_string = yardl.Optional(value); end - function expect_write_string_to_union_(obj, value) - obj.expected_string_to_union = yardl.Optional(value); + function expect_write_string_to_union_(self, value) + self.expected_string_to_union = yardl.Optional(value); end - function expect_write_aliased_generic_(obj, value) - obj.expected_aliased_generic = yardl.Optional(value); + function expect_write_aliased_generic_(self, value) + self.expected_aliased_generic = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_string_to_int, yardl.None, "Expected call to write_string_to_int_ was not received"); - obj.testCase_.verifyEqual(obj.expected_int_to_string, yardl.None, "Expected call to write_int_to_string_ was not received"); - obj.testCase_.verifyEqual(obj.expected_string_to_union, yardl.None, "Expected call to write_string_to_union_ was not received"); - obj.testCase_.verifyEqual(obj.expected_aliased_generic, yardl.None, "Expected call to write_aliased_generic_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_string_to_int, yardl.None, "Expected call to write_string_to_int_ was not received"); + self.testCase_.verifyEqual(self.expected_int_to_string, yardl.None, "Expected call to write_int_to_string_ was not received"); + self.testCase_.verifyEqual(self.expected_string_to_union, yardl.None, "Expected call to write_string_to_union_ was not received"); + self.testCase_.verifyEqual(self.expected_aliased_generic, yardl.None, "Expected call to write_aliased_generic_ was not received"); end end methods (Access=protected) - function write_string_to_int_(obj, value) - obj.testCase_.verifyTrue(obj.expected_string_to_int.has_value(), "Unexpected call to write_string_to_int_"); - obj.testCase_.verifyEqual(value, obj.expected_string_to_int.value, "Unexpected argument value for call to write_string_to_int_"); - obj.expected_string_to_int = yardl.None; + function write_string_to_int_(self, value) + self.testCase_.verifyTrue(self.expected_string_to_int.has_value(), "Unexpected call to write_string_to_int_"); + self.testCase_.verifyEqual(value, self.expected_string_to_int.value, "Unexpected argument value for call to write_string_to_int_"); + self.expected_string_to_int = yardl.None; end - function write_int_to_string_(obj, value) - obj.testCase_.verifyTrue(obj.expected_int_to_string.has_value(), "Unexpected call to write_int_to_string_"); - obj.testCase_.verifyEqual(value, obj.expected_int_to_string.value, "Unexpected argument value for call to write_int_to_string_"); - obj.expected_int_to_string = yardl.None; + function write_int_to_string_(self, value) + self.testCase_.verifyTrue(self.expected_int_to_string.has_value(), "Unexpected call to write_int_to_string_"); + self.testCase_.verifyEqual(value, self.expected_int_to_string.value, "Unexpected argument value for call to write_int_to_string_"); + self.expected_int_to_string = yardl.None; end - function write_string_to_union_(obj, value) - obj.testCase_.verifyTrue(obj.expected_string_to_union.has_value(), "Unexpected call to write_string_to_union_"); - obj.testCase_.verifyEqual(value, obj.expected_string_to_union.value, "Unexpected argument value for call to write_string_to_union_"); - obj.expected_string_to_union = yardl.None; + function write_string_to_union_(self, value) + self.testCase_.verifyTrue(self.expected_string_to_union.has_value(), "Unexpected call to write_string_to_union_"); + self.testCase_.verifyEqual(value, self.expected_string_to_union.value, "Unexpected argument value for call to write_string_to_union_"); + self.expected_string_to_union = yardl.None; end - function write_aliased_generic_(obj, value) - obj.testCase_.verifyTrue(obj.expected_aliased_generic.has_value(), "Unexpected call to write_aliased_generic_"); - obj.testCase_.verifyEqual(value, obj.expected_aliased_generic.value, "Unexpected argument value for call to write_aliased_generic_"); - obj.expected_aliased_generic = yardl.None; + function write_aliased_generic_(self, value) + self.testCase_.verifyTrue(self.expected_aliased_generic.has_value(), "Unexpected call to write_aliased_generic_"); + self.testCase_.verifyEqual(value, self.expected_aliased_generic.value, "Unexpected argument value for call to write_aliased_generic_"); + self.expected_aliased_generic = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m b/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m index 5adcbaa7..0674eedc 100644 --- a/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m +++ b/matlab/generated/+test_model/+testing/MockNDArraysSingleDimensionWriter.m @@ -10,66 +10,66 @@ end methods - function obj = MockNDArraysSingleDimensionWriter(testCase) - obj.testCase_ = testCase; - obj.expected_ints = yardl.None; - obj.expected_simple_record_array = yardl.None; - obj.expected_record_with_vlens_array = yardl.None; - obj.expected_record_with_nd_arrays = yardl.None; + function self = MockNDArraysSingleDimensionWriter(testCase) + self.testCase_ = testCase; + self.expected_ints = yardl.None; + self.expected_simple_record_array = yardl.None; + self.expected_record_with_vlens_array = yardl.None; + self.expected_record_with_nd_arrays = yardl.None; end - function expect_write_ints_(obj, value) - obj.expected_ints = yardl.Optional(value); + function expect_write_ints_(self, value) + self.expected_ints = yardl.Optional(value); end - function expect_write_simple_record_array_(obj, value) - obj.expected_simple_record_array = yardl.Optional(value); + function expect_write_simple_record_array_(self, value) + self.expected_simple_record_array = yardl.Optional(value); end - function expect_write_record_with_vlens_array_(obj, value) - obj.expected_record_with_vlens_array = yardl.Optional(value); + function expect_write_record_with_vlens_array_(self, value) + self.expected_record_with_vlens_array = yardl.Optional(value); end - function expect_write_record_with_nd_arrays_(obj, value) - obj.expected_record_with_nd_arrays = yardl.Optional(value); + function expect_write_record_with_nd_arrays_(self, value) + self.expected_record_with_nd_arrays = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_ints, yardl.None, "Expected call to write_ints_ was not received"); - obj.testCase_.verifyEqual(obj.expected_simple_record_array, yardl.None, "Expected call to write_simple_record_array_ was not received"); - obj.testCase_.verifyEqual(obj.expected_record_with_vlens_array, yardl.None, "Expected call to write_record_with_vlens_array_ was not received"); - obj.testCase_.verifyEqual(obj.expected_record_with_nd_arrays, yardl.None, "Expected call to write_record_with_nd_arrays_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_ints, yardl.None, "Expected call to write_ints_ was not received"); + self.testCase_.verifyEqual(self.expected_simple_record_array, yardl.None, "Expected call to write_simple_record_array_ was not received"); + self.testCase_.verifyEqual(self.expected_record_with_vlens_array, yardl.None, "Expected call to write_record_with_vlens_array_ was not received"); + self.testCase_.verifyEqual(self.expected_record_with_nd_arrays, yardl.None, "Expected call to write_record_with_nd_arrays_ was not received"); end end methods (Access=protected) - function write_ints_(obj, value) - obj.testCase_.verifyTrue(obj.expected_ints.has_value(), "Unexpected call to write_ints_"); - obj.testCase_.verifyEqual(value, obj.expected_ints.value, "Unexpected argument value for call to write_ints_"); - obj.expected_ints = yardl.None; + function write_ints_(self, value) + self.testCase_.verifyTrue(self.expected_ints.has_value(), "Unexpected call to write_ints_"); + self.testCase_.verifyEqual(value, self.expected_ints.value, "Unexpected argument value for call to write_ints_"); + self.expected_ints = yardl.None; end - function write_simple_record_array_(obj, value) - obj.testCase_.verifyTrue(obj.expected_simple_record_array.has_value(), "Unexpected call to write_simple_record_array_"); - obj.testCase_.verifyEqual(value, obj.expected_simple_record_array.value, "Unexpected argument value for call to write_simple_record_array_"); - obj.expected_simple_record_array = yardl.None; + function write_simple_record_array_(self, value) + self.testCase_.verifyTrue(self.expected_simple_record_array.has_value(), "Unexpected call to write_simple_record_array_"); + self.testCase_.verifyEqual(value, self.expected_simple_record_array.value, "Unexpected argument value for call to write_simple_record_array_"); + self.expected_simple_record_array = yardl.None; end - function write_record_with_vlens_array_(obj, value) - obj.testCase_.verifyTrue(obj.expected_record_with_vlens_array.has_value(), "Unexpected call to write_record_with_vlens_array_"); - obj.testCase_.verifyEqual(value, obj.expected_record_with_vlens_array.value, "Unexpected argument value for call to write_record_with_vlens_array_"); - obj.expected_record_with_vlens_array = yardl.None; + function write_record_with_vlens_array_(self, value) + self.testCase_.verifyTrue(self.expected_record_with_vlens_array.has_value(), "Unexpected call to write_record_with_vlens_array_"); + self.testCase_.verifyEqual(value, self.expected_record_with_vlens_array.value, "Unexpected argument value for call to write_record_with_vlens_array_"); + self.expected_record_with_vlens_array = yardl.None; end - function write_record_with_nd_arrays_(obj, value) - obj.testCase_.verifyTrue(obj.expected_record_with_nd_arrays.has_value(), "Unexpected call to write_record_with_nd_arrays_"); - obj.testCase_.verifyEqual(value, obj.expected_record_with_nd_arrays.value, "Unexpected argument value for call to write_record_with_nd_arrays_"); - obj.expected_record_with_nd_arrays = yardl.None; + function write_record_with_nd_arrays_(self, value) + self.testCase_.verifyTrue(self.expected_record_with_nd_arrays.has_value(), "Unexpected call to write_record_with_nd_arrays_"); + self.testCase_.verifyEqual(value, self.expected_record_with_nd_arrays.value, "Unexpected argument value for call to write_record_with_nd_arrays_"); + self.expected_record_with_nd_arrays = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockNDArraysWriter.m b/matlab/generated/+test_model/+testing/MockNDArraysWriter.m index adb9d551..595176c8 100644 --- a/matlab/generated/+test_model/+testing/MockNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockNDArraysWriter.m @@ -11,78 +11,78 @@ end methods - function obj = MockNDArraysWriter(testCase) - obj.testCase_ = testCase; - obj.expected_ints = yardl.None; - obj.expected_simple_record_array = yardl.None; - obj.expected_record_with_vlens_array = yardl.None; - obj.expected_record_with_nd_arrays = yardl.None; - obj.expected_named_array = yardl.None; + function self = MockNDArraysWriter(testCase) + self.testCase_ = testCase; + self.expected_ints = yardl.None; + self.expected_simple_record_array = yardl.None; + self.expected_record_with_vlens_array = yardl.None; + self.expected_record_with_nd_arrays = yardl.None; + self.expected_named_array = yardl.None; end - function expect_write_ints_(obj, value) - obj.expected_ints = yardl.Optional(value); + function expect_write_ints_(self, value) + self.expected_ints = yardl.Optional(value); end - function expect_write_simple_record_array_(obj, value) - obj.expected_simple_record_array = yardl.Optional(value); + function expect_write_simple_record_array_(self, value) + self.expected_simple_record_array = yardl.Optional(value); end - function expect_write_record_with_vlens_array_(obj, value) - obj.expected_record_with_vlens_array = yardl.Optional(value); + function expect_write_record_with_vlens_array_(self, value) + self.expected_record_with_vlens_array = yardl.Optional(value); end - function expect_write_record_with_nd_arrays_(obj, value) - obj.expected_record_with_nd_arrays = yardl.Optional(value); + function expect_write_record_with_nd_arrays_(self, value) + self.expected_record_with_nd_arrays = yardl.Optional(value); end - function expect_write_named_array_(obj, value) - obj.expected_named_array = yardl.Optional(value); + function expect_write_named_array_(self, value) + self.expected_named_array = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_ints, yardl.None, "Expected call to write_ints_ was not received"); - obj.testCase_.verifyEqual(obj.expected_simple_record_array, yardl.None, "Expected call to write_simple_record_array_ was not received"); - obj.testCase_.verifyEqual(obj.expected_record_with_vlens_array, yardl.None, "Expected call to write_record_with_vlens_array_ was not received"); - obj.testCase_.verifyEqual(obj.expected_record_with_nd_arrays, yardl.None, "Expected call to write_record_with_nd_arrays_ was not received"); - obj.testCase_.verifyEqual(obj.expected_named_array, yardl.None, "Expected call to write_named_array_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_ints, yardl.None, "Expected call to write_ints_ was not received"); + self.testCase_.verifyEqual(self.expected_simple_record_array, yardl.None, "Expected call to write_simple_record_array_ was not received"); + self.testCase_.verifyEqual(self.expected_record_with_vlens_array, yardl.None, "Expected call to write_record_with_vlens_array_ was not received"); + self.testCase_.verifyEqual(self.expected_record_with_nd_arrays, yardl.None, "Expected call to write_record_with_nd_arrays_ was not received"); + self.testCase_.verifyEqual(self.expected_named_array, yardl.None, "Expected call to write_named_array_ was not received"); end end methods (Access=protected) - function write_ints_(obj, value) - obj.testCase_.verifyTrue(obj.expected_ints.has_value(), "Unexpected call to write_ints_"); - obj.testCase_.verifyEqual(value, obj.expected_ints.value, "Unexpected argument value for call to write_ints_"); - obj.expected_ints = yardl.None; + function write_ints_(self, value) + self.testCase_.verifyTrue(self.expected_ints.has_value(), "Unexpected call to write_ints_"); + self.testCase_.verifyEqual(value, self.expected_ints.value, "Unexpected argument value for call to write_ints_"); + self.expected_ints = yardl.None; end - function write_simple_record_array_(obj, value) - obj.testCase_.verifyTrue(obj.expected_simple_record_array.has_value(), "Unexpected call to write_simple_record_array_"); - obj.testCase_.verifyEqual(value, obj.expected_simple_record_array.value, "Unexpected argument value for call to write_simple_record_array_"); - obj.expected_simple_record_array = yardl.None; + function write_simple_record_array_(self, value) + self.testCase_.verifyTrue(self.expected_simple_record_array.has_value(), "Unexpected call to write_simple_record_array_"); + self.testCase_.verifyEqual(value, self.expected_simple_record_array.value, "Unexpected argument value for call to write_simple_record_array_"); + self.expected_simple_record_array = yardl.None; end - function write_record_with_vlens_array_(obj, value) - obj.testCase_.verifyTrue(obj.expected_record_with_vlens_array.has_value(), "Unexpected call to write_record_with_vlens_array_"); - obj.testCase_.verifyEqual(value, obj.expected_record_with_vlens_array.value, "Unexpected argument value for call to write_record_with_vlens_array_"); - obj.expected_record_with_vlens_array = yardl.None; + function write_record_with_vlens_array_(self, value) + self.testCase_.verifyTrue(self.expected_record_with_vlens_array.has_value(), "Unexpected call to write_record_with_vlens_array_"); + self.testCase_.verifyEqual(value, self.expected_record_with_vlens_array.value, "Unexpected argument value for call to write_record_with_vlens_array_"); + self.expected_record_with_vlens_array = yardl.None; end - function write_record_with_nd_arrays_(obj, value) - obj.testCase_.verifyTrue(obj.expected_record_with_nd_arrays.has_value(), "Unexpected call to write_record_with_nd_arrays_"); - obj.testCase_.verifyEqual(value, obj.expected_record_with_nd_arrays.value, "Unexpected argument value for call to write_record_with_nd_arrays_"); - obj.expected_record_with_nd_arrays = yardl.None; + function write_record_with_nd_arrays_(self, value) + self.testCase_.verifyTrue(self.expected_record_with_nd_arrays.has_value(), "Unexpected call to write_record_with_nd_arrays_"); + self.testCase_.verifyEqual(value, self.expected_record_with_nd_arrays.value, "Unexpected argument value for call to write_record_with_nd_arrays_"); + self.expected_record_with_nd_arrays = yardl.None; end - function write_named_array_(obj, value) - obj.testCase_.verifyTrue(obj.expected_named_array.has_value(), "Unexpected call to write_named_array_"); - obj.testCase_.verifyEqual(value, obj.expected_named_array.value, "Unexpected argument value for call to write_named_array_"); - obj.expected_named_array = yardl.None; + function write_named_array_(self, value) + self.testCase_.verifyTrue(self.expected_named_array.has_value(), "Unexpected call to write_named_array_"); + self.testCase_.verifyEqual(value, self.expected_named_array.value, "Unexpected argument value for call to write_named_array_"); + self.expected_named_array = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m b/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m index 92cad2c2..591d0b68 100644 --- a/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/MockNestedRecordsWriter.m @@ -7,30 +7,30 @@ end methods - function obj = MockNestedRecordsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_tuple_with_records = yardl.None; + function self = MockNestedRecordsWriter(testCase) + self.testCase_ = testCase; + self.expected_tuple_with_records = yardl.None; end - function expect_write_tuple_with_records_(obj, value) - obj.expected_tuple_with_records = yardl.Optional(value); + function expect_write_tuple_with_records_(self, value) + self.expected_tuple_with_records = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_tuple_with_records, yardl.None, "Expected call to write_tuple_with_records_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_tuple_with_records, yardl.None, "Expected call to write_tuple_with_records_ was not received"); end end methods (Access=protected) - function write_tuple_with_records_(obj, value) - obj.testCase_.verifyTrue(obj.expected_tuple_with_records.has_value(), "Unexpected call to write_tuple_with_records_"); - obj.testCase_.verifyEqual(value, obj.expected_tuple_with_records.value, "Unexpected argument value for call to write_tuple_with_records_"); - obj.expected_tuple_with_records = yardl.None; + function write_tuple_with_records_(self, value) + self.testCase_.verifyTrue(self.expected_tuple_with_records.has_value(), "Unexpected call to write_tuple_with_records_"); + self.testCase_.verifyEqual(value, self.expected_tuple_with_records.value, "Unexpected argument value for call to write_tuple_with_records_"); + self.expected_tuple_with_records = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m b/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m index 84c42647..d1370323 100644 --- a/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/MockOptionalVectorsWriter.m @@ -7,30 +7,30 @@ end methods - function obj = MockOptionalVectorsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_record_with_optional_vector = yardl.None; + function self = MockOptionalVectorsWriter(testCase) + self.testCase_ = testCase; + self.expected_record_with_optional_vector = yardl.None; end - function expect_write_record_with_optional_vector_(obj, value) - obj.expected_record_with_optional_vector = yardl.Optional(value); + function expect_write_record_with_optional_vector_(self, value) + self.expected_record_with_optional_vector = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_record_with_optional_vector, yardl.None, "Expected call to write_record_with_optional_vector_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_record_with_optional_vector, yardl.None, "Expected call to write_record_with_optional_vector_ was not received"); end end methods (Access=protected) - function write_record_with_optional_vector_(obj, value) - obj.testCase_.verifyTrue(obj.expected_record_with_optional_vector.has_value(), "Unexpected call to write_record_with_optional_vector_"); - obj.testCase_.verifyEqual(value, obj.expected_record_with_optional_vector.value, "Unexpected argument value for call to write_record_with_optional_vector_"); - obj.expected_record_with_optional_vector = yardl.None; + function write_record_with_optional_vector_(self, value) + self.testCase_.verifyTrue(self.expected_record_with_optional_vector.has_value(), "Unexpected call to write_record_with_optional_vector_"); + self.testCase_.verifyEqual(value, self.expected_record_with_optional_vector.value, "Unexpected argument value for call to write_record_with_optional_vector_"); + self.expected_record_with_optional_vector = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m b/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m index 18f057a7..c6487c10 100644 --- a/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m +++ b/matlab/generated/+test_model/+testing/MockProtocolWithComputedFieldsWriter.m @@ -7,30 +7,30 @@ end methods - function obj = MockProtocolWithComputedFieldsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_record_with_computed_fields = yardl.None; + function self = MockProtocolWithComputedFieldsWriter(testCase) + self.testCase_ = testCase; + self.expected_record_with_computed_fields = yardl.None; end - function expect_write_record_with_computed_fields_(obj, value) - obj.expected_record_with_computed_fields = yardl.Optional(value); + function expect_write_record_with_computed_fields_(self, value) + self.expected_record_with_computed_fields = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_record_with_computed_fields, yardl.None, "Expected call to write_record_with_computed_fields_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_record_with_computed_fields, yardl.None, "Expected call to write_record_with_computed_fields_ was not received"); end end methods (Access=protected) - function write_record_with_computed_fields_(obj, value) - obj.testCase_.verifyTrue(obj.expected_record_with_computed_fields.has_value(), "Unexpected call to write_record_with_computed_fields_"); - obj.testCase_.verifyEqual(value, obj.expected_record_with_computed_fields.value, "Unexpected argument value for call to write_record_with_computed_fields_"); - obj.expected_record_with_computed_fields = yardl.None; + function write_record_with_computed_fields_(self, value) + self.testCase_.verifyTrue(self.expected_record_with_computed_fields.has_value(), "Unexpected call to write_record_with_computed_fields_"); + self.testCase_.verifyEqual(value, self.expected_record_with_computed_fields.value, "Unexpected argument value for call to write_record_with_computed_fields_"); + self.expected_record_with_computed_fields = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m index cf0506f4..8b727e67 100644 --- a/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m +++ b/matlab/generated/+test_model/+testing/MockProtocolWithKeywordStepsWriter.m @@ -8,16 +8,16 @@ end methods - function obj = MockProtocolWithKeywordStepsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_int = {}; - obj.expected_float = yardl.None; + function self = MockProtocolWithKeywordStepsWriter(testCase) + self.testCase_ = testCase; + self.expected_int = {}; + self.expected_float = yardl.None; end - function expect_write_int_(obj, value) + function expect_write_int_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_int{end+1} = value{n}; + self.expected_int{end+1} = value{n}; end return; end @@ -26,38 +26,38 @@ function expect_write_int_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_int{end+1} = value(index{:}, n); + self.expected_int{end+1} = value(index{:}, n); end end - function expect_write_float_(obj, value) - obj.expected_float = yardl.Optional(value); + function expect_write_float_(self, value) + self.expected_float = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.expected_int), "Expected call to write_int_ was not received"); - obj.testCase_.verifyEqual(obj.expected_float, yardl.None, "Expected call to write_float_ was not received"); + function verify(self) + self.testCase_.verifyTrue(isempty(self.expected_int), "Expected call to write_int_ was not received"); + self.testCase_.verifyEqual(self.expected_float, yardl.None, "Expected call to write_float_ was not received"); end end methods (Access=protected) - function write_int_(obj, value) + function write_int_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_int), "Unexpected call to write_int_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_int{1}, "Unexpected argument value for call to write_int_"); - obj.expected_int = obj.expected_int(2:end); + self.testCase_.verifyFalse(isempty(self.expected_int), "Unexpected call to write_int_"); + self.testCase_.verifyEqual(value{1}, self.expected_int{1}, "Unexpected argument value for call to write_int_"); + self.expected_int = self.expected_int(2:end); end - function write_float_(obj, value) - obj.testCase_.verifyTrue(obj.expected_float.has_value(), "Unexpected call to write_float_"); - obj.testCase_.verifyEqual(value, obj.expected_float.value, "Unexpected argument value for call to write_float_"); - obj.expected_float = yardl.None; + function write_float_(self, value) + self.testCase_.verifyTrue(self.expected_float.has_value(), "Unexpected call to write_float_"); + self.testCase_.verifyEqual(value, self.expected_float.value, "Unexpected argument value for call to write_float_"); + self.expected_float = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m b/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m index 67f04a63..df85b932 100644 --- a/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/MockScalarOptionalsWriter.m @@ -10,66 +10,66 @@ end methods - function obj = MockScalarOptionalsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_optional_int = yardl.None; - obj.expected_optional_record = yardl.None; - obj.expected_record_with_optional_fields = yardl.None; - obj.expected_optional_record_with_optional_fields = yardl.None; + function self = MockScalarOptionalsWriter(testCase) + self.testCase_ = testCase; + self.expected_optional_int = yardl.None; + self.expected_optional_record = yardl.None; + self.expected_record_with_optional_fields = yardl.None; + self.expected_optional_record_with_optional_fields = yardl.None; end - function expect_write_optional_int_(obj, value) - obj.expected_optional_int = yardl.Optional(value); + function expect_write_optional_int_(self, value) + self.expected_optional_int = yardl.Optional(value); end - function expect_write_optional_record_(obj, value) - obj.expected_optional_record = yardl.Optional(value); + function expect_write_optional_record_(self, value) + self.expected_optional_record = yardl.Optional(value); end - function expect_write_record_with_optional_fields_(obj, value) - obj.expected_record_with_optional_fields = yardl.Optional(value); + function expect_write_record_with_optional_fields_(self, value) + self.expected_record_with_optional_fields = yardl.Optional(value); end - function expect_write_optional_record_with_optional_fields_(obj, value) - obj.expected_optional_record_with_optional_fields = yardl.Optional(value); + function expect_write_optional_record_with_optional_fields_(self, value) + self.expected_optional_record_with_optional_fields = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_optional_int, yardl.None, "Expected call to write_optional_int_ was not received"); - obj.testCase_.verifyEqual(obj.expected_optional_record, yardl.None, "Expected call to write_optional_record_ was not received"); - obj.testCase_.verifyEqual(obj.expected_record_with_optional_fields, yardl.None, "Expected call to write_record_with_optional_fields_ was not received"); - obj.testCase_.verifyEqual(obj.expected_optional_record_with_optional_fields, yardl.None, "Expected call to write_optional_record_with_optional_fields_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_optional_int, yardl.None, "Expected call to write_optional_int_ was not received"); + self.testCase_.verifyEqual(self.expected_optional_record, yardl.None, "Expected call to write_optional_record_ was not received"); + self.testCase_.verifyEqual(self.expected_record_with_optional_fields, yardl.None, "Expected call to write_record_with_optional_fields_ was not received"); + self.testCase_.verifyEqual(self.expected_optional_record_with_optional_fields, yardl.None, "Expected call to write_optional_record_with_optional_fields_ was not received"); end end methods (Access=protected) - function write_optional_int_(obj, value) - obj.testCase_.verifyTrue(obj.expected_optional_int.has_value(), "Unexpected call to write_optional_int_"); - obj.testCase_.verifyEqual(value, obj.expected_optional_int.value, "Unexpected argument value for call to write_optional_int_"); - obj.expected_optional_int = yardl.None; + function write_optional_int_(self, value) + self.testCase_.verifyTrue(self.expected_optional_int.has_value(), "Unexpected call to write_optional_int_"); + self.testCase_.verifyEqual(value, self.expected_optional_int.value, "Unexpected argument value for call to write_optional_int_"); + self.expected_optional_int = yardl.None; end - function write_optional_record_(obj, value) - obj.testCase_.verifyTrue(obj.expected_optional_record.has_value(), "Unexpected call to write_optional_record_"); - obj.testCase_.verifyEqual(value, obj.expected_optional_record.value, "Unexpected argument value for call to write_optional_record_"); - obj.expected_optional_record = yardl.None; + function write_optional_record_(self, value) + self.testCase_.verifyTrue(self.expected_optional_record.has_value(), "Unexpected call to write_optional_record_"); + self.testCase_.verifyEqual(value, self.expected_optional_record.value, "Unexpected argument value for call to write_optional_record_"); + self.expected_optional_record = yardl.None; end - function write_record_with_optional_fields_(obj, value) - obj.testCase_.verifyTrue(obj.expected_record_with_optional_fields.has_value(), "Unexpected call to write_record_with_optional_fields_"); - obj.testCase_.verifyEqual(value, obj.expected_record_with_optional_fields.value, "Unexpected argument value for call to write_record_with_optional_fields_"); - obj.expected_record_with_optional_fields = yardl.None; + function write_record_with_optional_fields_(self, value) + self.testCase_.verifyTrue(self.expected_record_with_optional_fields.has_value(), "Unexpected call to write_record_with_optional_fields_"); + self.testCase_.verifyEqual(value, self.expected_record_with_optional_fields.value, "Unexpected argument value for call to write_record_with_optional_fields_"); + self.expected_record_with_optional_fields = yardl.None; end - function write_optional_record_with_optional_fields_(obj, value) - obj.testCase_.verifyTrue(obj.expected_optional_record_with_optional_fields.has_value(), "Unexpected call to write_optional_record_with_optional_fields_"); - obj.testCase_.verifyEqual(value, obj.expected_optional_record_with_optional_fields.value, "Unexpected argument value for call to write_optional_record_with_optional_fields_"); - obj.expected_optional_record_with_optional_fields = yardl.None; + function write_optional_record_with_optional_fields_(self, value) + self.testCase_.verifyTrue(self.expected_optional_record_with_optional_fields.has_value(), "Unexpected call to write_optional_record_with_optional_fields_"); + self.testCase_.verifyEqual(value, self.expected_optional_record_with_optional_fields.value, "Unexpected argument value for call to write_optional_record_with_optional_fields_"); + self.expected_optional_record_with_optional_fields = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockScalarsWriter.m b/matlab/generated/+test_model/+testing/MockScalarsWriter.m index 11db90e8..54c56b7f 100644 --- a/matlab/generated/+test_model/+testing/MockScalarsWriter.m +++ b/matlab/generated/+test_model/+testing/MockScalarsWriter.m @@ -8,42 +8,42 @@ end methods - function obj = MockScalarsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_int32 = yardl.None; - obj.expected_record = yardl.None; + function self = MockScalarsWriter(testCase) + self.testCase_ = testCase; + self.expected_int32 = yardl.None; + self.expected_record = yardl.None; end - function expect_write_int32_(obj, value) - obj.expected_int32 = yardl.Optional(value); + function expect_write_int32_(self, value) + self.expected_int32 = yardl.Optional(value); end - function expect_write_record_(obj, value) - obj.expected_record = yardl.Optional(value); + function expect_write_record_(self, value) + self.expected_record = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_int32, yardl.None, "Expected call to write_int32_ was not received"); - obj.testCase_.verifyEqual(obj.expected_record, yardl.None, "Expected call to write_record_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_int32, yardl.None, "Expected call to write_int32_ was not received"); + self.testCase_.verifyEqual(self.expected_record, yardl.None, "Expected call to write_record_ was not received"); end end methods (Access=protected) - function write_int32_(obj, value) - obj.testCase_.verifyTrue(obj.expected_int32.has_value(), "Unexpected call to write_int32_"); - obj.testCase_.verifyEqual(value, obj.expected_int32.value, "Unexpected argument value for call to write_int32_"); - obj.expected_int32 = yardl.None; + function write_int32_(self, value) + self.testCase_.verifyTrue(self.expected_int32.has_value(), "Unexpected call to write_int32_"); + self.testCase_.verifyEqual(value, self.expected_int32.value, "Unexpected argument value for call to write_int32_"); + self.expected_int32 = yardl.None; end - function write_record_(obj, value) - obj.testCase_.verifyTrue(obj.expected_record.has_value(), "Unexpected call to write_record_"); - obj.testCase_.verifyEqual(value, obj.expected_record.value, "Unexpected argument value for call to write_record_"); - obj.expected_record = yardl.None; + function write_record_(self, value) + self.testCase_.verifyTrue(self.expected_record.has_value(), "Unexpected call to write_record_"); + self.testCase_.verifyEqual(value, self.expected_record.value, "Unexpected argument value for call to write_record_"); + self.expected_record = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m b/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m index 21a86414..4e131bfc 100644 --- a/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/MockSimpleGenericsWriter.m @@ -15,55 +15,55 @@ end methods - function obj = MockSimpleGenericsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_float_image = yardl.None; - obj.expected_int_image = yardl.None; - obj.expected_int_image_alternate_syntax = yardl.None; - obj.expected_string_image = yardl.None; - obj.expected_int_float_tuple = yardl.None; - obj.expected_float_float_tuple = yardl.None; - obj.expected_int_float_tuple_alternate_syntax = yardl.None; - obj.expected_int_string_tuple = yardl.None; - obj.expected_stream_of_type_variants = {}; + function self = MockSimpleGenericsWriter(testCase) + self.testCase_ = testCase; + self.expected_float_image = yardl.None; + self.expected_int_image = yardl.None; + self.expected_int_image_alternate_syntax = yardl.None; + self.expected_string_image = yardl.None; + self.expected_int_float_tuple = yardl.None; + self.expected_float_float_tuple = yardl.None; + self.expected_int_float_tuple_alternate_syntax = yardl.None; + self.expected_int_string_tuple = yardl.None; + self.expected_stream_of_type_variants = {}; end - function expect_write_float_image_(obj, value) - obj.expected_float_image = yardl.Optional(value); + function expect_write_float_image_(self, value) + self.expected_float_image = yardl.Optional(value); end - function expect_write_int_image_(obj, value) - obj.expected_int_image = yardl.Optional(value); + function expect_write_int_image_(self, value) + self.expected_int_image = yardl.Optional(value); end - function expect_write_int_image_alternate_syntax_(obj, value) - obj.expected_int_image_alternate_syntax = yardl.Optional(value); + function expect_write_int_image_alternate_syntax_(self, value) + self.expected_int_image_alternate_syntax = yardl.Optional(value); end - function expect_write_string_image_(obj, value) - obj.expected_string_image = yardl.Optional(value); + function expect_write_string_image_(self, value) + self.expected_string_image = yardl.Optional(value); end - function expect_write_int_float_tuple_(obj, value) - obj.expected_int_float_tuple = yardl.Optional(value); + function expect_write_int_float_tuple_(self, value) + self.expected_int_float_tuple = yardl.Optional(value); end - function expect_write_float_float_tuple_(obj, value) - obj.expected_float_float_tuple = yardl.Optional(value); + function expect_write_float_float_tuple_(self, value) + self.expected_float_float_tuple = yardl.Optional(value); end - function expect_write_int_float_tuple_alternate_syntax_(obj, value) - obj.expected_int_float_tuple_alternate_syntax = yardl.Optional(value); + function expect_write_int_float_tuple_alternate_syntax_(self, value) + self.expected_int_float_tuple_alternate_syntax = yardl.Optional(value); end - function expect_write_int_string_tuple_(obj, value) - obj.expected_int_string_tuple = yardl.Optional(value); + function expect_write_int_string_tuple_(self, value) + self.expected_int_string_tuple = yardl.Optional(value); end - function expect_write_stream_of_type_variants_(obj, value) + function expect_write_stream_of_type_variants_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_stream_of_type_variants{end+1} = value{n}; + self.expected_stream_of_type_variants{end+1} = value{n}; end return; end @@ -72,83 +72,83 @@ function expect_write_stream_of_type_variants_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_stream_of_type_variants{end+1} = value(index{:}, n); + self.expected_stream_of_type_variants{end+1} = value(index{:}, n); end end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_float_image, yardl.None, "Expected call to write_float_image_ was not received"); - obj.testCase_.verifyEqual(obj.expected_int_image, yardl.None, "Expected call to write_int_image_ was not received"); - obj.testCase_.verifyEqual(obj.expected_int_image_alternate_syntax, yardl.None, "Expected call to write_int_image_alternate_syntax_ was not received"); - obj.testCase_.verifyEqual(obj.expected_string_image, yardl.None, "Expected call to write_string_image_ was not received"); - obj.testCase_.verifyEqual(obj.expected_int_float_tuple, yardl.None, "Expected call to write_int_float_tuple_ was not received"); - obj.testCase_.verifyEqual(obj.expected_float_float_tuple, yardl.None, "Expected call to write_float_float_tuple_ was not received"); - obj.testCase_.verifyEqual(obj.expected_int_float_tuple_alternate_syntax, yardl.None, "Expected call to write_int_float_tuple_alternate_syntax_ was not received"); - obj.testCase_.verifyEqual(obj.expected_int_string_tuple, yardl.None, "Expected call to write_int_string_tuple_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.expected_stream_of_type_variants), "Expected call to write_stream_of_type_variants_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_float_image, yardl.None, "Expected call to write_float_image_ was not received"); + self.testCase_.verifyEqual(self.expected_int_image, yardl.None, "Expected call to write_int_image_ was not received"); + self.testCase_.verifyEqual(self.expected_int_image_alternate_syntax, yardl.None, "Expected call to write_int_image_alternate_syntax_ was not received"); + self.testCase_.verifyEqual(self.expected_string_image, yardl.None, "Expected call to write_string_image_ was not received"); + self.testCase_.verifyEqual(self.expected_int_float_tuple, yardl.None, "Expected call to write_int_float_tuple_ was not received"); + self.testCase_.verifyEqual(self.expected_float_float_tuple, yardl.None, "Expected call to write_float_float_tuple_ was not received"); + self.testCase_.verifyEqual(self.expected_int_float_tuple_alternate_syntax, yardl.None, "Expected call to write_int_float_tuple_alternate_syntax_ was not received"); + self.testCase_.verifyEqual(self.expected_int_string_tuple, yardl.None, "Expected call to write_int_string_tuple_ was not received"); + self.testCase_.verifyTrue(isempty(self.expected_stream_of_type_variants), "Expected call to write_stream_of_type_variants_ was not received"); end end methods (Access=protected) - function write_float_image_(obj, value) - obj.testCase_.verifyTrue(obj.expected_float_image.has_value(), "Unexpected call to write_float_image_"); - obj.testCase_.verifyEqual(value, obj.expected_float_image.value, "Unexpected argument value for call to write_float_image_"); - obj.expected_float_image = yardl.None; + function write_float_image_(self, value) + self.testCase_.verifyTrue(self.expected_float_image.has_value(), "Unexpected call to write_float_image_"); + self.testCase_.verifyEqual(value, self.expected_float_image.value, "Unexpected argument value for call to write_float_image_"); + self.expected_float_image = yardl.None; end - function write_int_image_(obj, value) - obj.testCase_.verifyTrue(obj.expected_int_image.has_value(), "Unexpected call to write_int_image_"); - obj.testCase_.verifyEqual(value, obj.expected_int_image.value, "Unexpected argument value for call to write_int_image_"); - obj.expected_int_image = yardl.None; + function write_int_image_(self, value) + self.testCase_.verifyTrue(self.expected_int_image.has_value(), "Unexpected call to write_int_image_"); + self.testCase_.verifyEqual(value, self.expected_int_image.value, "Unexpected argument value for call to write_int_image_"); + self.expected_int_image = yardl.None; end - function write_int_image_alternate_syntax_(obj, value) - obj.testCase_.verifyTrue(obj.expected_int_image_alternate_syntax.has_value(), "Unexpected call to write_int_image_alternate_syntax_"); - obj.testCase_.verifyEqual(value, obj.expected_int_image_alternate_syntax.value, "Unexpected argument value for call to write_int_image_alternate_syntax_"); - obj.expected_int_image_alternate_syntax = yardl.None; + function write_int_image_alternate_syntax_(self, value) + self.testCase_.verifyTrue(self.expected_int_image_alternate_syntax.has_value(), "Unexpected call to write_int_image_alternate_syntax_"); + self.testCase_.verifyEqual(value, self.expected_int_image_alternate_syntax.value, "Unexpected argument value for call to write_int_image_alternate_syntax_"); + self.expected_int_image_alternate_syntax = yardl.None; end - function write_string_image_(obj, value) - obj.testCase_.verifyTrue(obj.expected_string_image.has_value(), "Unexpected call to write_string_image_"); - obj.testCase_.verifyEqual(value, obj.expected_string_image.value, "Unexpected argument value for call to write_string_image_"); - obj.expected_string_image = yardl.None; + function write_string_image_(self, value) + self.testCase_.verifyTrue(self.expected_string_image.has_value(), "Unexpected call to write_string_image_"); + self.testCase_.verifyEqual(value, self.expected_string_image.value, "Unexpected argument value for call to write_string_image_"); + self.expected_string_image = yardl.None; end - function write_int_float_tuple_(obj, value) - obj.testCase_.verifyTrue(obj.expected_int_float_tuple.has_value(), "Unexpected call to write_int_float_tuple_"); - obj.testCase_.verifyEqual(value, obj.expected_int_float_tuple.value, "Unexpected argument value for call to write_int_float_tuple_"); - obj.expected_int_float_tuple = yardl.None; + function write_int_float_tuple_(self, value) + self.testCase_.verifyTrue(self.expected_int_float_tuple.has_value(), "Unexpected call to write_int_float_tuple_"); + self.testCase_.verifyEqual(value, self.expected_int_float_tuple.value, "Unexpected argument value for call to write_int_float_tuple_"); + self.expected_int_float_tuple = yardl.None; end - function write_float_float_tuple_(obj, value) - obj.testCase_.verifyTrue(obj.expected_float_float_tuple.has_value(), "Unexpected call to write_float_float_tuple_"); - obj.testCase_.verifyEqual(value, obj.expected_float_float_tuple.value, "Unexpected argument value for call to write_float_float_tuple_"); - obj.expected_float_float_tuple = yardl.None; + function write_float_float_tuple_(self, value) + self.testCase_.verifyTrue(self.expected_float_float_tuple.has_value(), "Unexpected call to write_float_float_tuple_"); + self.testCase_.verifyEqual(value, self.expected_float_float_tuple.value, "Unexpected argument value for call to write_float_float_tuple_"); + self.expected_float_float_tuple = yardl.None; end - function write_int_float_tuple_alternate_syntax_(obj, value) - obj.testCase_.verifyTrue(obj.expected_int_float_tuple_alternate_syntax.has_value(), "Unexpected call to write_int_float_tuple_alternate_syntax_"); - obj.testCase_.verifyEqual(value, obj.expected_int_float_tuple_alternate_syntax.value, "Unexpected argument value for call to write_int_float_tuple_alternate_syntax_"); - obj.expected_int_float_tuple_alternate_syntax = yardl.None; + function write_int_float_tuple_alternate_syntax_(self, value) + self.testCase_.verifyTrue(self.expected_int_float_tuple_alternate_syntax.has_value(), "Unexpected call to write_int_float_tuple_alternate_syntax_"); + self.testCase_.verifyEqual(value, self.expected_int_float_tuple_alternate_syntax.value, "Unexpected argument value for call to write_int_float_tuple_alternate_syntax_"); + self.expected_int_float_tuple_alternate_syntax = yardl.None; end - function write_int_string_tuple_(obj, value) - obj.testCase_.verifyTrue(obj.expected_int_string_tuple.has_value(), "Unexpected call to write_int_string_tuple_"); - obj.testCase_.verifyEqual(value, obj.expected_int_string_tuple.value, "Unexpected argument value for call to write_int_string_tuple_"); - obj.expected_int_string_tuple = yardl.None; + function write_int_string_tuple_(self, value) + self.testCase_.verifyTrue(self.expected_int_string_tuple.has_value(), "Unexpected call to write_int_string_tuple_"); + self.testCase_.verifyEqual(value, self.expected_int_string_tuple.value, "Unexpected argument value for call to write_int_string_tuple_"); + self.expected_int_string_tuple = yardl.None; end - function write_stream_of_type_variants_(obj, value) + function write_stream_of_type_variants_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_stream_of_type_variants), "Unexpected call to write_stream_of_type_variants_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_stream_of_type_variants{1}, "Unexpected argument value for call to write_stream_of_type_variants_"); - obj.expected_stream_of_type_variants = obj.expected_stream_of_type_variants(2:end); + self.testCase_.verifyFalse(isempty(self.expected_stream_of_type_variants), "Unexpected call to write_stream_of_type_variants_"); + self.testCase_.verifyEqual(value{1}, self.expected_stream_of_type_variants{1}, "Unexpected argument value for call to write_stream_of_type_variants_"); + self.expected_stream_of_type_variants = self.expected_stream_of_type_variants(2:end); end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockStateTestWriter.m b/matlab/generated/+test_model/+testing/MockStateTestWriter.m index 23977099..dfdf50d0 100644 --- a/matlab/generated/+test_model/+testing/MockStateTestWriter.m +++ b/matlab/generated/+test_model/+testing/MockStateTestWriter.m @@ -9,21 +9,21 @@ end methods - function obj = MockStateTestWriter(testCase) - obj.testCase_ = testCase; - obj.expected_an_int = yardl.None; - obj.expected_a_stream = {}; - obj.expected_another_int = yardl.None; + function self = MockStateTestWriter(testCase) + self.testCase_ = testCase; + self.expected_an_int = yardl.None; + self.expected_a_stream = {}; + self.expected_another_int = yardl.None; end - function expect_write_an_int_(obj, value) - obj.expected_an_int = yardl.Optional(value); + function expect_write_an_int_(self, value) + self.expected_an_int = yardl.Optional(value); end - function expect_write_a_stream_(obj, value) + function expect_write_a_stream_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_a_stream{end+1} = value{n}; + self.expected_a_stream{end+1} = value{n}; end return; end @@ -32,45 +32,45 @@ function expect_write_a_stream_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_a_stream{end+1} = value(index{:}, n); + self.expected_a_stream{end+1} = value(index{:}, n); end end - function expect_write_another_int_(obj, value) - obj.expected_another_int = yardl.Optional(value); + function expect_write_another_int_(self, value) + self.expected_another_int = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_an_int, yardl.None, "Expected call to write_an_int_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.expected_a_stream), "Expected call to write_a_stream_ was not received"); - obj.testCase_.verifyEqual(obj.expected_another_int, yardl.None, "Expected call to write_another_int_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_an_int, yardl.None, "Expected call to write_an_int_ was not received"); + self.testCase_.verifyTrue(isempty(self.expected_a_stream), "Expected call to write_a_stream_ was not received"); + self.testCase_.verifyEqual(self.expected_another_int, yardl.None, "Expected call to write_another_int_ was not received"); end end methods (Access=protected) - function write_an_int_(obj, value) - obj.testCase_.verifyTrue(obj.expected_an_int.has_value(), "Unexpected call to write_an_int_"); - obj.testCase_.verifyEqual(value, obj.expected_an_int.value, "Unexpected argument value for call to write_an_int_"); - obj.expected_an_int = yardl.None; + function write_an_int_(self, value) + self.testCase_.verifyTrue(self.expected_an_int.has_value(), "Unexpected call to write_an_int_"); + self.testCase_.verifyEqual(value, self.expected_an_int.value, "Unexpected argument value for call to write_an_int_"); + self.expected_an_int = yardl.None; end - function write_a_stream_(obj, value) + function write_a_stream_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_a_stream), "Unexpected call to write_a_stream_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_a_stream{1}, "Unexpected argument value for call to write_a_stream_"); - obj.expected_a_stream = obj.expected_a_stream(2:end); + self.testCase_.verifyFalse(isempty(self.expected_a_stream), "Unexpected call to write_a_stream_"); + self.testCase_.verifyEqual(value{1}, self.expected_a_stream{1}, "Unexpected argument value for call to write_a_stream_"); + self.expected_a_stream = self.expected_a_stream(2:end); end - function write_another_int_(obj, value) - obj.testCase_.verifyTrue(obj.expected_another_int.has_value(), "Unexpected call to write_another_int_"); - obj.testCase_.verifyEqual(value, obj.expected_another_int.value, "Unexpected argument value for call to write_another_int_"); - obj.expected_another_int = yardl.None; + function write_another_int_(self, value) + self.testCase_.verifyTrue(self.expected_another_int.has_value(), "Unexpected call to write_another_int_"); + self.testCase_.verifyEqual(value, self.expected_another_int.value, "Unexpected argument value for call to write_another_int_"); + self.expected_another_int = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m index 4f4ac090..039c4c70 100644 --- a/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStreamsOfAliasedUnionsWriter.m @@ -8,16 +8,16 @@ end methods - function obj = MockStreamsOfAliasedUnionsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_int_or_simple_record = {}; - obj.expected_nullable_int_or_simple_record = {}; + function self = MockStreamsOfAliasedUnionsWriter(testCase) + self.testCase_ = testCase; + self.expected_int_or_simple_record = {}; + self.expected_nullable_int_or_simple_record = {}; end - function expect_write_int_or_simple_record_(obj, value) + function expect_write_int_or_simple_record_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_int_or_simple_record{end+1} = value{n}; + self.expected_int_or_simple_record{end+1} = value{n}; end return; end @@ -26,14 +26,14 @@ function expect_write_int_or_simple_record_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_int_or_simple_record{end+1} = value(index{:}, n); + self.expected_int_or_simple_record{end+1} = value(index{:}, n); end end - function expect_write_nullable_int_or_simple_record_(obj, value) + function expect_write_nullable_int_or_simple_record_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_nullable_int_or_simple_record{end+1} = value{n}; + self.expected_nullable_int_or_simple_record{end+1} = value{n}; end return; end @@ -42,36 +42,36 @@ function expect_write_nullable_int_or_simple_record_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_nullable_int_or_simple_record{end+1} = value(index{:}, n); + self.expected_nullable_int_or_simple_record{end+1} = value(index{:}, n); end end - function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.expected_int_or_simple_record), "Expected call to write_int_or_simple_record_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.expected_nullable_int_or_simple_record), "Expected call to write_nullable_int_or_simple_record_ was not received"); + function verify(self) + self.testCase_.verifyTrue(isempty(self.expected_int_or_simple_record), "Expected call to write_int_or_simple_record_ was not received"); + self.testCase_.verifyTrue(isempty(self.expected_nullable_int_or_simple_record), "Expected call to write_nullable_int_or_simple_record_ was not received"); end end methods (Access=protected) - function write_int_or_simple_record_(obj, value) + function write_int_or_simple_record_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_int_or_simple_record), "Unexpected call to write_int_or_simple_record_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_int_or_simple_record{1}, "Unexpected argument value for call to write_int_or_simple_record_"); - obj.expected_int_or_simple_record = obj.expected_int_or_simple_record(2:end); + self.testCase_.verifyFalse(isempty(self.expected_int_or_simple_record), "Unexpected call to write_int_or_simple_record_"); + self.testCase_.verifyEqual(value{1}, self.expected_int_or_simple_record{1}, "Unexpected argument value for call to write_int_or_simple_record_"); + self.expected_int_or_simple_record = self.expected_int_or_simple_record(2:end); end - function write_nullable_int_or_simple_record_(obj, value) + function write_nullable_int_or_simple_record_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_nullable_int_or_simple_record), "Unexpected call to write_nullable_int_or_simple_record_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_nullable_int_or_simple_record{1}, "Unexpected argument value for call to write_nullable_int_or_simple_record_"); - obj.expected_nullable_int_or_simple_record = obj.expected_nullable_int_or_simple_record(2:end); + self.testCase_.verifyFalse(isempty(self.expected_nullable_int_or_simple_record), "Unexpected call to write_nullable_int_or_simple_record_"); + self.testCase_.verifyEqual(value{1}, self.expected_nullable_int_or_simple_record{1}, "Unexpected argument value for call to write_nullable_int_or_simple_record_"); + self.expected_nullable_int_or_simple_record = self.expected_nullable_int_or_simple_record(2:end); end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m index 392d1aa0..4b836e75 100644 --- a/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStreamsOfUnionsWriter.m @@ -8,16 +8,16 @@ end methods - function obj = MockStreamsOfUnionsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_int_or_simple_record = {}; - obj.expected_nullable_int_or_simple_record = {}; + function self = MockStreamsOfUnionsWriter(testCase) + self.testCase_ = testCase; + self.expected_int_or_simple_record = {}; + self.expected_nullable_int_or_simple_record = {}; end - function expect_write_int_or_simple_record_(obj, value) + function expect_write_int_or_simple_record_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_int_or_simple_record{end+1} = value{n}; + self.expected_int_or_simple_record{end+1} = value{n}; end return; end @@ -26,14 +26,14 @@ function expect_write_int_or_simple_record_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_int_or_simple_record{end+1} = value(index{:}, n); + self.expected_int_or_simple_record{end+1} = value(index{:}, n); end end - function expect_write_nullable_int_or_simple_record_(obj, value) + function expect_write_nullable_int_or_simple_record_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_nullable_int_or_simple_record{end+1} = value{n}; + self.expected_nullable_int_or_simple_record{end+1} = value{n}; end return; end @@ -42,36 +42,36 @@ function expect_write_nullable_int_or_simple_record_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_nullable_int_or_simple_record{end+1} = value(index{:}, n); + self.expected_nullable_int_or_simple_record{end+1} = value(index{:}, n); end end - function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.expected_int_or_simple_record), "Expected call to write_int_or_simple_record_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.expected_nullable_int_or_simple_record), "Expected call to write_nullable_int_or_simple_record_ was not received"); + function verify(self) + self.testCase_.verifyTrue(isempty(self.expected_int_or_simple_record), "Expected call to write_int_or_simple_record_ was not received"); + self.testCase_.verifyTrue(isempty(self.expected_nullable_int_or_simple_record), "Expected call to write_nullable_int_or_simple_record_ was not received"); end end methods (Access=protected) - function write_int_or_simple_record_(obj, value) + function write_int_or_simple_record_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_int_or_simple_record), "Unexpected call to write_int_or_simple_record_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_int_or_simple_record{1}, "Unexpected argument value for call to write_int_or_simple_record_"); - obj.expected_int_or_simple_record = obj.expected_int_or_simple_record(2:end); + self.testCase_.verifyFalse(isempty(self.expected_int_or_simple_record), "Unexpected call to write_int_or_simple_record_"); + self.testCase_.verifyEqual(value{1}, self.expected_int_or_simple_record{1}, "Unexpected argument value for call to write_int_or_simple_record_"); + self.expected_int_or_simple_record = self.expected_int_or_simple_record(2:end); end - function write_nullable_int_or_simple_record_(obj, value) + function write_nullable_int_or_simple_record_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_nullable_int_or_simple_record), "Unexpected call to write_nullable_int_or_simple_record_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_nullable_int_or_simple_record{1}, "Unexpected argument value for call to write_nullable_int_or_simple_record_"); - obj.expected_nullable_int_or_simple_record = obj.expected_nullable_int_or_simple_record(2:end); + self.testCase_.verifyFalse(isempty(self.expected_nullable_int_or_simple_record), "Unexpected call to write_nullable_int_or_simple_record_"); + self.testCase_.verifyEqual(value{1}, self.expected_nullable_int_or_simple_record{1}, "Unexpected argument value for call to write_nullable_int_or_simple_record_"); + self.expected_nullable_int_or_simple_record = self.expected_nullable_int_or_simple_record(2:end); end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockStreamsWriter.m b/matlab/generated/+test_model/+testing/MockStreamsWriter.m index 4518f1fe..fd0988cd 100644 --- a/matlab/generated/+test_model/+testing/MockStreamsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStreamsWriter.m @@ -10,18 +10,18 @@ end methods - function obj = MockStreamsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_int_data = {}; - obj.expected_optional_int_data = {}; - obj.expected_record_with_optional_vector_data = {}; - obj.expected_fixed_vector = {}; + function self = MockStreamsWriter(testCase) + self.testCase_ = testCase; + self.expected_int_data = {}; + self.expected_optional_int_data = {}; + self.expected_record_with_optional_vector_data = {}; + self.expected_fixed_vector = {}; end - function expect_write_int_data_(obj, value) + function expect_write_int_data_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_int_data{end+1} = value{n}; + self.expected_int_data{end+1} = value{n}; end return; end @@ -30,14 +30,14 @@ function expect_write_int_data_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_int_data{end+1} = value(index{:}, n); + self.expected_int_data{end+1} = value(index{:}, n); end end - function expect_write_optional_int_data_(obj, value) + function expect_write_optional_int_data_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_optional_int_data{end+1} = value{n}; + self.expected_optional_int_data{end+1} = value{n}; end return; end @@ -46,14 +46,14 @@ function expect_write_optional_int_data_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_optional_int_data{end+1} = value(index{:}, n); + self.expected_optional_int_data{end+1} = value(index{:}, n); end end - function expect_write_record_with_optional_vector_data_(obj, value) + function expect_write_record_with_optional_vector_data_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_record_with_optional_vector_data{end+1} = value{n}; + self.expected_record_with_optional_vector_data{end+1} = value{n}; end return; end @@ -62,14 +62,14 @@ function expect_write_record_with_optional_vector_data_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_record_with_optional_vector_data{end+1} = value(index{:}, n); + self.expected_record_with_optional_vector_data{end+1} = value(index{:}, n); end end - function expect_write_fixed_vector_(obj, value) + function expect_write_fixed_vector_(self, value) if iscell(value) for n = 1:numel(value) - obj.expected_fixed_vector{end+1} = value{n}; + self.expected_fixed_vector{end+1} = value{n}; end return; end @@ -78,54 +78,54 @@ function expect_write_fixed_vector_(obj, value) count = shape(lastDim); index = repelem({':'}, lastDim-1); for n = 1:count - obj.expected_fixed_vector{end+1} = value(index{:}, n); + self.expected_fixed_vector{end+1} = value(index{:}, n); end end - function verify(obj) - obj.testCase_.verifyTrue(isempty(obj.expected_int_data), "Expected call to write_int_data_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.expected_optional_int_data), "Expected call to write_optional_int_data_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.expected_record_with_optional_vector_data), "Expected call to write_record_with_optional_vector_data_ was not received"); - obj.testCase_.verifyTrue(isempty(obj.expected_fixed_vector), "Expected call to write_fixed_vector_ was not received"); + function verify(self) + self.testCase_.verifyTrue(isempty(self.expected_int_data), "Expected call to write_int_data_ was not received"); + self.testCase_.verifyTrue(isempty(self.expected_optional_int_data), "Expected call to write_optional_int_data_ was not received"); + self.testCase_.verifyTrue(isempty(self.expected_record_with_optional_vector_data), "Expected call to write_record_with_optional_vector_data_ was not received"); + self.testCase_.verifyTrue(isempty(self.expected_fixed_vector), "Expected call to write_fixed_vector_ was not received"); end end methods (Access=protected) - function write_int_data_(obj, value) + function write_int_data_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_int_data), "Unexpected call to write_int_data_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_int_data{1}, "Unexpected argument value for call to write_int_data_"); - obj.expected_int_data = obj.expected_int_data(2:end); + self.testCase_.verifyFalse(isempty(self.expected_int_data), "Unexpected call to write_int_data_"); + self.testCase_.verifyEqual(value{1}, self.expected_int_data{1}, "Unexpected argument value for call to write_int_data_"); + self.expected_int_data = self.expected_int_data(2:end); end - function write_optional_int_data_(obj, value) + function write_optional_int_data_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_optional_int_data), "Unexpected call to write_optional_int_data_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_optional_int_data{1}, "Unexpected argument value for call to write_optional_int_data_"); - obj.expected_optional_int_data = obj.expected_optional_int_data(2:end); + self.testCase_.verifyFalse(isempty(self.expected_optional_int_data), "Unexpected call to write_optional_int_data_"); + self.testCase_.verifyEqual(value{1}, self.expected_optional_int_data{1}, "Unexpected argument value for call to write_optional_int_data_"); + self.expected_optional_int_data = self.expected_optional_int_data(2:end); end - function write_record_with_optional_vector_data_(obj, value) + function write_record_with_optional_vector_data_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_record_with_optional_vector_data), "Unexpected call to write_record_with_optional_vector_data_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_record_with_optional_vector_data{1}, "Unexpected argument value for call to write_record_with_optional_vector_data_"); - obj.expected_record_with_optional_vector_data = obj.expected_record_with_optional_vector_data(2:end); + self.testCase_.verifyFalse(isempty(self.expected_record_with_optional_vector_data), "Unexpected call to write_record_with_optional_vector_data_"); + self.testCase_.verifyEqual(value{1}, self.expected_record_with_optional_vector_data{1}, "Unexpected argument value for call to write_record_with_optional_vector_data_"); + self.expected_record_with_optional_vector_data = self.expected_record_with_optional_vector_data(2:end); end - function write_fixed_vector_(obj, value) + function write_fixed_vector_(self, value) assert(iscell(value)); assert(isscalar(value)); - obj.testCase_.verifyFalse(isempty(obj.expected_fixed_vector), "Unexpected call to write_fixed_vector_"); - obj.testCase_.verifyEqual(value{1}, obj.expected_fixed_vector{1}, "Unexpected argument value for call to write_fixed_vector_"); - obj.expected_fixed_vector = obj.expected_fixed_vector(2:end); + self.testCase_.verifyFalse(isempty(self.expected_fixed_vector), "Unexpected call to write_fixed_vector_"); + self.testCase_.verifyEqual(value{1}, self.expected_fixed_vector{1}, "Unexpected argument value for call to write_fixed_vector_"); + self.expected_fixed_vector = self.expected_fixed_vector(2:end); end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockStringsWriter.m b/matlab/generated/+test_model/+testing/MockStringsWriter.m index 68e9d70c..cdd7cb30 100644 --- a/matlab/generated/+test_model/+testing/MockStringsWriter.m +++ b/matlab/generated/+test_model/+testing/MockStringsWriter.m @@ -8,42 +8,42 @@ end methods - function obj = MockStringsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_single_string = yardl.None; - obj.expected_rec_with_string = yardl.None; + function self = MockStringsWriter(testCase) + self.testCase_ = testCase; + self.expected_single_string = yardl.None; + self.expected_rec_with_string = yardl.None; end - function expect_write_single_string_(obj, value) - obj.expected_single_string = yardl.Optional(value); + function expect_write_single_string_(self, value) + self.expected_single_string = yardl.Optional(value); end - function expect_write_rec_with_string_(obj, value) - obj.expected_rec_with_string = yardl.Optional(value); + function expect_write_rec_with_string_(self, value) + self.expected_rec_with_string = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_single_string, yardl.None, "Expected call to write_single_string_ was not received"); - obj.testCase_.verifyEqual(obj.expected_rec_with_string, yardl.None, "Expected call to write_rec_with_string_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_single_string, yardl.None, "Expected call to write_single_string_ was not received"); + self.testCase_.verifyEqual(self.expected_rec_with_string, yardl.None, "Expected call to write_rec_with_string_ was not received"); end end methods (Access=protected) - function write_single_string_(obj, value) - obj.testCase_.verifyTrue(obj.expected_single_string.has_value(), "Unexpected call to write_single_string_"); - obj.testCase_.verifyEqual(value, obj.expected_single_string.value, "Unexpected argument value for call to write_single_string_"); - obj.expected_single_string = yardl.None; + function write_single_string_(self, value) + self.testCase_.verifyTrue(self.expected_single_string.has_value(), "Unexpected call to write_single_string_"); + self.testCase_.verifyEqual(value, self.expected_single_string.value, "Unexpected argument value for call to write_single_string_"); + self.expected_single_string = yardl.None; end - function write_rec_with_string_(obj, value) - obj.testCase_.verifyTrue(obj.expected_rec_with_string.has_value(), "Unexpected call to write_rec_with_string_"); - obj.testCase_.verifyEqual(value, obj.expected_rec_with_string.value, "Unexpected argument value for call to write_rec_with_string_"); - obj.expected_rec_with_string = yardl.None; + function write_rec_with_string_(self, value) + self.testCase_.verifyTrue(self.expected_rec_with_string.has_value(), "Unexpected call to write_rec_with_string_"); + self.testCase_.verifyEqual(value, self.expected_rec_with_string.value, "Unexpected argument value for call to write_rec_with_string_"); + self.expected_rec_with_string = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m b/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m index 10fa51e5..35996647 100644 --- a/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/MockSubarraysInRecordsWriter.m @@ -8,42 +8,42 @@ end methods - function obj = MockSubarraysInRecordsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_with_fixed_subarrays = yardl.None; - obj.expected_with_vlen_subarrays = yardl.None; + function self = MockSubarraysInRecordsWriter(testCase) + self.testCase_ = testCase; + self.expected_with_fixed_subarrays = yardl.None; + self.expected_with_vlen_subarrays = yardl.None; end - function expect_write_with_fixed_subarrays_(obj, value) - obj.expected_with_fixed_subarrays = yardl.Optional(value); + function expect_write_with_fixed_subarrays_(self, value) + self.expected_with_fixed_subarrays = yardl.Optional(value); end - function expect_write_with_vlen_subarrays_(obj, value) - obj.expected_with_vlen_subarrays = yardl.Optional(value); + function expect_write_with_vlen_subarrays_(self, value) + self.expected_with_vlen_subarrays = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_with_fixed_subarrays, yardl.None, "Expected call to write_with_fixed_subarrays_ was not received"); - obj.testCase_.verifyEqual(obj.expected_with_vlen_subarrays, yardl.None, "Expected call to write_with_vlen_subarrays_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_with_fixed_subarrays, yardl.None, "Expected call to write_with_fixed_subarrays_ was not received"); + self.testCase_.verifyEqual(self.expected_with_vlen_subarrays, yardl.None, "Expected call to write_with_vlen_subarrays_ was not received"); end end methods (Access=protected) - function write_with_fixed_subarrays_(obj, value) - obj.testCase_.verifyTrue(obj.expected_with_fixed_subarrays.has_value(), "Unexpected call to write_with_fixed_subarrays_"); - obj.testCase_.verifyEqual(value, obj.expected_with_fixed_subarrays.value, "Unexpected argument value for call to write_with_fixed_subarrays_"); - obj.expected_with_fixed_subarrays = yardl.None; + function write_with_fixed_subarrays_(self, value) + self.testCase_.verifyTrue(self.expected_with_fixed_subarrays.has_value(), "Unexpected call to write_with_fixed_subarrays_"); + self.testCase_.verifyEqual(value, self.expected_with_fixed_subarrays.value, "Unexpected argument value for call to write_with_fixed_subarrays_"); + self.expected_with_fixed_subarrays = yardl.None; end - function write_with_vlen_subarrays_(obj, value) - obj.testCase_.verifyTrue(obj.expected_with_vlen_subarrays.has_value(), "Unexpected call to write_with_vlen_subarrays_"); - obj.testCase_.verifyEqual(value, obj.expected_with_vlen_subarrays.value, "Unexpected argument value for call to write_with_vlen_subarrays_"); - obj.expected_with_vlen_subarrays = yardl.None; + function write_with_vlen_subarrays_(self, value) + self.testCase_.verifyTrue(self.expected_with_vlen_subarrays.has_value(), "Unexpected call to write_with_vlen_subarrays_"); + self.testCase_.verifyEqual(value, self.expected_with_vlen_subarrays.value, "Unexpected argument value for call to write_with_vlen_subarrays_"); + self.expected_with_vlen_subarrays = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockSubarraysWriter.m b/matlab/generated/+test_model/+testing/MockSubarraysWriter.m index 23c7b37f..e0e48f43 100644 --- a/matlab/generated/+test_model/+testing/MockSubarraysWriter.m +++ b/matlab/generated/+test_model/+testing/MockSubarraysWriter.m @@ -15,126 +15,126 @@ end methods - function obj = MockSubarraysWriter(testCase) - obj.testCase_ = testCase; - obj.expected_dynamic_with_fixed_int_subarray = yardl.None; - obj.expected_dynamic_with_fixed_float_subarray = yardl.None; - obj.expected_known_dim_count_with_fixed_int_subarray = yardl.None; - obj.expected_known_dim_count_with_fixed_float_subarray = yardl.None; - obj.expected_fixed_with_fixed_int_subarray = yardl.None; - obj.expected_fixed_with_fixed_float_subarray = yardl.None; - obj.expected_nested_subarray = yardl.None; - obj.expected_dynamic_with_fixed_vector_subarray = yardl.None; - obj.expected_generic_subarray = yardl.None; + function self = MockSubarraysWriter(testCase) + self.testCase_ = testCase; + self.expected_dynamic_with_fixed_int_subarray = yardl.None; + self.expected_dynamic_with_fixed_float_subarray = yardl.None; + self.expected_known_dim_count_with_fixed_int_subarray = yardl.None; + self.expected_known_dim_count_with_fixed_float_subarray = yardl.None; + self.expected_fixed_with_fixed_int_subarray = yardl.None; + self.expected_fixed_with_fixed_float_subarray = yardl.None; + self.expected_nested_subarray = yardl.None; + self.expected_dynamic_with_fixed_vector_subarray = yardl.None; + self.expected_generic_subarray = yardl.None; end - function expect_write_dynamic_with_fixed_int_subarray_(obj, value) - obj.expected_dynamic_with_fixed_int_subarray = yardl.Optional(value); + function expect_write_dynamic_with_fixed_int_subarray_(self, value) + self.expected_dynamic_with_fixed_int_subarray = yardl.Optional(value); end - function expect_write_dynamic_with_fixed_float_subarray_(obj, value) - obj.expected_dynamic_with_fixed_float_subarray = yardl.Optional(value); + function expect_write_dynamic_with_fixed_float_subarray_(self, value) + self.expected_dynamic_with_fixed_float_subarray = yardl.Optional(value); end - function expect_write_known_dim_count_with_fixed_int_subarray_(obj, value) - obj.expected_known_dim_count_with_fixed_int_subarray = yardl.Optional(value); + function expect_write_known_dim_count_with_fixed_int_subarray_(self, value) + self.expected_known_dim_count_with_fixed_int_subarray = yardl.Optional(value); end - function expect_write_known_dim_count_with_fixed_float_subarray_(obj, value) - obj.expected_known_dim_count_with_fixed_float_subarray = yardl.Optional(value); + function expect_write_known_dim_count_with_fixed_float_subarray_(self, value) + self.expected_known_dim_count_with_fixed_float_subarray = yardl.Optional(value); end - function expect_write_fixed_with_fixed_int_subarray_(obj, value) - obj.expected_fixed_with_fixed_int_subarray = yardl.Optional(value); + function expect_write_fixed_with_fixed_int_subarray_(self, value) + self.expected_fixed_with_fixed_int_subarray = yardl.Optional(value); end - function expect_write_fixed_with_fixed_float_subarray_(obj, value) - obj.expected_fixed_with_fixed_float_subarray = yardl.Optional(value); + function expect_write_fixed_with_fixed_float_subarray_(self, value) + self.expected_fixed_with_fixed_float_subarray = yardl.Optional(value); end - function expect_write_nested_subarray_(obj, value) - obj.expected_nested_subarray = yardl.Optional(value); + function expect_write_nested_subarray_(self, value) + self.expected_nested_subarray = yardl.Optional(value); end - function expect_write_dynamic_with_fixed_vector_subarray_(obj, value) - obj.expected_dynamic_with_fixed_vector_subarray = yardl.Optional(value); + function expect_write_dynamic_with_fixed_vector_subarray_(self, value) + self.expected_dynamic_with_fixed_vector_subarray = yardl.Optional(value); end - function expect_write_generic_subarray_(obj, value) - obj.expected_generic_subarray = yardl.Optional(value); + function expect_write_generic_subarray_(self, value) + self.expected_generic_subarray = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_dynamic_with_fixed_int_subarray, yardl.None, "Expected call to write_dynamic_with_fixed_int_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.expected_dynamic_with_fixed_float_subarray, yardl.None, "Expected call to write_dynamic_with_fixed_float_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.expected_known_dim_count_with_fixed_int_subarray, yardl.None, "Expected call to write_known_dim_count_with_fixed_int_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.expected_known_dim_count_with_fixed_float_subarray, yardl.None, "Expected call to write_known_dim_count_with_fixed_float_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.expected_fixed_with_fixed_int_subarray, yardl.None, "Expected call to write_fixed_with_fixed_int_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.expected_fixed_with_fixed_float_subarray, yardl.None, "Expected call to write_fixed_with_fixed_float_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.expected_nested_subarray, yardl.None, "Expected call to write_nested_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.expected_dynamic_with_fixed_vector_subarray, yardl.None, "Expected call to write_dynamic_with_fixed_vector_subarray_ was not received"); - obj.testCase_.verifyEqual(obj.expected_generic_subarray, yardl.None, "Expected call to write_generic_subarray_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_dynamic_with_fixed_int_subarray, yardl.None, "Expected call to write_dynamic_with_fixed_int_subarray_ was not received"); + self.testCase_.verifyEqual(self.expected_dynamic_with_fixed_float_subarray, yardl.None, "Expected call to write_dynamic_with_fixed_float_subarray_ was not received"); + self.testCase_.verifyEqual(self.expected_known_dim_count_with_fixed_int_subarray, yardl.None, "Expected call to write_known_dim_count_with_fixed_int_subarray_ was not received"); + self.testCase_.verifyEqual(self.expected_known_dim_count_with_fixed_float_subarray, yardl.None, "Expected call to write_known_dim_count_with_fixed_float_subarray_ was not received"); + self.testCase_.verifyEqual(self.expected_fixed_with_fixed_int_subarray, yardl.None, "Expected call to write_fixed_with_fixed_int_subarray_ was not received"); + self.testCase_.verifyEqual(self.expected_fixed_with_fixed_float_subarray, yardl.None, "Expected call to write_fixed_with_fixed_float_subarray_ was not received"); + self.testCase_.verifyEqual(self.expected_nested_subarray, yardl.None, "Expected call to write_nested_subarray_ was not received"); + self.testCase_.verifyEqual(self.expected_dynamic_with_fixed_vector_subarray, yardl.None, "Expected call to write_dynamic_with_fixed_vector_subarray_ was not received"); + self.testCase_.verifyEqual(self.expected_generic_subarray, yardl.None, "Expected call to write_generic_subarray_ was not received"); end end methods (Access=protected) - function write_dynamic_with_fixed_int_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.expected_dynamic_with_fixed_int_subarray.has_value(), "Unexpected call to write_dynamic_with_fixed_int_subarray_"); - obj.testCase_.verifyEqual(value, obj.expected_dynamic_with_fixed_int_subarray.value, "Unexpected argument value for call to write_dynamic_with_fixed_int_subarray_"); - obj.expected_dynamic_with_fixed_int_subarray = yardl.None; + function write_dynamic_with_fixed_int_subarray_(self, value) + self.testCase_.verifyTrue(self.expected_dynamic_with_fixed_int_subarray.has_value(), "Unexpected call to write_dynamic_with_fixed_int_subarray_"); + self.testCase_.verifyEqual(value, self.expected_dynamic_with_fixed_int_subarray.value, "Unexpected argument value for call to write_dynamic_with_fixed_int_subarray_"); + self.expected_dynamic_with_fixed_int_subarray = yardl.None; end - function write_dynamic_with_fixed_float_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.expected_dynamic_with_fixed_float_subarray.has_value(), "Unexpected call to write_dynamic_with_fixed_float_subarray_"); - obj.testCase_.verifyEqual(value, obj.expected_dynamic_with_fixed_float_subarray.value, "Unexpected argument value for call to write_dynamic_with_fixed_float_subarray_"); - obj.expected_dynamic_with_fixed_float_subarray = yardl.None; + function write_dynamic_with_fixed_float_subarray_(self, value) + self.testCase_.verifyTrue(self.expected_dynamic_with_fixed_float_subarray.has_value(), "Unexpected call to write_dynamic_with_fixed_float_subarray_"); + self.testCase_.verifyEqual(value, self.expected_dynamic_with_fixed_float_subarray.value, "Unexpected argument value for call to write_dynamic_with_fixed_float_subarray_"); + self.expected_dynamic_with_fixed_float_subarray = yardl.None; end - function write_known_dim_count_with_fixed_int_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.expected_known_dim_count_with_fixed_int_subarray.has_value(), "Unexpected call to write_known_dim_count_with_fixed_int_subarray_"); - obj.testCase_.verifyEqual(value, obj.expected_known_dim_count_with_fixed_int_subarray.value, "Unexpected argument value for call to write_known_dim_count_with_fixed_int_subarray_"); - obj.expected_known_dim_count_with_fixed_int_subarray = yardl.None; + function write_known_dim_count_with_fixed_int_subarray_(self, value) + self.testCase_.verifyTrue(self.expected_known_dim_count_with_fixed_int_subarray.has_value(), "Unexpected call to write_known_dim_count_with_fixed_int_subarray_"); + self.testCase_.verifyEqual(value, self.expected_known_dim_count_with_fixed_int_subarray.value, "Unexpected argument value for call to write_known_dim_count_with_fixed_int_subarray_"); + self.expected_known_dim_count_with_fixed_int_subarray = yardl.None; end - function write_known_dim_count_with_fixed_float_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.expected_known_dim_count_with_fixed_float_subarray.has_value(), "Unexpected call to write_known_dim_count_with_fixed_float_subarray_"); - obj.testCase_.verifyEqual(value, obj.expected_known_dim_count_with_fixed_float_subarray.value, "Unexpected argument value for call to write_known_dim_count_with_fixed_float_subarray_"); - obj.expected_known_dim_count_with_fixed_float_subarray = yardl.None; + function write_known_dim_count_with_fixed_float_subarray_(self, value) + self.testCase_.verifyTrue(self.expected_known_dim_count_with_fixed_float_subarray.has_value(), "Unexpected call to write_known_dim_count_with_fixed_float_subarray_"); + self.testCase_.verifyEqual(value, self.expected_known_dim_count_with_fixed_float_subarray.value, "Unexpected argument value for call to write_known_dim_count_with_fixed_float_subarray_"); + self.expected_known_dim_count_with_fixed_float_subarray = yardl.None; end - function write_fixed_with_fixed_int_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.expected_fixed_with_fixed_int_subarray.has_value(), "Unexpected call to write_fixed_with_fixed_int_subarray_"); - obj.testCase_.verifyEqual(value, obj.expected_fixed_with_fixed_int_subarray.value, "Unexpected argument value for call to write_fixed_with_fixed_int_subarray_"); - obj.expected_fixed_with_fixed_int_subarray = yardl.None; + function write_fixed_with_fixed_int_subarray_(self, value) + self.testCase_.verifyTrue(self.expected_fixed_with_fixed_int_subarray.has_value(), "Unexpected call to write_fixed_with_fixed_int_subarray_"); + self.testCase_.verifyEqual(value, self.expected_fixed_with_fixed_int_subarray.value, "Unexpected argument value for call to write_fixed_with_fixed_int_subarray_"); + self.expected_fixed_with_fixed_int_subarray = yardl.None; end - function write_fixed_with_fixed_float_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.expected_fixed_with_fixed_float_subarray.has_value(), "Unexpected call to write_fixed_with_fixed_float_subarray_"); - obj.testCase_.verifyEqual(value, obj.expected_fixed_with_fixed_float_subarray.value, "Unexpected argument value for call to write_fixed_with_fixed_float_subarray_"); - obj.expected_fixed_with_fixed_float_subarray = yardl.None; + function write_fixed_with_fixed_float_subarray_(self, value) + self.testCase_.verifyTrue(self.expected_fixed_with_fixed_float_subarray.has_value(), "Unexpected call to write_fixed_with_fixed_float_subarray_"); + self.testCase_.verifyEqual(value, self.expected_fixed_with_fixed_float_subarray.value, "Unexpected argument value for call to write_fixed_with_fixed_float_subarray_"); + self.expected_fixed_with_fixed_float_subarray = yardl.None; end - function write_nested_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.expected_nested_subarray.has_value(), "Unexpected call to write_nested_subarray_"); - obj.testCase_.verifyEqual(value, obj.expected_nested_subarray.value, "Unexpected argument value for call to write_nested_subarray_"); - obj.expected_nested_subarray = yardl.None; + function write_nested_subarray_(self, value) + self.testCase_.verifyTrue(self.expected_nested_subarray.has_value(), "Unexpected call to write_nested_subarray_"); + self.testCase_.verifyEqual(value, self.expected_nested_subarray.value, "Unexpected argument value for call to write_nested_subarray_"); + self.expected_nested_subarray = yardl.None; end - function write_dynamic_with_fixed_vector_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.expected_dynamic_with_fixed_vector_subarray.has_value(), "Unexpected call to write_dynamic_with_fixed_vector_subarray_"); - obj.testCase_.verifyEqual(value, obj.expected_dynamic_with_fixed_vector_subarray.value, "Unexpected argument value for call to write_dynamic_with_fixed_vector_subarray_"); - obj.expected_dynamic_with_fixed_vector_subarray = yardl.None; + function write_dynamic_with_fixed_vector_subarray_(self, value) + self.testCase_.verifyTrue(self.expected_dynamic_with_fixed_vector_subarray.has_value(), "Unexpected call to write_dynamic_with_fixed_vector_subarray_"); + self.testCase_.verifyEqual(value, self.expected_dynamic_with_fixed_vector_subarray.value, "Unexpected argument value for call to write_dynamic_with_fixed_vector_subarray_"); + self.expected_dynamic_with_fixed_vector_subarray = yardl.None; end - function write_generic_subarray_(obj, value) - obj.testCase_.verifyTrue(obj.expected_generic_subarray.has_value(), "Unexpected call to write_generic_subarray_"); - obj.testCase_.verifyEqual(value, obj.expected_generic_subarray.value, "Unexpected argument value for call to write_generic_subarray_"); - obj.expected_generic_subarray = yardl.None; + function write_generic_subarray_(self, value) + self.testCase_.verifyTrue(self.expected_generic_subarray.has_value(), "Unexpected call to write_generic_subarray_"); + self.testCase_.verifyEqual(value, self.expected_generic_subarray.value, "Unexpected argument value for call to write_generic_subarray_"); + self.expected_generic_subarray = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockUnionsWriter.m b/matlab/generated/+test_model/+testing/MockUnionsWriter.m index e1860edc..0914a301 100644 --- a/matlab/generated/+test_model/+testing/MockUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/MockUnionsWriter.m @@ -10,66 +10,66 @@ end methods - function obj = MockUnionsWriter(testCase) - obj.testCase_ = testCase; - obj.expected_int_or_simple_record = yardl.None; - obj.expected_int_or_record_with_vlens = yardl.None; - obj.expected_monosotate_or_int_or_simple_record = yardl.None; - obj.expected_record_with_unions = yardl.None; + function self = MockUnionsWriter(testCase) + self.testCase_ = testCase; + self.expected_int_or_simple_record = yardl.None; + self.expected_int_or_record_with_vlens = yardl.None; + self.expected_monosotate_or_int_or_simple_record = yardl.None; + self.expected_record_with_unions = yardl.None; end - function expect_write_int_or_simple_record_(obj, value) - obj.expected_int_or_simple_record = yardl.Optional(value); + function expect_write_int_or_simple_record_(self, value) + self.expected_int_or_simple_record = yardl.Optional(value); end - function expect_write_int_or_record_with_vlens_(obj, value) - obj.expected_int_or_record_with_vlens = yardl.Optional(value); + function expect_write_int_or_record_with_vlens_(self, value) + self.expected_int_or_record_with_vlens = yardl.Optional(value); end - function expect_write_monosotate_or_int_or_simple_record_(obj, value) - obj.expected_monosotate_or_int_or_simple_record = yardl.Optional(value); + function expect_write_monosotate_or_int_or_simple_record_(self, value) + self.expected_monosotate_or_int_or_simple_record = yardl.Optional(value); end - function expect_write_record_with_unions_(obj, value) - obj.expected_record_with_unions = yardl.Optional(value); + function expect_write_record_with_unions_(self, value) + self.expected_record_with_unions = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_int_or_simple_record, yardl.None, "Expected call to write_int_or_simple_record_ was not received"); - obj.testCase_.verifyEqual(obj.expected_int_or_record_with_vlens, yardl.None, "Expected call to write_int_or_record_with_vlens_ was not received"); - obj.testCase_.verifyEqual(obj.expected_monosotate_or_int_or_simple_record, yardl.None, "Expected call to write_monosotate_or_int_or_simple_record_ was not received"); - obj.testCase_.verifyEqual(obj.expected_record_with_unions, yardl.None, "Expected call to write_record_with_unions_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_int_or_simple_record, yardl.None, "Expected call to write_int_or_simple_record_ was not received"); + self.testCase_.verifyEqual(self.expected_int_or_record_with_vlens, yardl.None, "Expected call to write_int_or_record_with_vlens_ was not received"); + self.testCase_.verifyEqual(self.expected_monosotate_or_int_or_simple_record, yardl.None, "Expected call to write_monosotate_or_int_or_simple_record_ was not received"); + self.testCase_.verifyEqual(self.expected_record_with_unions, yardl.None, "Expected call to write_record_with_unions_ was not received"); end end methods (Access=protected) - function write_int_or_simple_record_(obj, value) - obj.testCase_.verifyTrue(obj.expected_int_or_simple_record.has_value(), "Unexpected call to write_int_or_simple_record_"); - obj.testCase_.verifyEqual(value, obj.expected_int_or_simple_record.value, "Unexpected argument value for call to write_int_or_simple_record_"); - obj.expected_int_or_simple_record = yardl.None; + function write_int_or_simple_record_(self, value) + self.testCase_.verifyTrue(self.expected_int_or_simple_record.has_value(), "Unexpected call to write_int_or_simple_record_"); + self.testCase_.verifyEqual(value, self.expected_int_or_simple_record.value, "Unexpected argument value for call to write_int_or_simple_record_"); + self.expected_int_or_simple_record = yardl.None; end - function write_int_or_record_with_vlens_(obj, value) - obj.testCase_.verifyTrue(obj.expected_int_or_record_with_vlens.has_value(), "Unexpected call to write_int_or_record_with_vlens_"); - obj.testCase_.verifyEqual(value, obj.expected_int_or_record_with_vlens.value, "Unexpected argument value for call to write_int_or_record_with_vlens_"); - obj.expected_int_or_record_with_vlens = yardl.None; + function write_int_or_record_with_vlens_(self, value) + self.testCase_.verifyTrue(self.expected_int_or_record_with_vlens.has_value(), "Unexpected call to write_int_or_record_with_vlens_"); + self.testCase_.verifyEqual(value, self.expected_int_or_record_with_vlens.value, "Unexpected argument value for call to write_int_or_record_with_vlens_"); + self.expected_int_or_record_with_vlens = yardl.None; end - function write_monosotate_or_int_or_simple_record_(obj, value) - obj.testCase_.verifyTrue(obj.expected_monosotate_or_int_or_simple_record.has_value(), "Unexpected call to write_monosotate_or_int_or_simple_record_"); - obj.testCase_.verifyEqual(value, obj.expected_monosotate_or_int_or_simple_record.value, "Unexpected argument value for call to write_monosotate_or_int_or_simple_record_"); - obj.expected_monosotate_or_int_or_simple_record = yardl.None; + function write_monosotate_or_int_or_simple_record_(self, value) + self.testCase_.verifyTrue(self.expected_monosotate_or_int_or_simple_record.has_value(), "Unexpected call to write_monosotate_or_int_or_simple_record_"); + self.testCase_.verifyEqual(value, self.expected_monosotate_or_int_or_simple_record.value, "Unexpected argument value for call to write_monosotate_or_int_or_simple_record_"); + self.expected_monosotate_or_int_or_simple_record = yardl.None; end - function write_record_with_unions_(obj, value) - obj.testCase_.verifyTrue(obj.expected_record_with_unions.has_value(), "Unexpected call to write_record_with_unions_"); - obj.testCase_.verifyEqual(value, obj.expected_record_with_unions.value, "Unexpected argument value for call to write_record_with_unions_"); - obj.expected_record_with_unions = yardl.None; + function write_record_with_unions_(self, value) + self.testCase_.verifyTrue(self.expected_record_with_unions.has_value(), "Unexpected call to write_record_with_unions_"); + self.testCase_.verifyEqual(value, self.expected_record_with_unions.value, "Unexpected argument value for call to write_record_with_unions_"); + self.expected_record_with_unions = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/MockVlensWriter.m b/matlab/generated/+test_model/+testing/MockVlensWriter.m index b8864fc9..a7ba6b13 100644 --- a/matlab/generated/+test_model/+testing/MockVlensWriter.m +++ b/matlab/generated/+test_model/+testing/MockVlensWriter.m @@ -10,66 +10,66 @@ end methods - function obj = MockVlensWriter(testCase) - obj.testCase_ = testCase; - obj.expected_int_vector = yardl.None; - obj.expected_complex_vector = yardl.None; - obj.expected_record_with_vlens = yardl.None; - obj.expected_vlen_of_record_with_vlens = yardl.None; + function self = MockVlensWriter(testCase) + self.testCase_ = testCase; + self.expected_int_vector = yardl.None; + self.expected_complex_vector = yardl.None; + self.expected_record_with_vlens = yardl.None; + self.expected_vlen_of_record_with_vlens = yardl.None; end - function expect_write_int_vector_(obj, value) - obj.expected_int_vector = yardl.Optional(value); + function expect_write_int_vector_(self, value) + self.expected_int_vector = yardl.Optional(value); end - function expect_write_complex_vector_(obj, value) - obj.expected_complex_vector = yardl.Optional(value); + function expect_write_complex_vector_(self, value) + self.expected_complex_vector = yardl.Optional(value); end - function expect_write_record_with_vlens_(obj, value) - obj.expected_record_with_vlens = yardl.Optional(value); + function expect_write_record_with_vlens_(self, value) + self.expected_record_with_vlens = yardl.Optional(value); end - function expect_write_vlen_of_record_with_vlens_(obj, value) - obj.expected_vlen_of_record_with_vlens = yardl.Optional(value); + function expect_write_vlen_of_record_with_vlens_(self, value) + self.expected_vlen_of_record_with_vlens = yardl.Optional(value); end - function verify(obj) - obj.testCase_.verifyEqual(obj.expected_int_vector, yardl.None, "Expected call to write_int_vector_ was not received"); - obj.testCase_.verifyEqual(obj.expected_complex_vector, yardl.None, "Expected call to write_complex_vector_ was not received"); - obj.testCase_.verifyEqual(obj.expected_record_with_vlens, yardl.None, "Expected call to write_record_with_vlens_ was not received"); - obj.testCase_.verifyEqual(obj.expected_vlen_of_record_with_vlens, yardl.None, "Expected call to write_vlen_of_record_with_vlens_ was not received"); + function verify(self) + self.testCase_.verifyEqual(self.expected_int_vector, yardl.None, "Expected call to write_int_vector_ was not received"); + self.testCase_.verifyEqual(self.expected_complex_vector, yardl.None, "Expected call to write_complex_vector_ was not received"); + self.testCase_.verifyEqual(self.expected_record_with_vlens, yardl.None, "Expected call to write_record_with_vlens_ was not received"); + self.testCase_.verifyEqual(self.expected_vlen_of_record_with_vlens, yardl.None, "Expected call to write_vlen_of_record_with_vlens_ was not received"); end end methods (Access=protected) - function write_int_vector_(obj, value) - obj.testCase_.verifyTrue(obj.expected_int_vector.has_value(), "Unexpected call to write_int_vector_"); - obj.testCase_.verifyEqual(value, obj.expected_int_vector.value, "Unexpected argument value for call to write_int_vector_"); - obj.expected_int_vector = yardl.None; + function write_int_vector_(self, value) + self.testCase_.verifyTrue(self.expected_int_vector.has_value(), "Unexpected call to write_int_vector_"); + self.testCase_.verifyEqual(value, self.expected_int_vector.value, "Unexpected argument value for call to write_int_vector_"); + self.expected_int_vector = yardl.None; end - function write_complex_vector_(obj, value) - obj.testCase_.verifyTrue(obj.expected_complex_vector.has_value(), "Unexpected call to write_complex_vector_"); - obj.testCase_.verifyEqual(value, obj.expected_complex_vector.value, "Unexpected argument value for call to write_complex_vector_"); - obj.expected_complex_vector = yardl.None; + function write_complex_vector_(self, value) + self.testCase_.verifyTrue(self.expected_complex_vector.has_value(), "Unexpected call to write_complex_vector_"); + self.testCase_.verifyEqual(value, self.expected_complex_vector.value, "Unexpected argument value for call to write_complex_vector_"); + self.expected_complex_vector = yardl.None; end - function write_record_with_vlens_(obj, value) - obj.testCase_.verifyTrue(obj.expected_record_with_vlens.has_value(), "Unexpected call to write_record_with_vlens_"); - obj.testCase_.verifyEqual(value, obj.expected_record_with_vlens.value, "Unexpected argument value for call to write_record_with_vlens_"); - obj.expected_record_with_vlens = yardl.None; + function write_record_with_vlens_(self, value) + self.testCase_.verifyTrue(self.expected_record_with_vlens.has_value(), "Unexpected call to write_record_with_vlens_"); + self.testCase_.verifyEqual(value, self.expected_record_with_vlens.value, "Unexpected argument value for call to write_record_with_vlens_"); + self.expected_record_with_vlens = yardl.None; end - function write_vlen_of_record_with_vlens_(obj, value) - obj.testCase_.verifyTrue(obj.expected_vlen_of_record_with_vlens.has_value(), "Unexpected call to write_vlen_of_record_with_vlens_"); - obj.testCase_.verifyEqual(value, obj.expected_vlen_of_record_with_vlens.value, "Unexpected argument value for call to write_vlen_of_record_with_vlens_"); - obj.expected_vlen_of_record_with_vlens = yardl.None; + function write_vlen_of_record_with_vlens_(self, value) + self.testCase_.verifyTrue(self.expected_vlen_of_record_with_vlens.has_value(), "Unexpected call to write_vlen_of_record_with_vlens_"); + self.testCase_.verifyEqual(value, self.expected_vlen_of_record_with_vlens.value, "Unexpected argument value for call to write_vlen_of_record_with_vlens_"); + self.expected_vlen_of_record_with_vlens = yardl.None; end - function close_(obj) + function close_(self) end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m b/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m index 426b08e2..94039cde 100644 --- a/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/TestAdvancedGenericsWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestAdvancedGenericsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockAdvancedGenericsWriter(testCase); - obj.close_called_ = false; + function self = TestAdvancedGenericsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockAdvancedGenericsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestAdvancedGenericsWriter' to verify mocks")); end @@ -30,44 +30,44 @@ function delete(obj) end methods (Access=protected) - function write_float_image_image_(obj, value) - obj.writer_.write_float_image_image(value); - obj.mock_writer_.expect_write_float_image_image_(value); + function write_float_image_image_(self, value) + self.writer_.write_float_image_image(value); + self.mock_writer_.expect_write_float_image_image_(value); end - function write_generic_record_1_(obj, value) - obj.writer_.write_generic_record_1(value); - obj.mock_writer_.expect_write_generic_record_1_(value); + function write_generic_record_1_(self, value) + self.writer_.write_generic_record_1(value); + self.mock_writer_.expect_write_generic_record_1_(value); end - function write_tuple_of_optionals_(obj, value) - obj.writer_.write_tuple_of_optionals(value); - obj.mock_writer_.expect_write_tuple_of_optionals_(value); + function write_tuple_of_optionals_(self, value) + self.writer_.write_tuple_of_optionals(value); + self.mock_writer_.expect_write_tuple_of_optionals_(value); end - function write_tuple_of_optionals_alternate_syntax_(obj, value) - obj.writer_.write_tuple_of_optionals_alternate_syntax(value); - obj.mock_writer_.expect_write_tuple_of_optionals_alternate_syntax_(value); + function write_tuple_of_optionals_alternate_syntax_(self, value) + self.writer_.write_tuple_of_optionals_alternate_syntax(value); + self.mock_writer_.expect_write_tuple_of_optionals_alternate_syntax_(value); end - function write_tuple_of_vectors_(obj, value) - obj.writer_.write_tuple_of_vectors(value); - obj.mock_writer_.expect_write_tuple_of_vectors_(value); + function write_tuple_of_vectors_(self, value) + self.writer_.write_tuple_of_vectors(value); + self.mock_writer_.expect_write_tuple_of_vectors_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -75,7 +75,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestAliasesWriter.m b/matlab/generated/+test_model/+testing/TestAliasesWriter.m index 9c2b753d..b25c0a2f 100644 --- a/matlab/generated/+test_model/+testing/TestAliasesWriter.m +++ b/matlab/generated/+test_model/+testing/TestAliasesWriter.m @@ -11,93 +11,93 @@ end methods - function obj = TestAliasesWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockAliasesWriter(testCase); - obj.close_called_ = false; + function self = TestAliasesWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockAliasesWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestAliasesWriter' to verify mocks")); end end - function end_stream_of_aliased_generic_union_2(obj) - end_stream_of_aliased_generic_union_2@test_model.AliasesWriterBase(obj); - obj.writer_.end_stream_of_aliased_generic_union_2(); + function end_stream_of_aliased_generic_union_2(self) + end_stream_of_aliased_generic_union_2@test_model.AliasesWriterBase(self); + self.writer_.end_stream_of_aliased_generic_union_2(); end end methods (Access=protected) - function write_aliased_string_(obj, value) - obj.writer_.write_aliased_string(value); - obj.mock_writer_.expect_write_aliased_string_(value); + function write_aliased_string_(self, value) + self.writer_.write_aliased_string(value); + self.mock_writer_.expect_write_aliased_string_(value); end - function write_aliased_enum_(obj, value) - obj.writer_.write_aliased_enum(value); - obj.mock_writer_.expect_write_aliased_enum_(value); + function write_aliased_enum_(self, value) + self.writer_.write_aliased_enum(value); + self.mock_writer_.expect_write_aliased_enum_(value); end - function write_aliased_open_generic_(obj, value) - obj.writer_.write_aliased_open_generic(value); - obj.mock_writer_.expect_write_aliased_open_generic_(value); + function write_aliased_open_generic_(self, value) + self.writer_.write_aliased_open_generic(value); + self.mock_writer_.expect_write_aliased_open_generic_(value); end - function write_aliased_closed_generic_(obj, value) - obj.writer_.write_aliased_closed_generic(value); - obj.mock_writer_.expect_write_aliased_closed_generic_(value); + function write_aliased_closed_generic_(self, value) + self.writer_.write_aliased_closed_generic(value); + self.mock_writer_.expect_write_aliased_closed_generic_(value); end - function write_aliased_optional_(obj, value) - obj.writer_.write_aliased_optional(value); - obj.mock_writer_.expect_write_aliased_optional_(value); + function write_aliased_optional_(self, value) + self.writer_.write_aliased_optional(value); + self.mock_writer_.expect_write_aliased_optional_(value); end - function write_aliased_generic_optional_(obj, value) - obj.writer_.write_aliased_generic_optional(value); - obj.mock_writer_.expect_write_aliased_generic_optional_(value); + function write_aliased_generic_optional_(self, value) + self.writer_.write_aliased_generic_optional(value); + self.mock_writer_.expect_write_aliased_generic_optional_(value); end - function write_aliased_generic_union_2_(obj, value) - obj.writer_.write_aliased_generic_union_2(value); - obj.mock_writer_.expect_write_aliased_generic_union_2_(value); + function write_aliased_generic_union_2_(self, value) + self.writer_.write_aliased_generic_union_2(value); + self.mock_writer_.expect_write_aliased_generic_union_2_(value); end - function write_aliased_generic_vector_(obj, value) - obj.writer_.write_aliased_generic_vector(value); - obj.mock_writer_.expect_write_aliased_generic_vector_(value); + function write_aliased_generic_vector_(self, value) + self.writer_.write_aliased_generic_vector(value); + self.mock_writer_.expect_write_aliased_generic_vector_(value); end - function write_aliased_generic_fixed_vector_(obj, value) - obj.writer_.write_aliased_generic_fixed_vector(value); - obj.mock_writer_.expect_write_aliased_generic_fixed_vector_(value); + function write_aliased_generic_fixed_vector_(self, value) + self.writer_.write_aliased_generic_fixed_vector(value); + self.mock_writer_.expect_write_aliased_generic_fixed_vector_(value); end - function write_stream_of_aliased_generic_union_2_(obj, value) - obj.writer_.write_stream_of_aliased_generic_union_2(value); - obj.mock_writer_.expect_write_stream_of_aliased_generic_union_2_(value); + function write_stream_of_aliased_generic_union_2_(self, value) + self.writer_.write_stream_of_aliased_generic_union_2(value); + self.mock_writer_.expect_write_stream_of_aliased_generic_union_2_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -105,7 +105,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m b/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m index f8985076..b7af276c 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkFloat256x256Writer.m @@ -11,48 +11,48 @@ end methods - function obj = TestBenchmarkFloat256x256Writer(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockBenchmarkFloat256x256Writer(testCase); - obj.close_called_ = false; + function self = TestBenchmarkFloat256x256Writer(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockBenchmarkFloat256x256Writer(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkFloat256x256Writer' to verify mocks")); end end - function end_float256x256(obj) - end_float256x256@test_model.BenchmarkFloat256x256WriterBase(obj); - obj.writer_.end_float256x256(); + function end_float256x256(self) + end_float256x256@test_model.BenchmarkFloat256x256WriterBase(self); + self.writer_.end_float256x256(); end end methods (Access=protected) - function write_float256x256_(obj, value) - obj.writer_.write_float256x256(value); - obj.mock_writer_.expect_write_float256x256_(value); + function write_float256x256_(self, value) + self.writer_.write_float256x256(value); + self.mock_writer_.expect_write_float256x256_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -60,7 +60,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m index e7042ab3..836d7e4b 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkFloatVlenWriter.m @@ -11,48 +11,48 @@ end methods - function obj = TestBenchmarkFloatVlenWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockBenchmarkFloatVlenWriter(testCase); - obj.close_called_ = false; + function self = TestBenchmarkFloatVlenWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockBenchmarkFloatVlenWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkFloatVlenWriter' to verify mocks")); end end - function end_float_array(obj) - end_float_array@test_model.BenchmarkFloatVlenWriterBase(obj); - obj.writer_.end_float_array(); + function end_float_array(self) + end_float_array@test_model.BenchmarkFloatVlenWriterBase(self); + self.writer_.end_float_array(); end end methods (Access=protected) - function write_float_array_(obj, value) - obj.writer_.write_float_array(value); - obj.mock_writer_.expect_write_float_array_(value); + function write_float_array_(self, value) + self.writer_.write_float_array(value); + self.mock_writer_.expect_write_float_array_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -60,7 +60,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m b/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m index adcc80cf..2e733f74 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkInt256x256Writer.m @@ -11,48 +11,48 @@ end methods - function obj = TestBenchmarkInt256x256Writer(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockBenchmarkInt256x256Writer(testCase); - obj.close_called_ = false; + function self = TestBenchmarkInt256x256Writer(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockBenchmarkInt256x256Writer(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkInt256x256Writer' to verify mocks")); end end - function end_int256x256(obj) - end_int256x256@test_model.BenchmarkInt256x256WriterBase(obj); - obj.writer_.end_int256x256(); + function end_int256x256(self) + end_int256x256@test_model.BenchmarkInt256x256WriterBase(self); + self.writer_.end_int256x256(); end end methods (Access=protected) - function write_int256x256_(obj, value) - obj.writer_.write_int256x256(value); - obj.mock_writer_.expect_write_int256x256_(value); + function write_int256x256_(self, value) + self.writer_.write_int256x256(value); + self.mock_writer_.expect_write_int256x256_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -60,7 +60,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m index fe31d261..f55d5b49 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSimpleMrdWriter.m @@ -11,48 +11,48 @@ end methods - function obj = TestBenchmarkSimpleMrdWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockBenchmarkSimpleMrdWriter(testCase); - obj.close_called_ = false; + function self = TestBenchmarkSimpleMrdWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockBenchmarkSimpleMrdWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkSimpleMrdWriter' to verify mocks")); end end - function end_data(obj) - end_data@test_model.BenchmarkSimpleMrdWriterBase(obj); - obj.writer_.end_data(); + function end_data(self) + end_data@test_model.BenchmarkSimpleMrdWriterBase(self); + self.writer_.end_data(); end end methods (Access=protected) - function write_data_(obj, value) - obj.writer_.write_data(value); - obj.mock_writer_.expect_write_data_(value); + function write_data_(self, value) + self.writer_.write_data(value); + self.mock_writer_.expect_write_data_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -60,7 +60,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m index bcedfb46..bfee9adc 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWithOptionalsWriter.m @@ -11,48 +11,48 @@ end methods - function obj = TestBenchmarkSmallRecordWithOptionalsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockBenchmarkSmallRecordWithOptionalsWriter(testCase); - obj.close_called_ = false; + function self = TestBenchmarkSmallRecordWithOptionalsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockBenchmarkSmallRecordWithOptionalsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkSmallRecordWithOptionalsWriter' to verify mocks")); end end - function end_small_record(obj) - end_small_record@test_model.BenchmarkSmallRecordWithOptionalsWriterBase(obj); - obj.writer_.end_small_record(); + function end_small_record(self) + end_small_record@test_model.BenchmarkSmallRecordWithOptionalsWriterBase(self); + self.writer_.end_small_record(); end end methods (Access=protected) - function write_small_record_(obj, value) - obj.writer_.write_small_record(value); - obj.mock_writer_.expect_write_small_record_(value); + function write_small_record_(self, value) + self.writer_.write_small_record(value); + self.mock_writer_.expect_write_small_record_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -60,7 +60,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m index c1e98dfb..94695116 100644 --- a/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m +++ b/matlab/generated/+test_model/+testing/TestBenchmarkSmallRecordWriter.m @@ -11,48 +11,48 @@ end methods - function obj = TestBenchmarkSmallRecordWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockBenchmarkSmallRecordWriter(testCase); - obj.close_called_ = false; + function self = TestBenchmarkSmallRecordWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockBenchmarkSmallRecordWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestBenchmarkSmallRecordWriter' to verify mocks")); end end - function end_small_record(obj) - end_small_record@test_model.BenchmarkSmallRecordWriterBase(obj); - obj.writer_.end_small_record(); + function end_small_record(self) + end_small_record@test_model.BenchmarkSmallRecordWriterBase(self); + self.writer_.end_small_record(); end end methods (Access=protected) - function write_small_record_(obj, value) - obj.writer_.write_small_record(value); - obj.mock_writer_.expect_write_small_record_(value); + function write_small_record_(self, value) + self.writer_.write_small_record(value); + self.mock_writer_.expect_write_small_record_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -60,7 +60,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m b/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m index f7dd8751..95924669 100644 --- a/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestDynamicNDArraysWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestDynamicNDArraysWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockDynamicNDArraysWriter(testCase); - obj.close_called_ = false; + function self = TestDynamicNDArraysWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockDynamicNDArraysWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestDynamicNDArraysWriter' to verify mocks")); end @@ -30,39 +30,39 @@ function delete(obj) end methods (Access=protected) - function write_ints_(obj, value) - obj.writer_.write_ints(value); - obj.mock_writer_.expect_write_ints_(value); + function write_ints_(self, value) + self.writer_.write_ints(value); + self.mock_writer_.expect_write_ints_(value); end - function write_simple_record_array_(obj, value) - obj.writer_.write_simple_record_array(value); - obj.mock_writer_.expect_write_simple_record_array_(value); + function write_simple_record_array_(self, value) + self.writer_.write_simple_record_array(value); + self.mock_writer_.expect_write_simple_record_array_(value); end - function write_record_with_vlens_array_(obj, value) - obj.writer_.write_record_with_vlens_array(value); - obj.mock_writer_.expect_write_record_with_vlens_array_(value); + function write_record_with_vlens_array_(self, value) + self.writer_.write_record_with_vlens_array(value); + self.mock_writer_.expect_write_record_with_vlens_array_(value); end - function write_record_with_dynamic_nd_arrays_(obj, value) - obj.writer_.write_record_with_dynamic_nd_arrays(value); - obj.mock_writer_.expect_write_record_with_dynamic_nd_arrays_(value); + function write_record_with_dynamic_nd_arrays_(self, value) + self.writer_.write_record_with_dynamic_nd_arrays(value); + self.mock_writer_.expect_write_record_with_dynamic_nd_arrays_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -70,7 +70,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestEnumsWriter.m b/matlab/generated/+test_model/+testing/TestEnumsWriter.m index 767bfad0..883bdbae 100644 --- a/matlab/generated/+test_model/+testing/TestEnumsWriter.m +++ b/matlab/generated/+test_model/+testing/TestEnumsWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestEnumsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockEnumsWriter(testCase); - obj.close_called_ = false; + function self = TestEnumsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockEnumsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestEnumsWriter' to verify mocks")); end @@ -30,34 +30,34 @@ function delete(obj) end methods (Access=protected) - function write_single_(obj, value) - obj.writer_.write_single(value); - obj.mock_writer_.expect_write_single_(value); + function write_single_(self, value) + self.writer_.write_single(value); + self.mock_writer_.expect_write_single_(value); end - function write_vec_(obj, value) - obj.writer_.write_vec(value); - obj.mock_writer_.expect_write_vec_(value); + function write_vec_(self, value) + self.writer_.write_vec(value); + self.mock_writer_.expect_write_vec_(value); end - function write_size_(obj, value) - obj.writer_.write_size(value); - obj.mock_writer_.expect_write_size_(value); + function write_size_(self, value) + self.writer_.write_size(value); + self.mock_writer_.expect_write_size_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -65,7 +65,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m b/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m index 55011793..72597831 100644 --- a/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestFixedArraysWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestFixedArraysWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockFixedArraysWriter(testCase); - obj.close_called_ = false; + function self = TestFixedArraysWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockFixedArraysWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestFixedArraysWriter' to verify mocks")); end @@ -30,44 +30,44 @@ function delete(obj) end methods (Access=protected) - function write_ints_(obj, value) - obj.writer_.write_ints(value); - obj.mock_writer_.expect_write_ints_(value); + function write_ints_(self, value) + self.writer_.write_ints(value); + self.mock_writer_.expect_write_ints_(value); end - function write_fixed_simple_record_array_(obj, value) - obj.writer_.write_fixed_simple_record_array(value); - obj.mock_writer_.expect_write_fixed_simple_record_array_(value); + function write_fixed_simple_record_array_(self, value) + self.writer_.write_fixed_simple_record_array(value); + self.mock_writer_.expect_write_fixed_simple_record_array_(value); end - function write_fixed_record_with_vlens_array_(obj, value) - obj.writer_.write_fixed_record_with_vlens_array(value); - obj.mock_writer_.expect_write_fixed_record_with_vlens_array_(value); + function write_fixed_record_with_vlens_array_(self, value) + self.writer_.write_fixed_record_with_vlens_array(value); + self.mock_writer_.expect_write_fixed_record_with_vlens_array_(value); end - function write_record_with_fixed_arrays_(obj, value) - obj.writer_.write_record_with_fixed_arrays(value); - obj.mock_writer_.expect_write_record_with_fixed_arrays_(value); + function write_record_with_fixed_arrays_(self, value) + self.writer_.write_record_with_fixed_arrays(value); + self.mock_writer_.expect_write_record_with_fixed_arrays_(value); end - function write_named_array_(obj, value) - obj.writer_.write_named_array(value); - obj.mock_writer_.expect_write_named_array_(value); + function write_named_array_(self, value) + self.writer_.write_named_array(value); + self.mock_writer_.expect_write_named_array_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -75,7 +75,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m b/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m index 8849fd5a..dda1595a 100644 --- a/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/TestFixedVectorsWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestFixedVectorsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockFixedVectorsWriter(testCase); - obj.close_called_ = false; + function self = TestFixedVectorsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockFixedVectorsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestFixedVectorsWriter' to verify mocks")); end @@ -30,39 +30,39 @@ function delete(obj) end methods (Access=protected) - function write_fixed_int_vector_(obj, value) - obj.writer_.write_fixed_int_vector(value); - obj.mock_writer_.expect_write_fixed_int_vector_(value); + function write_fixed_int_vector_(self, value) + self.writer_.write_fixed_int_vector(value); + self.mock_writer_.expect_write_fixed_int_vector_(value); end - function write_fixed_simple_record_vector_(obj, value) - obj.writer_.write_fixed_simple_record_vector(value); - obj.mock_writer_.expect_write_fixed_simple_record_vector_(value); + function write_fixed_simple_record_vector_(self, value) + self.writer_.write_fixed_simple_record_vector(value); + self.mock_writer_.expect_write_fixed_simple_record_vector_(value); end - function write_fixed_record_with_vlens_vector_(obj, value) - obj.writer_.write_fixed_record_with_vlens_vector(value); - obj.mock_writer_.expect_write_fixed_record_with_vlens_vector_(value); + function write_fixed_record_with_vlens_vector_(self, value) + self.writer_.write_fixed_record_with_vlens_vector(value); + self.mock_writer_.expect_write_fixed_record_with_vlens_vector_(value); end - function write_record_with_fixed_vectors_(obj, value) - obj.writer_.write_record_with_fixed_vectors(value); - obj.mock_writer_.expect_write_record_with_fixed_vectors_(value); + function write_record_with_fixed_vectors_(self, value) + self.writer_.write_record_with_fixed_vectors(value); + self.mock_writer_.expect_write_record_with_fixed_vectors_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -70,7 +70,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestFlagsWriter.m b/matlab/generated/+test_model/+testing/TestFlagsWriter.m index 0e590ec0..30ccd756 100644 --- a/matlab/generated/+test_model/+testing/TestFlagsWriter.m +++ b/matlab/generated/+test_model/+testing/TestFlagsWriter.m @@ -11,58 +11,58 @@ end methods - function obj = TestFlagsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockFlagsWriter(testCase); - obj.close_called_ = false; + function self = TestFlagsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockFlagsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestFlagsWriter' to verify mocks")); end end - function end_days(obj) - end_days@test_model.FlagsWriterBase(obj); - obj.writer_.end_days(); + function end_days(self) + end_days@test_model.FlagsWriterBase(self); + self.writer_.end_days(); end - function end_formats(obj) - end_formats@test_model.FlagsWriterBase(obj); - obj.writer_.end_formats(); + function end_formats(self) + end_formats@test_model.FlagsWriterBase(self); + self.writer_.end_formats(); end end methods (Access=protected) - function write_days_(obj, value) - obj.writer_.write_days(value); - obj.mock_writer_.expect_write_days_(value); + function write_days_(self, value) + self.writer_.write_days(value); + self.mock_writer_.expect_write_days_(value); end - function write_formats_(obj, value) - obj.writer_.write_formats(value); - obj.mock_writer_.expect_write_formats_(value); + function write_formats_(self, value) + self.writer_.write_formats(value); + self.mock_writer_.expect_write_formats_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -70,7 +70,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestMapsWriter.m b/matlab/generated/+test_model/+testing/TestMapsWriter.m index 97cd6d2f..6eb76054 100644 --- a/matlab/generated/+test_model/+testing/TestMapsWriter.m +++ b/matlab/generated/+test_model/+testing/TestMapsWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestMapsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockMapsWriter(testCase); - obj.close_called_ = false; + function self = TestMapsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockMapsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestMapsWriter' to verify mocks")); end @@ -30,39 +30,39 @@ function delete(obj) end methods (Access=protected) - function write_string_to_int_(obj, value) - obj.writer_.write_string_to_int(value); - obj.mock_writer_.expect_write_string_to_int_(value); + function write_string_to_int_(self, value) + self.writer_.write_string_to_int(value); + self.mock_writer_.expect_write_string_to_int_(value); end - function write_int_to_string_(obj, value) - obj.writer_.write_int_to_string(value); - obj.mock_writer_.expect_write_int_to_string_(value); + function write_int_to_string_(self, value) + self.writer_.write_int_to_string(value); + self.mock_writer_.expect_write_int_to_string_(value); end - function write_string_to_union_(obj, value) - obj.writer_.write_string_to_union(value); - obj.mock_writer_.expect_write_string_to_union_(value); + function write_string_to_union_(self, value) + self.writer_.write_string_to_union(value); + self.mock_writer_.expect_write_string_to_union_(value); end - function write_aliased_generic_(obj, value) - obj.writer_.write_aliased_generic(value); - obj.mock_writer_.expect_write_aliased_generic_(value); + function write_aliased_generic_(self, value) + self.writer_.write_aliased_generic(value); + self.mock_writer_.expect_write_aliased_generic_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -70,7 +70,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m b/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m index b8651220..75ddaafe 100644 --- a/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m +++ b/matlab/generated/+test_model/+testing/TestNDArraysSingleDimensionWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestNDArraysSingleDimensionWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockNDArraysSingleDimensionWriter(testCase); - obj.close_called_ = false; + function self = TestNDArraysSingleDimensionWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockNDArraysSingleDimensionWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestNDArraysSingleDimensionWriter' to verify mocks")); end @@ -30,39 +30,39 @@ function delete(obj) end methods (Access=protected) - function write_ints_(obj, value) - obj.writer_.write_ints(value); - obj.mock_writer_.expect_write_ints_(value); + function write_ints_(self, value) + self.writer_.write_ints(value); + self.mock_writer_.expect_write_ints_(value); end - function write_simple_record_array_(obj, value) - obj.writer_.write_simple_record_array(value); - obj.mock_writer_.expect_write_simple_record_array_(value); + function write_simple_record_array_(self, value) + self.writer_.write_simple_record_array(value); + self.mock_writer_.expect_write_simple_record_array_(value); end - function write_record_with_vlens_array_(obj, value) - obj.writer_.write_record_with_vlens_array(value); - obj.mock_writer_.expect_write_record_with_vlens_array_(value); + function write_record_with_vlens_array_(self, value) + self.writer_.write_record_with_vlens_array(value); + self.mock_writer_.expect_write_record_with_vlens_array_(value); end - function write_record_with_nd_arrays_(obj, value) - obj.writer_.write_record_with_nd_arrays(value); - obj.mock_writer_.expect_write_record_with_nd_arrays_(value); + function write_record_with_nd_arrays_(self, value) + self.writer_.write_record_with_nd_arrays(value); + self.mock_writer_.expect_write_record_with_nd_arrays_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -70,7 +70,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestNDArraysWriter.m b/matlab/generated/+test_model/+testing/TestNDArraysWriter.m index 2d3d7b77..2e24fd6d 100644 --- a/matlab/generated/+test_model/+testing/TestNDArraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestNDArraysWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestNDArraysWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockNDArraysWriter(testCase); - obj.close_called_ = false; + function self = TestNDArraysWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockNDArraysWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestNDArraysWriter' to verify mocks")); end @@ -30,44 +30,44 @@ function delete(obj) end methods (Access=protected) - function write_ints_(obj, value) - obj.writer_.write_ints(value); - obj.mock_writer_.expect_write_ints_(value); + function write_ints_(self, value) + self.writer_.write_ints(value); + self.mock_writer_.expect_write_ints_(value); end - function write_simple_record_array_(obj, value) - obj.writer_.write_simple_record_array(value); - obj.mock_writer_.expect_write_simple_record_array_(value); + function write_simple_record_array_(self, value) + self.writer_.write_simple_record_array(value); + self.mock_writer_.expect_write_simple_record_array_(value); end - function write_record_with_vlens_array_(obj, value) - obj.writer_.write_record_with_vlens_array(value); - obj.mock_writer_.expect_write_record_with_vlens_array_(value); + function write_record_with_vlens_array_(self, value) + self.writer_.write_record_with_vlens_array(value); + self.mock_writer_.expect_write_record_with_vlens_array_(value); end - function write_record_with_nd_arrays_(obj, value) - obj.writer_.write_record_with_nd_arrays(value); - obj.mock_writer_.expect_write_record_with_nd_arrays_(value); + function write_record_with_nd_arrays_(self, value) + self.writer_.write_record_with_nd_arrays(value); + self.mock_writer_.expect_write_record_with_nd_arrays_(value); end - function write_named_array_(obj, value) - obj.writer_.write_named_array(value); - obj.mock_writer_.expect_write_named_array_(value); + function write_named_array_(self, value) + self.writer_.write_named_array(value); + self.mock_writer_.expect_write_named_array_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -75,7 +75,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m b/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m index 93b63669..93ca596e 100644 --- a/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/TestNestedRecordsWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestNestedRecordsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockNestedRecordsWriter(testCase); - obj.close_called_ = false; + function self = TestNestedRecordsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockNestedRecordsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestNestedRecordsWriter' to verify mocks")); end @@ -30,24 +30,24 @@ function delete(obj) end methods (Access=protected) - function write_tuple_with_records_(obj, value) - obj.writer_.write_tuple_with_records(value); - obj.mock_writer_.expect_write_tuple_with_records_(value); + function write_tuple_with_records_(self, value) + self.writer_.write_tuple_with_records(value); + self.mock_writer_.expect_write_tuple_with_records_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -55,7 +55,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m b/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m index d03459d9..2eefe3a6 100644 --- a/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m +++ b/matlab/generated/+test_model/+testing/TestOptionalVectorsWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestOptionalVectorsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockOptionalVectorsWriter(testCase); - obj.close_called_ = false; + function self = TestOptionalVectorsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockOptionalVectorsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestOptionalVectorsWriter' to verify mocks")); end @@ -30,24 +30,24 @@ function delete(obj) end methods (Access=protected) - function write_record_with_optional_vector_(obj, value) - obj.writer_.write_record_with_optional_vector(value); - obj.mock_writer_.expect_write_record_with_optional_vector_(value); + function write_record_with_optional_vector_(self, value) + self.writer_.write_record_with_optional_vector(value); + self.mock_writer_.expect_write_record_with_optional_vector_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -55,7 +55,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m b/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m index 7cfd0e6b..4201ad0c 100644 --- a/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m +++ b/matlab/generated/+test_model/+testing/TestProtocolWithComputedFieldsWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestProtocolWithComputedFieldsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockProtocolWithComputedFieldsWriter(testCase); - obj.close_called_ = false; + function self = TestProtocolWithComputedFieldsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockProtocolWithComputedFieldsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestProtocolWithComputedFieldsWriter' to verify mocks")); end @@ -30,24 +30,24 @@ function delete(obj) end methods (Access=protected) - function write_record_with_computed_fields_(obj, value) - obj.writer_.write_record_with_computed_fields(value); - obj.mock_writer_.expect_write_record_with_computed_fields_(value); + function write_record_with_computed_fields_(self, value) + self.writer_.write_record_with_computed_fields(value); + self.mock_writer_.expect_write_record_with_computed_fields_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -55,7 +55,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m b/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m index 48c67fb6..6e6f4117 100644 --- a/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m +++ b/matlab/generated/+test_model/+testing/TestProtocolWithKeywordStepsWriter.m @@ -11,53 +11,53 @@ end methods - function obj = TestProtocolWithKeywordStepsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockProtocolWithKeywordStepsWriter(testCase); - obj.close_called_ = false; + function self = TestProtocolWithKeywordStepsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockProtocolWithKeywordStepsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestProtocolWithKeywordStepsWriter' to verify mocks")); end end - function end_int(obj) - end_int@test_model.ProtocolWithKeywordStepsWriterBase(obj); - obj.writer_.end_int(); + function end_int(self) + end_int@test_model.ProtocolWithKeywordStepsWriterBase(self); + self.writer_.end_int(); end end methods (Access=protected) - function write_int_(obj, value) - obj.writer_.write_int(value); - obj.mock_writer_.expect_write_int_(value); + function write_int_(self, value) + self.writer_.write_int(value); + self.mock_writer_.expect_write_int_(value); end - function write_float_(obj, value) - obj.writer_.write_float(value); - obj.mock_writer_.expect_write_float_(value); + function write_float_(self, value) + self.writer_.write_float(value); + self.mock_writer_.expect_write_float_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -65,7 +65,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m b/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m index cd5fa608..c19f6f6d 100644 --- a/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m +++ b/matlab/generated/+test_model/+testing/TestScalarOptionalsWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestScalarOptionalsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockScalarOptionalsWriter(testCase); - obj.close_called_ = false; + function self = TestScalarOptionalsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockScalarOptionalsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestScalarOptionalsWriter' to verify mocks")); end @@ -30,39 +30,39 @@ function delete(obj) end methods (Access=protected) - function write_optional_int_(obj, value) - obj.writer_.write_optional_int(value); - obj.mock_writer_.expect_write_optional_int_(value); + function write_optional_int_(self, value) + self.writer_.write_optional_int(value); + self.mock_writer_.expect_write_optional_int_(value); end - function write_optional_record_(obj, value) - obj.writer_.write_optional_record(value); - obj.mock_writer_.expect_write_optional_record_(value); + function write_optional_record_(self, value) + self.writer_.write_optional_record(value); + self.mock_writer_.expect_write_optional_record_(value); end - function write_record_with_optional_fields_(obj, value) - obj.writer_.write_record_with_optional_fields(value); - obj.mock_writer_.expect_write_record_with_optional_fields_(value); + function write_record_with_optional_fields_(self, value) + self.writer_.write_record_with_optional_fields(value); + self.mock_writer_.expect_write_record_with_optional_fields_(value); end - function write_optional_record_with_optional_fields_(obj, value) - obj.writer_.write_optional_record_with_optional_fields(value); - obj.mock_writer_.expect_write_optional_record_with_optional_fields_(value); + function write_optional_record_with_optional_fields_(self, value) + self.writer_.write_optional_record_with_optional_fields(value); + self.mock_writer_.expect_write_optional_record_with_optional_fields_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -70,7 +70,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestScalarsWriter.m b/matlab/generated/+test_model/+testing/TestScalarsWriter.m index a8cd6cbc..e1e571c6 100644 --- a/matlab/generated/+test_model/+testing/TestScalarsWriter.m +++ b/matlab/generated/+test_model/+testing/TestScalarsWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestScalarsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockScalarsWriter(testCase); - obj.close_called_ = false; + function self = TestScalarsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockScalarsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestScalarsWriter' to verify mocks")); end @@ -30,29 +30,29 @@ function delete(obj) end methods (Access=protected) - function write_int32_(obj, value) - obj.writer_.write_int32(value); - obj.mock_writer_.expect_write_int32_(value); + function write_int32_(self, value) + self.writer_.write_int32(value); + self.mock_writer_.expect_write_int32_(value); end - function write_record_(obj, value) - obj.writer_.write_record(value); - obj.mock_writer_.expect_write_record_(value); + function write_record_(self, value) + self.writer_.write_record(value); + self.mock_writer_.expect_write_record_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -60,7 +60,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m b/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m index 74d4e62b..73d19bc2 100644 --- a/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m +++ b/matlab/generated/+test_model/+testing/TestSimpleGenericsWriter.m @@ -11,88 +11,88 @@ end methods - function obj = TestSimpleGenericsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockSimpleGenericsWriter(testCase); - obj.close_called_ = false; + function self = TestSimpleGenericsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockSimpleGenericsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestSimpleGenericsWriter' to verify mocks")); end end - function end_stream_of_type_variants(obj) - end_stream_of_type_variants@test_model.SimpleGenericsWriterBase(obj); - obj.writer_.end_stream_of_type_variants(); + function end_stream_of_type_variants(self) + end_stream_of_type_variants@test_model.SimpleGenericsWriterBase(self); + self.writer_.end_stream_of_type_variants(); end end methods (Access=protected) - function write_float_image_(obj, value) - obj.writer_.write_float_image(value); - obj.mock_writer_.expect_write_float_image_(value); + function write_float_image_(self, value) + self.writer_.write_float_image(value); + self.mock_writer_.expect_write_float_image_(value); end - function write_int_image_(obj, value) - obj.writer_.write_int_image(value); - obj.mock_writer_.expect_write_int_image_(value); + function write_int_image_(self, value) + self.writer_.write_int_image(value); + self.mock_writer_.expect_write_int_image_(value); end - function write_int_image_alternate_syntax_(obj, value) - obj.writer_.write_int_image_alternate_syntax(value); - obj.mock_writer_.expect_write_int_image_alternate_syntax_(value); + function write_int_image_alternate_syntax_(self, value) + self.writer_.write_int_image_alternate_syntax(value); + self.mock_writer_.expect_write_int_image_alternate_syntax_(value); end - function write_string_image_(obj, value) - obj.writer_.write_string_image(value); - obj.mock_writer_.expect_write_string_image_(value); + function write_string_image_(self, value) + self.writer_.write_string_image(value); + self.mock_writer_.expect_write_string_image_(value); end - function write_int_float_tuple_(obj, value) - obj.writer_.write_int_float_tuple(value); - obj.mock_writer_.expect_write_int_float_tuple_(value); + function write_int_float_tuple_(self, value) + self.writer_.write_int_float_tuple(value); + self.mock_writer_.expect_write_int_float_tuple_(value); end - function write_float_float_tuple_(obj, value) - obj.writer_.write_float_float_tuple(value); - obj.mock_writer_.expect_write_float_float_tuple_(value); + function write_float_float_tuple_(self, value) + self.writer_.write_float_float_tuple(value); + self.mock_writer_.expect_write_float_float_tuple_(value); end - function write_int_float_tuple_alternate_syntax_(obj, value) - obj.writer_.write_int_float_tuple_alternate_syntax(value); - obj.mock_writer_.expect_write_int_float_tuple_alternate_syntax_(value); + function write_int_float_tuple_alternate_syntax_(self, value) + self.writer_.write_int_float_tuple_alternate_syntax(value); + self.mock_writer_.expect_write_int_float_tuple_alternate_syntax_(value); end - function write_int_string_tuple_(obj, value) - obj.writer_.write_int_string_tuple(value); - obj.mock_writer_.expect_write_int_string_tuple_(value); + function write_int_string_tuple_(self, value) + self.writer_.write_int_string_tuple(value); + self.mock_writer_.expect_write_int_string_tuple_(value); end - function write_stream_of_type_variants_(obj, value) - obj.writer_.write_stream_of_type_variants(value); - obj.mock_writer_.expect_write_stream_of_type_variants_(value); + function write_stream_of_type_variants_(self, value) + self.writer_.write_stream_of_type_variants(value); + self.mock_writer_.expect_write_stream_of_type_variants_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -100,7 +100,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestStateTestWriter.m b/matlab/generated/+test_model/+testing/TestStateTestWriter.m index 3bda765b..38e6dbe0 100644 --- a/matlab/generated/+test_model/+testing/TestStateTestWriter.m +++ b/matlab/generated/+test_model/+testing/TestStateTestWriter.m @@ -11,58 +11,58 @@ end methods - function obj = TestStateTestWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockStateTestWriter(testCase); - obj.close_called_ = false; + function self = TestStateTestWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockStateTestWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestStateTestWriter' to verify mocks")); end end - function end_a_stream(obj) - end_a_stream@test_model.StateTestWriterBase(obj); - obj.writer_.end_a_stream(); + function end_a_stream(self) + end_a_stream@test_model.StateTestWriterBase(self); + self.writer_.end_a_stream(); end end methods (Access=protected) - function write_an_int_(obj, value) - obj.writer_.write_an_int(value); - obj.mock_writer_.expect_write_an_int_(value); + function write_an_int_(self, value) + self.writer_.write_an_int(value); + self.mock_writer_.expect_write_an_int_(value); end - function write_a_stream_(obj, value) - obj.writer_.write_a_stream(value); - obj.mock_writer_.expect_write_a_stream_(value); + function write_a_stream_(self, value) + self.writer_.write_a_stream(value); + self.mock_writer_.expect_write_a_stream_(value); end - function write_another_int_(obj, value) - obj.writer_.write_another_int(value); - obj.mock_writer_.expect_write_another_int_(value); + function write_another_int_(self, value) + self.writer_.write_another_int(value); + self.mock_writer_.expect_write_another_int_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -70,7 +70,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m index 28ccadc6..a4a599c0 100644 --- a/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStreamsOfAliasedUnionsWriter.m @@ -11,58 +11,58 @@ end methods - function obj = TestStreamsOfAliasedUnionsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockStreamsOfAliasedUnionsWriter(testCase); - obj.close_called_ = false; + function self = TestStreamsOfAliasedUnionsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockStreamsOfAliasedUnionsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestStreamsOfAliasedUnionsWriter' to verify mocks")); end end - function end_int_or_simple_record(obj) - end_int_or_simple_record@test_model.StreamsOfAliasedUnionsWriterBase(obj); - obj.writer_.end_int_or_simple_record(); + function end_int_or_simple_record(self) + end_int_or_simple_record@test_model.StreamsOfAliasedUnionsWriterBase(self); + self.writer_.end_int_or_simple_record(); end - function end_nullable_int_or_simple_record(obj) - end_nullable_int_or_simple_record@test_model.StreamsOfAliasedUnionsWriterBase(obj); - obj.writer_.end_nullable_int_or_simple_record(); + function end_nullable_int_or_simple_record(self) + end_nullable_int_or_simple_record@test_model.StreamsOfAliasedUnionsWriterBase(self); + self.writer_.end_nullable_int_or_simple_record(); end end methods (Access=protected) - function write_int_or_simple_record_(obj, value) - obj.writer_.write_int_or_simple_record(value); - obj.mock_writer_.expect_write_int_or_simple_record_(value); + function write_int_or_simple_record_(self, value) + self.writer_.write_int_or_simple_record(value); + self.mock_writer_.expect_write_int_or_simple_record_(value); end - function write_nullable_int_or_simple_record_(obj, value) - obj.writer_.write_nullable_int_or_simple_record(value); - obj.mock_writer_.expect_write_nullable_int_or_simple_record_(value); + function write_nullable_int_or_simple_record_(self, value) + self.writer_.write_nullable_int_or_simple_record(value); + self.mock_writer_.expect_write_nullable_int_or_simple_record_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -70,7 +70,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m index 1cf0bbe7..067e8bcf 100644 --- a/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStreamsOfUnionsWriter.m @@ -11,58 +11,58 @@ end methods - function obj = TestStreamsOfUnionsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockStreamsOfUnionsWriter(testCase); - obj.close_called_ = false; + function self = TestStreamsOfUnionsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockStreamsOfUnionsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestStreamsOfUnionsWriter' to verify mocks")); end end - function end_int_or_simple_record(obj) - end_int_or_simple_record@test_model.StreamsOfUnionsWriterBase(obj); - obj.writer_.end_int_or_simple_record(); + function end_int_or_simple_record(self) + end_int_or_simple_record@test_model.StreamsOfUnionsWriterBase(self); + self.writer_.end_int_or_simple_record(); end - function end_nullable_int_or_simple_record(obj) - end_nullable_int_or_simple_record@test_model.StreamsOfUnionsWriterBase(obj); - obj.writer_.end_nullable_int_or_simple_record(); + function end_nullable_int_or_simple_record(self) + end_nullable_int_or_simple_record@test_model.StreamsOfUnionsWriterBase(self); + self.writer_.end_nullable_int_or_simple_record(); end end methods (Access=protected) - function write_int_or_simple_record_(obj, value) - obj.writer_.write_int_or_simple_record(value); - obj.mock_writer_.expect_write_int_or_simple_record_(value); + function write_int_or_simple_record_(self, value) + self.writer_.write_int_or_simple_record(value); + self.mock_writer_.expect_write_int_or_simple_record_(value); end - function write_nullable_int_or_simple_record_(obj, value) - obj.writer_.write_nullable_int_or_simple_record(value); - obj.mock_writer_.expect_write_nullable_int_or_simple_record_(value); + function write_nullable_int_or_simple_record_(self, value) + self.writer_.write_nullable_int_or_simple_record(value); + self.mock_writer_.expect_write_nullable_int_or_simple_record_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -70,7 +70,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestStreamsWriter.m b/matlab/generated/+test_model/+testing/TestStreamsWriter.m index dfe5aa9d..29cbc5bd 100644 --- a/matlab/generated/+test_model/+testing/TestStreamsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStreamsWriter.m @@ -11,78 +11,78 @@ end methods - function obj = TestStreamsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockStreamsWriter(testCase); - obj.close_called_ = false; + function self = TestStreamsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockStreamsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestStreamsWriter' to verify mocks")); end end - function end_int_data(obj) - end_int_data@test_model.StreamsWriterBase(obj); - obj.writer_.end_int_data(); + function end_int_data(self) + end_int_data@test_model.StreamsWriterBase(self); + self.writer_.end_int_data(); end - function end_optional_int_data(obj) - end_optional_int_data@test_model.StreamsWriterBase(obj); - obj.writer_.end_optional_int_data(); + function end_optional_int_data(self) + end_optional_int_data@test_model.StreamsWriterBase(self); + self.writer_.end_optional_int_data(); end - function end_record_with_optional_vector_data(obj) - end_record_with_optional_vector_data@test_model.StreamsWriterBase(obj); - obj.writer_.end_record_with_optional_vector_data(); + function end_record_with_optional_vector_data(self) + end_record_with_optional_vector_data@test_model.StreamsWriterBase(self); + self.writer_.end_record_with_optional_vector_data(); end - function end_fixed_vector(obj) - end_fixed_vector@test_model.StreamsWriterBase(obj); - obj.writer_.end_fixed_vector(); + function end_fixed_vector(self) + end_fixed_vector@test_model.StreamsWriterBase(self); + self.writer_.end_fixed_vector(); end end methods (Access=protected) - function write_int_data_(obj, value) - obj.writer_.write_int_data(value); - obj.mock_writer_.expect_write_int_data_(value); + function write_int_data_(self, value) + self.writer_.write_int_data(value); + self.mock_writer_.expect_write_int_data_(value); end - function write_optional_int_data_(obj, value) - obj.writer_.write_optional_int_data(value); - obj.mock_writer_.expect_write_optional_int_data_(value); + function write_optional_int_data_(self, value) + self.writer_.write_optional_int_data(value); + self.mock_writer_.expect_write_optional_int_data_(value); end - function write_record_with_optional_vector_data_(obj, value) - obj.writer_.write_record_with_optional_vector_data(value); - obj.mock_writer_.expect_write_record_with_optional_vector_data_(value); + function write_record_with_optional_vector_data_(self, value) + self.writer_.write_record_with_optional_vector_data(value); + self.mock_writer_.expect_write_record_with_optional_vector_data_(value); end - function write_fixed_vector_(obj, value) - obj.writer_.write_fixed_vector(value); - obj.mock_writer_.expect_write_fixed_vector_(value); + function write_fixed_vector_(self, value) + self.writer_.write_fixed_vector(value); + self.mock_writer_.expect_write_fixed_vector_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -90,7 +90,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestStringsWriter.m b/matlab/generated/+test_model/+testing/TestStringsWriter.m index 4587d767..9b7e8b01 100644 --- a/matlab/generated/+test_model/+testing/TestStringsWriter.m +++ b/matlab/generated/+test_model/+testing/TestStringsWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestStringsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockStringsWriter(testCase); - obj.close_called_ = false; + function self = TestStringsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockStringsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestStringsWriter' to verify mocks")); end @@ -30,29 +30,29 @@ function delete(obj) end methods (Access=protected) - function write_single_string_(obj, value) - obj.writer_.write_single_string(value); - obj.mock_writer_.expect_write_single_string_(value); + function write_single_string_(self, value) + self.writer_.write_single_string(value); + self.mock_writer_.expect_write_single_string_(value); end - function write_rec_with_string_(obj, value) - obj.writer_.write_rec_with_string(value); - obj.mock_writer_.expect_write_rec_with_string_(value); + function write_rec_with_string_(self, value) + self.writer_.write_rec_with_string(value); + self.mock_writer_.expect_write_rec_with_string_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -60,7 +60,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m b/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m index 38c2ac15..d49337e4 100644 --- a/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m +++ b/matlab/generated/+test_model/+testing/TestSubarraysInRecordsWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestSubarraysInRecordsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockSubarraysInRecordsWriter(testCase); - obj.close_called_ = false; + function self = TestSubarraysInRecordsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockSubarraysInRecordsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestSubarraysInRecordsWriter' to verify mocks")); end @@ -30,29 +30,29 @@ function delete(obj) end methods (Access=protected) - function write_with_fixed_subarrays_(obj, value) - obj.writer_.write_with_fixed_subarrays(value); - obj.mock_writer_.expect_write_with_fixed_subarrays_(value); + function write_with_fixed_subarrays_(self, value) + self.writer_.write_with_fixed_subarrays(value); + self.mock_writer_.expect_write_with_fixed_subarrays_(value); end - function write_with_vlen_subarrays_(obj, value) - obj.writer_.write_with_vlen_subarrays(value); - obj.mock_writer_.expect_write_with_vlen_subarrays_(value); + function write_with_vlen_subarrays_(self, value) + self.writer_.write_with_vlen_subarrays(value); + self.mock_writer_.expect_write_with_vlen_subarrays_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -60,7 +60,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestSubarraysWriter.m b/matlab/generated/+test_model/+testing/TestSubarraysWriter.m index 98ede257..1774d956 100644 --- a/matlab/generated/+test_model/+testing/TestSubarraysWriter.m +++ b/matlab/generated/+test_model/+testing/TestSubarraysWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestSubarraysWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockSubarraysWriter(testCase); - obj.close_called_ = false; + function self = TestSubarraysWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockSubarraysWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestSubarraysWriter' to verify mocks")); end @@ -30,64 +30,64 @@ function delete(obj) end methods (Access=protected) - function write_dynamic_with_fixed_int_subarray_(obj, value) - obj.writer_.write_dynamic_with_fixed_int_subarray(value); - obj.mock_writer_.expect_write_dynamic_with_fixed_int_subarray_(value); + function write_dynamic_with_fixed_int_subarray_(self, value) + self.writer_.write_dynamic_with_fixed_int_subarray(value); + self.mock_writer_.expect_write_dynamic_with_fixed_int_subarray_(value); end - function write_dynamic_with_fixed_float_subarray_(obj, value) - obj.writer_.write_dynamic_with_fixed_float_subarray(value); - obj.mock_writer_.expect_write_dynamic_with_fixed_float_subarray_(value); + function write_dynamic_with_fixed_float_subarray_(self, value) + self.writer_.write_dynamic_with_fixed_float_subarray(value); + self.mock_writer_.expect_write_dynamic_with_fixed_float_subarray_(value); end - function write_known_dim_count_with_fixed_int_subarray_(obj, value) - obj.writer_.write_known_dim_count_with_fixed_int_subarray(value); - obj.mock_writer_.expect_write_known_dim_count_with_fixed_int_subarray_(value); + function write_known_dim_count_with_fixed_int_subarray_(self, value) + self.writer_.write_known_dim_count_with_fixed_int_subarray(value); + self.mock_writer_.expect_write_known_dim_count_with_fixed_int_subarray_(value); end - function write_known_dim_count_with_fixed_float_subarray_(obj, value) - obj.writer_.write_known_dim_count_with_fixed_float_subarray(value); - obj.mock_writer_.expect_write_known_dim_count_with_fixed_float_subarray_(value); + function write_known_dim_count_with_fixed_float_subarray_(self, value) + self.writer_.write_known_dim_count_with_fixed_float_subarray(value); + self.mock_writer_.expect_write_known_dim_count_with_fixed_float_subarray_(value); end - function write_fixed_with_fixed_int_subarray_(obj, value) - obj.writer_.write_fixed_with_fixed_int_subarray(value); - obj.mock_writer_.expect_write_fixed_with_fixed_int_subarray_(value); + function write_fixed_with_fixed_int_subarray_(self, value) + self.writer_.write_fixed_with_fixed_int_subarray(value); + self.mock_writer_.expect_write_fixed_with_fixed_int_subarray_(value); end - function write_fixed_with_fixed_float_subarray_(obj, value) - obj.writer_.write_fixed_with_fixed_float_subarray(value); - obj.mock_writer_.expect_write_fixed_with_fixed_float_subarray_(value); + function write_fixed_with_fixed_float_subarray_(self, value) + self.writer_.write_fixed_with_fixed_float_subarray(value); + self.mock_writer_.expect_write_fixed_with_fixed_float_subarray_(value); end - function write_nested_subarray_(obj, value) - obj.writer_.write_nested_subarray(value); - obj.mock_writer_.expect_write_nested_subarray_(value); + function write_nested_subarray_(self, value) + self.writer_.write_nested_subarray(value); + self.mock_writer_.expect_write_nested_subarray_(value); end - function write_dynamic_with_fixed_vector_subarray_(obj, value) - obj.writer_.write_dynamic_with_fixed_vector_subarray(value); - obj.mock_writer_.expect_write_dynamic_with_fixed_vector_subarray_(value); + function write_dynamic_with_fixed_vector_subarray_(self, value) + self.writer_.write_dynamic_with_fixed_vector_subarray(value); + self.mock_writer_.expect_write_dynamic_with_fixed_vector_subarray_(value); end - function write_generic_subarray_(obj, value) - obj.writer_.write_generic_subarray(value); - obj.mock_writer_.expect_write_generic_subarray_(value); + function write_generic_subarray_(self, value) + self.writer_.write_generic_subarray(value); + self.mock_writer_.expect_write_generic_subarray_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -95,7 +95,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestUnionsWriter.m b/matlab/generated/+test_model/+testing/TestUnionsWriter.m index 90e25dce..e4018521 100644 --- a/matlab/generated/+test_model/+testing/TestUnionsWriter.m +++ b/matlab/generated/+test_model/+testing/TestUnionsWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestUnionsWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockUnionsWriter(testCase); - obj.close_called_ = false; + function self = TestUnionsWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockUnionsWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestUnionsWriter' to verify mocks")); end @@ -30,39 +30,39 @@ function delete(obj) end methods (Access=protected) - function write_int_or_simple_record_(obj, value) - obj.writer_.write_int_or_simple_record(value); - obj.mock_writer_.expect_write_int_or_simple_record_(value); + function write_int_or_simple_record_(self, value) + self.writer_.write_int_or_simple_record(value); + self.mock_writer_.expect_write_int_or_simple_record_(value); end - function write_int_or_record_with_vlens_(obj, value) - obj.writer_.write_int_or_record_with_vlens(value); - obj.mock_writer_.expect_write_int_or_record_with_vlens_(value); + function write_int_or_record_with_vlens_(self, value) + self.writer_.write_int_or_record_with_vlens(value); + self.mock_writer_.expect_write_int_or_record_with_vlens_(value); end - function write_monosotate_or_int_or_simple_record_(obj, value) - obj.writer_.write_monosotate_or_int_or_simple_record(value); - obj.mock_writer_.expect_write_monosotate_or_int_or_simple_record_(value); + function write_monosotate_or_int_or_simple_record_(self, value) + self.writer_.write_monosotate_or_int_or_simple_record(value); + self.mock_writer_.expect_write_monosotate_or_int_or_simple_record_(value); end - function write_record_with_unions_(obj, value) - obj.writer_.write_record_with_unions(value); - obj.mock_writer_.expect_write_record_with_unions_(value); + function write_record_with_unions_(self, value) + self.writer_.write_record_with_unions(value); + self.mock_writer_.expect_write_record_with_unions_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -70,7 +70,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/+testing/TestVlensWriter.m b/matlab/generated/+test_model/+testing/TestVlensWriter.m index 0b389af0..3f27ee3e 100644 --- a/matlab/generated/+test_model/+testing/TestVlensWriter.m +++ b/matlab/generated/+test_model/+testing/TestVlensWriter.m @@ -11,18 +11,18 @@ end methods - function obj = TestVlensWriter(testCase, format, create_writer, create_reader) - obj.filename_ = tempname(); - obj.format_ = format; - obj.writer_ = create_writer(obj.filename_); - obj.create_reader_ = create_reader; - obj.mock_writer_ = test_model.testing.MockVlensWriter(testCase); - obj.close_called_ = false; + function self = TestVlensWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockVlensWriter(testCase); + self.close_called_ = false; end - function delete(obj) - delete(obj.filename_); - if ~obj.close_called_ + function delete(self) + delete(self.filename_); + if ~self.close_called_ % ADD_FAILURE() << ...; throw(yardl.RuntimeError("Close() must be called on 'TestVlensWriter' to verify mocks")); end @@ -30,39 +30,39 @@ function delete(obj) end methods (Access=protected) - function write_int_vector_(obj, value) - obj.writer_.write_int_vector(value); - obj.mock_writer_.expect_write_int_vector_(value); + function write_int_vector_(self, value) + self.writer_.write_int_vector(value); + self.mock_writer_.expect_write_int_vector_(value); end - function write_complex_vector_(obj, value) - obj.writer_.write_complex_vector(value); - obj.mock_writer_.expect_write_complex_vector_(value); + function write_complex_vector_(self, value) + self.writer_.write_complex_vector(value); + self.mock_writer_.expect_write_complex_vector_(value); end - function write_record_with_vlens_(obj, value) - obj.writer_.write_record_with_vlens(value); - obj.mock_writer_.expect_write_record_with_vlens_(value); + function write_record_with_vlens_(self, value) + self.writer_.write_record_with_vlens(value); + self.mock_writer_.expect_write_record_with_vlens_(value); end - function write_vlen_of_record_with_vlens_(obj, value) - obj.writer_.write_vlen_of_record_with_vlens(value); - obj.mock_writer_.expect_write_vlen_of_record_with_vlens_(value); + function write_vlen_of_record_with_vlens_(self, value) + self.writer_.write_vlen_of_record_with_vlens(value); + self.mock_writer_.expect_write_vlen_of_record_with_vlens_(value); end - function close_(obj) - obj.close_called_ = true; - obj.writer_.close(); - mock_copy = copy(obj.mock_writer_); + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); - reader = obj.create_reader_(obj.filename_); - reader.copy_to(obj.mock_writer_); + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); reader.close(); - obj.mock_writer_.verify(); - obj.mock_writer_.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); - translated = invoke_translator(obj.filename_, obj.format_, obj.format_); - reader = obj.create_reader_(translated); + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); reader.copy_to(mock_copy); reader.close(); mock_copy.verify(); @@ -70,7 +70,7 @@ function close_(obj) delete(translated); end - function end_stream_(obj) + function end_stream_(self) end end end diff --git a/matlab/generated/+test_model/AcquisitionOrImage.m b/matlab/generated/+test_model/AcquisitionOrImage.m index 749f6c7f..9a464604 100644 --- a/matlab/generated/+test_model/AcquisitionOrImage.m +++ b/matlab/generated/+test_model/AcquisitionOrImage.m @@ -25,6 +25,14 @@ end methods + function res = isAcquisition(self) + res = self.index == 1; + end + + function res = isImage(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'test_model.AcquisitionOrImage') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/AdvancedGenericsReaderBase.m b/matlab/generated/+test_model/AdvancedGenericsReaderBase.m index 124cb299..d0de2026 100644 --- a/matlab/generated/+test_model/AdvancedGenericsReaderBase.m +++ b/matlab/generated/+test_model/AdvancedGenericsReaderBase.m @@ -6,74 +6,74 @@ end methods - function obj = AdvancedGenericsReaderBase() - obj.state_ = 0; + function self = AdvancedGenericsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 5 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 5 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_float_image_image(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_float_image_image(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_float_image_image_(); - obj.state_ = 1; + value = self.read_float_image_image_(); + self.state_ = 1; end % Ordinal 1 - function value = read_generic_record_1(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_generic_record_1(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_generic_record_1_(); - obj.state_ = 2; + value = self.read_generic_record_1_(); + self.state_ = 2; end % Ordinal 2 - function value = read_tuple_of_optionals(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_tuple_of_optionals(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_tuple_of_optionals_(); - obj.state_ = 3; + value = self.read_tuple_of_optionals_(); + self.state_ = 3; end % Ordinal 3 - function value = read_tuple_of_optionals_alternate_syntax(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function value = read_tuple_of_optionals_alternate_syntax(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - value = obj.read_tuple_of_optionals_alternate_syntax_(); - obj.state_ = 4; + value = self.read_tuple_of_optionals_alternate_syntax_(); + self.state_ = 4; end % Ordinal 4 - function value = read_tuple_of_vectors(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + function value = read_tuple_of_vectors(self) + if self.state_ ~= 4 + self.raise_unexpected_state_(4); end - value = obj.read_tuple_of_vectors_(); - obj.state_ = 5; + value = self.read_tuple_of_vectors_(); + self.state_ = 5; end - function copy_to(obj, writer) - writer.write_float_image_image(obj.read_float_image_image()); - writer.write_generic_record_1(obj.read_generic_record_1()); - writer.write_tuple_of_optionals(obj.read_tuple_of_optionals()); - writer.write_tuple_of_optionals_alternate_syntax(obj.read_tuple_of_optionals_alternate_syntax()); - writer.write_tuple_of_vectors(obj.read_tuple_of_vectors()); + function copy_to(self, writer) + writer.write_float_image_image(self.read_float_image_image()); + writer.write_generic_record_1(self.read_generic_record_1()); + writer.write_tuple_of_optionals(self.read_tuple_of_optionals()); + writer.write_tuple_of_optionals_alternate_syntax(self.read_tuple_of_optionals_alternate_syntax()); + writer.write_tuple_of_vectors(self.read_tuple_of_vectors()); end end @@ -84,35 +84,35 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_float_image_image_(obj) - read_generic_record_1_(obj) - read_tuple_of_optionals_(obj) - read_tuple_of_optionals_alternate_syntax_(obj) - read_tuple_of_vectors_(obj) + read_float_image_image_(self) + read_generic_record_1_(self) + read_tuple_of_optionals_(self) + read_tuple_of_optionals_alternate_syntax_(self) + read_tuple_of_vectors_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_float_image_image'; + name = "read_float_image_image"; elseif state == 1 - name = 'read_generic_record_1'; + name = "read_generic_record_1"; elseif state == 2 - name = 'read_tuple_of_optionals'; + name = "read_tuple_of_optionals"; elseif state == 3 - name = 'read_tuple_of_optionals_alternate_syntax'; + name = "read_tuple_of_optionals_alternate_syntax"; elseif state == 4 - name = 'read_tuple_of_vectors'; + name = "read_tuple_of_vectors"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/AdvancedGenericsWriterBase.m b/matlab/generated/+test_model/AdvancedGenericsWriterBase.m index b492e163..c62c2188 100644 --- a/matlab/generated/+test_model/AdvancedGenericsWriterBase.m +++ b/matlab/generated/+test_model/AdvancedGenericsWriterBase.m @@ -7,66 +7,66 @@ end methods - function obj = AdvancedGenericsWriterBase() - obj.state_ = 0; + function self = AdvancedGenericsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 5 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 5 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_float_image_image(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_float_image_image(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_float_image_image_(value); - obj.state_ = 1; + self.write_float_image_image_(value); + self.state_ = 1; end % Ordinal 1 - function write_generic_record_1(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_generic_record_1(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_generic_record_1_(value); - obj.state_ = 2; + self.write_generic_record_1_(value); + self.state_ = 2; end % Ordinal 2 - function write_tuple_of_optionals(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_tuple_of_optionals(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_tuple_of_optionals_(value); - obj.state_ = 3; + self.write_tuple_of_optionals_(value); + self.state_ = 3; end % Ordinal 3 - function write_tuple_of_optionals_alternate_syntax(obj, value) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function write_tuple_of_optionals_alternate_syntax(self, value) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - obj.write_tuple_of_optionals_alternate_syntax_(value); - obj.state_ = 4; + self.write_tuple_of_optionals_alternate_syntax_(value); + self.state_ = 4; end % Ordinal 4 - function write_tuple_of_vectors(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + function write_tuple_of_vectors(self, value) + if self.state_ ~= 4 + self.raise_unexpected_state_(4); end - obj.write_tuple_of_vectors_(value); - obj.state_ = 5; + self.write_tuple_of_vectors_(value); + self.state_ = 5; end end @@ -77,34 +77,34 @@ function write_tuple_of_vectors(obj, value) end methods (Abstract, Access=protected) - write_float_image_image_(obj, value) - write_generic_record_1_(obj, value) - write_tuple_of_optionals_(obj, value) - write_tuple_of_optionals_alternate_syntax_(obj, value) - write_tuple_of_vectors_(obj, value) - - end_stream_(obj) - close_(obj) + write_float_image_image_(self, value) + write_generic_record_1_(self, value) + write_tuple_of_optionals_(self, value) + write_tuple_of_optionals_alternate_syntax_(self, value) + write_tuple_of_vectors_(self, value) + + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_float_image_image'; + name = "write_float_image_image"; elseif state == 1 - name = 'write_generic_record_1'; + name = "write_generic_record_1"; elseif state == 2 - name = 'write_tuple_of_optionals'; + name = "write_tuple_of_optionals"; elseif state == 3 - name = 'write_tuple_of_optionals_alternate_syntax'; + name = "write_tuple_of_optionals_alternate_syntax"; elseif state == 4 - name = 'write_tuple_of_vectors'; + name = "write_tuple_of_vectors"; else name = ''; end diff --git a/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m b/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m index a72db99d..edd8bc17 100644 --- a/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m +++ b/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m @@ -25,6 +25,14 @@ end methods + function res = isInt32(self) + res = self.index == 1; + end + + function res = isSimpleRecord(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'test_model.AliasedIntOrSimpleRecord') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/AliasedMultiGenericOptional.m b/matlab/generated/+test_model/AliasedMultiGenericOptional.m index 7619c5d9..ca211257 100644 --- a/matlab/generated/+test_model/AliasedMultiGenericOptional.m +++ b/matlab/generated/+test_model/AliasedMultiGenericOptional.m @@ -25,6 +25,14 @@ end methods + function res = isT(self) + res = self.index == 1; + end + + function res = isU(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'test_model.AliasedMultiGenericOptional') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m b/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m index 71c24fc1..22f3420a 100644 --- a/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m +++ b/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m @@ -25,6 +25,14 @@ end methods + function res = isInt32(self) + res = self.index == 1; + end + + function res = isSimpleRecord(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'test_model.AliasedNullableIntSimpleRecord') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/AliasedOptional.m b/matlab/generated/+test_model/AliasedOptional.m index fce1bd99..3ec56142 100644 --- a/matlab/generated/+test_model/AliasedOptional.m +++ b/matlab/generated/+test_model/AliasedOptional.m @@ -1,6 +1,8 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. function o = AliasedOptional(value) - assert(isa(value, 'int32')); + arguments + value int32 + end o = yardl.Optional(value); end diff --git a/matlab/generated/+test_model/AliasesReaderBase.m b/matlab/generated/+test_model/AliasesReaderBase.m index 1684481d..20a783ae 100644 --- a/matlab/generated/+test_model/AliasesReaderBase.m +++ b/matlab/generated/+test_model/AliasesReaderBase.m @@ -6,140 +6,140 @@ end methods - function obj = AliasesReaderBase() - obj.state_ = 0; + function self = AliasesReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 10 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 10 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_aliased_string(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_aliased_string(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_aliased_string_(); - obj.state_ = 1; + value = self.read_aliased_string_(); + self.state_ = 1; end % Ordinal 1 - function value = read_aliased_enum(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_aliased_enum(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_aliased_enum_(); - obj.state_ = 2; + value = self.read_aliased_enum_(); + self.state_ = 2; end % Ordinal 2 - function value = read_aliased_open_generic(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_aliased_open_generic(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_aliased_open_generic_(); - obj.state_ = 3; + value = self.read_aliased_open_generic_(); + self.state_ = 3; end % Ordinal 3 - function value = read_aliased_closed_generic(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function value = read_aliased_closed_generic(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - value = obj.read_aliased_closed_generic_(); - obj.state_ = 4; + value = self.read_aliased_closed_generic_(); + self.state_ = 4; end % Ordinal 4 - function value = read_aliased_optional(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + function value = read_aliased_optional(self) + if self.state_ ~= 4 + self.raise_unexpected_state_(4); end - value = obj.read_aliased_optional_(); - obj.state_ = 5; + value = self.read_aliased_optional_(); + self.state_ = 5; end % Ordinal 5 - function value = read_aliased_generic_optional(obj) - if obj.state_ ~= 5 - obj.raise_unexpected_state_(5); + function value = read_aliased_generic_optional(self) + if self.state_ ~= 5 + self.raise_unexpected_state_(5); end - value = obj.read_aliased_generic_optional_(); - obj.state_ = 6; + value = self.read_aliased_generic_optional_(); + self.state_ = 6; end % Ordinal 6 - function value = read_aliased_generic_union_2(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + function value = read_aliased_generic_union_2(self) + if self.state_ ~= 6 + self.raise_unexpected_state_(6); end - value = obj.read_aliased_generic_union_2_(); - obj.state_ = 7; + value = self.read_aliased_generic_union_2_(); + self.state_ = 7; end % Ordinal 7 - function value = read_aliased_generic_vector(obj) - if obj.state_ ~= 7 - obj.raise_unexpected_state_(7); + function value = read_aliased_generic_vector(self) + if self.state_ ~= 7 + self.raise_unexpected_state_(7); end - value = obj.read_aliased_generic_vector_(); - obj.state_ = 8; + value = self.read_aliased_generic_vector_(); + self.state_ = 8; end % Ordinal 8 - function value = read_aliased_generic_fixed_vector(obj) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + function value = read_aliased_generic_fixed_vector(self) + if self.state_ ~= 8 + self.raise_unexpected_state_(8); end - value = obj.read_aliased_generic_fixed_vector_(); - obj.state_ = 9; + value = self.read_aliased_generic_fixed_vector_(); + self.state_ = 9; end % Ordinal 9 - function more = has_stream_of_aliased_generic_union_2(obj) - if obj.state_ ~= 9 - obj.raise_unexpected_state_(9); + function more = has_stream_of_aliased_generic_union_2(self) + if self.state_ ~= 9 + self.raise_unexpected_state_(9); end - more = obj.has_stream_of_aliased_generic_union_2_(); + more = self.has_stream_of_aliased_generic_union_2_(); if ~more - obj.state_ = 10; + self.state_ = 10; end end - function value = read_stream_of_aliased_generic_union_2(obj) - if obj.state_ ~= 9 - obj.raise_unexpected_state_(9); + function value = read_stream_of_aliased_generic_union_2(self) + if self.state_ ~= 9 + self.raise_unexpected_state_(9); end - value = obj.read_stream_of_aliased_generic_union_2_(); - end - - function copy_to(obj, writer) - writer.write_aliased_string(obj.read_aliased_string()); - writer.write_aliased_enum(obj.read_aliased_enum()); - writer.write_aliased_open_generic(obj.read_aliased_open_generic()); - writer.write_aliased_closed_generic(obj.read_aliased_closed_generic()); - writer.write_aliased_optional(obj.read_aliased_optional()); - writer.write_aliased_generic_optional(obj.read_aliased_generic_optional()); - writer.write_aliased_generic_union_2(obj.read_aliased_generic_union_2()); - writer.write_aliased_generic_vector(obj.read_aliased_generic_vector()); - writer.write_aliased_generic_fixed_vector(obj.read_aliased_generic_fixed_vector()); - while obj.has_stream_of_aliased_generic_union_2() - item = obj.read_stream_of_aliased_generic_union_2(); + value = self.read_stream_of_aliased_generic_union_2_(); + end + + function copy_to(self, writer) + writer.write_aliased_string(self.read_aliased_string()); + writer.write_aliased_enum(self.read_aliased_enum()); + writer.write_aliased_open_generic(self.read_aliased_open_generic()); + writer.write_aliased_closed_generic(self.read_aliased_closed_generic()); + writer.write_aliased_optional(self.read_aliased_optional()); + writer.write_aliased_generic_optional(self.read_aliased_generic_optional()); + writer.write_aliased_generic_union_2(self.read_aliased_generic_union_2()); + writer.write_aliased_generic_vector(self.read_aliased_generic_vector()); + writer.write_aliased_generic_fixed_vector(self.read_aliased_generic_fixed_vector()); + while self.has_stream_of_aliased_generic_union_2() + item = self.read_stream_of_aliased_generic_union_2(); writer.write_stream_of_aliased_generic_union_2({item}); end writer.end_stream_of_aliased_generic_union_2(); @@ -153,51 +153,51 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_aliased_string_(obj) - read_aliased_enum_(obj) - read_aliased_open_generic_(obj) - read_aliased_closed_generic_(obj) - read_aliased_optional_(obj) - read_aliased_generic_optional_(obj) - read_aliased_generic_union_2_(obj) - read_aliased_generic_vector_(obj) - read_aliased_generic_fixed_vector_(obj) - has_stream_of_aliased_generic_union_2_(obj) - read_stream_of_aliased_generic_union_2_(obj) - - close_(obj) + read_aliased_string_(self) + read_aliased_enum_(self) + read_aliased_open_generic_(self) + read_aliased_closed_generic_(self) + read_aliased_optional_(self) + read_aliased_generic_optional_(self) + read_aliased_generic_union_2_(self) + read_aliased_generic_vector_(self) + read_aliased_generic_fixed_vector_(self) + has_stream_of_aliased_generic_union_2_(self) + read_stream_of_aliased_generic_union_2_(self) + + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_aliased_string'; + name = "read_aliased_string"; elseif state == 1 - name = 'read_aliased_enum'; + name = "read_aliased_enum"; elseif state == 2 - name = 'read_aliased_open_generic'; + name = "read_aliased_open_generic"; elseif state == 3 - name = 'read_aliased_closed_generic'; + name = "read_aliased_closed_generic"; elseif state == 4 - name = 'read_aliased_optional'; + name = "read_aliased_optional"; elseif state == 5 - name = 'read_aliased_generic_optional'; + name = "read_aliased_generic_optional"; elseif state == 6 - name = 'read_aliased_generic_union_2'; + name = "read_aliased_generic_union_2"; elseif state == 7 - name = 'read_aliased_generic_vector'; + name = "read_aliased_generic_vector"; elseif state == 8 - name = 'read_aliased_generic_fixed_vector'; + name = "read_aliased_generic_fixed_vector"; elseif state == 9 - name = 'read_stream_of_aliased_generic_union_2'; + name = "read_stream_of_aliased_generic_union_2"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/AliasesWriterBase.m b/matlab/generated/+test_model/AliasesWriterBase.m index ca413e8d..2ac21fc5 100644 --- a/matlab/generated/+test_model/AliasesWriterBase.m +++ b/matlab/generated/+test_model/AliasesWriterBase.m @@ -7,124 +7,124 @@ end methods - function obj = AliasesWriterBase() - obj.state_ = 0; + function self = AliasesWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 10 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 10 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_aliased_string(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_aliased_string(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_aliased_string_(value); - obj.state_ = 1; + self.write_aliased_string_(value); + self.state_ = 1; end % Ordinal 1 - function write_aliased_enum(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_aliased_enum(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_aliased_enum_(value); - obj.state_ = 2; + self.write_aliased_enum_(value); + self.state_ = 2; end % Ordinal 2 - function write_aliased_open_generic(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_aliased_open_generic(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_aliased_open_generic_(value); - obj.state_ = 3; + self.write_aliased_open_generic_(value); + self.state_ = 3; end % Ordinal 3 - function write_aliased_closed_generic(obj, value) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function write_aliased_closed_generic(self, value) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - obj.write_aliased_closed_generic_(value); - obj.state_ = 4; + self.write_aliased_closed_generic_(value); + self.state_ = 4; end % Ordinal 4 - function write_aliased_optional(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + function write_aliased_optional(self, value) + if self.state_ ~= 4 + self.raise_unexpected_state_(4); end - obj.write_aliased_optional_(value); - obj.state_ = 5; + self.write_aliased_optional_(value); + self.state_ = 5; end % Ordinal 5 - function write_aliased_generic_optional(obj, value) - if obj.state_ ~= 5 - obj.raise_unexpected_state_(5); + function write_aliased_generic_optional(self, value) + if self.state_ ~= 5 + self.raise_unexpected_state_(5); end - obj.write_aliased_generic_optional_(value); - obj.state_ = 6; + self.write_aliased_generic_optional_(value); + self.state_ = 6; end % Ordinal 6 - function write_aliased_generic_union_2(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + function write_aliased_generic_union_2(self, value) + if self.state_ ~= 6 + self.raise_unexpected_state_(6); end - obj.write_aliased_generic_union_2_(value); - obj.state_ = 7; + self.write_aliased_generic_union_2_(value); + self.state_ = 7; end % Ordinal 7 - function write_aliased_generic_vector(obj, value) - if obj.state_ ~= 7 - obj.raise_unexpected_state_(7); + function write_aliased_generic_vector(self, value) + if self.state_ ~= 7 + self.raise_unexpected_state_(7); end - obj.write_aliased_generic_vector_(value); - obj.state_ = 8; + self.write_aliased_generic_vector_(value); + self.state_ = 8; end % Ordinal 8 - function write_aliased_generic_fixed_vector(obj, value) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + function write_aliased_generic_fixed_vector(self, value) + if self.state_ ~= 8 + self.raise_unexpected_state_(8); end - obj.write_aliased_generic_fixed_vector_(value); - obj.state_ = 9; + self.write_aliased_generic_fixed_vector_(value); + self.state_ = 9; end % Ordinal 9 - function write_stream_of_aliased_generic_union_2(obj, value) - if obj.state_ ~= 9 - obj.raise_unexpected_state_(9); + function write_stream_of_aliased_generic_union_2(self, value) + if self.state_ ~= 9 + self.raise_unexpected_state_(9); end - obj.write_stream_of_aliased_generic_union_2_(value); + self.write_stream_of_aliased_generic_union_2_(value); end - function end_stream_of_aliased_generic_union_2(obj) - if obj.state_ ~= 9 - obj.raise_unexpected_state_(9); + function end_stream_of_aliased_generic_union_2(self) + if self.state_ ~= 9 + self.raise_unexpected_state_(9); end - obj.end_stream_(); - obj.state_ = 10; + self.end_stream_(); + self.state_ = 10; end end @@ -135,49 +135,49 @@ function end_stream_of_aliased_generic_union_2(obj) end methods (Abstract, Access=protected) - write_aliased_string_(obj, value) - write_aliased_enum_(obj, value) - write_aliased_open_generic_(obj, value) - write_aliased_closed_generic_(obj, value) - write_aliased_optional_(obj, value) - write_aliased_generic_optional_(obj, value) - write_aliased_generic_union_2_(obj, value) - write_aliased_generic_vector_(obj, value) - write_aliased_generic_fixed_vector_(obj, value) - write_stream_of_aliased_generic_union_2_(obj, value) - - end_stream_(obj) - close_(obj) + write_aliased_string_(self, value) + write_aliased_enum_(self, value) + write_aliased_open_generic_(self, value) + write_aliased_closed_generic_(self, value) + write_aliased_optional_(self, value) + write_aliased_generic_optional_(self, value) + write_aliased_generic_union_2_(self, value) + write_aliased_generic_vector_(self, value) + write_aliased_generic_fixed_vector_(self, value) + write_stream_of_aliased_generic_union_2_(self, value) + + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_aliased_string'; + name = "write_aliased_string"; elseif state == 1 - name = 'write_aliased_enum'; + name = "write_aliased_enum"; elseif state == 2 - name = 'write_aliased_open_generic'; + name = "write_aliased_open_generic"; elseif state == 3 - name = 'write_aliased_closed_generic'; + name = "write_aliased_closed_generic"; elseif state == 4 - name = 'write_aliased_optional'; + name = "write_aliased_optional"; elseif state == 5 - name = 'write_aliased_generic_optional'; + name = "write_aliased_generic_optional"; elseif state == 6 - name = 'write_aliased_generic_union_2'; + name = "write_aliased_generic_union_2"; elseif state == 7 - name = 'write_aliased_generic_vector'; + name = "write_aliased_generic_vector"; elseif state == 8 - name = 'write_aliased_generic_fixed_vector'; + name = "write_aliased_generic_fixed_vector"; elseif state == 9 - name = 'write_stream_of_aliased_generic_union_2 or end_stream_of_aliased_generic_union_2'; + name = "write_stream_of_aliased_generic_union_2 or end_stream_of_aliased_generic_union_2"; else name = ''; end diff --git a/matlab/generated/+test_model/ArrayOrScalar.m b/matlab/generated/+test_model/ArrayOrScalar.m index 62ac2a6d..c8587b7c 100644 --- a/matlab/generated/+test_model/ArrayOrScalar.m +++ b/matlab/generated/+test_model/ArrayOrScalar.m @@ -25,6 +25,14 @@ end methods + function res = isArray(self) + res = self.index == 1; + end + + function res = isScalar(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'test_model.ArrayOrScalar') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m b/matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m index 4be1c4a4..e1d85eba 100644 --- a/matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m +++ b/matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m @@ -1,6 +1,8 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. function a = ArrayWithKeywordDimensionNames(array) - assert(isa(array, 'int32')); + arguments + array int32 + end a = array; end diff --git a/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m b/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m index 5870df86..80aa258a 100644 --- a/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkFloat256x256ReaderBase.m @@ -6,41 +6,41 @@ end methods - function obj = BenchmarkFloat256x256ReaderBase() - obj.state_ = 0; + function self = BenchmarkFloat256x256ReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function more = has_float256x256(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function more = has_float256x256(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - more = obj.has_float256x256_(); + more = self.has_float256x256_(); if ~more - obj.state_ = 1; + self.state_ = 1; end end - function value = read_float256x256(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_float256x256(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_float256x256_(); + value = self.read_float256x256_(); end - function copy_to(obj, writer) - while obj.has_float256x256() - item = obj.read_float256x256(); + function copy_to(self, writer) + while self.has_float256x256() + item = self.read_float256x256(); writer.write_float256x256({item}); end writer.end_float256x256(); @@ -54,24 +54,24 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - has_float256x256_(obj) - read_float256x256_(obj) + has_float256x256_(self) + read_float256x256_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_float256x256'; + name = "read_float256x256"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m b/matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m index 3a430a90..81128c89 100644 --- a/matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m +++ b/matlab/generated/+test_model/BenchmarkFloat256x256WriterBase.m @@ -7,34 +7,34 @@ end methods - function obj = BenchmarkFloat256x256WriterBase() - obj.state_ = 0; + function self = BenchmarkFloat256x256WriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_float256x256(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_float256x256(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_float256x256_(value); + self.write_float256x256_(value); end - function end_float256x256(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function end_float256x256(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.end_stream_(); - obj.state_ = 1; + self.end_stream_(); + self.state_ = 1; end end @@ -45,22 +45,22 @@ function end_float256x256(obj) end methods (Abstract, Access=protected) - write_float256x256_(obj, value) + write_float256x256_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_float256x256 or end_float256x256'; + name = "write_float256x256 or end_float256x256"; else name = ''; end diff --git a/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m b/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m index f5d77caa..f92c84c3 100644 --- a/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkFloatVlenReaderBase.m @@ -6,41 +6,41 @@ end methods - function obj = BenchmarkFloatVlenReaderBase() - obj.state_ = 0; + function self = BenchmarkFloatVlenReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function more = has_float_array(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function more = has_float_array(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - more = obj.has_float_array_(); + more = self.has_float_array_(); if ~more - obj.state_ = 1; + self.state_ = 1; end end - function value = read_float_array(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_float_array(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_float_array_(); + value = self.read_float_array_(); end - function copy_to(obj, writer) - while obj.has_float_array() - item = obj.read_float_array(); + function copy_to(self, writer) + while self.has_float_array() + item = self.read_float_array(); writer.write_float_array({item}); end writer.end_float_array(); @@ -54,24 +54,24 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - has_float_array_(obj) - read_float_array_(obj) + has_float_array_(self) + read_float_array_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_float_array'; + name = "read_float_array"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m b/matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m index de021dea..acb85a59 100644 --- a/matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m +++ b/matlab/generated/+test_model/BenchmarkFloatVlenWriterBase.m @@ -7,34 +7,34 @@ end methods - function obj = BenchmarkFloatVlenWriterBase() - obj.state_ = 0; + function self = BenchmarkFloatVlenWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_float_array(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_float_array(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_float_array_(value); + self.write_float_array_(value); end - function end_float_array(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function end_float_array(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.end_stream_(); - obj.state_ = 1; + self.end_stream_(); + self.state_ = 1; end end @@ -45,22 +45,22 @@ function end_float_array(obj) end methods (Abstract, Access=protected) - write_float_array_(obj, value) + write_float_array_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_float_array or end_float_array'; + name = "write_float_array or end_float_array"; else name = ''; end diff --git a/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m b/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m index 7f707c47..103766a0 100644 --- a/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkInt256x256ReaderBase.m @@ -6,41 +6,41 @@ end methods - function obj = BenchmarkInt256x256ReaderBase() - obj.state_ = 0; + function self = BenchmarkInt256x256ReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function more = has_int256x256(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function more = has_int256x256(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - more = obj.has_int256x256_(); + more = self.has_int256x256_(); if ~more - obj.state_ = 1; + self.state_ = 1; end end - function value = read_int256x256(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_int256x256(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_int256x256_(); + value = self.read_int256x256_(); end - function copy_to(obj, writer) - while obj.has_int256x256() - item = obj.read_int256x256(); + function copy_to(self, writer) + while self.has_int256x256() + item = self.read_int256x256(); writer.write_int256x256({item}); end writer.end_int256x256(); @@ -54,24 +54,24 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - has_int256x256_(obj) - read_int256x256_(obj) + has_int256x256_(self) + read_int256x256_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_int256x256'; + name = "read_int256x256"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m b/matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m index ea3a988d..ccf6c330 100644 --- a/matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m +++ b/matlab/generated/+test_model/BenchmarkInt256x256WriterBase.m @@ -7,34 +7,34 @@ end methods - function obj = BenchmarkInt256x256WriterBase() - obj.state_ = 0; + function self = BenchmarkInt256x256WriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_int256x256(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_int256x256(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_int256x256_(value); + self.write_int256x256_(value); end - function end_int256x256(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function end_int256x256(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.end_stream_(); - obj.state_ = 1; + self.end_stream_(); + self.state_ = 1; end end @@ -45,22 +45,22 @@ function end_int256x256(obj) end methods (Abstract, Access=protected) - write_int256x256_(obj, value) + write_int256x256_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_int256x256 or end_int256x256'; + name = "write_int256x256 or end_int256x256"; else name = ''; end diff --git a/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m b/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m index e97413e5..90ea028c 100644 --- a/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkSimpleMrdReaderBase.m @@ -6,41 +6,41 @@ end methods - function obj = BenchmarkSimpleMrdReaderBase() - obj.state_ = 0; + function self = BenchmarkSimpleMrdReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function more = has_data(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function more = has_data(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - more = obj.has_data_(); + more = self.has_data_(); if ~more - obj.state_ = 1; + self.state_ = 1; end end - function value = read_data(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_data(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_data_(); + value = self.read_data_(); end - function copy_to(obj, writer) - while obj.has_data() - item = obj.read_data(); + function copy_to(self, writer) + while self.has_data() + item = self.read_data(); writer.write_data({item}); end writer.end_data(); @@ -54,24 +54,24 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - has_data_(obj) - read_data_(obj) + has_data_(self) + read_data_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_data'; + name = "read_data"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m b/matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m index 63f1a7de..6d546b6b 100644 --- a/matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m +++ b/matlab/generated/+test_model/BenchmarkSimpleMrdWriterBase.m @@ -7,34 +7,34 @@ end methods - function obj = BenchmarkSimpleMrdWriterBase() - obj.state_ = 0; + function self = BenchmarkSimpleMrdWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_data(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_data(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_data_(value); + self.write_data_(value); end - function end_data(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function end_data(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.end_stream_(); - obj.state_ = 1; + self.end_stream_(); + self.state_ = 1; end end @@ -45,22 +45,22 @@ function end_data(obj) end methods (Abstract, Access=protected) - write_data_(obj, value) + write_data_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_data or end_data'; + name = "write_data or end_data"; else name = ''; end diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m index fc1260d4..f646f161 100644 --- a/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkSmallRecordReaderBase.m @@ -6,41 +6,41 @@ end methods - function obj = BenchmarkSmallRecordReaderBase() - obj.state_ = 0; + function self = BenchmarkSmallRecordReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function more = has_small_record(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function more = has_small_record(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - more = obj.has_small_record_(); + more = self.has_small_record_(); if ~more - obj.state_ = 1; + self.state_ = 1; end end - function value = read_small_record(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_small_record(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_small_record_(); + value = self.read_small_record_(); end - function copy_to(obj, writer) - while obj.has_small_record() - item = obj.read_small_record(); + function copy_to(self, writer) + while self.has_small_record() + item = self.read_small_record(); writer.write_small_record({item}); end writer.end_small_record(); @@ -54,24 +54,24 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - has_small_record_(obj) - read_small_record_(obj) + has_small_record_(self) + read_small_record_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_small_record'; + name = "read_small_record"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m index e44d05d8..09cd351f 100644 --- a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m +++ b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsReaderBase.m @@ -6,41 +6,41 @@ end methods - function obj = BenchmarkSmallRecordWithOptionalsReaderBase() - obj.state_ = 0; + function self = BenchmarkSmallRecordWithOptionalsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function more = has_small_record(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function more = has_small_record(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - more = obj.has_small_record_(); + more = self.has_small_record_(); if ~more - obj.state_ = 1; + self.state_ = 1; end end - function value = read_small_record(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_small_record(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_small_record_(); + value = self.read_small_record_(); end - function copy_to(obj, writer) - while obj.has_small_record() - item = obj.read_small_record(); + function copy_to(self, writer) + while self.has_small_record() + item = self.read_small_record(); writer.write_small_record({item}); end writer.end_small_record(); @@ -54,24 +54,24 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - has_small_record_(obj) - read_small_record_(obj) + has_small_record_(self) + read_small_record_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_small_record'; + name = "read_small_record"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m index a9b8a9f8..f486af50 100644 --- a/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m +++ b/matlab/generated/+test_model/BenchmarkSmallRecordWithOptionalsWriterBase.m @@ -7,34 +7,34 @@ end methods - function obj = BenchmarkSmallRecordWithOptionalsWriterBase() - obj.state_ = 0; + function self = BenchmarkSmallRecordWithOptionalsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_small_record(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_small_record(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_small_record_(value); + self.write_small_record_(value); end - function end_small_record(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function end_small_record(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.end_stream_(); - obj.state_ = 1; + self.end_stream_(); + self.state_ = 1; end end @@ -45,22 +45,22 @@ function end_small_record(obj) end methods (Abstract, Access=protected) - write_small_record_(obj, value) + write_small_record_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_small_record or end_small_record'; + name = "write_small_record or end_small_record"; else name = ''; end diff --git a/matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m b/matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m index 24844c3e..6bb9d83f 100644 --- a/matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m +++ b/matlab/generated/+test_model/BenchmarkSmallRecordWriterBase.m @@ -7,34 +7,34 @@ end methods - function obj = BenchmarkSmallRecordWriterBase() - obj.state_ = 0; + function self = BenchmarkSmallRecordWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_small_record(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_small_record(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_small_record_(value); + self.write_small_record_(value); end - function end_small_record(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function end_small_record(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.end_stream_(); - obj.state_ = 1; + self.end_stream_(); + self.state_ = 1; end end @@ -45,22 +45,22 @@ function end_small_record(obj) end methods (Abstract, Access=protected) - write_small_record_(obj, value) + write_small_record_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_small_record or end_small_record'; + name = "write_small_record or end_small_record"; else name = ''; end diff --git a/matlab/generated/+test_model/DynamicNDArraysReaderBase.m b/matlab/generated/+test_model/DynamicNDArraysReaderBase.m index 496272d5..3a02e898 100644 --- a/matlab/generated/+test_model/DynamicNDArraysReaderBase.m +++ b/matlab/generated/+test_model/DynamicNDArraysReaderBase.m @@ -6,63 +6,63 @@ end methods - function obj = DynamicNDArraysReaderBase() - obj.state_ = 0; + function self = DynamicNDArraysReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_ints(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_ints(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_ints_(); - obj.state_ = 1; + value = self.read_ints_(); + self.state_ = 1; end % Ordinal 1 - function value = read_simple_record_array(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_simple_record_array(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_simple_record_array_(); - obj.state_ = 2; + value = self.read_simple_record_array_(); + self.state_ = 2; end % Ordinal 2 - function value = read_record_with_vlens_array(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_record_with_vlens_array(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_record_with_vlens_array_(); - obj.state_ = 3; + value = self.read_record_with_vlens_array_(); + self.state_ = 3; end % Ordinal 3 - function value = read_record_with_dynamic_nd_arrays(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function value = read_record_with_dynamic_nd_arrays(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - value = obj.read_record_with_dynamic_nd_arrays_(); - obj.state_ = 4; + value = self.read_record_with_dynamic_nd_arrays_(); + self.state_ = 4; end - function copy_to(obj, writer) - writer.write_ints(obj.read_ints()); - writer.write_simple_record_array(obj.read_simple_record_array()); - writer.write_record_with_vlens_array(obj.read_record_with_vlens_array()); - writer.write_record_with_dynamic_nd_arrays(obj.read_record_with_dynamic_nd_arrays()); + function copy_to(self, writer) + writer.write_ints(self.read_ints()); + writer.write_simple_record_array(self.read_simple_record_array()); + writer.write_record_with_vlens_array(self.read_record_with_vlens_array()); + writer.write_record_with_dynamic_nd_arrays(self.read_record_with_dynamic_nd_arrays()); end end @@ -73,32 +73,32 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_ints_(obj) - read_simple_record_array_(obj) - read_record_with_vlens_array_(obj) - read_record_with_dynamic_nd_arrays_(obj) + read_ints_(self) + read_simple_record_array_(self) + read_record_with_vlens_array_(self) + read_record_with_dynamic_nd_arrays_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_ints'; + name = "read_ints"; elseif state == 1 - name = 'read_simple_record_array'; + name = "read_simple_record_array"; elseif state == 2 - name = 'read_record_with_vlens_array'; + name = "read_record_with_vlens_array"; elseif state == 3 - name = 'read_record_with_dynamic_nd_arrays'; + name = "read_record_with_dynamic_nd_arrays"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/DynamicNDArraysWriterBase.m b/matlab/generated/+test_model/DynamicNDArraysWriterBase.m index 0962508a..3dbbaf9e 100644 --- a/matlab/generated/+test_model/DynamicNDArraysWriterBase.m +++ b/matlab/generated/+test_model/DynamicNDArraysWriterBase.m @@ -7,56 +7,56 @@ end methods - function obj = DynamicNDArraysWriterBase() - obj.state_ = 0; + function self = DynamicNDArraysWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_ints(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_ints(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_ints_(value); - obj.state_ = 1; + self.write_ints_(value); + self.state_ = 1; end % Ordinal 1 - function write_simple_record_array(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_simple_record_array(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_simple_record_array_(value); - obj.state_ = 2; + self.write_simple_record_array_(value); + self.state_ = 2; end % Ordinal 2 - function write_record_with_vlens_array(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_record_with_vlens_array(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_record_with_vlens_array_(value); - obj.state_ = 3; + self.write_record_with_vlens_array_(value); + self.state_ = 3; end % Ordinal 3 - function write_record_with_dynamic_nd_arrays(obj, value) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function write_record_with_dynamic_nd_arrays(self, value) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - obj.write_record_with_dynamic_nd_arrays_(value); - obj.state_ = 4; + self.write_record_with_dynamic_nd_arrays_(value); + self.state_ = 4; end end @@ -67,31 +67,31 @@ function write_record_with_dynamic_nd_arrays(obj, value) end methods (Abstract, Access=protected) - write_ints_(obj, value) - write_simple_record_array_(obj, value) - write_record_with_vlens_array_(obj, value) - write_record_with_dynamic_nd_arrays_(obj, value) + write_ints_(self, value) + write_simple_record_array_(self, value) + write_record_with_vlens_array_(self, value) + write_record_with_dynamic_nd_arrays_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_ints'; + name = "write_ints"; elseif state == 1 - name = 'write_simple_record_array'; + name = "write_simple_record_array"; elseif state == 2 - name = 'write_record_with_vlens_array'; + name = "write_record_with_vlens_array"; elseif state == 3 - name = 'write_record_with_dynamic_nd_arrays'; + name = "write_record_with_dynamic_nd_arrays"; else name = ''; end diff --git a/matlab/generated/+test_model/EnumsReaderBase.m b/matlab/generated/+test_model/EnumsReaderBase.m index b42a931c..ec4da09a 100644 --- a/matlab/generated/+test_model/EnumsReaderBase.m +++ b/matlab/generated/+test_model/EnumsReaderBase.m @@ -6,52 +6,52 @@ end methods - function obj = EnumsReaderBase() - obj.state_ = 0; + function self = EnumsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 3 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 3 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_single(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_single(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_single_(); - obj.state_ = 1; + value = self.read_single_(); + self.state_ = 1; end % Ordinal 1 - function value = read_vec(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_vec(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_vec_(); - obj.state_ = 2; + value = self.read_vec_(); + self.state_ = 2; end % Ordinal 2 - function value = read_size(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_size(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_size_(); - obj.state_ = 3; + value = self.read_size_(); + self.state_ = 3; end - function copy_to(obj, writer) - writer.write_single(obj.read_single()); - writer.write_vec(obj.read_vec()); - writer.write_size(obj.read_size()); + function copy_to(self, writer) + writer.write_single(self.read_single()); + writer.write_vec(self.read_vec()); + writer.write_size(self.read_size()); end end @@ -62,29 +62,29 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_single_(obj) - read_vec_(obj) - read_size_(obj) + read_single_(self) + read_vec_(self) + read_size_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_single'; + name = "read_single"; elseif state == 1 - name = 'read_vec'; + name = "read_vec"; elseif state == 2 - name = 'read_size'; + name = "read_size"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/EnumsWriterBase.m b/matlab/generated/+test_model/EnumsWriterBase.m index 88b13d86..21e4267e 100644 --- a/matlab/generated/+test_model/EnumsWriterBase.m +++ b/matlab/generated/+test_model/EnumsWriterBase.m @@ -7,46 +7,46 @@ end methods - function obj = EnumsWriterBase() - obj.state_ = 0; + function self = EnumsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 3 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 3 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_single(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_single(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_single_(value); - obj.state_ = 1; + self.write_single_(value); + self.state_ = 1; end % Ordinal 1 - function write_vec(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_vec(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_vec_(value); - obj.state_ = 2; + self.write_vec_(value); + self.state_ = 2; end % Ordinal 2 - function write_size(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_size(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_size_(value); - obj.state_ = 3; + self.write_size_(value); + self.state_ = 3; end end @@ -57,28 +57,28 @@ function write_size(obj, value) end methods (Abstract, Access=protected) - write_single_(obj, value) - write_vec_(obj, value) - write_size_(obj, value) + write_single_(self, value) + write_vec_(self, value) + write_size_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_single'; + name = "write_single"; elseif state == 1 - name = 'write_vec'; + name = "write_vec"; elseif state == 2 - name = 'write_size'; + name = "write_size"; else name = ''; end diff --git a/matlab/generated/+test_model/FixedArraysReaderBase.m b/matlab/generated/+test_model/FixedArraysReaderBase.m index c1f53772..41944345 100644 --- a/matlab/generated/+test_model/FixedArraysReaderBase.m +++ b/matlab/generated/+test_model/FixedArraysReaderBase.m @@ -6,74 +6,74 @@ end methods - function obj = FixedArraysReaderBase() - obj.state_ = 0; + function self = FixedArraysReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 5 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 5 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_ints(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_ints(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_ints_(); - obj.state_ = 1; + value = self.read_ints_(); + self.state_ = 1; end % Ordinal 1 - function value = read_fixed_simple_record_array(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_fixed_simple_record_array(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_fixed_simple_record_array_(); - obj.state_ = 2; + value = self.read_fixed_simple_record_array_(); + self.state_ = 2; end % Ordinal 2 - function value = read_fixed_record_with_vlens_array(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_fixed_record_with_vlens_array(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_fixed_record_with_vlens_array_(); - obj.state_ = 3; + value = self.read_fixed_record_with_vlens_array_(); + self.state_ = 3; end % Ordinal 3 - function value = read_record_with_fixed_arrays(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function value = read_record_with_fixed_arrays(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - value = obj.read_record_with_fixed_arrays_(); - obj.state_ = 4; + value = self.read_record_with_fixed_arrays_(); + self.state_ = 4; end % Ordinal 4 - function value = read_named_array(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + function value = read_named_array(self) + if self.state_ ~= 4 + self.raise_unexpected_state_(4); end - value = obj.read_named_array_(); - obj.state_ = 5; + value = self.read_named_array_(); + self.state_ = 5; end - function copy_to(obj, writer) - writer.write_ints(obj.read_ints()); - writer.write_fixed_simple_record_array(obj.read_fixed_simple_record_array()); - writer.write_fixed_record_with_vlens_array(obj.read_fixed_record_with_vlens_array()); - writer.write_record_with_fixed_arrays(obj.read_record_with_fixed_arrays()); - writer.write_named_array(obj.read_named_array()); + function copy_to(self, writer) + writer.write_ints(self.read_ints()); + writer.write_fixed_simple_record_array(self.read_fixed_simple_record_array()); + writer.write_fixed_record_with_vlens_array(self.read_fixed_record_with_vlens_array()); + writer.write_record_with_fixed_arrays(self.read_record_with_fixed_arrays()); + writer.write_named_array(self.read_named_array()); end end @@ -84,35 +84,35 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_ints_(obj) - read_fixed_simple_record_array_(obj) - read_fixed_record_with_vlens_array_(obj) - read_record_with_fixed_arrays_(obj) - read_named_array_(obj) + read_ints_(self) + read_fixed_simple_record_array_(self) + read_fixed_record_with_vlens_array_(self) + read_record_with_fixed_arrays_(self) + read_named_array_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_ints'; + name = "read_ints"; elseif state == 1 - name = 'read_fixed_simple_record_array'; + name = "read_fixed_simple_record_array"; elseif state == 2 - name = 'read_fixed_record_with_vlens_array'; + name = "read_fixed_record_with_vlens_array"; elseif state == 3 - name = 'read_record_with_fixed_arrays'; + name = "read_record_with_fixed_arrays"; elseif state == 4 - name = 'read_named_array'; + name = "read_named_array"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/FixedArraysWriterBase.m b/matlab/generated/+test_model/FixedArraysWriterBase.m index d17e24a6..07543395 100644 --- a/matlab/generated/+test_model/FixedArraysWriterBase.m +++ b/matlab/generated/+test_model/FixedArraysWriterBase.m @@ -7,66 +7,66 @@ end methods - function obj = FixedArraysWriterBase() - obj.state_ = 0; + function self = FixedArraysWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 5 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 5 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_ints(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_ints(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_ints_(value); - obj.state_ = 1; + self.write_ints_(value); + self.state_ = 1; end % Ordinal 1 - function write_fixed_simple_record_array(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_fixed_simple_record_array(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_fixed_simple_record_array_(value); - obj.state_ = 2; + self.write_fixed_simple_record_array_(value); + self.state_ = 2; end % Ordinal 2 - function write_fixed_record_with_vlens_array(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_fixed_record_with_vlens_array(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_fixed_record_with_vlens_array_(value); - obj.state_ = 3; + self.write_fixed_record_with_vlens_array_(value); + self.state_ = 3; end % Ordinal 3 - function write_record_with_fixed_arrays(obj, value) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function write_record_with_fixed_arrays(self, value) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - obj.write_record_with_fixed_arrays_(value); - obj.state_ = 4; + self.write_record_with_fixed_arrays_(value); + self.state_ = 4; end % Ordinal 4 - function write_named_array(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + function write_named_array(self, value) + if self.state_ ~= 4 + self.raise_unexpected_state_(4); end - obj.write_named_array_(value); - obj.state_ = 5; + self.write_named_array_(value); + self.state_ = 5; end end @@ -77,34 +77,34 @@ function write_named_array(obj, value) end methods (Abstract, Access=protected) - write_ints_(obj, value) - write_fixed_simple_record_array_(obj, value) - write_fixed_record_with_vlens_array_(obj, value) - write_record_with_fixed_arrays_(obj, value) - write_named_array_(obj, value) - - end_stream_(obj) - close_(obj) + write_ints_(self, value) + write_fixed_simple_record_array_(self, value) + write_fixed_record_with_vlens_array_(self, value) + write_record_with_fixed_arrays_(self, value) + write_named_array_(self, value) + + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_ints'; + name = "write_ints"; elseif state == 1 - name = 'write_fixed_simple_record_array'; + name = "write_fixed_simple_record_array"; elseif state == 2 - name = 'write_fixed_record_with_vlens_array'; + name = "write_fixed_record_with_vlens_array"; elseif state == 3 - name = 'write_record_with_fixed_arrays'; + name = "write_record_with_fixed_arrays"; elseif state == 4 - name = 'write_named_array'; + name = "write_named_array"; else name = ''; end diff --git a/matlab/generated/+test_model/FixedVectorsReaderBase.m b/matlab/generated/+test_model/FixedVectorsReaderBase.m index f70fe945..a70601d0 100644 --- a/matlab/generated/+test_model/FixedVectorsReaderBase.m +++ b/matlab/generated/+test_model/FixedVectorsReaderBase.m @@ -6,63 +6,63 @@ end methods - function obj = FixedVectorsReaderBase() - obj.state_ = 0; + function self = FixedVectorsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_fixed_int_vector(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_fixed_int_vector(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_fixed_int_vector_(); - obj.state_ = 1; + value = self.read_fixed_int_vector_(); + self.state_ = 1; end % Ordinal 1 - function value = read_fixed_simple_record_vector(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_fixed_simple_record_vector(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_fixed_simple_record_vector_(); - obj.state_ = 2; + value = self.read_fixed_simple_record_vector_(); + self.state_ = 2; end % Ordinal 2 - function value = read_fixed_record_with_vlens_vector(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_fixed_record_with_vlens_vector(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_fixed_record_with_vlens_vector_(); - obj.state_ = 3; + value = self.read_fixed_record_with_vlens_vector_(); + self.state_ = 3; end % Ordinal 3 - function value = read_record_with_fixed_vectors(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function value = read_record_with_fixed_vectors(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - value = obj.read_record_with_fixed_vectors_(); - obj.state_ = 4; + value = self.read_record_with_fixed_vectors_(); + self.state_ = 4; end - function copy_to(obj, writer) - writer.write_fixed_int_vector(obj.read_fixed_int_vector()); - writer.write_fixed_simple_record_vector(obj.read_fixed_simple_record_vector()); - writer.write_fixed_record_with_vlens_vector(obj.read_fixed_record_with_vlens_vector()); - writer.write_record_with_fixed_vectors(obj.read_record_with_fixed_vectors()); + function copy_to(self, writer) + writer.write_fixed_int_vector(self.read_fixed_int_vector()); + writer.write_fixed_simple_record_vector(self.read_fixed_simple_record_vector()); + writer.write_fixed_record_with_vlens_vector(self.read_fixed_record_with_vlens_vector()); + writer.write_record_with_fixed_vectors(self.read_record_with_fixed_vectors()); end end @@ -73,32 +73,32 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_fixed_int_vector_(obj) - read_fixed_simple_record_vector_(obj) - read_fixed_record_with_vlens_vector_(obj) - read_record_with_fixed_vectors_(obj) + read_fixed_int_vector_(self) + read_fixed_simple_record_vector_(self) + read_fixed_record_with_vlens_vector_(self) + read_record_with_fixed_vectors_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_fixed_int_vector'; + name = "read_fixed_int_vector"; elseif state == 1 - name = 'read_fixed_simple_record_vector'; + name = "read_fixed_simple_record_vector"; elseif state == 2 - name = 'read_fixed_record_with_vlens_vector'; + name = "read_fixed_record_with_vlens_vector"; elseif state == 3 - name = 'read_record_with_fixed_vectors'; + name = "read_record_with_fixed_vectors"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/FixedVectorsWriterBase.m b/matlab/generated/+test_model/FixedVectorsWriterBase.m index a6cfb043..828e597c 100644 --- a/matlab/generated/+test_model/FixedVectorsWriterBase.m +++ b/matlab/generated/+test_model/FixedVectorsWriterBase.m @@ -7,56 +7,56 @@ end methods - function obj = FixedVectorsWriterBase() - obj.state_ = 0; + function self = FixedVectorsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_fixed_int_vector(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_fixed_int_vector(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_fixed_int_vector_(value); - obj.state_ = 1; + self.write_fixed_int_vector_(value); + self.state_ = 1; end % Ordinal 1 - function write_fixed_simple_record_vector(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_fixed_simple_record_vector(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_fixed_simple_record_vector_(value); - obj.state_ = 2; + self.write_fixed_simple_record_vector_(value); + self.state_ = 2; end % Ordinal 2 - function write_fixed_record_with_vlens_vector(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_fixed_record_with_vlens_vector(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_fixed_record_with_vlens_vector_(value); - obj.state_ = 3; + self.write_fixed_record_with_vlens_vector_(value); + self.state_ = 3; end % Ordinal 3 - function write_record_with_fixed_vectors(obj, value) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function write_record_with_fixed_vectors(self, value) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - obj.write_record_with_fixed_vectors_(value); - obj.state_ = 4; + self.write_record_with_fixed_vectors_(value); + self.state_ = 4; end end @@ -67,31 +67,31 @@ function write_record_with_fixed_vectors(obj, value) end methods (Abstract, Access=protected) - write_fixed_int_vector_(obj, value) - write_fixed_simple_record_vector_(obj, value) - write_fixed_record_with_vlens_vector_(obj, value) - write_record_with_fixed_vectors_(obj, value) + write_fixed_int_vector_(self, value) + write_fixed_simple_record_vector_(self, value) + write_fixed_record_with_vlens_vector_(self, value) + write_record_with_fixed_vectors_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_fixed_int_vector'; + name = "write_fixed_int_vector"; elseif state == 1 - name = 'write_fixed_simple_record_vector'; + name = "write_fixed_simple_record_vector"; elseif state == 2 - name = 'write_fixed_record_with_vlens_vector'; + name = "write_fixed_record_with_vlens_vector"; elseif state == 3 - name = 'write_record_with_fixed_vectors'; + name = "write_record_with_fixed_vectors"; else name = ''; end diff --git a/matlab/generated/+test_model/FlagsReaderBase.m b/matlab/generated/+test_model/FlagsReaderBase.m index 89114613..b88407d9 100644 --- a/matlab/generated/+test_model/FlagsReaderBase.m +++ b/matlab/generated/+test_model/FlagsReaderBase.m @@ -6,66 +6,66 @@ end methods - function obj = FlagsReaderBase() - obj.state_ = 0; + function self = FlagsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 2 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function more = has_days(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function more = has_days(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - more = obj.has_days_(); + more = self.has_days_(); if ~more - obj.state_ = 1; + self.state_ = 1; end end - function value = read_days(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_days(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_days_(); + value = self.read_days_(); end % Ordinal 1 - function more = has_formats(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function more = has_formats(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - more = obj.has_formats_(); + more = self.has_formats_(); if ~more - obj.state_ = 2; + self.state_ = 2; end end - function value = read_formats(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_formats(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_formats_(); + value = self.read_formats_(); end - function copy_to(obj, writer) - while obj.has_days() - item = obj.read_days(); + function copy_to(self, writer) + while self.has_days() + item = self.read_days(); writer.write_days({item}); end writer.end_days(); - while obj.has_formats() - item = obj.read_formats(); + while self.has_formats() + item = self.read_formats(); writer.write_formats({item}); end writer.end_formats(); @@ -79,28 +79,28 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - has_days_(obj) - read_days_(obj) - has_formats_(obj) - read_formats_(obj) + has_days_(self) + read_days_(self) + has_formats_(self) + read_formats_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_days'; + name = "read_days"; elseif state == 1 - name = 'read_formats'; + name = "read_formats"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/FlagsWriterBase.m b/matlab/generated/+test_model/FlagsWriterBase.m index b0d970cd..57842e28 100644 --- a/matlab/generated/+test_model/FlagsWriterBase.m +++ b/matlab/generated/+test_model/FlagsWriterBase.m @@ -7,52 +7,52 @@ end methods - function obj = FlagsWriterBase() - obj.state_ = 0; + function self = FlagsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 2 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_days(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_days(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_days_(value); + self.write_days_(value); end - function end_days(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function end_days(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.end_stream_(); - obj.state_ = 1; + self.end_stream_(); + self.state_ = 1; end % Ordinal 1 - function write_formats(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_formats(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_formats_(value); + self.write_formats_(value); end - function end_formats(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function end_formats(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.end_stream_(); - obj.state_ = 2; + self.end_stream_(); + self.state_ = 2; end end @@ -63,25 +63,25 @@ function end_formats(obj) end methods (Abstract, Access=protected) - write_days_(obj, value) - write_formats_(obj, value) + write_days_(self, value) + write_formats_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_days or end_days'; + name = "write_days or end_days"; elseif state == 1 - name = 'write_formats or end_formats'; + name = "write_formats or end_formats"; else name = ''; end diff --git a/matlab/generated/+test_model/GenericRecord.m b/matlab/generated/+test_model/GenericRecord.m index 9d9ebfd3..c23e56f5 100644 --- a/matlab/generated/+test_model/GenericRecord.m +++ b/matlab/generated/+test_model/GenericRecord.m @@ -9,24 +9,24 @@ end methods - function obj = GenericRecord(scalar_1, scalar_2, vector_1, image_2) - obj.scalar_1 = scalar_1; - obj.scalar_2 = scalar_2; - obj.vector_1 = vector_1; - obj.image_2 = image_2; + function self = GenericRecord(scalar_1, scalar_2, vector_1, image_2) + self.scalar_1 = scalar_1; + self.scalar_2 = scalar_2; + self.vector_1 = vector_1; + self.image_2 = image_2; end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.GenericRecord') && ... - isequal(obj.scalar_1, other.scalar_1) && ... - isequal(obj.scalar_2, other.scalar_2) && ... - isequal(obj.vector_1, other.vector_1) && ... - isequal(obj.image_2, other.image_2); + isequal(self.scalar_1, other.scalar_1) && ... + isequal(self.scalar_2, other.scalar_2) && ... + isequal(self.vector_1, other.vector_1) && ... + isequal(self.image_2, other.image_2); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/GenericUnion3.m b/matlab/generated/+test_model/GenericUnion3.m index 429be971..f82bbeb4 100644 --- a/matlab/generated/+test_model/GenericUnion3.m +++ b/matlab/generated/+test_model/GenericUnion3.m @@ -29,6 +29,18 @@ end methods + function res = isT(self) + res = self.index == 1; + end + + function res = isU(self) + res = self.index == 2; + end + + function res = isV(self) + res = self.index == 3; + end + function eq = eq(self, other) eq = isa(other, 'test_model.GenericUnion3') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/GenericUnion3Alternate.m b/matlab/generated/+test_model/GenericUnion3Alternate.m index 6acc05e5..6ab24e60 100644 --- a/matlab/generated/+test_model/GenericUnion3Alternate.m +++ b/matlab/generated/+test_model/GenericUnion3Alternate.m @@ -29,6 +29,18 @@ end methods + function res = isU(self) + res = self.index == 1; + end + + function res = isV(self) + res = self.index == 2; + end + + function res = isW(self) + res = self.index == 3; + end + function eq = eq(self, other) eq = isa(other, 'test_model.GenericUnion3Alternate') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m b/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m index c85b0ef3..f26fa7a5 100644 --- a/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m +++ b/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m @@ -29,6 +29,18 @@ end methods + function res = isT(self) + res = self.index == 1; + end + + function res = isTv(self) + res = self.index == 2; + end + + function res = isTa(self) + res = self.index == 3; + end + function eq = eq(self, other) eq = isa(other, 'test_model.GenericUnionWithRepeatedTypeParameters') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/ImageFloatOrImageDouble.m b/matlab/generated/+test_model/ImageFloatOrImageDouble.m index 0e0211f5..4276ef37 100644 --- a/matlab/generated/+test_model/ImageFloatOrImageDouble.m +++ b/matlab/generated/+test_model/ImageFloatOrImageDouble.m @@ -25,6 +25,14 @@ end methods + function res = isImageFloat(self) + res = self.index == 1; + end + + function res = isImageDouble(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'test_model.ImageFloatOrImageDouble') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/Int32OrFloat32.m b/matlab/generated/+test_model/Int32OrFloat32.m index 431b47d3..6f5edf3e 100644 --- a/matlab/generated/+test_model/Int32OrFloat32.m +++ b/matlab/generated/+test_model/Int32OrFloat32.m @@ -25,6 +25,14 @@ end methods + function res = isInt32(self) + res = self.index == 1; + end + + function res = isFloat32(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'test_model.Int32OrFloat32') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/Int32OrRecordWithVlens.m b/matlab/generated/+test_model/Int32OrRecordWithVlens.m index e8b94efa..79ce155f 100644 --- a/matlab/generated/+test_model/Int32OrRecordWithVlens.m +++ b/matlab/generated/+test_model/Int32OrRecordWithVlens.m @@ -25,6 +25,14 @@ end methods + function res = isInt32(self) + res = self.index == 1; + end + + function res = isRecordWithVlens(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'test_model.Int32OrRecordWithVlens') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/Int32OrSimpleRecord.m b/matlab/generated/+test_model/Int32OrSimpleRecord.m index 12e38b94..0533ad08 100644 --- a/matlab/generated/+test_model/Int32OrSimpleRecord.m +++ b/matlab/generated/+test_model/Int32OrSimpleRecord.m @@ -25,6 +25,14 @@ end methods + function res = isInt32(self) + res = self.index == 1; + end + + function res = isSimpleRecord(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'test_model.Int32OrSimpleRecord') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/IntArray.m b/matlab/generated/+test_model/IntArray.m index 3d87ad7a..26fd860b 100644 --- a/matlab/generated/+test_model/IntArray.m +++ b/matlab/generated/+test_model/IntArray.m @@ -1,6 +1,8 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. function a = IntArray(array) - assert(isa(array, 'int32')); + arguments + array int32 + end a = array; end diff --git a/matlab/generated/+test_model/IntFixedArray.m b/matlab/generated/+test_model/IntFixedArray.m index 11bdd16f..6ef07b92 100644 --- a/matlab/generated/+test_model/IntFixedArray.m +++ b/matlab/generated/+test_model/IntFixedArray.m @@ -1,6 +1,8 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. function a = IntFixedArray(array) - assert(isa(array, 'int32')); + arguments + array int32 + end a = array; end diff --git a/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m b/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m index 68e2eaea..55bdeccc 100644 --- a/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m +++ b/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m @@ -25,6 +25,14 @@ end methods + function res = isInt(self) + res = self.index == 1; + end + + function res = isGenericRecordWithComputedFields(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'test_model.IntOrGenericRecordWithComputedFields') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/IntRank2Array.m b/matlab/generated/+test_model/IntRank2Array.m index 10405a6c..a1296d15 100644 --- a/matlab/generated/+test_model/IntRank2Array.m +++ b/matlab/generated/+test_model/IntRank2Array.m @@ -1,6 +1,8 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. function a = IntRank2Array(array) - assert(isa(array, 'int32')); + arguments + array int32 + end a = array; end diff --git a/matlab/generated/+test_model/MapOrScalar.m b/matlab/generated/+test_model/MapOrScalar.m index f5e562e5..4d129afa 100644 --- a/matlab/generated/+test_model/MapOrScalar.m +++ b/matlab/generated/+test_model/MapOrScalar.m @@ -25,6 +25,14 @@ end methods + function res = isMap(self) + res = self.index == 1; + end + + function res = isScalar(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'test_model.MapOrScalar') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/MapsReaderBase.m b/matlab/generated/+test_model/MapsReaderBase.m index fe221b9e..05f9b0f3 100644 --- a/matlab/generated/+test_model/MapsReaderBase.m +++ b/matlab/generated/+test_model/MapsReaderBase.m @@ -6,63 +6,63 @@ end methods - function obj = MapsReaderBase() - obj.state_ = 0; + function self = MapsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_string_to_int(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_string_to_int(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_string_to_int_(); - obj.state_ = 1; + value = self.read_string_to_int_(); + self.state_ = 1; end % Ordinal 1 - function value = read_int_to_string(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_int_to_string(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_int_to_string_(); - obj.state_ = 2; + value = self.read_int_to_string_(); + self.state_ = 2; end % Ordinal 2 - function value = read_string_to_union(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_string_to_union(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_string_to_union_(); - obj.state_ = 3; + value = self.read_string_to_union_(); + self.state_ = 3; end % Ordinal 3 - function value = read_aliased_generic(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function value = read_aliased_generic(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - value = obj.read_aliased_generic_(); - obj.state_ = 4; + value = self.read_aliased_generic_(); + self.state_ = 4; end - function copy_to(obj, writer) - writer.write_string_to_int(obj.read_string_to_int()); - writer.write_int_to_string(obj.read_int_to_string()); - writer.write_string_to_union(obj.read_string_to_union()); - writer.write_aliased_generic(obj.read_aliased_generic()); + function copy_to(self, writer) + writer.write_string_to_int(self.read_string_to_int()); + writer.write_int_to_string(self.read_int_to_string()); + writer.write_string_to_union(self.read_string_to_union()); + writer.write_aliased_generic(self.read_aliased_generic()); end end @@ -73,32 +73,32 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_string_to_int_(obj) - read_int_to_string_(obj) - read_string_to_union_(obj) - read_aliased_generic_(obj) + read_string_to_int_(self) + read_int_to_string_(self) + read_string_to_union_(self) + read_aliased_generic_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_string_to_int'; + name = "read_string_to_int"; elseif state == 1 - name = 'read_int_to_string'; + name = "read_int_to_string"; elseif state == 2 - name = 'read_string_to_union'; + name = "read_string_to_union"; elseif state == 3 - name = 'read_aliased_generic'; + name = "read_aliased_generic"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/MapsWriterBase.m b/matlab/generated/+test_model/MapsWriterBase.m index e1ba4b7f..ec91d127 100644 --- a/matlab/generated/+test_model/MapsWriterBase.m +++ b/matlab/generated/+test_model/MapsWriterBase.m @@ -7,56 +7,56 @@ end methods - function obj = MapsWriterBase() - obj.state_ = 0; + function self = MapsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_string_to_int(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_string_to_int(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_string_to_int_(value); - obj.state_ = 1; + self.write_string_to_int_(value); + self.state_ = 1; end % Ordinal 1 - function write_int_to_string(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_int_to_string(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_int_to_string_(value); - obj.state_ = 2; + self.write_int_to_string_(value); + self.state_ = 2; end % Ordinal 2 - function write_string_to_union(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_string_to_union(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_string_to_union_(value); - obj.state_ = 3; + self.write_string_to_union_(value); + self.state_ = 3; end % Ordinal 3 - function write_aliased_generic(obj, value) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function write_aliased_generic(self, value) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - obj.write_aliased_generic_(value); - obj.state_ = 4; + self.write_aliased_generic_(value); + self.state_ = 4; end end @@ -67,31 +67,31 @@ function write_aliased_generic(obj, value) end methods (Abstract, Access=protected) - write_string_to_int_(obj, value) - write_int_to_string_(obj, value) - write_string_to_union_(obj, value) - write_aliased_generic_(obj, value) + write_string_to_int_(self, value) + write_int_to_string_(self, value) + write_string_to_union_(self, value) + write_aliased_generic_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_string_to_int'; + name = "write_string_to_int"; elseif state == 1 - name = 'write_int_to_string'; + name = "write_int_to_string"; elseif state == 2 - name = 'write_string_to_union'; + name = "write_string_to_union"; elseif state == 3 - name = 'write_aliased_generic'; + name = "write_aliased_generic"; else name = ''; end diff --git a/matlab/generated/+test_model/NDArraysReaderBase.m b/matlab/generated/+test_model/NDArraysReaderBase.m index cce25c5d..b36dc83a 100644 --- a/matlab/generated/+test_model/NDArraysReaderBase.m +++ b/matlab/generated/+test_model/NDArraysReaderBase.m @@ -6,74 +6,74 @@ end methods - function obj = NDArraysReaderBase() - obj.state_ = 0; + function self = NDArraysReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 5 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 5 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_ints(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_ints(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_ints_(); - obj.state_ = 1; + value = self.read_ints_(); + self.state_ = 1; end % Ordinal 1 - function value = read_simple_record_array(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_simple_record_array(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_simple_record_array_(); - obj.state_ = 2; + value = self.read_simple_record_array_(); + self.state_ = 2; end % Ordinal 2 - function value = read_record_with_vlens_array(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_record_with_vlens_array(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_record_with_vlens_array_(); - obj.state_ = 3; + value = self.read_record_with_vlens_array_(); + self.state_ = 3; end % Ordinal 3 - function value = read_record_with_nd_arrays(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function value = read_record_with_nd_arrays(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - value = obj.read_record_with_nd_arrays_(); - obj.state_ = 4; + value = self.read_record_with_nd_arrays_(); + self.state_ = 4; end % Ordinal 4 - function value = read_named_array(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + function value = read_named_array(self) + if self.state_ ~= 4 + self.raise_unexpected_state_(4); end - value = obj.read_named_array_(); - obj.state_ = 5; + value = self.read_named_array_(); + self.state_ = 5; end - function copy_to(obj, writer) - writer.write_ints(obj.read_ints()); - writer.write_simple_record_array(obj.read_simple_record_array()); - writer.write_record_with_vlens_array(obj.read_record_with_vlens_array()); - writer.write_record_with_nd_arrays(obj.read_record_with_nd_arrays()); - writer.write_named_array(obj.read_named_array()); + function copy_to(self, writer) + writer.write_ints(self.read_ints()); + writer.write_simple_record_array(self.read_simple_record_array()); + writer.write_record_with_vlens_array(self.read_record_with_vlens_array()); + writer.write_record_with_nd_arrays(self.read_record_with_nd_arrays()); + writer.write_named_array(self.read_named_array()); end end @@ -84,35 +84,35 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_ints_(obj) - read_simple_record_array_(obj) - read_record_with_vlens_array_(obj) - read_record_with_nd_arrays_(obj) - read_named_array_(obj) + read_ints_(self) + read_simple_record_array_(self) + read_record_with_vlens_array_(self) + read_record_with_nd_arrays_(self) + read_named_array_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_ints'; + name = "read_ints"; elseif state == 1 - name = 'read_simple_record_array'; + name = "read_simple_record_array"; elseif state == 2 - name = 'read_record_with_vlens_array'; + name = "read_record_with_vlens_array"; elseif state == 3 - name = 'read_record_with_nd_arrays'; + name = "read_record_with_nd_arrays"; elseif state == 4 - name = 'read_named_array'; + name = "read_named_array"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m b/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m index 038416f0..52ff5c90 100644 --- a/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m +++ b/matlab/generated/+test_model/NDArraysSingleDimensionReaderBase.m @@ -6,63 +6,63 @@ end methods - function obj = NDArraysSingleDimensionReaderBase() - obj.state_ = 0; + function self = NDArraysSingleDimensionReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_ints(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_ints(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_ints_(); - obj.state_ = 1; + value = self.read_ints_(); + self.state_ = 1; end % Ordinal 1 - function value = read_simple_record_array(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_simple_record_array(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_simple_record_array_(); - obj.state_ = 2; + value = self.read_simple_record_array_(); + self.state_ = 2; end % Ordinal 2 - function value = read_record_with_vlens_array(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_record_with_vlens_array(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_record_with_vlens_array_(); - obj.state_ = 3; + value = self.read_record_with_vlens_array_(); + self.state_ = 3; end % Ordinal 3 - function value = read_record_with_nd_arrays(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function value = read_record_with_nd_arrays(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - value = obj.read_record_with_nd_arrays_(); - obj.state_ = 4; + value = self.read_record_with_nd_arrays_(); + self.state_ = 4; end - function copy_to(obj, writer) - writer.write_ints(obj.read_ints()); - writer.write_simple_record_array(obj.read_simple_record_array()); - writer.write_record_with_vlens_array(obj.read_record_with_vlens_array()); - writer.write_record_with_nd_arrays(obj.read_record_with_nd_arrays()); + function copy_to(self, writer) + writer.write_ints(self.read_ints()); + writer.write_simple_record_array(self.read_simple_record_array()); + writer.write_record_with_vlens_array(self.read_record_with_vlens_array()); + writer.write_record_with_nd_arrays(self.read_record_with_nd_arrays()); end end @@ -73,32 +73,32 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_ints_(obj) - read_simple_record_array_(obj) - read_record_with_vlens_array_(obj) - read_record_with_nd_arrays_(obj) + read_ints_(self) + read_simple_record_array_(self) + read_record_with_vlens_array_(self) + read_record_with_nd_arrays_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_ints'; + name = "read_ints"; elseif state == 1 - name = 'read_simple_record_array'; + name = "read_simple_record_array"; elseif state == 2 - name = 'read_record_with_vlens_array'; + name = "read_record_with_vlens_array"; elseif state == 3 - name = 'read_record_with_nd_arrays'; + name = "read_record_with_nd_arrays"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m b/matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m index 0a60a963..5b1dbb9a 100644 --- a/matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m +++ b/matlab/generated/+test_model/NDArraysSingleDimensionWriterBase.m @@ -7,56 +7,56 @@ end methods - function obj = NDArraysSingleDimensionWriterBase() - obj.state_ = 0; + function self = NDArraysSingleDimensionWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_ints(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_ints(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_ints_(value); - obj.state_ = 1; + self.write_ints_(value); + self.state_ = 1; end % Ordinal 1 - function write_simple_record_array(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_simple_record_array(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_simple_record_array_(value); - obj.state_ = 2; + self.write_simple_record_array_(value); + self.state_ = 2; end % Ordinal 2 - function write_record_with_vlens_array(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_record_with_vlens_array(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_record_with_vlens_array_(value); - obj.state_ = 3; + self.write_record_with_vlens_array_(value); + self.state_ = 3; end % Ordinal 3 - function write_record_with_nd_arrays(obj, value) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function write_record_with_nd_arrays(self, value) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - obj.write_record_with_nd_arrays_(value); - obj.state_ = 4; + self.write_record_with_nd_arrays_(value); + self.state_ = 4; end end @@ -67,31 +67,31 @@ function write_record_with_nd_arrays(obj, value) end methods (Abstract, Access=protected) - write_ints_(obj, value) - write_simple_record_array_(obj, value) - write_record_with_vlens_array_(obj, value) - write_record_with_nd_arrays_(obj, value) + write_ints_(self, value) + write_simple_record_array_(self, value) + write_record_with_vlens_array_(self, value) + write_record_with_nd_arrays_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_ints'; + name = "write_ints"; elseif state == 1 - name = 'write_simple_record_array'; + name = "write_simple_record_array"; elseif state == 2 - name = 'write_record_with_vlens_array'; + name = "write_record_with_vlens_array"; elseif state == 3 - name = 'write_record_with_nd_arrays'; + name = "write_record_with_nd_arrays"; else name = ''; end diff --git a/matlab/generated/+test_model/NDArraysWriterBase.m b/matlab/generated/+test_model/NDArraysWriterBase.m index 7b03daa2..d8ed7e3b 100644 --- a/matlab/generated/+test_model/NDArraysWriterBase.m +++ b/matlab/generated/+test_model/NDArraysWriterBase.m @@ -7,66 +7,66 @@ end methods - function obj = NDArraysWriterBase() - obj.state_ = 0; + function self = NDArraysWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 5 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 5 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_ints(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_ints(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_ints_(value); - obj.state_ = 1; + self.write_ints_(value); + self.state_ = 1; end % Ordinal 1 - function write_simple_record_array(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_simple_record_array(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_simple_record_array_(value); - obj.state_ = 2; + self.write_simple_record_array_(value); + self.state_ = 2; end % Ordinal 2 - function write_record_with_vlens_array(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_record_with_vlens_array(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_record_with_vlens_array_(value); - obj.state_ = 3; + self.write_record_with_vlens_array_(value); + self.state_ = 3; end % Ordinal 3 - function write_record_with_nd_arrays(obj, value) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function write_record_with_nd_arrays(self, value) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - obj.write_record_with_nd_arrays_(value); - obj.state_ = 4; + self.write_record_with_nd_arrays_(value); + self.state_ = 4; end % Ordinal 4 - function write_named_array(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + function write_named_array(self, value) + if self.state_ ~= 4 + self.raise_unexpected_state_(4); end - obj.write_named_array_(value); - obj.state_ = 5; + self.write_named_array_(value); + self.state_ = 5; end end @@ -77,34 +77,34 @@ function write_named_array(obj, value) end methods (Abstract, Access=protected) - write_ints_(obj, value) - write_simple_record_array_(obj, value) - write_record_with_vlens_array_(obj, value) - write_record_with_nd_arrays_(obj, value) - write_named_array_(obj, value) - - end_stream_(obj) - close_(obj) + write_ints_(self, value) + write_simple_record_array_(self, value) + write_record_with_vlens_array_(self, value) + write_record_with_nd_arrays_(self, value) + write_named_array_(self, value) + + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_ints'; + name = "write_ints"; elseif state == 1 - name = 'write_simple_record_array'; + name = "write_simple_record_array"; elseif state == 2 - name = 'write_record_with_vlens_array'; + name = "write_record_with_vlens_array"; elseif state == 3 - name = 'write_record_with_nd_arrays'; + name = "write_record_with_nd_arrays"; elseif state == 4 - name = 'write_named_array'; + name = "write_named_array"; else name = ''; end diff --git a/matlab/generated/+test_model/NamedFixedNDArray.m b/matlab/generated/+test_model/NamedFixedNDArray.m index 12b7a391..417d0678 100644 --- a/matlab/generated/+test_model/NamedFixedNDArray.m +++ b/matlab/generated/+test_model/NamedFixedNDArray.m @@ -1,6 +1,8 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. function a = NamedFixedNDArray(array) - assert(isa(array, 'int32')); + arguments + array int32 + end a = array; end diff --git a/matlab/generated/+test_model/NamedNDArray.m b/matlab/generated/+test_model/NamedNDArray.m index 8976c715..ad3f0b98 100644 --- a/matlab/generated/+test_model/NamedNDArray.m +++ b/matlab/generated/+test_model/NamedNDArray.m @@ -1,6 +1,8 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. function a = NamedNDArray(array) - assert(isa(array, 'int32')); + arguments + array int32 + end a = array; end diff --git a/matlab/generated/+test_model/NestedRecordsReaderBase.m b/matlab/generated/+test_model/NestedRecordsReaderBase.m index 1923a281..4267b57b 100644 --- a/matlab/generated/+test_model/NestedRecordsReaderBase.m +++ b/matlab/generated/+test_model/NestedRecordsReaderBase.m @@ -6,30 +6,30 @@ end methods - function obj = NestedRecordsReaderBase() - obj.state_ = 0; + function self = NestedRecordsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_tuple_with_records(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_tuple_with_records(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_tuple_with_records_(); - obj.state_ = 1; + value = self.read_tuple_with_records_(); + self.state_ = 1; end - function copy_to(obj, writer) - writer.write_tuple_with_records(obj.read_tuple_with_records()); + function copy_to(self, writer) + writer.write_tuple_with_records(self.read_tuple_with_records()); end end @@ -40,23 +40,23 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_tuple_with_records_(obj) + read_tuple_with_records_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_tuple_with_records'; + name = "read_tuple_with_records"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/NestedRecordsWriterBase.m b/matlab/generated/+test_model/NestedRecordsWriterBase.m index 1957b9e5..2751f5ef 100644 --- a/matlab/generated/+test_model/NestedRecordsWriterBase.m +++ b/matlab/generated/+test_model/NestedRecordsWriterBase.m @@ -7,26 +7,26 @@ end methods - function obj = NestedRecordsWriterBase() - obj.state_ = 0; + function self = NestedRecordsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_tuple_with_records(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_tuple_with_records(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_tuple_with_records_(value); - obj.state_ = 1; + self.write_tuple_with_records_(value); + self.state_ = 1; end end @@ -37,22 +37,22 @@ function write_tuple_with_records(obj, value) end methods (Abstract, Access=protected) - write_tuple_with_records_(obj, value) + write_tuple_with_records_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_tuple_with_records'; + name = "write_tuple_with_records"; else name = ''; end diff --git a/matlab/generated/+test_model/OptionalVectorsReaderBase.m b/matlab/generated/+test_model/OptionalVectorsReaderBase.m index bfdb8b87..73d65774 100644 --- a/matlab/generated/+test_model/OptionalVectorsReaderBase.m +++ b/matlab/generated/+test_model/OptionalVectorsReaderBase.m @@ -6,30 +6,30 @@ end methods - function obj = OptionalVectorsReaderBase() - obj.state_ = 0; + function self = OptionalVectorsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_record_with_optional_vector(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_record_with_optional_vector(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_record_with_optional_vector_(); - obj.state_ = 1; + value = self.read_record_with_optional_vector_(); + self.state_ = 1; end - function copy_to(obj, writer) - writer.write_record_with_optional_vector(obj.read_record_with_optional_vector()); + function copy_to(self, writer) + writer.write_record_with_optional_vector(self.read_record_with_optional_vector()); end end @@ -40,23 +40,23 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_record_with_optional_vector_(obj) + read_record_with_optional_vector_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_record_with_optional_vector'; + name = "read_record_with_optional_vector"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/OptionalVectorsWriterBase.m b/matlab/generated/+test_model/OptionalVectorsWriterBase.m index 51bde231..be314f03 100644 --- a/matlab/generated/+test_model/OptionalVectorsWriterBase.m +++ b/matlab/generated/+test_model/OptionalVectorsWriterBase.m @@ -7,26 +7,26 @@ end methods - function obj = OptionalVectorsWriterBase() - obj.state_ = 0; + function self = OptionalVectorsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_record_with_optional_vector(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_record_with_optional_vector(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_record_with_optional_vector_(value); - obj.state_ = 1; + self.write_record_with_optional_vector_(value); + self.state_ = 1; end end @@ -37,22 +37,22 @@ function write_record_with_optional_vector(obj, value) end methods (Abstract, Access=protected) - write_record_with_optional_vector_(obj, value) + write_record_with_optional_vector_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_record_with_optional_vector'; + name = "write_record_with_optional_vector"; else name = ''; end diff --git a/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m b/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m index 7cfa5f28..1619dea3 100644 --- a/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m +++ b/matlab/generated/+test_model/ProtocolWithComputedFieldsReaderBase.m @@ -6,30 +6,30 @@ end methods - function obj = ProtocolWithComputedFieldsReaderBase() - obj.state_ = 0; + function self = ProtocolWithComputedFieldsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_record_with_computed_fields(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_record_with_computed_fields(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_record_with_computed_fields_(); - obj.state_ = 1; + value = self.read_record_with_computed_fields_(); + self.state_ = 1; end - function copy_to(obj, writer) - writer.write_record_with_computed_fields(obj.read_record_with_computed_fields()); + function copy_to(self, writer) + writer.write_record_with_computed_fields(self.read_record_with_computed_fields()); end end @@ -40,23 +40,23 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_record_with_computed_fields_(obj) + read_record_with_computed_fields_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_record_with_computed_fields'; + name = "read_record_with_computed_fields"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m b/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m index 6975e1b9..83d59ee2 100644 --- a/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m +++ b/matlab/generated/+test_model/ProtocolWithComputedFieldsWriterBase.m @@ -7,26 +7,26 @@ end methods - function obj = ProtocolWithComputedFieldsWriterBase() - obj.state_ = 0; + function self = ProtocolWithComputedFieldsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 1 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_record_with_computed_fields(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_record_with_computed_fields(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_record_with_computed_fields_(value); - obj.state_ = 1; + self.write_record_with_computed_fields_(value); + self.state_ = 1; end end @@ -37,22 +37,22 @@ function write_record_with_computed_fields(obj, value) end methods (Abstract, Access=protected) - write_record_with_computed_fields_(obj, value) + write_record_with_computed_fields_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_record_with_computed_fields'; + name = "write_record_with_computed_fields"; else name = ''; end diff --git a/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m b/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m index 64c18c81..55fbe654 100644 --- a/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m +++ b/matlab/generated/+test_model/ProtocolWithKeywordStepsReaderBase.m @@ -6,55 +6,55 @@ end methods - function obj = ProtocolWithKeywordStepsReaderBase() - obj.state_ = 0; + function self = ProtocolWithKeywordStepsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 2 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function more = has_int(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function more = has_int(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - more = obj.has_int_(); + more = self.has_int_(); if ~more - obj.state_ = 1; + self.state_ = 1; end end - function value = read_int(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_int(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_int_(); + value = self.read_int_(); end % Ordinal 1 - function value = read_float(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_float(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_float_(); - obj.state_ = 2; + value = self.read_float_(); + self.state_ = 2; end - function copy_to(obj, writer) - while obj.has_int() - item = obj.read_int(); + function copy_to(self, writer) + while self.has_int() + item = self.read_int(); writer.write_int({item}); end writer.end_int(); - writer.write_float(obj.read_float()); + writer.write_float(self.read_float()); end end @@ -65,27 +65,27 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - has_int_(obj) - read_int_(obj) - read_float_(obj) + has_int_(self) + read_int_(self) + read_float_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_int'; + name = "read_int"; elseif state == 1 - name = 'read_float'; + name = "read_float"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m b/matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m index d9f68586..ea5b7476 100644 --- a/matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m +++ b/matlab/generated/+test_model/ProtocolWithKeywordStepsWriterBase.m @@ -7,44 +7,44 @@ end methods - function obj = ProtocolWithKeywordStepsWriterBase() - obj.state_ = 0; + function self = ProtocolWithKeywordStepsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 2 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_int(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_int(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_int_(value); + self.write_int_(value); end - function end_int(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function end_int(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.end_stream_(); - obj.state_ = 1; + self.end_stream_(); + self.state_ = 1; end % Ordinal 1 - function write_float(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_float(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_float_(value); - obj.state_ = 2; + self.write_float_(value); + self.state_ = 2; end end @@ -55,25 +55,25 @@ function write_float(obj, value) end methods (Abstract, Access=protected) - write_int_(obj, value) - write_float_(obj, value) + write_int_(self, value) + write_float_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_int or end_int'; + name = "write_int or end_int"; elseif state == 1 - name = 'write_float'; + name = "write_float"; else name = ''; end diff --git a/matlab/generated/+test_model/RecordContainingGenericRecords.m b/matlab/generated/+test_model/RecordContainingGenericRecords.m index ae916c49..15dc2531 100644 --- a/matlab/generated/+test_model/RecordContainingGenericRecords.m +++ b/matlab/generated/+test_model/RecordContainingGenericRecords.m @@ -15,36 +15,36 @@ end methods - function obj = RecordContainingGenericRecords(g1, g1a, g2, g2a, g3, g3a, g4, g5, g6, g7) - obj.g1 = g1; - obj.g1a = g1a; - obj.g2 = g2; - obj.g2a = g2a; - obj.g3 = g3; - obj.g3a = g3a; - obj.g4 = g4; - obj.g5 = g5; - obj.g6 = g6; - obj.g7 = g7; + function self = RecordContainingGenericRecords(g1, g1a, g2, g2a, g3, g3a, g4, g5, g6, g7) + self.g1 = g1; + self.g1a = g1a; + self.g2 = g2; + self.g2a = g2a; + self.g3 = g3; + self.g3a = g3a; + self.g4 = g4; + self.g5 = g5; + self.g6 = g6; + self.g7 = g7; end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordContainingGenericRecords') && ... - isequal(obj.g1, other.g1) && ... - isequal(obj.g1a, other.g1a) && ... - isequal(obj.g2, other.g2) && ... - isequal(obj.g2a, other.g2a) && ... - isequal(obj.g3, other.g3) && ... - isequal(obj.g3a, other.g3a) && ... - isequal(obj.g4, other.g4) && ... - isequal(obj.g5, other.g5) && ... - isequal(obj.g6, other.g6) && ... - isequal(obj.g7, other.g7); + isequal(self.g1, other.g1) && ... + isequal(self.g1a, other.g1a) && ... + isequal(self.g2, other.g2) && ... + isequal(self.g2a, other.g2a) && ... + isequal(self.g3, other.g3) && ... + isequal(self.g3a, other.g3a) && ... + isequal(self.g4, other.g4) && ... + isequal(self.g5, other.g5) && ... + isequal(self.g6, other.g6) && ... + isequal(self.g7, other.g7); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m b/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m index 63a2849a..200f79bf 100644 --- a/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m +++ b/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m @@ -10,34 +10,34 @@ end methods - function obj = RecordContainingNestedGenericRecords(f1, f1a, f2, f2a, nested) + function self = RecordContainingNestedGenericRecords(f1, f1a, f2, f2a, nested) if nargin > 0 - obj.f1 = f1; - obj.f1a = f1a; - obj.f2 = f2; - obj.f2a = f2a; - obj.nested = nested; + self.f1 = f1; + self.f1a = f1a; + self.f2 = f2; + self.f2a = f2a; + self.nested = nested; else - obj.f1 = test_model.RecordWithOptionalGenericField(yardl.None); - obj.f1a = test_model.RecordWithAliasedOptionalGenericField(yardl.None); - obj.f2 = test_model.RecordWithOptionalGenericUnionField(yardl.None); - obj.f2a = test_model.RecordWithAliasedOptionalGenericUnionField(yardl.None); - obj.nested = test_model.RecordContainingGenericRecords(test_model.RecordWithOptionalGenericField(yardl.None), test_model.RecordWithAliasedOptionalGenericField(yardl.None), test_model.RecordWithOptionalGenericUnionField(yardl.None), test_model.RecordWithAliasedOptionalGenericUnionField(yardl.None), tuples.Tuple("", int32(0)), tuples.Tuple("", int32(0)), test_model.RecordWithGenericVectors(int32.empty(), int32.empty()), test_model.RecordWithGenericFixedVectors(repelem(int32(0), 3), repelem(int32(0), 3)), test_model.RecordWithGenericArrays(int32.empty(0, 0), repelem(int32(0), 8, 16), int32.empty(), int32.empty(0, 0), repelem(int32(0), 8, 16), int32.empty()), test_model.RecordWithGenericMaps(dictionary, dictionary)); + self.f1 = test_model.RecordWithOptionalGenericField(yardl.None); + self.f1a = test_model.RecordWithAliasedOptionalGenericField(yardl.None); + self.f2 = test_model.RecordWithOptionalGenericUnionField(yardl.None); + self.f2a = test_model.RecordWithAliasedOptionalGenericUnionField(yardl.None); + self.nested = test_model.RecordContainingGenericRecords(test_model.RecordWithOptionalGenericField(yardl.None), test_model.RecordWithAliasedOptionalGenericField(yardl.None), test_model.RecordWithOptionalGenericUnionField(yardl.None), test_model.RecordWithAliasedOptionalGenericUnionField(yardl.None), tuples.Tuple("", int32(0)), tuples.Tuple("", int32(0)), test_model.RecordWithGenericVectors(int32.empty(), int32.empty()), test_model.RecordWithGenericFixedVectors(repelem(int32(0), 3), repelem(int32(0), 3)), test_model.RecordWithGenericArrays(int32.empty(0, 0), repelem(int32(0), 8, 16), int32.empty(), int32.empty(0, 0), repelem(int32(0), 8, 16), int32.empty()), test_model.RecordWithGenericMaps(dictionary, dictionary)); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordContainingNestedGenericRecords') && ... - all([obj.f1] == [other.f1]) && ... - isequal(obj.f1a, other.f1a) && ... - all([obj.f2] == [other.f2]) && ... - isequal(obj.f2a, other.f2a) && ... - isequal(obj.nested, other.nested); + all([self.f1] == [other.f1]) && ... + isequal(self.f1a, other.f1a) && ... + all([self.f2] == [other.f2]) && ... + isequal(self.f2a, other.f2a) && ... + isequal(self.nested, other.nested); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordNotUsedInProtocol.m b/matlab/generated/+test_model/RecordNotUsedInProtocol.m index d69e7e1d..b49dbc75 100644 --- a/matlab/generated/+test_model/RecordNotUsedInProtocol.m +++ b/matlab/generated/+test_model/RecordNotUsedInProtocol.m @@ -7,25 +7,25 @@ end methods - function obj = RecordNotUsedInProtocol(u1, u2) + function self = RecordNotUsedInProtocol(u1, u2) if nargin > 0 - obj.u1 = u1; - obj.u2 = u2; + self.u1 = u1; + self.u2 = u2; else - obj.u1 = test_model.GenericUnion3.T(int32(0)); - obj.u2 = test_model.GenericUnion3Alternate.U(int32(0)); + self.u1 = test_model.GenericUnion3.T(int32(0)); + self.u2 = test_model.GenericUnion3Alternate.U(int32(0)); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordNotUsedInProtocol') && ... - all([obj.u1] == [other.u1]) && ... - all([obj.u2] == [other.u2]); + all([self.u1] == [other.u1]) && ... + all([self.u2] == [other.u2]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithAliasedGenerics.m b/matlab/generated/+test_model/RecordWithAliasedGenerics.m index 8ca7aae7..4736bee9 100644 --- a/matlab/generated/+test_model/RecordWithAliasedGenerics.m +++ b/matlab/generated/+test_model/RecordWithAliasedGenerics.m @@ -7,25 +7,25 @@ end methods - function obj = RecordWithAliasedGenerics(my_strings, aliased_strings) + function self = RecordWithAliasedGenerics(my_strings, aliased_strings) if nargin > 0 - obj.my_strings = my_strings; - obj.aliased_strings = aliased_strings; + self.my_strings = my_strings; + self.aliased_strings = aliased_strings; else - obj.my_strings = tuples.Tuple("", ""); - obj.aliased_strings = tuples.Tuple("", ""); + self.my_strings = tuples.Tuple("", ""); + self.aliased_strings = tuples.Tuple("", ""); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithAliasedGenerics') && ... - isequal(obj.my_strings, other.my_strings) && ... - isequal(obj.aliased_strings, other.aliased_strings); + isequal(self.my_strings, other.my_strings) && ... + isequal(self.aliased_strings, other.aliased_strings); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m index de9f82b2..52bf3bf4 100644 --- a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m +++ b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m @@ -6,22 +6,22 @@ end methods - function obj = RecordWithAliasedOptionalGenericField(v) + function self = RecordWithAliasedOptionalGenericField(v) if nargin > 0 - obj.v = v; + self.v = v; else - obj.v = yardl.None; + self.v = yardl.None; end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithAliasedOptionalGenericField') && ... - isequal(obj.v, other.v); + isequal(self.v, other.v); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m index 4c29edd0..cf980ec2 100644 --- a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m +++ b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m @@ -6,22 +6,22 @@ end methods - function obj = RecordWithAliasedOptionalGenericUnionField(v) + function self = RecordWithAliasedOptionalGenericUnionField(v) if nargin > 0 - obj.v = v; + self.v = v; else - obj.v = yardl.None; + self.v = yardl.None; end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithAliasedOptionalGenericUnionField') && ... - isequal(obj.v, other.v); + isequal(self.v, other.v); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithArrays.m b/matlab/generated/+test_model/RecordWithArrays.m index ca885162..b878a086 100644 --- a/matlab/generated/+test_model/RecordWithArrays.m +++ b/matlab/generated/+test_model/RecordWithArrays.m @@ -14,46 +14,46 @@ end methods - function obj = RecordWithArrays(default_array, default_array_with_empty_dimension, rank_1_array, rank_2_array, rank_2_array_with_named_dimensions, rank_2_fixed_array, rank_2_fixed_array_with_named_dimensions, dynamic_array, array_of_vectors) + function self = RecordWithArrays(default_array, default_array_with_empty_dimension, rank_1_array, rank_2_array, rank_2_array_with_named_dimensions, rank_2_fixed_array, rank_2_fixed_array_with_named_dimensions, dynamic_array, array_of_vectors) if nargin > 0 - obj.default_array = default_array; - obj.default_array_with_empty_dimension = default_array_with_empty_dimension; - obj.rank_1_array = rank_1_array; - obj.rank_2_array = rank_2_array; - obj.rank_2_array_with_named_dimensions = rank_2_array_with_named_dimensions; - obj.rank_2_fixed_array = rank_2_fixed_array; - obj.rank_2_fixed_array_with_named_dimensions = rank_2_fixed_array_with_named_dimensions; - obj.dynamic_array = dynamic_array; - obj.array_of_vectors = array_of_vectors; + self.default_array = default_array; + self.default_array_with_empty_dimension = default_array_with_empty_dimension; + self.rank_1_array = rank_1_array; + self.rank_2_array = rank_2_array; + self.rank_2_array_with_named_dimensions = rank_2_array_with_named_dimensions; + self.rank_2_fixed_array = rank_2_fixed_array; + self.rank_2_fixed_array_with_named_dimensions = rank_2_fixed_array_with_named_dimensions; + self.dynamic_array = dynamic_array; + self.array_of_vectors = array_of_vectors; else - obj.default_array = int32.empty(); - obj.default_array_with_empty_dimension = int32.empty(); - obj.rank_1_array = int32.empty(0); - obj.rank_2_array = int32.empty(0, 0); - obj.rank_2_array_with_named_dimensions = int32.empty(0, 0); - obj.rank_2_fixed_array = repelem(int32(0), 4, 3); - obj.rank_2_fixed_array_with_named_dimensions = repelem(int32(0), 4, 3); - obj.dynamic_array = int32.empty(); - obj.array_of_vectors = repelem(repelem(int32(0), 4), 5, 1); + self.default_array = int32.empty(); + self.default_array_with_empty_dimension = int32.empty(); + self.rank_1_array = int32.empty(0); + self.rank_2_array = int32.empty(0, 0); + self.rank_2_array_with_named_dimensions = int32.empty(0, 0); + self.rank_2_fixed_array = repelem(int32(0), 4, 3); + self.rank_2_fixed_array_with_named_dimensions = repelem(int32(0), 4, 3); + self.dynamic_array = int32.empty(); + self.array_of_vectors = repelem(repelem(int32(0), 4), 5, 1); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithArrays') && ... - isequal(obj.default_array, other.default_array) && ... - isequal(obj.default_array_with_empty_dimension, other.default_array_with_empty_dimension) && ... - isequal(obj.rank_1_array, other.rank_1_array) && ... - isequal(obj.rank_2_array, other.rank_2_array) && ... - isequal(obj.rank_2_array_with_named_dimensions, other.rank_2_array_with_named_dimensions) && ... - isequal(obj.rank_2_fixed_array, other.rank_2_fixed_array) && ... - isequal(obj.rank_2_fixed_array_with_named_dimensions, other.rank_2_fixed_array_with_named_dimensions) && ... - isequal(obj.dynamic_array, other.dynamic_array) && ... - isequal(obj.array_of_vectors, other.array_of_vectors); + isequal(self.default_array, other.default_array) && ... + isequal(self.default_array_with_empty_dimension, other.default_array_with_empty_dimension) && ... + isequal(self.rank_1_array, other.rank_1_array) && ... + isequal(self.rank_2_array, other.rank_2_array) && ... + isequal(self.rank_2_array_with_named_dimensions, other.rank_2_array_with_named_dimensions) && ... + isequal(self.rank_2_fixed_array, other.rank_2_fixed_array) && ... + isequal(self.rank_2_fixed_array_with_named_dimensions, other.rank_2_fixed_array_with_named_dimensions) && ... + isequal(self.dynamic_array, other.dynamic_array) && ... + isequal(self.array_of_vectors, other.array_of_vectors); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m b/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m index 77c9e830..a85b2cb6 100644 --- a/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m +++ b/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m @@ -14,46 +14,46 @@ end methods - function obj = RecordWithArraysSimpleSyntax(default_array, default_array_with_empty_dimension, rank_1_array, rank_2_array, rank_2_array_with_named_dimensions, rank_2_fixed_array, rank_2_fixed_array_with_named_dimensions, dynamic_array, array_of_vectors) + function self = RecordWithArraysSimpleSyntax(default_array, default_array_with_empty_dimension, rank_1_array, rank_2_array, rank_2_array_with_named_dimensions, rank_2_fixed_array, rank_2_fixed_array_with_named_dimensions, dynamic_array, array_of_vectors) if nargin > 0 - obj.default_array = default_array; - obj.default_array_with_empty_dimension = default_array_with_empty_dimension; - obj.rank_1_array = rank_1_array; - obj.rank_2_array = rank_2_array; - obj.rank_2_array_with_named_dimensions = rank_2_array_with_named_dimensions; - obj.rank_2_fixed_array = rank_2_fixed_array; - obj.rank_2_fixed_array_with_named_dimensions = rank_2_fixed_array_with_named_dimensions; - obj.dynamic_array = dynamic_array; - obj.array_of_vectors = array_of_vectors; + self.default_array = default_array; + self.default_array_with_empty_dimension = default_array_with_empty_dimension; + self.rank_1_array = rank_1_array; + self.rank_2_array = rank_2_array; + self.rank_2_array_with_named_dimensions = rank_2_array_with_named_dimensions; + self.rank_2_fixed_array = rank_2_fixed_array; + self.rank_2_fixed_array_with_named_dimensions = rank_2_fixed_array_with_named_dimensions; + self.dynamic_array = dynamic_array; + self.array_of_vectors = array_of_vectors; else - obj.default_array = int32.empty(); - obj.default_array_with_empty_dimension = int32.empty(); - obj.rank_1_array = int32.empty(0); - obj.rank_2_array = int32.empty(0, 0); - obj.rank_2_array_with_named_dimensions = int32.empty(0, 0); - obj.rank_2_fixed_array = repelem(int32(0), 4, 3); - obj.rank_2_fixed_array_with_named_dimensions = repelem(int32(0), 4, 3); - obj.dynamic_array = int32.empty(); - obj.array_of_vectors = repelem(repelem(int32(0), 4), 5, 1); + self.default_array = int32.empty(); + self.default_array_with_empty_dimension = int32.empty(); + self.rank_1_array = int32.empty(0); + self.rank_2_array = int32.empty(0, 0); + self.rank_2_array_with_named_dimensions = int32.empty(0, 0); + self.rank_2_fixed_array = repelem(int32(0), 4, 3); + self.rank_2_fixed_array_with_named_dimensions = repelem(int32(0), 4, 3); + self.dynamic_array = int32.empty(); + self.array_of_vectors = repelem(repelem(int32(0), 4), 5, 1); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithArraysSimpleSyntax') && ... - isequal(obj.default_array, other.default_array) && ... - isequal(obj.default_array_with_empty_dimension, other.default_array_with_empty_dimension) && ... - isequal(obj.rank_1_array, other.rank_1_array) && ... - isequal(obj.rank_2_array, other.rank_2_array) && ... - isequal(obj.rank_2_array_with_named_dimensions, other.rank_2_array_with_named_dimensions) && ... - isequal(obj.rank_2_fixed_array, other.rank_2_fixed_array) && ... - isequal(obj.rank_2_fixed_array_with_named_dimensions, other.rank_2_fixed_array_with_named_dimensions) && ... - isequal(obj.dynamic_array, other.dynamic_array) && ... - isequal(obj.array_of_vectors, other.array_of_vectors); + isequal(self.default_array, other.default_array) && ... + isequal(self.default_array_with_empty_dimension, other.default_array_with_empty_dimension) && ... + isequal(self.rank_1_array, other.rank_1_array) && ... + isequal(self.rank_2_array, other.rank_2_array) && ... + isequal(self.rank_2_array_with_named_dimensions, other.rank_2_array_with_named_dimensions) && ... + isequal(self.rank_2_fixed_array, other.rank_2_fixed_array) && ... + isequal(self.rank_2_fixed_array_with_named_dimensions, other.rank_2_fixed_array_with_named_dimensions) && ... + isequal(self.dynamic_array, other.dynamic_array) && ... + isequal(self.array_of_vectors, other.array_of_vectors); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithComputedFields.m b/matlab/generated/+test_model/RecordWithComputedFields.m index 1af53603..5fac958b 100644 --- a/matlab/generated/+test_model/RecordWithComputedFields.m +++ b/matlab/generated/+test_model/RecordWithComputedFields.m @@ -33,65 +33,65 @@ end methods - function obj = RecordWithComputedFields(array_field, array_field_map_dimensions, dynamic_array_field, fixed_array_field, int_field, int8_field, uint8_field, int16_field, uint16_field, uint32_field, int64_field, uint64_field, size_field, float32_field, float64_field, complexfloat32_field, complexfloat64_field, string_field, tuple_field, vector_field, vector_of_vectors_field, fixed_vector_field, fixed_vector_of_vectors_field, optional_named_array, int_float_union, nullable_int_float_union, union_with_nested_generic_union, map_field) + function self = RecordWithComputedFields(array_field, array_field_map_dimensions, dynamic_array_field, fixed_array_field, int_field, int8_field, uint8_field, int16_field, uint16_field, uint32_field, int64_field, uint64_field, size_field, float32_field, float64_field, complexfloat32_field, complexfloat64_field, string_field, tuple_field, vector_field, vector_of_vectors_field, fixed_vector_field, fixed_vector_of_vectors_field, optional_named_array, int_float_union, nullable_int_float_union, union_with_nested_generic_union, map_field) if nargin > 0 - obj.array_field = array_field; - obj.array_field_map_dimensions = array_field_map_dimensions; - obj.dynamic_array_field = dynamic_array_field; - obj.fixed_array_field = fixed_array_field; - obj.int_field = int_field; - obj.int8_field = int8_field; - obj.uint8_field = uint8_field; - obj.int16_field = int16_field; - obj.uint16_field = uint16_field; - obj.uint32_field = uint32_field; - obj.int64_field = int64_field; - obj.uint64_field = uint64_field; - obj.size_field = size_field; - obj.float32_field = float32_field; - obj.float64_field = float64_field; - obj.complexfloat32_field = complexfloat32_field; - obj.complexfloat64_field = complexfloat64_field; - obj.string_field = string_field; - obj.tuple_field = tuple_field; - obj.vector_field = vector_field; - obj.vector_of_vectors_field = vector_of_vectors_field; - obj.fixed_vector_field = fixed_vector_field; - obj.fixed_vector_of_vectors_field = fixed_vector_of_vectors_field; - obj.optional_named_array = optional_named_array; - obj.int_float_union = int_float_union; - obj.nullable_int_float_union = nullable_int_float_union; - obj.union_with_nested_generic_union = union_with_nested_generic_union; - obj.map_field = map_field; + self.array_field = array_field; + self.array_field_map_dimensions = array_field_map_dimensions; + self.dynamic_array_field = dynamic_array_field; + self.fixed_array_field = fixed_array_field; + self.int_field = int_field; + self.int8_field = int8_field; + self.uint8_field = uint8_field; + self.int16_field = int16_field; + self.uint16_field = uint16_field; + self.uint32_field = uint32_field; + self.int64_field = int64_field; + self.uint64_field = uint64_field; + self.size_field = size_field; + self.float32_field = float32_field; + self.float64_field = float64_field; + self.complexfloat32_field = complexfloat32_field; + self.complexfloat64_field = complexfloat64_field; + self.string_field = string_field; + self.tuple_field = tuple_field; + self.vector_field = vector_field; + self.vector_of_vectors_field = vector_of_vectors_field; + self.fixed_vector_field = fixed_vector_field; + self.fixed_vector_of_vectors_field = fixed_vector_of_vectors_field; + self.optional_named_array = optional_named_array; + self.int_float_union = int_float_union; + self.nullable_int_float_union = nullable_int_float_union; + self.union_with_nested_generic_union = union_with_nested_generic_union; + self.map_field = map_field; else - obj.array_field = int32.empty(0, 0); - obj.array_field_map_dimensions = int32.empty(0, 0); - obj.dynamic_array_field = int32.empty(); - obj.fixed_array_field = repelem(int32(0), 4, 3); - obj.int_field = int32(0); - obj.int8_field = int8(0); - obj.uint8_field = uint8(0); - obj.int16_field = int16(0); - obj.uint16_field = uint16(0); - obj.uint32_field = uint32(0); - obj.int64_field = int64(0); - obj.uint64_field = uint64(0); - obj.size_field = uint64(0); - obj.float32_field = single(0); - obj.float64_field = double(0); - obj.complexfloat32_field = complex(single(0)); - obj.complexfloat64_field = complex(0); - obj.string_field = ""; - obj.tuple_field = tuples.Tuple(int32(0), int32(0)); - obj.vector_field = int32.empty(); - obj.vector_of_vectors_field = int32.empty(); - obj.fixed_vector_field = repelem(int32(0), 3); - obj.fixed_vector_of_vectors_field = repelem({repelem(int32(0), 3)}, 2); - obj.optional_named_array = yardl.None; - obj.int_float_union = test_model.Int32OrFloat32.Int32(int32(0)); - obj.nullable_int_float_union = yardl.None; - obj.union_with_nested_generic_union = test_model.IntOrGenericRecordWithComputedFields.Int(int32(0)); - obj.map_field = dictionary; + self.array_field = int32.empty(0, 0); + self.array_field_map_dimensions = int32.empty(0, 0); + self.dynamic_array_field = int32.empty(); + self.fixed_array_field = repelem(int32(0), 4, 3); + self.int_field = int32(0); + self.int8_field = int8(0); + self.uint8_field = uint8(0); + self.int16_field = int16(0); + self.uint16_field = uint16(0); + self.uint32_field = uint32(0); + self.int64_field = int64(0); + self.uint64_field = uint64(0); + self.size_field = uint64(0); + self.float32_field = single(0); + self.float64_field = double(0); + self.complexfloat32_field = complex(single(0)); + self.complexfloat64_field = complex(0); + self.string_field = ""; + self.tuple_field = tuples.Tuple(int32(0), int32(0)); + self.vector_field = int32.empty(); + self.vector_of_vectors_field = int32.empty(); + self.fixed_vector_field = repelem(int32(0), 3); + self.fixed_vector_of_vectors_field = repelem({repelem(int32(0), 3)}, 2); + self.optional_named_array = yardl.None; + self.int_float_union = test_model.Int32OrFloat32.Int32(int32(0)); + self.nullable_int_float_union = yardl.None; + self.union_with_nested_generic_union = test_model.IntOrGenericRecordWithComputedFields.Int(int32(0)); + self.map_field = dictionary; end end @@ -227,7 +227,7 @@ elseif dim_name == "y" dim = 1; else - throw(yardl.KeyError("Unknown dimension name: '%s'", dim_name)); + throw(yardl.ValueError("Unknown dimension name: '%s'", dim_name)); end end @@ -292,7 +292,7 @@ elseif dim_name == "y" dim = 1; else - throw(yardl.KeyError("Unknown dimension name: '%s'", dim_name)); + throw(yardl.ValueError("Unknown dimension name: '%s'", dim_name)); end end @@ -525,41 +525,41 @@ end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithComputedFields') && ... - isequal(obj.array_field, other.array_field) && ... - isequal(obj.array_field_map_dimensions, other.array_field_map_dimensions) && ... - isequal(obj.dynamic_array_field, other.dynamic_array_field) && ... - isequal(obj.fixed_array_field, other.fixed_array_field) && ... - all([obj.int_field] == [other.int_field]) && ... - all([obj.int8_field] == [other.int8_field]) && ... - all([obj.uint8_field] == [other.uint8_field]) && ... - all([obj.int16_field] == [other.int16_field]) && ... - all([obj.uint16_field] == [other.uint16_field]) && ... - all([obj.uint32_field] == [other.uint32_field]) && ... - all([obj.int64_field] == [other.int64_field]) && ... - all([obj.uint64_field] == [other.uint64_field]) && ... - all([obj.size_field] == [other.size_field]) && ... - all([obj.float32_field] == [other.float32_field]) && ... - all([obj.float64_field] == [other.float64_field]) && ... - all([obj.complexfloat32_field] == [other.complexfloat32_field]) && ... - all([obj.complexfloat64_field] == [other.complexfloat64_field]) && ... - all([obj.string_field] == [other.string_field]) && ... - isequal(obj.tuple_field, other.tuple_field) && ... - all([obj.vector_field] == [other.vector_field]) && ... - all([obj.vector_of_vectors_field] == [other.vector_of_vectors_field]) && ... - all([obj.fixed_vector_field] == [other.fixed_vector_field]) && ... - all([obj.fixed_vector_of_vectors_field] == [other.fixed_vector_of_vectors_field]) && ... - isequal(obj.optional_named_array, other.optional_named_array) && ... - all([obj.int_float_union] == [other.int_float_union]) && ... - all([obj.nullable_int_float_union] == [other.nullable_int_float_union]) && ... - all([obj.union_with_nested_generic_union] == [other.union_with_nested_generic_union]) && ... - all([obj.map_field] == [other.map_field]); - end - - function res = ne(obj, other) - res = ~obj.eq(other); + isequal(self.array_field, other.array_field) && ... + isequal(self.array_field_map_dimensions, other.array_field_map_dimensions) && ... + isequal(self.dynamic_array_field, other.dynamic_array_field) && ... + isequal(self.fixed_array_field, other.fixed_array_field) && ... + all([self.int_field] == [other.int_field]) && ... + all([self.int8_field] == [other.int8_field]) && ... + all([self.uint8_field] == [other.uint8_field]) && ... + all([self.int16_field] == [other.int16_field]) && ... + all([self.uint16_field] == [other.uint16_field]) && ... + all([self.uint32_field] == [other.uint32_field]) && ... + all([self.int64_field] == [other.int64_field]) && ... + all([self.uint64_field] == [other.uint64_field]) && ... + all([self.size_field] == [other.size_field]) && ... + all([self.float32_field] == [other.float32_field]) && ... + all([self.float64_field] == [other.float64_field]) && ... + all([self.complexfloat32_field] == [other.complexfloat32_field]) && ... + all([self.complexfloat64_field] == [other.complexfloat64_field]) && ... + all([self.string_field] == [other.string_field]) && ... + isequal(self.tuple_field, other.tuple_field) && ... + all([self.vector_field] == [other.vector_field]) && ... + all([self.vector_of_vectors_field] == [other.vector_of_vectors_field]) && ... + all([self.fixed_vector_field] == [other.fixed_vector_field]) && ... + all([self.fixed_vector_of_vectors_field] == [other.fixed_vector_of_vectors_field]) && ... + isequal(self.optional_named_array, other.optional_named_array) && ... + all([self.int_float_union] == [other.int_float_union]) && ... + all([self.nullable_int_float_union] == [other.nullable_int_float_union]) && ... + all([self.union_with_nested_generic_union] == [other.union_with_nested_generic_union]) && ... + all([self.map_field] == [other.map_field]); + end + + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithDynamicNDArrays.m b/matlab/generated/+test_model/RecordWithDynamicNDArrays.m index af574e89..862484ef 100644 --- a/matlab/generated/+test_model/RecordWithDynamicNDArrays.m +++ b/matlab/generated/+test_model/RecordWithDynamicNDArrays.m @@ -8,28 +8,28 @@ end methods - function obj = RecordWithDynamicNDArrays(ints, simple_record_array, record_with_vlens_array) + function self = RecordWithDynamicNDArrays(ints, simple_record_array, record_with_vlens_array) if nargin > 0 - obj.ints = ints; - obj.simple_record_array = simple_record_array; - obj.record_with_vlens_array = record_with_vlens_array; + self.ints = ints; + self.simple_record_array = simple_record_array; + self.record_with_vlens_array = record_with_vlens_array; else - obj.ints = int32.empty(); - obj.simple_record_array = test_model.SimpleRecord.empty(); - obj.record_with_vlens_array = test_model.RecordWithVlens.empty(); + self.ints = int32.empty(); + self.simple_record_array = test_model.SimpleRecord.empty(); + self.record_with_vlens_array = test_model.RecordWithVlens.empty(); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithDynamicNDArrays') && ... - isequal(obj.ints, other.ints) && ... - isequal(obj.simple_record_array, other.simple_record_array) && ... - isequal(obj.record_with_vlens_array, other.record_with_vlens_array); + isequal(self.ints, other.ints) && ... + isequal(self.simple_record_array, other.simple_record_array) && ... + isequal(self.record_with_vlens_array, other.record_with_vlens_array); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithEnums.m b/matlab/generated/+test_model/RecordWithEnums.m index fd3df750..c8976891 100644 --- a/matlab/generated/+test_model/RecordWithEnums.m +++ b/matlab/generated/+test_model/RecordWithEnums.m @@ -8,28 +8,28 @@ end methods - function obj = RecordWithEnums(enum, flags, flags_2) + function self = RecordWithEnums(enum, flags, flags_2) if nargin > 0 - obj.enum = enum; - obj.flags = flags; - obj.flags_2 = flags_2; + self.enum = enum; + self.flags = flags; + self.flags_2 = flags_2; else - obj.enum = basic_types.Fruits.APPLE; - obj.flags = basic_types.DaysOfWeek(0); - obj.flags_2 = basic_types.TextFormat.REGULAR; + self.enum = basic_types.Fruits.APPLE; + self.flags = basic_types.DaysOfWeek(0); + self.flags_2 = basic_types.TextFormat.REGULAR; end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithEnums') && ... - all([obj.enum] == [other.enum]) && ... - all([obj.flags] == [other.flags]) && ... - all([obj.flags_2] == [other.flags_2]); + all([self.enum] == [other.enum]) && ... + all([self.flags] == [other.flags]) && ... + all([self.flags_2] == [other.flags_2]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithFixedArrays.m b/matlab/generated/+test_model/RecordWithFixedArrays.m index 2ba602b3..93f4575c 100644 --- a/matlab/generated/+test_model/RecordWithFixedArrays.m +++ b/matlab/generated/+test_model/RecordWithFixedArrays.m @@ -8,28 +8,28 @@ end methods - function obj = RecordWithFixedArrays(ints, fixed_simple_record_array, fixed_record_with_vlens_array) + function self = RecordWithFixedArrays(ints, fixed_simple_record_array, fixed_record_with_vlens_array) if nargin > 0 - obj.ints = ints; - obj.fixed_simple_record_array = fixed_simple_record_array; - obj.fixed_record_with_vlens_array = fixed_record_with_vlens_array; + self.ints = ints; + self.fixed_simple_record_array = fixed_simple_record_array; + self.fixed_record_with_vlens_array = fixed_record_with_vlens_array; else - obj.ints = repelem(int32(0), 3, 2); - obj.fixed_simple_record_array = repelem(test_model.SimpleRecord(), 2, 3); - obj.fixed_record_with_vlens_array = repelem(test_model.RecordWithVlens(), 2, 2); + self.ints = repelem(int32(0), 3, 2); + self.fixed_simple_record_array = repelem(test_model.SimpleRecord(), 2, 3); + self.fixed_record_with_vlens_array = repelem(test_model.RecordWithVlens(), 2, 2); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithFixedArrays') && ... - isequal(obj.ints, other.ints) && ... - isequal(obj.fixed_simple_record_array, other.fixed_simple_record_array) && ... - isequal(obj.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); + isequal(self.ints, other.ints) && ... + isequal(self.fixed_simple_record_array, other.fixed_simple_record_array) && ... + isequal(self.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithFixedCollections.m b/matlab/generated/+test_model/RecordWithFixedCollections.m index 48099eb4..c0d06ddd 100644 --- a/matlab/generated/+test_model/RecordWithFixedCollections.m +++ b/matlab/generated/+test_model/RecordWithFixedCollections.m @@ -7,25 +7,25 @@ end methods - function obj = RecordWithFixedCollections(fixed_vector, fixed_array) + function self = RecordWithFixedCollections(fixed_vector, fixed_array) if nargin > 0 - obj.fixed_vector = fixed_vector; - obj.fixed_array = fixed_array; + self.fixed_vector = fixed_vector; + self.fixed_array = fixed_array; else - obj.fixed_vector = repelem(int32(0), 3); - obj.fixed_array = repelem(int32(0), 3, 2); + self.fixed_vector = repelem(int32(0), 3); + self.fixed_array = repelem(int32(0), 3, 2); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithFixedCollections') && ... - all([obj.fixed_vector] == [other.fixed_vector]) && ... - isequal(obj.fixed_array, other.fixed_array); + all([self.fixed_vector] == [other.fixed_vector]) && ... + isequal(self.fixed_array, other.fixed_array); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithFixedVectors.m b/matlab/generated/+test_model/RecordWithFixedVectors.m index 08a21af1..abf1302d 100644 --- a/matlab/generated/+test_model/RecordWithFixedVectors.m +++ b/matlab/generated/+test_model/RecordWithFixedVectors.m @@ -8,28 +8,28 @@ end methods - function obj = RecordWithFixedVectors(fixed_int_vector, fixed_simple_record_vector, fixed_record_with_vlens_vector) + function self = RecordWithFixedVectors(fixed_int_vector, fixed_simple_record_vector, fixed_record_with_vlens_vector) if nargin > 0 - obj.fixed_int_vector = fixed_int_vector; - obj.fixed_simple_record_vector = fixed_simple_record_vector; - obj.fixed_record_with_vlens_vector = fixed_record_with_vlens_vector; + self.fixed_int_vector = fixed_int_vector; + self.fixed_simple_record_vector = fixed_simple_record_vector; + self.fixed_record_with_vlens_vector = fixed_record_with_vlens_vector; else - obj.fixed_int_vector = repelem(int32(0), 5); - obj.fixed_simple_record_vector = repelem(test_model.SimpleRecord(), 3); - obj.fixed_record_with_vlens_vector = repelem(test_model.RecordWithVlens(), 2); + self.fixed_int_vector = repelem(int32(0), 5); + self.fixed_simple_record_vector = repelem(test_model.SimpleRecord(), 3); + self.fixed_record_with_vlens_vector = repelem(test_model.RecordWithVlens(), 2); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithFixedVectors') && ... - all([obj.fixed_int_vector] == [other.fixed_int_vector]) && ... - all([obj.fixed_simple_record_vector] == [other.fixed_simple_record_vector]) && ... - all([obj.fixed_record_with_vlens_vector] == [other.fixed_record_with_vlens_vector]); + all([self.fixed_int_vector] == [other.fixed_int_vector]) && ... + all([self.fixed_simple_record_vector] == [other.fixed_simple_record_vector]) && ... + all([self.fixed_record_with_vlens_vector] == [other.fixed_record_with_vlens_vector]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithGenericArrays.m b/matlab/generated/+test_model/RecordWithGenericArrays.m index 80c578d3..db12b66a 100644 --- a/matlab/generated/+test_model/RecordWithGenericArrays.m +++ b/matlab/generated/+test_model/RecordWithGenericArrays.m @@ -11,28 +11,28 @@ end methods - function obj = RecordWithGenericArrays(nd, fixed_nd, dynamic_nd, aliased_nd, aliased_fixed_nd, aliased_dynamic_nd) - obj.nd = nd; - obj.fixed_nd = fixed_nd; - obj.dynamic_nd = dynamic_nd; - obj.aliased_nd = aliased_nd; - obj.aliased_fixed_nd = aliased_fixed_nd; - obj.aliased_dynamic_nd = aliased_dynamic_nd; + function self = RecordWithGenericArrays(nd, fixed_nd, dynamic_nd, aliased_nd, aliased_fixed_nd, aliased_dynamic_nd) + self.nd = nd; + self.fixed_nd = fixed_nd; + self.dynamic_nd = dynamic_nd; + self.aliased_nd = aliased_nd; + self.aliased_fixed_nd = aliased_fixed_nd; + self.aliased_dynamic_nd = aliased_dynamic_nd; end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithGenericArrays') && ... - isequal(obj.nd, other.nd) && ... - isequal(obj.fixed_nd, other.fixed_nd) && ... - isequal(obj.dynamic_nd, other.dynamic_nd) && ... - isequal(obj.aliased_nd, other.aliased_nd) && ... - isequal(obj.aliased_fixed_nd, other.aliased_fixed_nd) && ... - isequal(obj.aliased_dynamic_nd, other.aliased_dynamic_nd); + isequal(self.nd, other.nd) && ... + isequal(self.fixed_nd, other.fixed_nd) && ... + isequal(self.dynamic_nd, other.dynamic_nd) && ... + isequal(self.aliased_nd, other.aliased_nd) && ... + isequal(self.aliased_fixed_nd, other.aliased_fixed_nd) && ... + isequal(self.aliased_dynamic_nd, other.aliased_dynamic_nd); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithGenericFixedVectors.m b/matlab/generated/+test_model/RecordWithGenericFixedVectors.m index 73475e12..7bfedc7a 100644 --- a/matlab/generated/+test_model/RecordWithGenericFixedVectors.m +++ b/matlab/generated/+test_model/RecordWithGenericFixedVectors.m @@ -7,20 +7,20 @@ end methods - function obj = RecordWithGenericFixedVectors(fv, afv) - obj.fv = fv; - obj.afv = afv; + function self = RecordWithGenericFixedVectors(fv, afv) + self.fv = fv; + self.afv = afv; end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithGenericFixedVectors') && ... - isequal(obj.fv, other.fv) && ... - isequal(obj.afv, other.afv); + isequal(self.fv, other.fv) && ... + isequal(self.afv, other.afv); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithGenericMaps.m b/matlab/generated/+test_model/RecordWithGenericMaps.m index 52793233..28a282aa 100644 --- a/matlab/generated/+test_model/RecordWithGenericMaps.m +++ b/matlab/generated/+test_model/RecordWithGenericMaps.m @@ -7,25 +7,25 @@ end methods - function obj = RecordWithGenericMaps(m, am) + function self = RecordWithGenericMaps(m, am) if nargin > 0 - obj.m = m; - obj.am = am; + self.m = m; + self.am = am; else - obj.m = dictionary; - obj.am = dictionary; + self.m = dictionary; + self.am = dictionary; end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithGenericMaps') && ... - isequal(obj.m, other.m) && ... - isequal(obj.am, other.am); + isequal(self.m, other.m) && ... + isequal(self.am, other.am); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m b/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m index 7ee39136..cdd3afb2 100644 --- a/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m +++ b/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m @@ -6,18 +6,18 @@ end methods - function obj = RecordWithGenericVectorOfRecords(v) - obj.v = v; + function self = RecordWithGenericVectorOfRecords(v) + self.v = v; end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithGenericVectorOfRecords') && ... - isequal(obj.v, other.v); + isequal(self.v, other.v); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithGenericVectors.m b/matlab/generated/+test_model/RecordWithGenericVectors.m index 99b6e21a..9e6be939 100644 --- a/matlab/generated/+test_model/RecordWithGenericVectors.m +++ b/matlab/generated/+test_model/RecordWithGenericVectors.m @@ -7,20 +7,20 @@ end methods - function obj = RecordWithGenericVectors(v, av) - obj.v = v; - obj.av = av; + function self = RecordWithGenericVectors(v, av) + self.v = v; + self.av = av; end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithGenericVectors') && ... - isequal(obj.v, other.v) && ... - isequal(obj.av, other.av); + isequal(self.v, other.v) && ... + isequal(self.av, other.av); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithKeywordFields.m b/matlab/generated/+test_model/RecordWithKeywordFields.m index 6809fcb4..9f310072 100644 --- a/matlab/generated/+test_model/RecordWithKeywordFields.m +++ b/matlab/generated/+test_model/RecordWithKeywordFields.m @@ -8,10 +8,10 @@ end methods - function obj = RecordWithKeywordFields(int, sizeof, if_) - obj.int = int; - obj.sizeof = sizeof; - obj.if_ = if_; + function self = RecordWithKeywordFields(int, sizeof, if_) + self.int = int; + self.sizeof = sizeof; + self.if_ = if_; end function res = float(self) @@ -30,16 +30,16 @@ end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithKeywordFields') && ... - all([obj.int] == [other.int]) && ... - isequal(obj.sizeof, other.sizeof) && ... - all([obj.if_] == [other.if_]); + all([self.int] == [other.int]) && ... + isequal(self.sizeof, other.sizeof) && ... + all([self.if_] == [other.if_]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithNDArrays.m b/matlab/generated/+test_model/RecordWithNDArrays.m index 0ddc15f8..1b054102 100644 --- a/matlab/generated/+test_model/RecordWithNDArrays.m +++ b/matlab/generated/+test_model/RecordWithNDArrays.m @@ -8,28 +8,28 @@ end methods - function obj = RecordWithNDArrays(ints, fixed_simple_record_array, fixed_record_with_vlens_array) + function self = RecordWithNDArrays(ints, fixed_simple_record_array, fixed_record_with_vlens_array) if nargin > 0 - obj.ints = ints; - obj.fixed_simple_record_array = fixed_simple_record_array; - obj.fixed_record_with_vlens_array = fixed_record_with_vlens_array; + self.ints = ints; + self.fixed_simple_record_array = fixed_simple_record_array; + self.fixed_record_with_vlens_array = fixed_record_with_vlens_array; else - obj.ints = int32.empty(0, 0); - obj.fixed_simple_record_array = test_model.SimpleRecord.empty(0, 0); - obj.fixed_record_with_vlens_array = test_model.RecordWithVlens.empty(0, 0); + self.ints = int32.empty(0, 0); + self.fixed_simple_record_array = test_model.SimpleRecord.empty(0, 0); + self.fixed_record_with_vlens_array = test_model.RecordWithVlens.empty(0, 0); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithNDArrays') && ... - isequal(obj.ints, other.ints) && ... - isequal(obj.fixed_simple_record_array, other.fixed_simple_record_array) && ... - isequal(obj.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); + isequal(self.ints, other.ints) && ... + isequal(self.fixed_simple_record_array, other.fixed_simple_record_array) && ... + isequal(self.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m b/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m index ab973a92..263a7107 100644 --- a/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m +++ b/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m @@ -8,28 +8,28 @@ end methods - function obj = RecordWithNDArraysSingleDimension(ints, fixed_simple_record_array, fixed_record_with_vlens_array) + function self = RecordWithNDArraysSingleDimension(ints, fixed_simple_record_array, fixed_record_with_vlens_array) if nargin > 0 - obj.ints = ints; - obj.fixed_simple_record_array = fixed_simple_record_array; - obj.fixed_record_with_vlens_array = fixed_record_with_vlens_array; + self.ints = ints; + self.fixed_simple_record_array = fixed_simple_record_array; + self.fixed_record_with_vlens_array = fixed_record_with_vlens_array; else - obj.ints = int32.empty(0); - obj.fixed_simple_record_array = test_model.SimpleRecord.empty(0); - obj.fixed_record_with_vlens_array = test_model.RecordWithVlens.empty(0); + self.ints = int32.empty(0); + self.fixed_simple_record_array = test_model.SimpleRecord.empty(0); + self.fixed_record_with_vlens_array = test_model.RecordWithVlens.empty(0); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithNDArraysSingleDimension') && ... - isequal(obj.ints, other.ints) && ... - isequal(obj.fixed_simple_record_array, other.fixed_simple_record_array) && ... - isequal(obj.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); + isequal(self.ints, other.ints) && ... + isequal(self.fixed_simple_record_array, other.fixed_simple_record_array) && ... + isequal(self.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithNamedFixedArrays.m b/matlab/generated/+test_model/RecordWithNamedFixedArrays.m index 929f09ce..7ffc2b35 100644 --- a/matlab/generated/+test_model/RecordWithNamedFixedArrays.m +++ b/matlab/generated/+test_model/RecordWithNamedFixedArrays.m @@ -8,28 +8,28 @@ end methods - function obj = RecordWithNamedFixedArrays(ints, fixed_simple_record_array, fixed_record_with_vlens_array) + function self = RecordWithNamedFixedArrays(ints, fixed_simple_record_array, fixed_record_with_vlens_array) if nargin > 0 - obj.ints = ints; - obj.fixed_simple_record_array = fixed_simple_record_array; - obj.fixed_record_with_vlens_array = fixed_record_with_vlens_array; + self.ints = ints; + self.fixed_simple_record_array = fixed_simple_record_array; + self.fixed_record_with_vlens_array = fixed_record_with_vlens_array; else - obj.ints = repelem(int32(0), 3, 2); - obj.fixed_simple_record_array = repelem(test_model.SimpleRecord(), 2, 3); - obj.fixed_record_with_vlens_array = repelem(test_model.RecordWithVlens(), 2, 2); + self.ints = repelem(int32(0), 3, 2); + self.fixed_simple_record_array = repelem(test_model.SimpleRecord(), 2, 3); + self.fixed_record_with_vlens_array = repelem(test_model.RecordWithVlens(), 2, 2); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithNamedFixedArrays') && ... - isequal(obj.ints, other.ints) && ... - isequal(obj.fixed_simple_record_array, other.fixed_simple_record_array) && ... - isequal(obj.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); + isequal(self.ints, other.ints) && ... + isequal(self.fixed_simple_record_array, other.fixed_simple_record_array) && ... + isequal(self.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithOptionalFields.m b/matlab/generated/+test_model/RecordWithOptionalFields.m index e53b3320..b4359d52 100644 --- a/matlab/generated/+test_model/RecordWithOptionalFields.m +++ b/matlab/generated/+test_model/RecordWithOptionalFields.m @@ -8,28 +8,28 @@ end methods - function obj = RecordWithOptionalFields(optional_int, optional_int_alternate_syntax, optional_time) + function self = RecordWithOptionalFields(optional_int, optional_int_alternate_syntax, optional_time) if nargin > 0 - obj.optional_int = optional_int; - obj.optional_int_alternate_syntax = optional_int_alternate_syntax; - obj.optional_time = optional_time; + self.optional_int = optional_int; + self.optional_int_alternate_syntax = optional_int_alternate_syntax; + self.optional_time = optional_time; else - obj.optional_int = yardl.None; - obj.optional_int_alternate_syntax = yardl.None; - obj.optional_time = yardl.None; + self.optional_int = yardl.None; + self.optional_int_alternate_syntax = yardl.None; + self.optional_time = yardl.None; end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithOptionalFields') && ... - all([obj.optional_int] == [other.optional_int]) && ... - all([obj.optional_int_alternate_syntax] == [other.optional_int_alternate_syntax]) && ... - all([obj.optional_time] == [other.optional_time]); + all([self.optional_int] == [other.optional_int]) && ... + all([self.optional_int_alternate_syntax] == [other.optional_int_alternate_syntax]) && ... + all([self.optional_time] == [other.optional_time]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithOptionalGenericField.m b/matlab/generated/+test_model/RecordWithOptionalGenericField.m index c4b897fb..e2b51e96 100644 --- a/matlab/generated/+test_model/RecordWithOptionalGenericField.m +++ b/matlab/generated/+test_model/RecordWithOptionalGenericField.m @@ -6,22 +6,22 @@ end methods - function obj = RecordWithOptionalGenericField(v) + function self = RecordWithOptionalGenericField(v) if nargin > 0 - obj.v = v; + self.v = v; else - obj.v = yardl.None; + self.v = yardl.None; end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithOptionalGenericField') && ... - isequal(obj.v, other.v); + isequal(self.v, other.v); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m b/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m index 409d2183..06928b69 100644 --- a/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m +++ b/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m @@ -6,22 +6,22 @@ end methods - function obj = RecordWithOptionalGenericUnionField(v) + function self = RecordWithOptionalGenericUnionField(v) if nargin > 0 - obj.v = v; + self.v = v; else - obj.v = yardl.None; + self.v = yardl.None; end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithOptionalGenericUnionField') && ... - isequal(obj.v, other.v); + isequal(self.v, other.v); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithOptionalVector.m b/matlab/generated/+test_model/RecordWithOptionalVector.m index c735ce2d..c6235943 100644 --- a/matlab/generated/+test_model/RecordWithOptionalVector.m +++ b/matlab/generated/+test_model/RecordWithOptionalVector.m @@ -6,22 +6,22 @@ end methods - function obj = RecordWithOptionalVector(optional_vector) + function self = RecordWithOptionalVector(optional_vector) if nargin > 0 - obj.optional_vector = optional_vector; + self.optional_vector = optional_vector; else - obj.optional_vector = yardl.None; + self.optional_vector = yardl.None; end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithOptionalVector') && ... - all([obj.optional_vector] == [other.optional_vector]); + all([self.optional_vector] == [other.optional_vector]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithPrimitiveAliases.m b/matlab/generated/+test_model/RecordWithPrimitiveAliases.m index 89d6b9c5..cc4f84ac 100644 --- a/matlab/generated/+test_model/RecordWithPrimitiveAliases.m +++ b/matlab/generated/+test_model/RecordWithPrimitiveAliases.m @@ -14,46 +14,46 @@ end methods - function obj = RecordWithPrimitiveAliases(byte_field, int_field, uint_field, long_field, ulong_field, float_field, double_field, complexfloat_field, complexdouble_field) + function self = RecordWithPrimitiveAliases(byte_field, int_field, uint_field, long_field, ulong_field, float_field, double_field, complexfloat_field, complexdouble_field) if nargin > 0 - obj.byte_field = byte_field; - obj.int_field = int_field; - obj.uint_field = uint_field; - obj.long_field = long_field; - obj.ulong_field = ulong_field; - obj.float_field = float_field; - obj.double_field = double_field; - obj.complexfloat_field = complexfloat_field; - obj.complexdouble_field = complexdouble_field; + self.byte_field = byte_field; + self.int_field = int_field; + self.uint_field = uint_field; + self.long_field = long_field; + self.ulong_field = ulong_field; + self.float_field = float_field; + self.double_field = double_field; + self.complexfloat_field = complexfloat_field; + self.complexdouble_field = complexdouble_field; else - obj.byte_field = uint8(0); - obj.int_field = int32(0); - obj.uint_field = uint32(0); - obj.long_field = int64(0); - obj.ulong_field = uint64(0); - obj.float_field = single(0); - obj.double_field = double(0); - obj.complexfloat_field = complex(single(0)); - obj.complexdouble_field = complex(0); + self.byte_field = uint8(0); + self.int_field = int32(0); + self.uint_field = uint32(0); + self.long_field = int64(0); + self.ulong_field = uint64(0); + self.float_field = single(0); + self.double_field = double(0); + self.complexfloat_field = complex(single(0)); + self.complexdouble_field = complex(0); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithPrimitiveAliases') && ... - all([obj.byte_field] == [other.byte_field]) && ... - all([obj.int_field] == [other.int_field]) && ... - all([obj.uint_field] == [other.uint_field]) && ... - all([obj.long_field] == [other.long_field]) && ... - all([obj.ulong_field] == [other.ulong_field]) && ... - all([obj.float_field] == [other.float_field]) && ... - all([obj.double_field] == [other.double_field]) && ... - all([obj.complexfloat_field] == [other.complexfloat_field]) && ... - all([obj.complexdouble_field] == [other.complexdouble_field]); + all([self.byte_field] == [other.byte_field]) && ... + all([self.int_field] == [other.int_field]) && ... + all([self.uint_field] == [other.uint_field]) && ... + all([self.long_field] == [other.long_field]) && ... + all([self.ulong_field] == [other.ulong_field]) && ... + all([self.float_field] == [other.float_field]) && ... + all([self.double_field] == [other.double_field]) && ... + all([self.complexfloat_field] == [other.complexfloat_field]) && ... + all([self.complexdouble_field] == [other.complexdouble_field]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithPrimitives.m b/matlab/generated/+test_model/RecordWithPrimitives.m index 0b450113..22a59ae3 100644 --- a/matlab/generated/+test_model/RecordWithPrimitives.m +++ b/matlab/generated/+test_model/RecordWithPrimitives.m @@ -22,70 +22,70 @@ end methods - function obj = RecordWithPrimitives(bool_field, int8_field, uint8_field, int16_field, uint16_field, int32_field, uint32_field, int64_field, uint64_field, size_field, float32_field, float64_field, complexfloat32_field, complexfloat64_field, date_field, time_field, datetime_field) + function self = RecordWithPrimitives(bool_field, int8_field, uint8_field, int16_field, uint16_field, int32_field, uint32_field, int64_field, uint64_field, size_field, float32_field, float64_field, complexfloat32_field, complexfloat64_field, date_field, time_field, datetime_field) if nargin > 0 - obj.bool_field = bool_field; - obj.int8_field = int8_field; - obj.uint8_field = uint8_field; - obj.int16_field = int16_field; - obj.uint16_field = uint16_field; - obj.int32_field = int32_field; - obj.uint32_field = uint32_field; - obj.int64_field = int64_field; - obj.uint64_field = uint64_field; - obj.size_field = size_field; - obj.float32_field = float32_field; - obj.float64_field = float64_field; - obj.complexfloat32_field = complexfloat32_field; - obj.complexfloat64_field = complexfloat64_field; - obj.date_field = date_field; - obj.time_field = time_field; - obj.datetime_field = datetime_field; + self.bool_field = bool_field; + self.int8_field = int8_field; + self.uint8_field = uint8_field; + self.int16_field = int16_field; + self.uint16_field = uint16_field; + self.int32_field = int32_field; + self.uint32_field = uint32_field; + self.int64_field = int64_field; + self.uint64_field = uint64_field; + self.size_field = size_field; + self.float32_field = float32_field; + self.float64_field = float64_field; + self.complexfloat32_field = complexfloat32_field; + self.complexfloat64_field = complexfloat64_field; + self.date_field = date_field; + self.time_field = time_field; + self.datetime_field = datetime_field; else - obj.bool_field = false; - obj.int8_field = int8(0); - obj.uint8_field = uint8(0); - obj.int16_field = int16(0); - obj.uint16_field = uint16(0); - obj.int32_field = int32(0); - obj.uint32_field = uint32(0); - obj.int64_field = int64(0); - obj.uint64_field = uint64(0); - obj.size_field = uint64(0); - obj.float32_field = single(0); - obj.float64_field = double(0); - obj.complexfloat32_field = complex(single(0)); - obj.complexfloat64_field = complex(0); - obj.date_field = yardl.Date(); - obj.time_field = yardl.Time(); - obj.datetime_field = yardl.DateTime(); + self.bool_field = false; + self.int8_field = int8(0); + self.uint8_field = uint8(0); + self.int16_field = int16(0); + self.uint16_field = uint16(0); + self.int32_field = int32(0); + self.uint32_field = uint32(0); + self.int64_field = int64(0); + self.uint64_field = uint64(0); + self.size_field = uint64(0); + self.float32_field = single(0); + self.float64_field = double(0); + self.complexfloat32_field = complex(single(0)); + self.complexfloat64_field = complex(0); + self.date_field = yardl.Date(); + self.time_field = yardl.Time(); + self.datetime_field = yardl.DateTime(); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithPrimitives') && ... - all([obj.bool_field] == [other.bool_field]) && ... - all([obj.int8_field] == [other.int8_field]) && ... - all([obj.uint8_field] == [other.uint8_field]) && ... - all([obj.int16_field] == [other.int16_field]) && ... - all([obj.uint16_field] == [other.uint16_field]) && ... - all([obj.int32_field] == [other.int32_field]) && ... - all([obj.uint32_field] == [other.uint32_field]) && ... - all([obj.int64_field] == [other.int64_field]) && ... - all([obj.uint64_field] == [other.uint64_field]) && ... - all([obj.size_field] == [other.size_field]) && ... - all([obj.float32_field] == [other.float32_field]) && ... - all([obj.float64_field] == [other.float64_field]) && ... - all([obj.complexfloat32_field] == [other.complexfloat32_field]) && ... - all([obj.complexfloat64_field] == [other.complexfloat64_field]) && ... - all([obj.date_field] == [other.date_field]) && ... - all([obj.time_field] == [other.time_field]) && ... - all([obj.datetime_field] == [other.datetime_field]); + all([self.bool_field] == [other.bool_field]) && ... + all([self.int8_field] == [other.int8_field]) && ... + all([self.uint8_field] == [other.uint8_field]) && ... + all([self.int16_field] == [other.int16_field]) && ... + all([self.uint16_field] == [other.uint16_field]) && ... + all([self.int32_field] == [other.int32_field]) && ... + all([self.uint32_field] == [other.uint32_field]) && ... + all([self.int64_field] == [other.int64_field]) && ... + all([self.uint64_field] == [other.uint64_field]) && ... + all([self.size_field] == [other.size_field]) && ... + all([self.float32_field] == [other.float32_field]) && ... + all([self.float64_field] == [other.float64_field]) && ... + all([self.complexfloat32_field] == [other.complexfloat32_field]) && ... + all([self.complexfloat64_field] == [other.complexfloat64_field]) && ... + all([self.date_field] == [other.date_field]) && ... + all([self.time_field] == [other.time_field]) && ... + all([self.datetime_field] == [other.datetime_field]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithStrings.m b/matlab/generated/+test_model/RecordWithStrings.m index b3212991..a394bde6 100644 --- a/matlab/generated/+test_model/RecordWithStrings.m +++ b/matlab/generated/+test_model/RecordWithStrings.m @@ -7,25 +7,25 @@ end methods - function obj = RecordWithStrings(a, b) + function self = RecordWithStrings(a, b) if nargin > 0 - obj.a = a; - obj.b = b; + self.a = a; + self.b = b; else - obj.a = ""; - obj.b = ""; + self.a = ""; + self.b = ""; end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithStrings') && ... - all([obj.a] == [other.a]) && ... - all([obj.b] == [other.b]); + all([self.a] == [other.a]) && ... + all([self.b] == [other.b]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithUnionsOfContainers.m b/matlab/generated/+test_model/RecordWithUnionsOfContainers.m index f07f452b..b6b71c76 100644 --- a/matlab/generated/+test_model/RecordWithUnionsOfContainers.m +++ b/matlab/generated/+test_model/RecordWithUnionsOfContainers.m @@ -8,28 +8,28 @@ end methods - function obj = RecordWithUnionsOfContainers(map_or_scalar, vector_or_scalar, array_or_scalar) + function self = RecordWithUnionsOfContainers(map_or_scalar, vector_or_scalar, array_or_scalar) if nargin > 0 - obj.map_or_scalar = map_or_scalar; - obj.vector_or_scalar = vector_or_scalar; - obj.array_or_scalar = array_or_scalar; + self.map_or_scalar = map_or_scalar; + self.vector_or_scalar = vector_or_scalar; + self.array_or_scalar = array_or_scalar; else - obj.map_or_scalar = test_model.MapOrScalar.Map(dictionary); - obj.vector_or_scalar = test_model.VectorOrScalar.Vector(int32.empty()); - obj.array_or_scalar = test_model.ArrayOrScalar.Array(int32.empty()); + self.map_or_scalar = test_model.MapOrScalar.Map(dictionary); + self.vector_or_scalar = test_model.VectorOrScalar.Vector(int32.empty()); + self.array_or_scalar = test_model.ArrayOrScalar.Array(int32.empty()); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithUnionsOfContainers') && ... - all([obj.map_or_scalar] == [other.map_or_scalar]) && ... - all([obj.vector_or_scalar] == [other.vector_or_scalar]) && ... - isequal(obj.array_or_scalar, other.array_or_scalar); + all([self.map_or_scalar] == [other.map_or_scalar]) && ... + all([self.vector_or_scalar] == [other.vector_or_scalar]) && ... + isequal(self.array_or_scalar, other.array_or_scalar); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithVectorOfTimes.m b/matlab/generated/+test_model/RecordWithVectorOfTimes.m index ba8ee3e0..6c87279b 100644 --- a/matlab/generated/+test_model/RecordWithVectorOfTimes.m +++ b/matlab/generated/+test_model/RecordWithVectorOfTimes.m @@ -6,22 +6,22 @@ end methods - function obj = RecordWithVectorOfTimes(times) + function self = RecordWithVectorOfTimes(times) if nargin > 0 - obj.times = times; + self.times = times; else - obj.times = yardl.Time.empty(); + self.times = yardl.Time.empty(); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithVectorOfTimes') && ... - all([obj.times] == [other.times]); + all([self.times] == [other.times]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithVectors.m b/matlab/generated/+test_model/RecordWithVectors.m index d8c06d27..691da897 100644 --- a/matlab/generated/+test_model/RecordWithVectors.m +++ b/matlab/generated/+test_model/RecordWithVectors.m @@ -8,28 +8,28 @@ end methods - function obj = RecordWithVectors(default_vector, default_vector_fixed_length, vector_of_vectors) + function self = RecordWithVectors(default_vector, default_vector_fixed_length, vector_of_vectors) if nargin > 0 - obj.default_vector = default_vector; - obj.default_vector_fixed_length = default_vector_fixed_length; - obj.vector_of_vectors = vector_of_vectors; + self.default_vector = default_vector; + self.default_vector_fixed_length = default_vector_fixed_length; + self.vector_of_vectors = vector_of_vectors; else - obj.default_vector = int32.empty(); - obj.default_vector_fixed_length = repelem(int32(0), 3); - obj.vector_of_vectors = int32.empty(); + self.default_vector = int32.empty(); + self.default_vector_fixed_length = repelem(int32(0), 3); + self.vector_of_vectors = int32.empty(); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithVectors') && ... - all([obj.default_vector] == [other.default_vector]) && ... - all([obj.default_vector_fixed_length] == [other.default_vector_fixed_length]) && ... - all([obj.vector_of_vectors] == [other.vector_of_vectors]); + all([self.default_vector] == [other.default_vector]) && ... + all([self.default_vector_fixed_length] == [other.default_vector_fixed_length]) && ... + all([self.vector_of_vectors] == [other.vector_of_vectors]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithVlenCollections.m b/matlab/generated/+test_model/RecordWithVlenCollections.m index e346a3d7..61b958a5 100644 --- a/matlab/generated/+test_model/RecordWithVlenCollections.m +++ b/matlab/generated/+test_model/RecordWithVlenCollections.m @@ -7,25 +7,25 @@ end methods - function obj = RecordWithVlenCollections(vector, array) + function self = RecordWithVlenCollections(vector, array) if nargin > 0 - obj.vector = vector; - obj.array = array; + self.vector = vector; + self.array = array; else - obj.vector = int32.empty(); - obj.array = int32.empty(0, 0); + self.vector = int32.empty(); + self.array = int32.empty(0, 0); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithVlenCollections') && ... - all([obj.vector] == [other.vector]) && ... - isequal(obj.array, other.array); + all([self.vector] == [other.vector]) && ... + isequal(self.array, other.array); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithVlens.m b/matlab/generated/+test_model/RecordWithVlens.m index 35c333d8..ab6c8f77 100644 --- a/matlab/generated/+test_model/RecordWithVlens.m +++ b/matlab/generated/+test_model/RecordWithVlens.m @@ -8,28 +8,28 @@ end methods - function obj = RecordWithVlens(a, b, c) + function self = RecordWithVlens(a, b, c) if nargin > 0 - obj.a = a; - obj.b = b; - obj.c = c; + self.a = a; + self.b = b; + self.c = c; else - obj.a = test_model.SimpleRecord.empty(); - obj.b = int32(0); - obj.c = int32(0); + self.a = test_model.SimpleRecord.empty(); + self.b = int32(0); + self.c = int32(0); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.RecordWithVlens') && ... - all([obj.a] == [other.a]) && ... - all([obj.b] == [other.b]) && ... - all([obj.c] == [other.c]); + all([self.a] == [other.a]) && ... + all([self.b] == [other.b]) && ... + all([self.c] == [other.c]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/RecordWithVlensFixedArray.m b/matlab/generated/+test_model/RecordWithVlensFixedArray.m index b63350e1..71f9d411 100644 --- a/matlab/generated/+test_model/RecordWithVlensFixedArray.m +++ b/matlab/generated/+test_model/RecordWithVlensFixedArray.m @@ -1,6 +1,8 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. function a = RecordWithVlensFixedArray(array) - assert(isa(array, 'test_model.RecordWithVlens')); + arguments + array test_model.RecordWithVlens + end a = array; end diff --git a/matlab/generated/+test_model/ScalarOptionalsReaderBase.m b/matlab/generated/+test_model/ScalarOptionalsReaderBase.m index 025be340..033483f7 100644 --- a/matlab/generated/+test_model/ScalarOptionalsReaderBase.m +++ b/matlab/generated/+test_model/ScalarOptionalsReaderBase.m @@ -6,63 +6,63 @@ end methods - function obj = ScalarOptionalsReaderBase() - obj.state_ = 0; + function self = ScalarOptionalsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_optional_int(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_optional_int(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_optional_int_(); - obj.state_ = 1; + value = self.read_optional_int_(); + self.state_ = 1; end % Ordinal 1 - function value = read_optional_record(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_optional_record(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_optional_record_(); - obj.state_ = 2; + value = self.read_optional_record_(); + self.state_ = 2; end % Ordinal 2 - function value = read_record_with_optional_fields(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_record_with_optional_fields(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_record_with_optional_fields_(); - obj.state_ = 3; + value = self.read_record_with_optional_fields_(); + self.state_ = 3; end % Ordinal 3 - function value = read_optional_record_with_optional_fields(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function value = read_optional_record_with_optional_fields(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - value = obj.read_optional_record_with_optional_fields_(); - obj.state_ = 4; + value = self.read_optional_record_with_optional_fields_(); + self.state_ = 4; end - function copy_to(obj, writer) - writer.write_optional_int(obj.read_optional_int()); - writer.write_optional_record(obj.read_optional_record()); - writer.write_record_with_optional_fields(obj.read_record_with_optional_fields()); - writer.write_optional_record_with_optional_fields(obj.read_optional_record_with_optional_fields()); + function copy_to(self, writer) + writer.write_optional_int(self.read_optional_int()); + writer.write_optional_record(self.read_optional_record()); + writer.write_record_with_optional_fields(self.read_record_with_optional_fields()); + writer.write_optional_record_with_optional_fields(self.read_optional_record_with_optional_fields()); end end @@ -73,32 +73,32 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_optional_int_(obj) - read_optional_record_(obj) - read_record_with_optional_fields_(obj) - read_optional_record_with_optional_fields_(obj) + read_optional_int_(self) + read_optional_record_(self) + read_record_with_optional_fields_(self) + read_optional_record_with_optional_fields_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_optional_int'; + name = "read_optional_int"; elseif state == 1 - name = 'read_optional_record'; + name = "read_optional_record"; elseif state == 2 - name = 'read_record_with_optional_fields'; + name = "read_record_with_optional_fields"; elseif state == 3 - name = 'read_optional_record_with_optional_fields'; + name = "read_optional_record_with_optional_fields"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/ScalarOptionalsWriterBase.m b/matlab/generated/+test_model/ScalarOptionalsWriterBase.m index 31f97826..0a5a24ab 100644 --- a/matlab/generated/+test_model/ScalarOptionalsWriterBase.m +++ b/matlab/generated/+test_model/ScalarOptionalsWriterBase.m @@ -7,56 +7,56 @@ end methods - function obj = ScalarOptionalsWriterBase() - obj.state_ = 0; + function self = ScalarOptionalsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_optional_int(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_optional_int(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_optional_int_(value); - obj.state_ = 1; + self.write_optional_int_(value); + self.state_ = 1; end % Ordinal 1 - function write_optional_record(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_optional_record(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_optional_record_(value); - obj.state_ = 2; + self.write_optional_record_(value); + self.state_ = 2; end % Ordinal 2 - function write_record_with_optional_fields(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_record_with_optional_fields(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_record_with_optional_fields_(value); - obj.state_ = 3; + self.write_record_with_optional_fields_(value); + self.state_ = 3; end % Ordinal 3 - function write_optional_record_with_optional_fields(obj, value) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function write_optional_record_with_optional_fields(self, value) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - obj.write_optional_record_with_optional_fields_(value); - obj.state_ = 4; + self.write_optional_record_with_optional_fields_(value); + self.state_ = 4; end end @@ -67,31 +67,31 @@ function write_optional_record_with_optional_fields(obj, value) end methods (Abstract, Access=protected) - write_optional_int_(obj, value) - write_optional_record_(obj, value) - write_record_with_optional_fields_(obj, value) - write_optional_record_with_optional_fields_(obj, value) + write_optional_int_(self, value) + write_optional_record_(self, value) + write_record_with_optional_fields_(self, value) + write_optional_record_with_optional_fields_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_optional_int'; + name = "write_optional_int"; elseif state == 1 - name = 'write_optional_record'; + name = "write_optional_record"; elseif state == 2 - name = 'write_record_with_optional_fields'; + name = "write_record_with_optional_fields"; elseif state == 3 - name = 'write_optional_record_with_optional_fields'; + name = "write_optional_record_with_optional_fields"; else name = ''; end diff --git a/matlab/generated/+test_model/ScalarsReaderBase.m b/matlab/generated/+test_model/ScalarsReaderBase.m index fb963c40..54acf102 100644 --- a/matlab/generated/+test_model/ScalarsReaderBase.m +++ b/matlab/generated/+test_model/ScalarsReaderBase.m @@ -6,41 +6,41 @@ end methods - function obj = ScalarsReaderBase() - obj.state_ = 0; + function self = ScalarsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 2 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_int32(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_int32(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_int32_(); - obj.state_ = 1; + value = self.read_int32_(); + self.state_ = 1; end % Ordinal 1 - function value = read_record(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_record(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_record_(); - obj.state_ = 2; + value = self.read_record_(); + self.state_ = 2; end - function copy_to(obj, writer) - writer.write_int32(obj.read_int32()); - writer.write_record(obj.read_record()); + function copy_to(self, writer) + writer.write_int32(self.read_int32()); + writer.write_record(self.read_record()); end end @@ -51,26 +51,26 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_int32_(obj) - read_record_(obj) + read_int32_(self) + read_record_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_int32'; + name = "read_int32"; elseif state == 1 - name = 'read_record'; + name = "read_record"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/ScalarsWriterBase.m b/matlab/generated/+test_model/ScalarsWriterBase.m index 82682635..fb95039d 100644 --- a/matlab/generated/+test_model/ScalarsWriterBase.m +++ b/matlab/generated/+test_model/ScalarsWriterBase.m @@ -7,36 +7,36 @@ end methods - function obj = ScalarsWriterBase() - obj.state_ = 0; + function self = ScalarsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 2 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_int32(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_int32(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_int32_(value); - obj.state_ = 1; + self.write_int32_(value); + self.state_ = 1; end % Ordinal 1 - function write_record(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_record(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_record_(value); - obj.state_ = 2; + self.write_record_(value); + self.state_ = 2; end end @@ -47,25 +47,25 @@ function write_record(obj, value) end methods (Abstract, Access=protected) - write_int32_(obj, value) - write_record_(obj, value) + write_int32_(self, value) + write_record_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_int32'; + name = "write_int32"; elseif state == 1 - name = 'write_record'; + name = "write_record"; else name = ''; end diff --git a/matlab/generated/+test_model/SimpleAcquisition.m b/matlab/generated/+test_model/SimpleAcquisition.m index 4487a13b..584e9dcb 100644 --- a/matlab/generated/+test_model/SimpleAcquisition.m +++ b/matlab/generated/+test_model/SimpleAcquisition.m @@ -9,31 +9,31 @@ end methods - function obj = SimpleAcquisition(flags, idx, data, trajectory) + function self = SimpleAcquisition(flags, idx, data, trajectory) if nargin > 0 - obj.flags = flags; - obj.idx = idx; - obj.data = data; - obj.trajectory = trajectory; + self.flags = flags; + self.idx = idx; + self.data = data; + self.trajectory = trajectory; else - obj.flags = uint64(0); - obj.idx = test_model.SimpleEncodingCounters(); - obj.data = single.empty(0, 0); - obj.trajectory = single.empty(0, 0); + self.flags = uint64(0); + self.idx = test_model.SimpleEncodingCounters(); + self.data = single.empty(0, 0); + self.trajectory = single.empty(0, 0); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.SimpleAcquisition') && ... - all([obj.flags] == [other.flags]) && ... - all([obj.idx] == [other.idx]) && ... - isequal(obj.data, other.data) && ... - isequal(obj.trajectory, other.trajectory); + all([self.flags] == [other.flags]) && ... + all([self.idx] == [other.idx]) && ... + isequal(self.data, other.data) && ... + isequal(self.trajectory, other.trajectory); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/SimpleEncodingCounters.m b/matlab/generated/+test_model/SimpleEncodingCounters.m index da69c5a5..c248d969 100644 --- a/matlab/generated/+test_model/SimpleEncodingCounters.m +++ b/matlab/generated/+test_model/SimpleEncodingCounters.m @@ -9,31 +9,31 @@ end methods - function obj = SimpleEncodingCounters(e1, e2, slice, repetition) + function self = SimpleEncodingCounters(e1, e2, slice, repetition) if nargin > 0 - obj.e1 = e1; - obj.e2 = e2; - obj.slice = slice; - obj.repetition = repetition; + self.e1 = e1; + self.e2 = e2; + self.slice = slice; + self.repetition = repetition; else - obj.e1 = yardl.None; - obj.e2 = yardl.None; - obj.slice = yardl.None; - obj.repetition = yardl.None; + self.e1 = yardl.None; + self.e2 = yardl.None; + self.slice = yardl.None; + self.repetition = yardl.None; end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.SimpleEncodingCounters') && ... - all([obj.e1] == [other.e1]) && ... - all([obj.e2] == [other.e2]) && ... - all([obj.slice] == [other.slice]) && ... - all([obj.repetition] == [other.repetition]); + all([self.e1] == [other.e1]) && ... + all([self.e2] == [other.e2]) && ... + all([self.slice] == [other.slice]) && ... + all([self.repetition] == [other.repetition]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/SimpleGenericsReaderBase.m b/matlab/generated/+test_model/SimpleGenericsReaderBase.m index 1f8741fa..744c6936 100644 --- a/matlab/generated/+test_model/SimpleGenericsReaderBase.m +++ b/matlab/generated/+test_model/SimpleGenericsReaderBase.m @@ -6,129 +6,129 @@ end methods - function obj = SimpleGenericsReaderBase() - obj.state_ = 0; + function self = SimpleGenericsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 9 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 9 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_float_image(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_float_image(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_float_image_(); - obj.state_ = 1; + value = self.read_float_image_(); + self.state_ = 1; end % Ordinal 1 - function value = read_int_image(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_int_image(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_int_image_(); - obj.state_ = 2; + value = self.read_int_image_(); + self.state_ = 2; end % Ordinal 2 - function value = read_int_image_alternate_syntax(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_int_image_alternate_syntax(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_int_image_alternate_syntax_(); - obj.state_ = 3; + value = self.read_int_image_alternate_syntax_(); + self.state_ = 3; end % Ordinal 3 - function value = read_string_image(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function value = read_string_image(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - value = obj.read_string_image_(); - obj.state_ = 4; + value = self.read_string_image_(); + self.state_ = 4; end % Ordinal 4 - function value = read_int_float_tuple(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + function value = read_int_float_tuple(self) + if self.state_ ~= 4 + self.raise_unexpected_state_(4); end - value = obj.read_int_float_tuple_(); - obj.state_ = 5; + value = self.read_int_float_tuple_(); + self.state_ = 5; end % Ordinal 5 - function value = read_float_float_tuple(obj) - if obj.state_ ~= 5 - obj.raise_unexpected_state_(5); + function value = read_float_float_tuple(self) + if self.state_ ~= 5 + self.raise_unexpected_state_(5); end - value = obj.read_float_float_tuple_(); - obj.state_ = 6; + value = self.read_float_float_tuple_(); + self.state_ = 6; end % Ordinal 6 - function value = read_int_float_tuple_alternate_syntax(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + function value = read_int_float_tuple_alternate_syntax(self) + if self.state_ ~= 6 + self.raise_unexpected_state_(6); end - value = obj.read_int_float_tuple_alternate_syntax_(); - obj.state_ = 7; + value = self.read_int_float_tuple_alternate_syntax_(); + self.state_ = 7; end % Ordinal 7 - function value = read_int_string_tuple(obj) - if obj.state_ ~= 7 - obj.raise_unexpected_state_(7); + function value = read_int_string_tuple(self) + if self.state_ ~= 7 + self.raise_unexpected_state_(7); end - value = obj.read_int_string_tuple_(); - obj.state_ = 8; + value = self.read_int_string_tuple_(); + self.state_ = 8; end % Ordinal 8 - function more = has_stream_of_type_variants(obj) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + function more = has_stream_of_type_variants(self) + if self.state_ ~= 8 + self.raise_unexpected_state_(8); end - more = obj.has_stream_of_type_variants_(); + more = self.has_stream_of_type_variants_(); if ~more - obj.state_ = 9; + self.state_ = 9; end end - function value = read_stream_of_type_variants(obj) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + function value = read_stream_of_type_variants(self) + if self.state_ ~= 8 + self.raise_unexpected_state_(8); end - value = obj.read_stream_of_type_variants_(); + value = self.read_stream_of_type_variants_(); end - function copy_to(obj, writer) - writer.write_float_image(obj.read_float_image()); - writer.write_int_image(obj.read_int_image()); - writer.write_int_image_alternate_syntax(obj.read_int_image_alternate_syntax()); - writer.write_string_image(obj.read_string_image()); - writer.write_int_float_tuple(obj.read_int_float_tuple()); - writer.write_float_float_tuple(obj.read_float_float_tuple()); - writer.write_int_float_tuple_alternate_syntax(obj.read_int_float_tuple_alternate_syntax()); - writer.write_int_string_tuple(obj.read_int_string_tuple()); - while obj.has_stream_of_type_variants() - item = obj.read_stream_of_type_variants(); + function copy_to(self, writer) + writer.write_float_image(self.read_float_image()); + writer.write_int_image(self.read_int_image()); + writer.write_int_image_alternate_syntax(self.read_int_image_alternate_syntax()); + writer.write_string_image(self.read_string_image()); + writer.write_int_float_tuple(self.read_int_float_tuple()); + writer.write_float_float_tuple(self.read_float_float_tuple()); + writer.write_int_float_tuple_alternate_syntax(self.read_int_float_tuple_alternate_syntax()); + writer.write_int_string_tuple(self.read_int_string_tuple()); + while self.has_stream_of_type_variants() + item = self.read_stream_of_type_variants(); writer.write_stream_of_type_variants({item}); end writer.end_stream_of_type_variants(); @@ -142,48 +142,48 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_float_image_(obj) - read_int_image_(obj) - read_int_image_alternate_syntax_(obj) - read_string_image_(obj) - read_int_float_tuple_(obj) - read_float_float_tuple_(obj) - read_int_float_tuple_alternate_syntax_(obj) - read_int_string_tuple_(obj) - has_stream_of_type_variants_(obj) - read_stream_of_type_variants_(obj) - - close_(obj) + read_float_image_(self) + read_int_image_(self) + read_int_image_alternate_syntax_(self) + read_string_image_(self) + read_int_float_tuple_(self) + read_float_float_tuple_(self) + read_int_float_tuple_alternate_syntax_(self) + read_int_string_tuple_(self) + has_stream_of_type_variants_(self) + read_stream_of_type_variants_(self) + + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_float_image'; + name = "read_float_image"; elseif state == 1 - name = 'read_int_image'; + name = "read_int_image"; elseif state == 2 - name = 'read_int_image_alternate_syntax'; + name = "read_int_image_alternate_syntax"; elseif state == 3 - name = 'read_string_image'; + name = "read_string_image"; elseif state == 4 - name = 'read_int_float_tuple'; + name = "read_int_float_tuple"; elseif state == 5 - name = 'read_float_float_tuple'; + name = "read_float_float_tuple"; elseif state == 6 - name = 'read_int_float_tuple_alternate_syntax'; + name = "read_int_float_tuple_alternate_syntax"; elseif state == 7 - name = 'read_int_string_tuple'; + name = "read_int_string_tuple"; elseif state == 8 - name = 'read_stream_of_type_variants'; + name = "read_stream_of_type_variants"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/SimpleGenericsWriterBase.m b/matlab/generated/+test_model/SimpleGenericsWriterBase.m index f79af39f..4e5240ea 100644 --- a/matlab/generated/+test_model/SimpleGenericsWriterBase.m +++ b/matlab/generated/+test_model/SimpleGenericsWriterBase.m @@ -7,114 +7,114 @@ end methods - function obj = SimpleGenericsWriterBase() - obj.state_ = 0; + function self = SimpleGenericsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 9 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 9 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_float_image(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_float_image(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_float_image_(value); - obj.state_ = 1; + self.write_float_image_(value); + self.state_ = 1; end % Ordinal 1 - function write_int_image(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_int_image(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_int_image_(value); - obj.state_ = 2; + self.write_int_image_(value); + self.state_ = 2; end % Ordinal 2 - function write_int_image_alternate_syntax(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_int_image_alternate_syntax(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_int_image_alternate_syntax_(value); - obj.state_ = 3; + self.write_int_image_alternate_syntax_(value); + self.state_ = 3; end % Ordinal 3 - function write_string_image(obj, value) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function write_string_image(self, value) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - obj.write_string_image_(value); - obj.state_ = 4; + self.write_string_image_(value); + self.state_ = 4; end % Ordinal 4 - function write_int_float_tuple(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + function write_int_float_tuple(self, value) + if self.state_ ~= 4 + self.raise_unexpected_state_(4); end - obj.write_int_float_tuple_(value); - obj.state_ = 5; + self.write_int_float_tuple_(value); + self.state_ = 5; end % Ordinal 5 - function write_float_float_tuple(obj, value) - if obj.state_ ~= 5 - obj.raise_unexpected_state_(5); + function write_float_float_tuple(self, value) + if self.state_ ~= 5 + self.raise_unexpected_state_(5); end - obj.write_float_float_tuple_(value); - obj.state_ = 6; + self.write_float_float_tuple_(value); + self.state_ = 6; end % Ordinal 6 - function write_int_float_tuple_alternate_syntax(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + function write_int_float_tuple_alternate_syntax(self, value) + if self.state_ ~= 6 + self.raise_unexpected_state_(6); end - obj.write_int_float_tuple_alternate_syntax_(value); - obj.state_ = 7; + self.write_int_float_tuple_alternate_syntax_(value); + self.state_ = 7; end % Ordinal 7 - function write_int_string_tuple(obj, value) - if obj.state_ ~= 7 - obj.raise_unexpected_state_(7); + function write_int_string_tuple(self, value) + if self.state_ ~= 7 + self.raise_unexpected_state_(7); end - obj.write_int_string_tuple_(value); - obj.state_ = 8; + self.write_int_string_tuple_(value); + self.state_ = 8; end % Ordinal 8 - function write_stream_of_type_variants(obj, value) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + function write_stream_of_type_variants(self, value) + if self.state_ ~= 8 + self.raise_unexpected_state_(8); end - obj.write_stream_of_type_variants_(value); + self.write_stream_of_type_variants_(value); end - function end_stream_of_type_variants(obj) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + function end_stream_of_type_variants(self) + if self.state_ ~= 8 + self.raise_unexpected_state_(8); end - obj.end_stream_(); - obj.state_ = 9; + self.end_stream_(); + self.state_ = 9; end end @@ -125,46 +125,46 @@ function end_stream_of_type_variants(obj) end methods (Abstract, Access=protected) - write_float_image_(obj, value) - write_int_image_(obj, value) - write_int_image_alternate_syntax_(obj, value) - write_string_image_(obj, value) - write_int_float_tuple_(obj, value) - write_float_float_tuple_(obj, value) - write_int_float_tuple_alternate_syntax_(obj, value) - write_int_string_tuple_(obj, value) - write_stream_of_type_variants_(obj, value) - - end_stream_(obj) - close_(obj) + write_float_image_(self, value) + write_int_image_(self, value) + write_int_image_alternate_syntax_(self, value) + write_string_image_(self, value) + write_int_float_tuple_(self, value) + write_float_float_tuple_(self, value) + write_int_float_tuple_alternate_syntax_(self, value) + write_int_string_tuple_(self, value) + write_stream_of_type_variants_(self, value) + + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_float_image'; + name = "write_float_image"; elseif state == 1 - name = 'write_int_image'; + name = "write_int_image"; elseif state == 2 - name = 'write_int_image_alternate_syntax'; + name = "write_int_image_alternate_syntax"; elseif state == 3 - name = 'write_string_image'; + name = "write_string_image"; elseif state == 4 - name = 'write_int_float_tuple'; + name = "write_int_float_tuple"; elseif state == 5 - name = 'write_float_float_tuple'; + name = "write_float_float_tuple"; elseif state == 6 - name = 'write_int_float_tuple_alternate_syntax'; + name = "write_int_float_tuple_alternate_syntax"; elseif state == 7 - name = 'write_int_string_tuple'; + name = "write_int_string_tuple"; elseif state == 8 - name = 'write_stream_of_type_variants or end_stream_of_type_variants'; + name = "write_stream_of_type_variants or end_stream_of_type_variants"; else name = ''; end diff --git a/matlab/generated/+test_model/SimpleRecord.m b/matlab/generated/+test_model/SimpleRecord.m index e70dd649..1c54c310 100644 --- a/matlab/generated/+test_model/SimpleRecord.m +++ b/matlab/generated/+test_model/SimpleRecord.m @@ -8,28 +8,28 @@ end methods - function obj = SimpleRecord(x, y, z) + function self = SimpleRecord(x, y, z) if nargin > 0 - obj.x = x; - obj.y = y; - obj.z = z; + self.x = x; + self.y = y; + self.z = z; else - obj.x = int32(0); - obj.y = int32(0); - obj.z = int32(0); + self.x = int32(0); + self.y = int32(0); + self.z = int32(0); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.SimpleRecord') && ... - all([obj.x] == [other.x]) && ... - all([obj.y] == [other.y]) && ... - all([obj.z] == [other.z]); + all([self.x] == [other.x]) && ... + all([self.y] == [other.y]) && ... + all([self.z] == [other.z]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/SimpleRecordFixedArray.m b/matlab/generated/+test_model/SimpleRecordFixedArray.m index 4ebc0649..b53b7636 100644 --- a/matlab/generated/+test_model/SimpleRecordFixedArray.m +++ b/matlab/generated/+test_model/SimpleRecordFixedArray.m @@ -1,6 +1,8 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. function a = SimpleRecordFixedArray(array) - assert(isa(array, 'test_model.SimpleRecord')); + arguments + array test_model.SimpleRecord + end a = array; end diff --git a/matlab/generated/+test_model/SmallBenchmarkRecord.m b/matlab/generated/+test_model/SmallBenchmarkRecord.m index 6a9b9566..f27c0e8d 100644 --- a/matlab/generated/+test_model/SmallBenchmarkRecord.m +++ b/matlab/generated/+test_model/SmallBenchmarkRecord.m @@ -8,28 +8,28 @@ end methods - function obj = SmallBenchmarkRecord(a, b, c) + function self = SmallBenchmarkRecord(a, b, c) if nargin > 0 - obj.a = a; - obj.b = b; - obj.c = c; + self.a = a; + self.b = b; + self.c = c; else - obj.a = double(0); - obj.b = single(0); - obj.c = single(0); + self.a = double(0); + self.b = single(0); + self.c = single(0); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.SmallBenchmarkRecord') && ... - all([obj.a] == [other.a]) && ... - all([obj.b] == [other.b]) && ... - all([obj.c] == [other.c]); + all([self.a] == [other.a]) && ... + all([self.b] == [other.b]) && ... + all([self.c] == [other.c]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/StateTestReaderBase.m b/matlab/generated/+test_model/StateTestReaderBase.m index e1e61f1a..78a134e5 100644 --- a/matlab/generated/+test_model/StateTestReaderBase.m +++ b/matlab/generated/+test_model/StateTestReaderBase.m @@ -6,66 +6,66 @@ end methods - function obj = StateTestReaderBase() - obj.state_ = 0; + function self = StateTestReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 3 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 3 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_an_int(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_an_int(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_an_int_(); - obj.state_ = 1; + value = self.read_an_int_(); + self.state_ = 1; end % Ordinal 1 - function more = has_a_stream(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function more = has_a_stream(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - more = obj.has_a_stream_(); + more = self.has_a_stream_(); if ~more - obj.state_ = 2; + self.state_ = 2; end end - function value = read_a_stream(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_a_stream(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_a_stream_(); + value = self.read_a_stream_(); end % Ordinal 2 - function value = read_another_int(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_another_int(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_another_int_(); - obj.state_ = 3; + value = self.read_another_int_(); + self.state_ = 3; end - function copy_to(obj, writer) - writer.write_an_int(obj.read_an_int()); - while obj.has_a_stream() - item = obj.read_a_stream(); + function copy_to(self, writer) + writer.write_an_int(self.read_an_int()); + while self.has_a_stream() + item = self.read_a_stream(); writer.write_a_stream({item}); end writer.end_a_stream(); - writer.write_another_int(obj.read_another_int()); + writer.write_another_int(self.read_another_int()); end end @@ -76,30 +76,30 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_an_int_(obj) - has_a_stream_(obj) - read_a_stream_(obj) - read_another_int_(obj) + read_an_int_(self) + has_a_stream_(self) + read_a_stream_(self) + read_another_int_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_an_int'; + name = "read_an_int"; elseif state == 1 - name = 'read_a_stream'; + name = "read_a_stream"; elseif state == 2 - name = 'read_another_int'; + name = "read_another_int"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/StateTestWriterBase.m b/matlab/generated/+test_model/StateTestWriterBase.m index 1e588e01..44130dd8 100644 --- a/matlab/generated/+test_model/StateTestWriterBase.m +++ b/matlab/generated/+test_model/StateTestWriterBase.m @@ -7,54 +7,54 @@ end methods - function obj = StateTestWriterBase() - obj.state_ = 0; + function self = StateTestWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 3 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 3 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_an_int(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_an_int(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_an_int_(value); - obj.state_ = 1; + self.write_an_int_(value); + self.state_ = 1; end % Ordinal 1 - function write_a_stream(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_a_stream(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_a_stream_(value); + self.write_a_stream_(value); end - function end_a_stream(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function end_a_stream(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.end_stream_(); - obj.state_ = 2; + self.end_stream_(); + self.state_ = 2; end % Ordinal 2 - function write_another_int(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_another_int(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_another_int_(value); - obj.state_ = 3; + self.write_another_int_(value); + self.state_ = 3; end end @@ -65,28 +65,28 @@ function write_another_int(obj, value) end methods (Abstract, Access=protected) - write_an_int_(obj, value) - write_a_stream_(obj, value) - write_another_int_(obj, value) + write_an_int_(self, value) + write_a_stream_(self, value) + write_another_int_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_an_int'; + name = "write_an_int"; elseif state == 1 - name = 'write_a_stream or end_a_stream'; + name = "write_a_stream or end_a_stream"; elseif state == 2 - name = 'write_another_int'; + name = "write_another_int"; else name = ''; end diff --git a/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m b/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m index 7880f2df..cb6b79c1 100644 --- a/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m +++ b/matlab/generated/+test_model/StreamsOfAliasedUnionsReaderBase.m @@ -6,66 +6,66 @@ end methods - function obj = StreamsOfAliasedUnionsReaderBase() - obj.state_ = 0; + function self = StreamsOfAliasedUnionsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 2 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function more = has_int_or_simple_record(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function more = has_int_or_simple_record(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - more = obj.has_int_or_simple_record_(); + more = self.has_int_or_simple_record_(); if ~more - obj.state_ = 1; + self.state_ = 1; end end - function value = read_int_or_simple_record(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_int_or_simple_record(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_int_or_simple_record_(); + value = self.read_int_or_simple_record_(); end % Ordinal 1 - function more = has_nullable_int_or_simple_record(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function more = has_nullable_int_or_simple_record(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - more = obj.has_nullable_int_or_simple_record_(); + more = self.has_nullable_int_or_simple_record_(); if ~more - obj.state_ = 2; + self.state_ = 2; end end - function value = read_nullable_int_or_simple_record(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_nullable_int_or_simple_record(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_nullable_int_or_simple_record_(); + value = self.read_nullable_int_or_simple_record_(); end - function copy_to(obj, writer) - while obj.has_int_or_simple_record() - item = obj.read_int_or_simple_record(); + function copy_to(self, writer) + while self.has_int_or_simple_record() + item = self.read_int_or_simple_record(); writer.write_int_or_simple_record({item}); end writer.end_int_or_simple_record(); - while obj.has_nullable_int_or_simple_record() - item = obj.read_nullable_int_or_simple_record(); + while self.has_nullable_int_or_simple_record() + item = self.read_nullable_int_or_simple_record(); writer.write_nullable_int_or_simple_record({item}); end writer.end_nullable_int_or_simple_record(); @@ -79,28 +79,28 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - has_int_or_simple_record_(obj) - read_int_or_simple_record_(obj) - has_nullable_int_or_simple_record_(obj) - read_nullable_int_or_simple_record_(obj) + has_int_or_simple_record_(self) + read_int_or_simple_record_(self) + has_nullable_int_or_simple_record_(self) + read_nullable_int_or_simple_record_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_int_or_simple_record'; + name = "read_int_or_simple_record"; elseif state == 1 - name = 'read_nullable_int_or_simple_record'; + name = "read_nullable_int_or_simple_record"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m b/matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m index 5a5d347b..300e16af 100644 --- a/matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m +++ b/matlab/generated/+test_model/StreamsOfAliasedUnionsWriterBase.m @@ -7,52 +7,52 @@ end methods - function obj = StreamsOfAliasedUnionsWriterBase() - obj.state_ = 0; + function self = StreamsOfAliasedUnionsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 2 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_int_or_simple_record(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_int_or_simple_record(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_int_or_simple_record_(value); + self.write_int_or_simple_record_(value); end - function end_int_or_simple_record(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function end_int_or_simple_record(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.end_stream_(); - obj.state_ = 1; + self.end_stream_(); + self.state_ = 1; end % Ordinal 1 - function write_nullable_int_or_simple_record(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_nullable_int_or_simple_record(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_nullable_int_or_simple_record_(value); + self.write_nullable_int_or_simple_record_(value); end - function end_nullable_int_or_simple_record(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function end_nullable_int_or_simple_record(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.end_stream_(); - obj.state_ = 2; + self.end_stream_(); + self.state_ = 2; end end @@ -63,25 +63,25 @@ function end_nullable_int_or_simple_record(obj) end methods (Abstract, Access=protected) - write_int_or_simple_record_(obj, value) - write_nullable_int_or_simple_record_(obj, value) + write_int_or_simple_record_(self, value) + write_nullable_int_or_simple_record_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_int_or_simple_record or end_int_or_simple_record'; + name = "write_int_or_simple_record or end_int_or_simple_record"; elseif state == 1 - name = 'write_nullable_int_or_simple_record or end_nullable_int_or_simple_record'; + name = "write_nullable_int_or_simple_record or end_nullable_int_or_simple_record"; else name = ''; end diff --git a/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m b/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m index 56e3c674..04f6642f 100644 --- a/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m +++ b/matlab/generated/+test_model/StreamsOfUnionsReaderBase.m @@ -6,66 +6,66 @@ end methods - function obj = StreamsOfUnionsReaderBase() - obj.state_ = 0; + function self = StreamsOfUnionsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 2 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function more = has_int_or_simple_record(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function more = has_int_or_simple_record(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - more = obj.has_int_or_simple_record_(); + more = self.has_int_or_simple_record_(); if ~more - obj.state_ = 1; + self.state_ = 1; end end - function value = read_int_or_simple_record(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_int_or_simple_record(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_int_or_simple_record_(); + value = self.read_int_or_simple_record_(); end % Ordinal 1 - function more = has_nullable_int_or_simple_record(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function more = has_nullable_int_or_simple_record(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - more = obj.has_nullable_int_or_simple_record_(); + more = self.has_nullable_int_or_simple_record_(); if ~more - obj.state_ = 2; + self.state_ = 2; end end - function value = read_nullable_int_or_simple_record(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_nullable_int_or_simple_record(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_nullable_int_or_simple_record_(); + value = self.read_nullable_int_or_simple_record_(); end - function copy_to(obj, writer) - while obj.has_int_or_simple_record() - item = obj.read_int_or_simple_record(); + function copy_to(self, writer) + while self.has_int_or_simple_record() + item = self.read_int_or_simple_record(); writer.write_int_or_simple_record({item}); end writer.end_int_or_simple_record(); - while obj.has_nullable_int_or_simple_record() - item = obj.read_nullable_int_or_simple_record(); + while self.has_nullable_int_or_simple_record() + item = self.read_nullable_int_or_simple_record(); writer.write_nullable_int_or_simple_record({item}); end writer.end_nullable_int_or_simple_record(); @@ -79,28 +79,28 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - has_int_or_simple_record_(obj) - read_int_or_simple_record_(obj) - has_nullable_int_or_simple_record_(obj) - read_nullable_int_or_simple_record_(obj) + has_int_or_simple_record_(self) + read_int_or_simple_record_(self) + has_nullable_int_or_simple_record_(self) + read_nullable_int_or_simple_record_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_int_or_simple_record'; + name = "read_int_or_simple_record"; elseif state == 1 - name = 'read_nullable_int_or_simple_record'; + name = "read_nullable_int_or_simple_record"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/StreamsOfUnionsWriterBase.m b/matlab/generated/+test_model/StreamsOfUnionsWriterBase.m index cb21be23..565dbc1b 100644 --- a/matlab/generated/+test_model/StreamsOfUnionsWriterBase.m +++ b/matlab/generated/+test_model/StreamsOfUnionsWriterBase.m @@ -7,52 +7,52 @@ end methods - function obj = StreamsOfUnionsWriterBase() - obj.state_ = 0; + function self = StreamsOfUnionsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 2 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_int_or_simple_record(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_int_or_simple_record(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_int_or_simple_record_(value); + self.write_int_or_simple_record_(value); end - function end_int_or_simple_record(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function end_int_or_simple_record(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.end_stream_(); - obj.state_ = 1; + self.end_stream_(); + self.state_ = 1; end % Ordinal 1 - function write_nullable_int_or_simple_record(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_nullable_int_or_simple_record(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_nullable_int_or_simple_record_(value); + self.write_nullable_int_or_simple_record_(value); end - function end_nullable_int_or_simple_record(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function end_nullable_int_or_simple_record(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.end_stream_(); - obj.state_ = 2; + self.end_stream_(); + self.state_ = 2; end end @@ -63,25 +63,25 @@ function end_nullable_int_or_simple_record(obj) end methods (Abstract, Access=protected) - write_int_or_simple_record_(obj, value) - write_nullable_int_or_simple_record_(obj, value) + write_int_or_simple_record_(self, value) + write_nullable_int_or_simple_record_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_int_or_simple_record or end_int_or_simple_record'; + name = "write_int_or_simple_record or end_int_or_simple_record"; elseif state == 1 - name = 'write_nullable_int_or_simple_record or end_nullable_int_or_simple_record'; + name = "write_nullable_int_or_simple_record or end_nullable_int_or_simple_record"; else name = ''; end diff --git a/matlab/generated/+test_model/StreamsReaderBase.m b/matlab/generated/+test_model/StreamsReaderBase.m index 26a17394..803408ec 100644 --- a/matlab/generated/+test_model/StreamsReaderBase.m +++ b/matlab/generated/+test_model/StreamsReaderBase.m @@ -6,116 +6,116 @@ end methods - function obj = StreamsReaderBase() - obj.state_ = 0; + function self = StreamsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function more = has_int_data(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function more = has_int_data(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - more = obj.has_int_data_(); + more = self.has_int_data_(); if ~more - obj.state_ = 1; + self.state_ = 1; end end - function value = read_int_data(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_int_data(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_int_data_(); + value = self.read_int_data_(); end % Ordinal 1 - function more = has_optional_int_data(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function more = has_optional_int_data(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - more = obj.has_optional_int_data_(); + more = self.has_optional_int_data_(); if ~more - obj.state_ = 2; + self.state_ = 2; end end - function value = read_optional_int_data(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_optional_int_data(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_optional_int_data_(); + value = self.read_optional_int_data_(); end % Ordinal 2 - function more = has_record_with_optional_vector_data(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function more = has_record_with_optional_vector_data(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - more = obj.has_record_with_optional_vector_data_(); + more = self.has_record_with_optional_vector_data_(); if ~more - obj.state_ = 3; + self.state_ = 3; end end - function value = read_record_with_optional_vector_data(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_record_with_optional_vector_data(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_record_with_optional_vector_data_(); + value = self.read_record_with_optional_vector_data_(); end % Ordinal 3 - function more = has_fixed_vector(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function more = has_fixed_vector(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - more = obj.has_fixed_vector_(); + more = self.has_fixed_vector_(); if ~more - obj.state_ = 4; + self.state_ = 4; end end - function value = read_fixed_vector(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function value = read_fixed_vector(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - value = obj.read_fixed_vector_(); + value = self.read_fixed_vector_(); end - function copy_to(obj, writer) - while obj.has_int_data() - item = obj.read_int_data(); + function copy_to(self, writer) + while self.has_int_data() + item = self.read_int_data(); writer.write_int_data({item}); end writer.end_int_data(); - while obj.has_optional_int_data() - item = obj.read_optional_int_data(); + while self.has_optional_int_data() + item = self.read_optional_int_data(); writer.write_optional_int_data({item}); end writer.end_optional_int_data(); - while obj.has_record_with_optional_vector_data() - item = obj.read_record_with_optional_vector_data(); + while self.has_record_with_optional_vector_data() + item = self.read_record_with_optional_vector_data(); writer.write_record_with_optional_vector_data({item}); end writer.end_record_with_optional_vector_data(); - while obj.has_fixed_vector() - item = obj.read_fixed_vector(); + while self.has_fixed_vector() + item = self.read_fixed_vector(); writer.write_fixed_vector({item}); end writer.end_fixed_vector(); @@ -129,36 +129,36 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - has_int_data_(obj) - read_int_data_(obj) - has_optional_int_data_(obj) - read_optional_int_data_(obj) - has_record_with_optional_vector_data_(obj) - read_record_with_optional_vector_data_(obj) - has_fixed_vector_(obj) - read_fixed_vector_(obj) - - close_(obj) + has_int_data_(self) + read_int_data_(self) + has_optional_int_data_(self) + read_optional_int_data_(self) + has_record_with_optional_vector_data_(self) + read_record_with_optional_vector_data_(self) + has_fixed_vector_(self) + read_fixed_vector_(self) + + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_int_data'; + name = "read_int_data"; elseif state == 1 - name = 'read_optional_int_data'; + name = "read_optional_int_data"; elseif state == 2 - name = 'read_record_with_optional_vector_data'; + name = "read_record_with_optional_vector_data"; elseif state == 3 - name = 'read_fixed_vector'; + name = "read_fixed_vector"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/StreamsWriterBase.m b/matlab/generated/+test_model/StreamsWriterBase.m index 62ec15cb..940a39f7 100644 --- a/matlab/generated/+test_model/StreamsWriterBase.m +++ b/matlab/generated/+test_model/StreamsWriterBase.m @@ -7,88 +7,88 @@ end methods - function obj = StreamsWriterBase() - obj.state_ = 0; + function self = StreamsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_int_data(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_int_data(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_int_data_(value); + self.write_int_data_(value); end - function end_int_data(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function end_int_data(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.end_stream_(); - obj.state_ = 1; + self.end_stream_(); + self.state_ = 1; end % Ordinal 1 - function write_optional_int_data(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_optional_int_data(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_optional_int_data_(value); + self.write_optional_int_data_(value); end - function end_optional_int_data(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function end_optional_int_data(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.end_stream_(); - obj.state_ = 2; + self.end_stream_(); + self.state_ = 2; end % Ordinal 2 - function write_record_with_optional_vector_data(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_record_with_optional_vector_data(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_record_with_optional_vector_data_(value); + self.write_record_with_optional_vector_data_(value); end - function end_record_with_optional_vector_data(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function end_record_with_optional_vector_data(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.end_stream_(); - obj.state_ = 3; + self.end_stream_(); + self.state_ = 3; end % Ordinal 3 - function write_fixed_vector(obj, value) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function write_fixed_vector(self, value) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - obj.write_fixed_vector_(value); + self.write_fixed_vector_(value); end - function end_fixed_vector(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function end_fixed_vector(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - obj.end_stream_(); - obj.state_ = 4; + self.end_stream_(); + self.state_ = 4; end end @@ -99,31 +99,31 @@ function end_fixed_vector(obj) end methods (Abstract, Access=protected) - write_int_data_(obj, value) - write_optional_int_data_(obj, value) - write_record_with_optional_vector_data_(obj, value) - write_fixed_vector_(obj, value) + write_int_data_(self, value) + write_optional_int_data_(self, value) + write_record_with_optional_vector_data_(self, value) + write_fixed_vector_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_int_data or end_int_data'; + name = "write_int_data or end_int_data"; elseif state == 1 - name = 'write_optional_int_data or end_optional_int_data'; + name = "write_optional_int_data or end_optional_int_data"; elseif state == 2 - name = 'write_record_with_optional_vector_data or end_record_with_optional_vector_data'; + name = "write_record_with_optional_vector_data or end_record_with_optional_vector_data"; elseif state == 3 - name = 'write_fixed_vector or end_fixed_vector'; + name = "write_fixed_vector or end_fixed_vector"; else name = ''; end diff --git a/matlab/generated/+test_model/StringOrInt32.m b/matlab/generated/+test_model/StringOrInt32.m index 7b7d9726..ae06927e 100644 --- a/matlab/generated/+test_model/StringOrInt32.m +++ b/matlab/generated/+test_model/StringOrInt32.m @@ -25,6 +25,14 @@ end methods + function res = isString(self) + res = self.index == 1; + end + + function res = isInt32(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'test_model.StringOrInt32') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/StringsReaderBase.m b/matlab/generated/+test_model/StringsReaderBase.m index f816cf1c..bc79a89f 100644 --- a/matlab/generated/+test_model/StringsReaderBase.m +++ b/matlab/generated/+test_model/StringsReaderBase.m @@ -6,41 +6,41 @@ end methods - function obj = StringsReaderBase() - obj.state_ = 0; + function self = StringsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 2 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_single_string(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_single_string(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_single_string_(); - obj.state_ = 1; + value = self.read_single_string_(); + self.state_ = 1; end % Ordinal 1 - function value = read_rec_with_string(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_rec_with_string(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_rec_with_string_(); - obj.state_ = 2; + value = self.read_rec_with_string_(); + self.state_ = 2; end - function copy_to(obj, writer) - writer.write_single_string(obj.read_single_string()); - writer.write_rec_with_string(obj.read_rec_with_string()); + function copy_to(self, writer) + writer.write_single_string(self.read_single_string()); + writer.write_rec_with_string(self.read_rec_with_string()); end end @@ -51,26 +51,26 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_single_string_(obj) - read_rec_with_string_(obj) + read_single_string_(self) + read_rec_with_string_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_single_string'; + name = "read_single_string"; elseif state == 1 - name = 'read_rec_with_string'; + name = "read_rec_with_string"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/StringsWriterBase.m b/matlab/generated/+test_model/StringsWriterBase.m index 6d6945c4..7c2d5b92 100644 --- a/matlab/generated/+test_model/StringsWriterBase.m +++ b/matlab/generated/+test_model/StringsWriterBase.m @@ -7,36 +7,36 @@ end methods - function obj = StringsWriterBase() - obj.state_ = 0; + function self = StringsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 2 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_single_string(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_single_string(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_single_string_(value); - obj.state_ = 1; + self.write_single_string_(value); + self.state_ = 1; end % Ordinal 1 - function write_rec_with_string(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_rec_with_string(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_rec_with_string_(value); - obj.state_ = 2; + self.write_rec_with_string_(value); + self.state_ = 2; end end @@ -47,25 +47,25 @@ function write_rec_with_string(obj, value) end methods (Abstract, Access=protected) - write_single_string_(obj, value) - write_rec_with_string_(obj, value) + write_single_string_(self, value) + write_rec_with_string_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_single_string'; + name = "write_single_string"; elseif state == 1 - name = 'write_rec_with_string'; + name = "write_rec_with_string"; else name = ''; end diff --git a/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m b/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m index ba161677..00332db1 100644 --- a/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m +++ b/matlab/generated/+test_model/SubarraysInRecordsReaderBase.m @@ -6,41 +6,41 @@ end methods - function obj = SubarraysInRecordsReaderBase() - obj.state_ = 0; + function self = SubarraysInRecordsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 2 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_with_fixed_subarrays(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_with_fixed_subarrays(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_with_fixed_subarrays_(); - obj.state_ = 1; + value = self.read_with_fixed_subarrays_(); + self.state_ = 1; end % Ordinal 1 - function value = read_with_vlen_subarrays(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_with_vlen_subarrays(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_with_vlen_subarrays_(); - obj.state_ = 2; + value = self.read_with_vlen_subarrays_(); + self.state_ = 2; end - function copy_to(obj, writer) - writer.write_with_fixed_subarrays(obj.read_with_fixed_subarrays()); - writer.write_with_vlen_subarrays(obj.read_with_vlen_subarrays()); + function copy_to(self, writer) + writer.write_with_fixed_subarrays(self.read_with_fixed_subarrays()); + writer.write_with_vlen_subarrays(self.read_with_vlen_subarrays()); end end @@ -51,26 +51,26 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_with_fixed_subarrays_(obj) - read_with_vlen_subarrays_(obj) + read_with_fixed_subarrays_(self) + read_with_vlen_subarrays_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_with_fixed_subarrays'; + name = "read_with_fixed_subarrays"; elseif state == 1 - name = 'read_with_vlen_subarrays'; + name = "read_with_vlen_subarrays"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/SubarraysInRecordsWriterBase.m b/matlab/generated/+test_model/SubarraysInRecordsWriterBase.m index b92097f9..89d53486 100644 --- a/matlab/generated/+test_model/SubarraysInRecordsWriterBase.m +++ b/matlab/generated/+test_model/SubarraysInRecordsWriterBase.m @@ -7,36 +7,36 @@ end methods - function obj = SubarraysInRecordsWriterBase() - obj.state_ = 0; + function self = SubarraysInRecordsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 2 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_with_fixed_subarrays(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_with_fixed_subarrays(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_with_fixed_subarrays_(value); - obj.state_ = 1; + self.write_with_fixed_subarrays_(value); + self.state_ = 1; end % Ordinal 1 - function write_with_vlen_subarrays(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_with_vlen_subarrays(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_with_vlen_subarrays_(value); - obj.state_ = 2; + self.write_with_vlen_subarrays_(value); + self.state_ = 2; end end @@ -47,25 +47,25 @@ function write_with_vlen_subarrays(obj, value) end methods (Abstract, Access=protected) - write_with_fixed_subarrays_(obj, value) - write_with_vlen_subarrays_(obj, value) + write_with_fixed_subarrays_(self, value) + write_with_vlen_subarrays_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_with_fixed_subarrays'; + name = "write_with_fixed_subarrays"; elseif state == 1 - name = 'write_with_vlen_subarrays'; + name = "write_with_vlen_subarrays"; else name = ''; end diff --git a/matlab/generated/+test_model/SubarraysReaderBase.m b/matlab/generated/+test_model/SubarraysReaderBase.m index 368edd59..5efef824 100644 --- a/matlab/generated/+test_model/SubarraysReaderBase.m +++ b/matlab/generated/+test_model/SubarraysReaderBase.m @@ -6,118 +6,118 @@ end methods - function obj = SubarraysReaderBase() - obj.state_ = 0; + function self = SubarraysReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 9 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 9 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_dynamic_with_fixed_int_subarray(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_dynamic_with_fixed_int_subarray(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_dynamic_with_fixed_int_subarray_(); - obj.state_ = 1; + value = self.read_dynamic_with_fixed_int_subarray_(); + self.state_ = 1; end % Ordinal 1 - function value = read_dynamic_with_fixed_float_subarray(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_dynamic_with_fixed_float_subarray(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_dynamic_with_fixed_float_subarray_(); - obj.state_ = 2; + value = self.read_dynamic_with_fixed_float_subarray_(); + self.state_ = 2; end % Ordinal 2 - function value = read_known_dim_count_with_fixed_int_subarray(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_known_dim_count_with_fixed_int_subarray(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_known_dim_count_with_fixed_int_subarray_(); - obj.state_ = 3; + value = self.read_known_dim_count_with_fixed_int_subarray_(); + self.state_ = 3; end % Ordinal 3 - function value = read_known_dim_count_with_fixed_float_subarray(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function value = read_known_dim_count_with_fixed_float_subarray(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - value = obj.read_known_dim_count_with_fixed_float_subarray_(); - obj.state_ = 4; + value = self.read_known_dim_count_with_fixed_float_subarray_(); + self.state_ = 4; end % Ordinal 4 - function value = read_fixed_with_fixed_int_subarray(obj) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + function value = read_fixed_with_fixed_int_subarray(self) + if self.state_ ~= 4 + self.raise_unexpected_state_(4); end - value = obj.read_fixed_with_fixed_int_subarray_(); - obj.state_ = 5; + value = self.read_fixed_with_fixed_int_subarray_(); + self.state_ = 5; end % Ordinal 5 - function value = read_fixed_with_fixed_float_subarray(obj) - if obj.state_ ~= 5 - obj.raise_unexpected_state_(5); + function value = read_fixed_with_fixed_float_subarray(self) + if self.state_ ~= 5 + self.raise_unexpected_state_(5); end - value = obj.read_fixed_with_fixed_float_subarray_(); - obj.state_ = 6; + value = self.read_fixed_with_fixed_float_subarray_(); + self.state_ = 6; end % Ordinal 6 - function value = read_nested_subarray(obj) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + function value = read_nested_subarray(self) + if self.state_ ~= 6 + self.raise_unexpected_state_(6); end - value = obj.read_nested_subarray_(); - obj.state_ = 7; + value = self.read_nested_subarray_(); + self.state_ = 7; end % Ordinal 7 - function value = read_dynamic_with_fixed_vector_subarray(obj) - if obj.state_ ~= 7 - obj.raise_unexpected_state_(7); + function value = read_dynamic_with_fixed_vector_subarray(self) + if self.state_ ~= 7 + self.raise_unexpected_state_(7); end - value = obj.read_dynamic_with_fixed_vector_subarray_(); - obj.state_ = 8; + value = self.read_dynamic_with_fixed_vector_subarray_(); + self.state_ = 8; end % Ordinal 8 - function value = read_generic_subarray(obj) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + function value = read_generic_subarray(self) + if self.state_ ~= 8 + self.raise_unexpected_state_(8); end - value = obj.read_generic_subarray_(); - obj.state_ = 9; + value = self.read_generic_subarray_(); + self.state_ = 9; end - function copy_to(obj, writer) - writer.write_dynamic_with_fixed_int_subarray(obj.read_dynamic_with_fixed_int_subarray()); - writer.write_dynamic_with_fixed_float_subarray(obj.read_dynamic_with_fixed_float_subarray()); - writer.write_known_dim_count_with_fixed_int_subarray(obj.read_known_dim_count_with_fixed_int_subarray()); - writer.write_known_dim_count_with_fixed_float_subarray(obj.read_known_dim_count_with_fixed_float_subarray()); - writer.write_fixed_with_fixed_int_subarray(obj.read_fixed_with_fixed_int_subarray()); - writer.write_fixed_with_fixed_float_subarray(obj.read_fixed_with_fixed_float_subarray()); - writer.write_nested_subarray(obj.read_nested_subarray()); - writer.write_dynamic_with_fixed_vector_subarray(obj.read_dynamic_with_fixed_vector_subarray()); - writer.write_generic_subarray(obj.read_generic_subarray()); + function copy_to(self, writer) + writer.write_dynamic_with_fixed_int_subarray(self.read_dynamic_with_fixed_int_subarray()); + writer.write_dynamic_with_fixed_float_subarray(self.read_dynamic_with_fixed_float_subarray()); + writer.write_known_dim_count_with_fixed_int_subarray(self.read_known_dim_count_with_fixed_int_subarray()); + writer.write_known_dim_count_with_fixed_float_subarray(self.read_known_dim_count_with_fixed_float_subarray()); + writer.write_fixed_with_fixed_int_subarray(self.read_fixed_with_fixed_int_subarray()); + writer.write_fixed_with_fixed_float_subarray(self.read_fixed_with_fixed_float_subarray()); + writer.write_nested_subarray(self.read_nested_subarray()); + writer.write_dynamic_with_fixed_vector_subarray(self.read_dynamic_with_fixed_vector_subarray()); + writer.write_generic_subarray(self.read_generic_subarray()); end end @@ -128,47 +128,47 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_dynamic_with_fixed_int_subarray_(obj) - read_dynamic_with_fixed_float_subarray_(obj) - read_known_dim_count_with_fixed_int_subarray_(obj) - read_known_dim_count_with_fixed_float_subarray_(obj) - read_fixed_with_fixed_int_subarray_(obj) - read_fixed_with_fixed_float_subarray_(obj) - read_nested_subarray_(obj) - read_dynamic_with_fixed_vector_subarray_(obj) - read_generic_subarray_(obj) - - close_(obj) + read_dynamic_with_fixed_int_subarray_(self) + read_dynamic_with_fixed_float_subarray_(self) + read_known_dim_count_with_fixed_int_subarray_(self) + read_known_dim_count_with_fixed_float_subarray_(self) + read_fixed_with_fixed_int_subarray_(self) + read_fixed_with_fixed_float_subarray_(self) + read_nested_subarray_(self) + read_dynamic_with_fixed_vector_subarray_(self) + read_generic_subarray_(self) + + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_dynamic_with_fixed_int_subarray'; + name = "read_dynamic_with_fixed_int_subarray"; elseif state == 1 - name = 'read_dynamic_with_fixed_float_subarray'; + name = "read_dynamic_with_fixed_float_subarray"; elseif state == 2 - name = 'read_known_dim_count_with_fixed_int_subarray'; + name = "read_known_dim_count_with_fixed_int_subarray"; elseif state == 3 - name = 'read_known_dim_count_with_fixed_float_subarray'; + name = "read_known_dim_count_with_fixed_float_subarray"; elseif state == 4 - name = 'read_fixed_with_fixed_int_subarray'; + name = "read_fixed_with_fixed_int_subarray"; elseif state == 5 - name = 'read_fixed_with_fixed_float_subarray'; + name = "read_fixed_with_fixed_float_subarray"; elseif state == 6 - name = 'read_nested_subarray'; + name = "read_nested_subarray"; elseif state == 7 - name = 'read_dynamic_with_fixed_vector_subarray'; + name = "read_dynamic_with_fixed_vector_subarray"; elseif state == 8 - name = 'read_generic_subarray'; + name = "read_generic_subarray"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/SubarraysWriterBase.m b/matlab/generated/+test_model/SubarraysWriterBase.m index c250c9aa..014763fa 100644 --- a/matlab/generated/+test_model/SubarraysWriterBase.m +++ b/matlab/generated/+test_model/SubarraysWriterBase.m @@ -7,106 +7,106 @@ end methods - function obj = SubarraysWriterBase() - obj.state_ = 0; + function self = SubarraysWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 9 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 9 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_dynamic_with_fixed_int_subarray(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_dynamic_with_fixed_int_subarray(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_dynamic_with_fixed_int_subarray_(value); - obj.state_ = 1; + self.write_dynamic_with_fixed_int_subarray_(value); + self.state_ = 1; end % Ordinal 1 - function write_dynamic_with_fixed_float_subarray(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_dynamic_with_fixed_float_subarray(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_dynamic_with_fixed_float_subarray_(value); - obj.state_ = 2; + self.write_dynamic_with_fixed_float_subarray_(value); + self.state_ = 2; end % Ordinal 2 - function write_known_dim_count_with_fixed_int_subarray(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_known_dim_count_with_fixed_int_subarray(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_known_dim_count_with_fixed_int_subarray_(value); - obj.state_ = 3; + self.write_known_dim_count_with_fixed_int_subarray_(value); + self.state_ = 3; end % Ordinal 3 - function write_known_dim_count_with_fixed_float_subarray(obj, value) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function write_known_dim_count_with_fixed_float_subarray(self, value) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - obj.write_known_dim_count_with_fixed_float_subarray_(value); - obj.state_ = 4; + self.write_known_dim_count_with_fixed_float_subarray_(value); + self.state_ = 4; end % Ordinal 4 - function write_fixed_with_fixed_int_subarray(obj, value) - if obj.state_ ~= 4 - obj.raise_unexpected_state_(4); + function write_fixed_with_fixed_int_subarray(self, value) + if self.state_ ~= 4 + self.raise_unexpected_state_(4); end - obj.write_fixed_with_fixed_int_subarray_(value); - obj.state_ = 5; + self.write_fixed_with_fixed_int_subarray_(value); + self.state_ = 5; end % Ordinal 5 - function write_fixed_with_fixed_float_subarray(obj, value) - if obj.state_ ~= 5 - obj.raise_unexpected_state_(5); + function write_fixed_with_fixed_float_subarray(self, value) + if self.state_ ~= 5 + self.raise_unexpected_state_(5); end - obj.write_fixed_with_fixed_float_subarray_(value); - obj.state_ = 6; + self.write_fixed_with_fixed_float_subarray_(value); + self.state_ = 6; end % Ordinal 6 - function write_nested_subarray(obj, value) - if obj.state_ ~= 6 - obj.raise_unexpected_state_(6); + function write_nested_subarray(self, value) + if self.state_ ~= 6 + self.raise_unexpected_state_(6); end - obj.write_nested_subarray_(value); - obj.state_ = 7; + self.write_nested_subarray_(value); + self.state_ = 7; end % Ordinal 7 - function write_dynamic_with_fixed_vector_subarray(obj, value) - if obj.state_ ~= 7 - obj.raise_unexpected_state_(7); + function write_dynamic_with_fixed_vector_subarray(self, value) + if self.state_ ~= 7 + self.raise_unexpected_state_(7); end - obj.write_dynamic_with_fixed_vector_subarray_(value); - obj.state_ = 8; + self.write_dynamic_with_fixed_vector_subarray_(value); + self.state_ = 8; end % Ordinal 8 - function write_generic_subarray(obj, value) - if obj.state_ ~= 8 - obj.raise_unexpected_state_(8); + function write_generic_subarray(self, value) + if self.state_ ~= 8 + self.raise_unexpected_state_(8); end - obj.write_generic_subarray_(value); - obj.state_ = 9; + self.write_generic_subarray_(value); + self.state_ = 9; end end @@ -117,46 +117,46 @@ function write_generic_subarray(obj, value) end methods (Abstract, Access=protected) - write_dynamic_with_fixed_int_subarray_(obj, value) - write_dynamic_with_fixed_float_subarray_(obj, value) - write_known_dim_count_with_fixed_int_subarray_(obj, value) - write_known_dim_count_with_fixed_float_subarray_(obj, value) - write_fixed_with_fixed_int_subarray_(obj, value) - write_fixed_with_fixed_float_subarray_(obj, value) - write_nested_subarray_(obj, value) - write_dynamic_with_fixed_vector_subarray_(obj, value) - write_generic_subarray_(obj, value) - - end_stream_(obj) - close_(obj) + write_dynamic_with_fixed_int_subarray_(self, value) + write_dynamic_with_fixed_float_subarray_(self, value) + write_known_dim_count_with_fixed_int_subarray_(self, value) + write_known_dim_count_with_fixed_float_subarray_(self, value) + write_fixed_with_fixed_int_subarray_(self, value) + write_fixed_with_fixed_float_subarray_(self, value) + write_nested_subarray_(self, value) + write_dynamic_with_fixed_vector_subarray_(self, value) + write_generic_subarray_(self, value) + + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_dynamic_with_fixed_int_subarray'; + name = "write_dynamic_with_fixed_int_subarray"; elseif state == 1 - name = 'write_dynamic_with_fixed_float_subarray'; + name = "write_dynamic_with_fixed_float_subarray"; elseif state == 2 - name = 'write_known_dim_count_with_fixed_int_subarray'; + name = "write_known_dim_count_with_fixed_int_subarray"; elseif state == 3 - name = 'write_known_dim_count_with_fixed_float_subarray'; + name = "write_known_dim_count_with_fixed_float_subarray"; elseif state == 4 - name = 'write_fixed_with_fixed_int_subarray'; + name = "write_fixed_with_fixed_int_subarray"; elseif state == 5 - name = 'write_fixed_with_fixed_float_subarray'; + name = "write_fixed_with_fixed_float_subarray"; elseif state == 6 - name = 'write_nested_subarray'; + name = "write_nested_subarray"; elseif state == 7 - name = 'write_dynamic_with_fixed_vector_subarray'; + name = "write_dynamic_with_fixed_vector_subarray"; elseif state == 8 - name = 'write_generic_subarray'; + name = "write_generic_subarray"; else name = ''; end diff --git a/matlab/generated/+test_model/TupleWithRecords.m b/matlab/generated/+test_model/TupleWithRecords.m index 953d10e6..36ebfa6f 100644 --- a/matlab/generated/+test_model/TupleWithRecords.m +++ b/matlab/generated/+test_model/TupleWithRecords.m @@ -7,25 +7,25 @@ end methods - function obj = TupleWithRecords(a, b) + function self = TupleWithRecords(a, b) if nargin > 0 - obj.a = a; - obj.b = b; + self.a = a; + self.b = b; else - obj.a = test_model.SimpleRecord(); - obj.b = test_model.SimpleRecord(); + self.a = test_model.SimpleRecord(); + self.b = test_model.SimpleRecord(); end end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'test_model.TupleWithRecords') && ... - all([obj.a] == [other.a]) && ... - all([obj.b] == [other.b]); + all([self.a] == [other.a]) && ... + all([self.b] == [other.b]); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/generated/+test_model/UOrV.m b/matlab/generated/+test_model/UOrV.m index 131a6ba1..a609b1ea 100644 --- a/matlab/generated/+test_model/UOrV.m +++ b/matlab/generated/+test_model/UOrV.m @@ -25,6 +25,14 @@ end methods + function res = isU(self) + res = self.index == 1; + end + + function res = isV(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'test_model.UOrV') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/UnionsReaderBase.m b/matlab/generated/+test_model/UnionsReaderBase.m index 9e378df0..ed23e28b 100644 --- a/matlab/generated/+test_model/UnionsReaderBase.m +++ b/matlab/generated/+test_model/UnionsReaderBase.m @@ -6,63 +6,63 @@ end methods - function obj = UnionsReaderBase() - obj.state_ = 0; + function self = UnionsReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_int_or_simple_record(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_int_or_simple_record(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_int_or_simple_record_(); - obj.state_ = 1; + value = self.read_int_or_simple_record_(); + self.state_ = 1; end % Ordinal 1 - function value = read_int_or_record_with_vlens(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_int_or_record_with_vlens(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_int_or_record_with_vlens_(); - obj.state_ = 2; + value = self.read_int_or_record_with_vlens_(); + self.state_ = 2; end % Ordinal 2 - function value = read_monosotate_or_int_or_simple_record(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_monosotate_or_int_or_simple_record(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_monosotate_or_int_or_simple_record_(); - obj.state_ = 3; + value = self.read_monosotate_or_int_or_simple_record_(); + self.state_ = 3; end % Ordinal 3 - function value = read_record_with_unions(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function value = read_record_with_unions(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - value = obj.read_record_with_unions_(); - obj.state_ = 4; + value = self.read_record_with_unions_(); + self.state_ = 4; end - function copy_to(obj, writer) - writer.write_int_or_simple_record(obj.read_int_or_simple_record()); - writer.write_int_or_record_with_vlens(obj.read_int_or_record_with_vlens()); - writer.write_monosotate_or_int_or_simple_record(obj.read_monosotate_or_int_or_simple_record()); - writer.write_record_with_unions(obj.read_record_with_unions()); + function copy_to(self, writer) + writer.write_int_or_simple_record(self.read_int_or_simple_record()); + writer.write_int_or_record_with_vlens(self.read_int_or_record_with_vlens()); + writer.write_monosotate_or_int_or_simple_record(self.read_monosotate_or_int_or_simple_record()); + writer.write_record_with_unions(self.read_record_with_unions()); end end @@ -73,32 +73,32 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_int_or_simple_record_(obj) - read_int_or_record_with_vlens_(obj) - read_monosotate_or_int_or_simple_record_(obj) - read_record_with_unions_(obj) + read_int_or_simple_record_(self) + read_int_or_record_with_vlens_(self) + read_monosotate_or_int_or_simple_record_(self) + read_record_with_unions_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_int_or_simple_record'; + name = "read_int_or_simple_record"; elseif state == 1 - name = 'read_int_or_record_with_vlens'; + name = "read_int_or_record_with_vlens"; elseif state == 2 - name = 'read_monosotate_or_int_or_simple_record'; + name = "read_monosotate_or_int_or_simple_record"; elseif state == 3 - name = 'read_record_with_unions'; + name = "read_record_with_unions"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/UnionsWriterBase.m b/matlab/generated/+test_model/UnionsWriterBase.m index c8fa38c0..d90aab88 100644 --- a/matlab/generated/+test_model/UnionsWriterBase.m +++ b/matlab/generated/+test_model/UnionsWriterBase.m @@ -7,56 +7,56 @@ end methods - function obj = UnionsWriterBase() - obj.state_ = 0; + function self = UnionsWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_int_or_simple_record(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_int_or_simple_record(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_int_or_simple_record_(value); - obj.state_ = 1; + self.write_int_or_simple_record_(value); + self.state_ = 1; end % Ordinal 1 - function write_int_or_record_with_vlens(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_int_or_record_with_vlens(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_int_or_record_with_vlens_(value); - obj.state_ = 2; + self.write_int_or_record_with_vlens_(value); + self.state_ = 2; end % Ordinal 2 - function write_monosotate_or_int_or_simple_record(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_monosotate_or_int_or_simple_record(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_monosotate_or_int_or_simple_record_(value); - obj.state_ = 3; + self.write_monosotate_or_int_or_simple_record_(value); + self.state_ = 3; end % Ordinal 3 - function write_record_with_unions(obj, value) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function write_record_with_unions(self, value) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - obj.write_record_with_unions_(value); - obj.state_ = 4; + self.write_record_with_unions_(value); + self.state_ = 4; end end @@ -67,31 +67,31 @@ function write_record_with_unions(obj, value) end methods (Abstract, Access=protected) - write_int_or_simple_record_(obj, value) - write_int_or_record_with_vlens_(obj, value) - write_monosotate_or_int_or_simple_record_(obj, value) - write_record_with_unions_(obj, value) + write_int_or_simple_record_(self, value) + write_int_or_record_with_vlens_(self, value) + write_monosotate_or_int_or_simple_record_(self, value) + write_record_with_unions_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_int_or_simple_record'; + name = "write_int_or_simple_record"; elseif state == 1 - name = 'write_int_or_record_with_vlens'; + name = "write_int_or_record_with_vlens"; elseif state == 2 - name = 'write_monosotate_or_int_or_simple_record'; + name = "write_monosotate_or_int_or_simple_record"; elseif state == 3 - name = 'write_record_with_unions'; + name = "write_record_with_unions"; else name = ''; end diff --git a/matlab/generated/+test_model/VectorOrScalar.m b/matlab/generated/+test_model/VectorOrScalar.m index b6a5f80a..b1bf0fd5 100644 --- a/matlab/generated/+test_model/VectorOrScalar.m +++ b/matlab/generated/+test_model/VectorOrScalar.m @@ -25,6 +25,14 @@ end methods + function res = isVector(self) + res = self.index == 1; + end + + function res = isScalar(self) + res = self.index == 2; + end + function eq = eq(self, other) eq = isa(other, 'test_model.VectorOrScalar') && other.index == self.index && other.value == self.value; end diff --git a/matlab/generated/+test_model/VlensReaderBase.m b/matlab/generated/+test_model/VlensReaderBase.m index fb95f40f..9d80cf61 100644 --- a/matlab/generated/+test_model/VlensReaderBase.m +++ b/matlab/generated/+test_model/VlensReaderBase.m @@ -6,63 +6,63 @@ end methods - function obj = VlensReaderBase() - obj.state_ = 0; + function self = VlensReaderBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(obj.state_); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function value = read_int_vector(obj) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function value = read_int_vector(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - value = obj.read_int_vector_(); - obj.state_ = 1; + value = self.read_int_vector_(); + self.state_ = 1; end % Ordinal 1 - function value = read_complex_vector(obj) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function value = read_complex_vector(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - value = obj.read_complex_vector_(); - obj.state_ = 2; + value = self.read_complex_vector_(); + self.state_ = 2; end % Ordinal 2 - function value = read_record_with_vlens(obj) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function value = read_record_with_vlens(self) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - value = obj.read_record_with_vlens_(); - obj.state_ = 3; + value = self.read_record_with_vlens_(); + self.state_ = 3; end % Ordinal 3 - function value = read_vlen_of_record_with_vlens(obj) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function value = read_vlen_of_record_with_vlens(self) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - value = obj.read_vlen_of_record_with_vlens_(); - obj.state_ = 4; + value = self.read_vlen_of_record_with_vlens_(); + self.state_ = 4; end - function copy_to(obj, writer) - writer.write_int_vector(obj.read_int_vector()); - writer.write_complex_vector(obj.read_complex_vector()); - writer.write_record_with_vlens(obj.read_record_with_vlens()); - writer.write_vlen_of_record_with_vlens(obj.read_vlen_of_record_with_vlens()); + function copy_to(self, writer) + writer.write_int_vector(self.read_int_vector()); + writer.write_complex_vector(self.read_complex_vector()); + writer.write_record_with_vlens(self.read_record_with_vlens()); + writer.write_vlen_of_record_with_vlens(self.read_vlen_of_record_with_vlens()); end end @@ -73,32 +73,32 @@ function copy_to(obj, writer) end methods (Abstract, Access=protected) - read_int_vector_(obj) - read_complex_vector_(obj) - read_record_with_vlens_(obj) - read_vlen_of_record_with_vlens_(obj) + read_int_vector_(self) + read_complex_vector_(self) + read_record_with_vlens_(self) + read_vlen_of_record_with_vlens_(self) - close_(obj) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - actual_method = obj.state_to_method_name_(actual); - expected_method = obj.state_to_method_name_(obj.state_); + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'read_int_vector'; + name = "read_int_vector"; elseif state == 1 - name = 'read_complex_vector'; + name = "read_complex_vector"; elseif state == 2 - name = 'read_record_with_vlens'; + name = "read_record_with_vlens"; elseif state == 3 - name = 'read_vlen_of_record_with_vlens'; + name = "read_vlen_of_record_with_vlens"; else - name = ''; + name = ""; end end end diff --git a/matlab/generated/+test_model/VlensWriterBase.m b/matlab/generated/+test_model/VlensWriterBase.m index 2bcb2eac..e5be397c 100644 --- a/matlab/generated/+test_model/VlensWriterBase.m +++ b/matlab/generated/+test_model/VlensWriterBase.m @@ -7,56 +7,56 @@ end methods - function obj = VlensWriterBase() - obj.state_ = 0; + function self = VlensWriterBase() + self.state_ = 0; end - function close(obj) - obj.close_(); - if obj.state_ ~= 4 - expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8'))); + function close(self) + self.close_(); + if self.state_ ~= 4 + expected_method = self.state_to_method_name_(self.state_); throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); end end % Ordinal 0 - function write_int_vector(obj, value) - if obj.state_ ~= 0 - obj.raise_unexpected_state_(0); + function write_int_vector(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); end - obj.write_int_vector_(value); - obj.state_ = 1; + self.write_int_vector_(value); + self.state_ = 1; end % Ordinal 1 - function write_complex_vector(obj, value) - if obj.state_ ~= 1 - obj.raise_unexpected_state_(1); + function write_complex_vector(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); end - obj.write_complex_vector_(value); - obj.state_ = 2; + self.write_complex_vector_(value); + self.state_ = 2; end % Ordinal 2 - function write_record_with_vlens(obj, value) - if obj.state_ ~= 2 - obj.raise_unexpected_state_(2); + function write_record_with_vlens(self, value) + if self.state_ ~= 2 + self.raise_unexpected_state_(2); end - obj.write_record_with_vlens_(value); - obj.state_ = 3; + self.write_record_with_vlens_(value); + self.state_ = 3; end % Ordinal 3 - function write_vlen_of_record_with_vlens(obj, value) - if obj.state_ ~= 3 - obj.raise_unexpected_state_(3); + function write_vlen_of_record_with_vlens(self, value) + if self.state_ ~= 3 + self.raise_unexpected_state_(3); end - obj.write_vlen_of_record_with_vlens_(value); - obj.state_ = 4; + self.write_vlen_of_record_with_vlens_(value); + self.state_ = 4; end end @@ -67,31 +67,31 @@ function write_vlen_of_record_with_vlens(obj, value) end methods (Abstract, Access=protected) - write_int_vector_(obj, value) - write_complex_vector_(obj, value) - write_record_with_vlens_(obj, value) - write_vlen_of_record_with_vlens_(obj, value) + write_int_vector_(self, value) + write_complex_vector_(self, value) + write_record_with_vlens_(self, value) + write_vlen_of_record_with_vlens_(self, value) - end_stream_(obj) - close_(obj) + end_stream_(self) + close_(self) end methods (Access=private) - function raise_unexpected_state_(obj, actual) - expected_method = obj.state_to_method_name_(obj.state_); - actual_method = obj.state_to_method_name_(actual); + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); end - function name = state_to_method_name_(obj, state) + function name = state_to_method_name_(self, state) if state == 0 - name = 'write_int_vector'; + name = "write_int_vector"; elseif state == 1 - name = 'write_complex_vector'; + name = "write_complex_vector"; elseif state == 2 - name = 'write_record_with_vlens'; + name = "write_record_with_vlens"; elseif state == 3 - name = 'write_vlen_of_record_with_vlens'; + name = "write_vlen_of_record_with_vlens"; else name = ''; end diff --git a/matlab/generated/+tuples/+binary/TupleSerializer.m b/matlab/generated/+tuples/+binary/TupleSerializer.m index 229c17ee..52e59af2 100644 --- a/matlab/generated/+tuples/+binary/TupleSerializer.m +++ b/matlab/generated/+tuples/+binary/TupleSerializer.m @@ -2,19 +2,23 @@ classdef TupleSerializer < yardl.binary.RecordSerializer methods - function obj = TupleSerializer(t1_serializer, t2_serializer) + function self = TupleSerializer(t1_serializer, t2_serializer) field_serializers{1} = t1_serializer; field_serializers{2} = t2_serializer; - obj@yardl.binary.RecordSerializer('tuples.Tuple', field_serializers); + self@yardl.binary.RecordSerializer('tuples.Tuple', field_serializers); end - function write(obj, outstream, value) - assert(isa(value, 'tuples.Tuple')); - obj.write_(outstream, value.v1, value.v2) + function write(self, outstream, value) + arguments + self + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) tuples.Tuple + end + self.write_(outstream, value.v1, value.v2) end - function value = read(obj, instream) - field_values = obj.read_(instream); + function value = read(self, instream) + field_values = self.read_(instream); value = tuples.Tuple(field_values{:}); end end diff --git a/matlab/generated/+tuples/Tuple.m b/matlab/generated/+tuples/Tuple.m index 411ae9ec..7d578b07 100644 --- a/matlab/generated/+tuples/Tuple.m +++ b/matlab/generated/+tuples/Tuple.m @@ -7,20 +7,20 @@ end methods - function obj = Tuple(v1, v2) - obj.v1 = v1; - obj.v2 = v2; + function self = Tuple(v1, v2) + self.v1 = v1; + self.v2 = v2; end - function res = eq(obj, other) + function res = eq(self, other) res = ... isa(other, 'tuples.Tuple') && ... - isequal(obj.v1, other.v1) && ... - isequal(obj.v2, other.v2); + isequal(self.v1, other.v1) && ... + isequal(self.v2, other.v2); end - function res = ne(obj, other) - res = ~obj.eq(other); + function res = ne(self, other) + res = ~self.eq(other); end end diff --git a/matlab/test/CodedStreamTest.m b/matlab/test/CodedStreamTest.m index fd07a3f7..a13b9bca 100644 --- a/matlab/test/CodedStreamTest.m +++ b/matlab/test/CodedStreamTest.m @@ -5,14 +5,6 @@ methods (Test) - function testScalarByte(testCase) - % w = yardl.binary.CodedOutputStream(tempname) - % for i = 0:15 - % w. - % end - end - - function testVarShort(testCase) entries = int16([0, 1, 5, 33, 0x7E, 0x7F, 0x80, 0x81, 255, 256, 257, 838, 0x3FFF, 0x4000, 0x4001, 0x7FFF]); @@ -30,6 +22,8 @@ function testVarShort(testCase) testCase.verifyEqual(yardl.binary.Int16Serializer.read(r), -entries(i)); end r.close(); + + delete(filename); end function testVarUShort(testCase) @@ -47,6 +41,8 @@ function testVarUShort(testCase) testCase.verifyEqual(yardl.binary.Uint16Serializer.read(r), entries(i)); end r.close(); + + delete(filename); end function testVarIntegers(testCase) @@ -86,6 +82,45 @@ function testVarIntegers(testCase) testCase.verifyEqual(yardl.binary.Int64Serializer.read(r), -bitor(int64(entries(i)), int64(0x400000000))); end r.close(); + + delete(filename); + end + + function testBytes(testCase) + filename = tempname; + + val = 42; + unsigned = uint8([0, 1, 5, 33, 0x7E, 0x7F, 0x80, 0x81, 255]); + signed = int8([0, 1, 5, 33, 0x7E, 0x7F, -0x80, -0x7F, -1]); + + unsignedSerializer = yardl.binary.Uint8Serializer; + signedSerializer = yardl.binary.Int8Serializer; + + w = yardl.binary.CodedOutputStream(filename); + w.write_byte(uint8(val)); + testCase.verifyError(@() w.write_byte(-1), 'MATLAB:validators:mustBeA'); + testCase.verifyError(@() w.write_byte(256), 'MATLAB:validators:mustBeA'); + + w.write_bytes(unsigned); + testCase.verifyError(@() w.write_bytes(signed), 'MATLAB:validators:mustBeA'); + + unsignedSerializer.write(w, val); + unsignedSerializer.write_trivially(w, unsigned); + + signedSerializer.write(w, -val); + signedSerializer.write_trivially(w, signed); + w.close(); + + r = yardl.binary.CodedInputStream(filename); + testCase.verifyEqual(r.read_byte(), uint8(val)); + testCase.verifyEqual(r.read_bytes(length(unsigned)), unsigned); + testCase.verifyEqual(unsignedSerializer.read(r), uint8(val)); + testCase.verifyEqual(unsignedSerializer.read_trivially(r, length(unsigned)), unsigned); + testCase.verifyEqual(signedSerializer.read(r), int8(-val)); + testCase.verifyEqual(signedSerializer.read_trivially(r, length(signed)), signed); + r.close(); + + delete(filename); end function testFloats(testCase) @@ -109,24 +144,69 @@ function testFloats(testCase) w = yardl.binary.CodedOutputStream(filename); float32Serializer.write(w, f); float64Serializer.write(w, d); - float32Serializer.writeTrivially(w, fs); - float64Serializer.writeTrivially(w, ds); + float32Serializer.write_trivially(w, fs); + float64Serializer.write_trivially(w, ds); complexFloat32Serializer.write(w, cf); complexFloat64Serializer.write(w, df); - complexFloat32Serializer.writeTrivially(w, cfs); - complexFloat64Serializer.writeTrivially(w, dfs); + complexFloat32Serializer.write_trivially(w, cfs); + complexFloat64Serializer.write_trivially(w, dfs); w.close(); r = yardl.binary.CodedInputStream(filename); testCase.verifyEqual(float32Serializer.read(r), f); testCase.verifyEqual(float64Serializer.read(r), d); - testCase.verifyEqual(float32Serializer.readTrivially(r, size(fs)), fs); - testCase.verifyEqual(float64Serializer.readTrivially(r, size(ds)), ds); + testCase.verifyEqual(float32Serializer.read_trivially(r, size(fs)), fs); + testCase.verifyEqual(float64Serializer.read_trivially(r, size(ds)), ds); testCase.verifyEqual(complexFloat32Serializer.read(r), cf); testCase.verifyEqual(complexFloat64Serializer.read(r), df); - testCase.verifyEqual(complexFloat32Serializer.readTrivially(r, size(cfs)), cfs); - testCase.verifyEqual(complexFloat64Serializer.readTrivially(r, size(dfs)), dfs); + testCase.verifyEqual(complexFloat32Serializer.read_trivially(r, size(cfs)), cfs); + testCase.verifyEqual(complexFloat64Serializer.read_trivially(r, size(dfs)), dfs); r.close(); + + delete(filename); + end + + function testBools(testCase) + filename = tempname; + + bools = [true, false, true, false]; + boolSerializer = yardl.binary.BoolSerializer; + + w = yardl.binary.CodedOutputStream(filename); + boolSerializer.write(w, true); + boolSerializer.write_trivially(w, bools); + w.close(); + + r = yardl.binary.CodedInputStream(filename); + testCase.verifyEqual(boolSerializer.read(r), true); + testCase.verifyEqual(boolSerializer.read_trivially(r, size(bools)), bools); + r.close(); + + delete(filename); + end + + function testNonTrivialErrors(testCase) + filename = tempname; + + int16Serializer = yardl.binary.Int16Serializer; + int32Serializer = yardl.binary.Int32Serializer; + int64Serializer = yardl.binary.Int64Serializer; + uint16Serializer = yardl.binary.Uint16Serializer; + uint32Serializer = yardl.binary.Uint32Serializer; + uint64Serializer = yardl.binary.Uint64Serializer; + stringSerializer = yardl.binary.StringSerializer; + + w = yardl.binary.CodedOutputStream(filename); + testCase.verifyError(@() int16Serializer.write_trivially(w, []), 'yardl:TypeError'); + testCase.verifyError(@() int32Serializer.write_trivially(w, []), 'yardl:TypeError'); + testCase.verifyError(@() int64Serializer.write_trivially(w, []), 'yardl:TypeError'); + testCase.verifyError(@() uint16Serializer.write_trivially(w, []), 'yardl:TypeError'); + testCase.verifyError(@() uint32Serializer.write_trivially(w, []), 'yardl:TypeError'); + testCase.verifyError(@() uint64Serializer.write_trivially(w, []), 'yardl:TypeError'); + testCase.verifyError(@() stringSerializer.write_trivially(w, []), 'yardl:TypeError'); + w.close(); + + delete(filename); end end end diff --git a/matlab/test/ComputedFieldsTest.m b/matlab/test/ComputedFieldsTest.m index 494c844d..d302606a 100644 --- a/matlab/test/ComputedFieldsTest.m +++ b/matlab/test/ComputedFieldsTest.m @@ -58,7 +58,7 @@ function testDimensionIndex(testCase) testCase.verifyEqual(r.array_dimension_index_from_string_field(), 1); r.string_field = "missing"; - testCase.verifyError(@() r.array_dimension_index_from_string_field(), "yardl:KeyError"); + testCase.verifyError(@() r.array_dimension_index_from_string_field(), "yardl:ValueError"); end function testDimensionCount(testCase) @@ -109,7 +109,7 @@ function testArraySize(testCase) testCase.verifyEqual(r.array_size_from_string_field(), 3); r.string_field = "missing"; - testCase.verifyError(@() r.array_size_from_string_field(), "yardl:KeyError"); + testCase.verifyError(@() r.array_size_from_string_field(), "yardl:ValueError"); r.tuple_field.v1 = 1; testCase.verifyEqual(r.array_size_from_nested_int_field(), 3); diff --git a/matlab/test/SerializerShapeTest.m b/matlab/test/SerializerShapeTest.m index eaf5fd00..c54ca35b 100644 --- a/matlab/test/SerializerShapeTest.m +++ b/matlab/test/SerializerShapeTest.m @@ -6,102 +6,102 @@ function testFixedVectorShape(testCase) fvs = yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 42); - testCase.verifyEqual(fvs.getShape(), [1, 42]); + testCase.verifyEqual(fvs.get_shape(), [1, 42]); fvs = yardl.binary.FixedVectorSerializer(fvs, 11); - testCase.verifyEqual(fvs.getShape(), [42, 11]); + testCase.verifyEqual(fvs.get_shape(), [42, 11]); fvs = yardl.binary.FixedVectorSerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), 13); - testCase.verifyEqual(fvs.getShape(), [1, 13]); + testCase.verifyEqual(fvs.get_shape(), [1, 13]); fvs = yardl.binary.FixedVectorSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 4]), 5); - testCase.verifyEqual(fvs.getShape(), [3, 4, 5]); + testCase.verifyEqual(fvs.get_shape(), [3, 4, 5]); fvs = yardl.binary.FixedVectorSerializer(yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2), 6); - testCase.verifyEqual(fvs.getShape(), [1, 6]); + testCase.verifyEqual(fvs.get_shape(), [1, 6]); fvs = yardl.binary.FixedVectorSerializer(yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer), 7); - testCase.verifyEqual(fvs.getShape(), [1, 7]); + testCase.verifyEqual(fvs.get_shape(), [1, 7]); end function testVectorShape(testCase) vs = yardl.binary.VectorSerializer(yardl.binary.Int32Serializer); - testCase.verifyEqual(vs.getShape(), []); + testCase.verifyEqual(vs.get_shape(), []); vs = yardl.binary.VectorSerializer(vs); - testCase.verifyEqual(vs.getShape(), []); + testCase.verifyEqual(vs.get_shape(), []); vs = yardl.binary.VectorSerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 42)); - testCase.verifyEqual(vs.getShape(), []); + testCase.verifyEqual(vs.get_shape(), []); fvs = yardl.binary.VectorSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 4])); - testCase.verifyEqual(fvs.getShape(), []); + testCase.verifyEqual(fvs.get_shape(), []); fvs = yardl.binary.VectorSerializer(yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2)); - testCase.verifyEqual(fvs.getShape(), []); + testCase.verifyEqual(fvs.get_shape(), []); fvs = yardl.binary.VectorSerializer(yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer)); - testCase.verifyEqual(fvs.getShape(), []); + testCase.verifyEqual(fvs.get_shape(), []); end function testFixedNDArrayShape(testCase) fas = yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [3, 4]); - testCase.verifyEqual(fas.getShape(), [3, 4]); + testCase.verifyEqual(fas.get_shape(), [3, 4]); fas = yardl.binary.FixedNDArraySerializer(fas, [5, 6]); - testCase.verifyEqual(fas.getShape(), [3, 4, 5, 6]); + testCase.verifyEqual(fas.get_shape(), [3, 4, 5, 6]); fas = yardl.binary.FixedNDArraySerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), [7, 8]); - testCase.verifyEqual(fas.getShape(), [7, 8]); + testCase.verifyEqual(fas.get_shape(), [7, 8]); fas = yardl.binary.FixedNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 42), [7, 8]); - testCase.verifyEqual(fas.getShape(), [42, 7, 8]); + testCase.verifyEqual(fas.get_shape(), [42, 7, 8]); fas = yardl.binary.FixedNDArraySerializer(yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2), [7, 8]); - testCase.verifyEqual(fas.getShape(), [7, 8]); + testCase.verifyEqual(fas.get_shape(), [7, 8]); fas = yardl.binary.FixedNDArraySerializer(yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer), [7, 8]); - testCase.verifyEqual(fas.getShape(), [7, 8]); + testCase.verifyEqual(fas.get_shape(), [7, 8]); end function testNDArrayShape(testCase) nas = yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2); - testCase.verifyEqual(nas.getShape(), []); + testCase.verifyEqual(nas.get_shape(), []); nas = yardl.binary.NDArraySerializer(nas, 3); - testCase.verifyEqual(nas.getShape(), []); + testCase.verifyEqual(nas.get_shape(), []); nas = yardl.binary.NDArraySerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer), 2); - testCase.verifyEqual(nas.getShape(), []); + testCase.verifyEqual(nas.get_shape(), []); nas = yardl.binary.NDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 42), 2); - testCase.verifyEqual(nas.getShape(), []); + testCase.verifyEqual(nas.get_shape(), []); nas = yardl.binary.NDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [5, 6]), 2); - testCase.verifyEqual(nas.getShape(), []); + testCase.verifyEqual(nas.get_shape(), []); nas = yardl.binary.NDArraySerializer(yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer), 2); - testCase.verifyEqual(nas.getShape(), []); + testCase.verifyEqual(nas.get_shape(), []); end function testDynamicNDArrayShape(testCase) das = yardl.binary.DynamicNDArraySerializer(yardl.binary.Int32Serializer); - testCase.verifyEqual(das.getShape(), []); + testCase.verifyEqual(das.get_shape(), []); das = yardl.binary.DynamicNDArraySerializer(das); - testCase.verifyEqual(das.getShape(), []); + testCase.verifyEqual(das.get_shape(), []); das = yardl.binary.DynamicNDArraySerializer(yardl.binary.VectorSerializer(yardl.binary.Int32Serializer)); - testCase.verifyEqual(das.getShape(), []); + testCase.verifyEqual(das.get_shape(), []); das = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedVectorSerializer(yardl.binary.Int32Serializer, 42)); - testCase.verifyEqual(das.getShape(), []); + testCase.verifyEqual(das.get_shape(), []); das = yardl.binary.DynamicNDArraySerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Int32Serializer, [5, 6])); - testCase.verifyEqual(das.getShape(), []); + testCase.verifyEqual(das.get_shape(), []); das = yardl.binary.DynamicNDArraySerializer(yardl.binary.NDArraySerializer(yardl.binary.Int32Serializer, 2)); - testCase.verifyEqual(das.getShape(), []); + testCase.verifyEqual(das.get_shape(), []); end end end diff --git a/tooling/internal/matlab/binary/binary.go b/tooling/internal/matlab/binary/binary.go index 155ba023..c7ed3544 100644 --- a/tooling/internal/matlab/binary/binary.go +++ b/tooling/internal/matlab/binary/binary.go @@ -54,12 +54,12 @@ func writeProtocolWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, w.WriteStringln("") w.WriteStringln("methods") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "function obj = %s(filename)\n", BinaryWriterName(p)) + fmt.Fprintf(w, "function self = %s(filename)\n", BinaryWriterName(p)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj@%s();\n", abstractWriterName) - fmt.Fprintf(w, "obj@yardl.binary.BinaryProtocolWriter(filename, %s.schema);\n", abstractWriterName) + fmt.Fprintf(w, "self@%s();\n", abstractWriterName) + fmt.Fprintf(w, "self@yardl.binary.BinaryProtocolWriter(filename, %s.schema);\n", abstractWriterName) for _, step := range p.Sequence { - fmt.Fprintf(w, "obj.%s = %s;\n", serializerName(step), typeSerializer(step.Type, ns.Name, nil)) + fmt.Fprintf(w, "self.%s = %s;\n", serializerName(step), typeSerializer(step.Type, ns.Name, nil)) } }) }) @@ -68,9 +68,9 @@ func writeProtocolWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, w.WriteStringln("methods (Access=protected)") common.WriteBlockBody(w, func() { for i, step := range p.Sequence { - fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "function %s(self, value)\n", common.ProtocolWriteImplMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.%s.write(obj.stream_, value);\n", serializerName(step)) + fmt.Fprintf(w, "self.%s.write(self.stream_, value);\n", serializerName(step)) }) if i < len(p.Sequence)-1 { w.WriteStringln("") @@ -99,12 +99,12 @@ func writeProtocolReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, w.WriteStringln("methods") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "function obj = %s(filename)\n", BinaryReaderName(p)) + fmt.Fprintf(w, "function self = %s(filename)\n", BinaryReaderName(p)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj@%s();\n", abstractReaderName) - fmt.Fprintf(w, "obj@yardl.binary.BinaryProtocolReader(filename, %s.schema);\n", abstractReaderName) + fmt.Fprintf(w, "self@%s();\n", abstractReaderName) + fmt.Fprintf(w, "self@yardl.binary.BinaryProtocolReader(filename, %s.schema);\n", abstractReaderName) for _, step := range p.Sequence { - fmt.Fprintf(w, "obj.%s = %s;\n", serializerName(step), typeSerializer(step.Type, ns.Name, nil)) + fmt.Fprintf(w, "self.%s = %s;\n", serializerName(step), typeSerializer(step.Type, ns.Name, nil)) } }) }) @@ -114,16 +114,16 @@ func writeProtocolReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, common.WriteBlockBody(w, func() { for i, step := range p.Sequence { if step.IsStream() { - fmt.Fprintf(w, "function more = %s(obj)\n", common.ProtocolHasMoreImplMethodName(step)) + fmt.Fprintf(w, "function more = %s(self)\n", common.ProtocolHasMoreImplMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "more = obj.%s.hasnext(obj.stream_);\n", serializerName(step)) + fmt.Fprintf(w, "more = self.%s.hasnext(self.stream_);\n", serializerName(step)) }) w.WriteStringln("") } - fmt.Fprintf(w, "function value = %s(obj)\n", common.ProtocolReadImplMethodName(step)) + fmt.Fprintf(w, "function value = %s(self)\n", common.ProtocolReadImplMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "value = obj.%s.read(obj.stream_);\n", serializerName(step)) + fmt.Fprintf(w, "value = self.%s.read(self.stream_);\n", serializerName(step)) }) if i < len(p.Sequence)-1 { w.WriteStringln("") @@ -167,34 +167,39 @@ func writeRecordSerializer(fw *common.MatlabFileWriter, rec *dsl.RecordDefinitio typeDefinitionSerializer(tp, ns.Name)) } - fmt.Fprintf(w, "function obj = %s(%s)\n", recordSerializerClassName(rec, ns.Name), strings.Join(typeParamSerializers, ", ")) + fmt.Fprintf(w, "function self = %s(%s)\n", recordSerializerClassName(rec, ns.Name), strings.Join(typeParamSerializers, ", ")) } else { - fmt.Fprintf(w, "function obj = %s()\n", recordSerializerClassName(rec, ns.Name)) + fmt.Fprintf(w, "function self = %s()\n", recordSerializerClassName(rec, ns.Name)) } common.WriteBlockBody(w, func() { for i, field := range rec.Fields { fmt.Fprintf(w, "field_serializers{%d} = %s;\n", i+1, typeSerializer(field.Type, ns.Name, nil)) } - fmt.Fprintf(w, "obj@yardl.binary.RecordSerializer('%s', field_serializers);\n", typeSyntax) + fmt.Fprintf(w, "self@yardl.binary.RecordSerializer('%s', field_serializers);\n", typeSyntax) }) w.WriteStringln("") - fmt.Fprintf(w, "function write(obj, outstream, value)\n") + fmt.Fprintf(w, "function write(self, outstream, value)\n") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "assert(isa(value, '%s'));\n", typeSyntax) + w.WriteStringln("arguments") + common.WriteBlockBody(w, func() { + w.WriteStringln("self") + w.WriteStringln("outstream (1,1) yardl.binary.CodedOutputStream") + fmt.Fprintf(w, "value (1,1) %s\n", typeSyntax) + }) fieldAccesses := make([]string, len(rec.Fields)) for i, field := range rec.Fields { fieldAccesses[i] = fmt.Sprintf("value.%s", common.FieldIdentifierName(field.Name)) } - fmt.Fprintf(w, "obj.write_(outstream, %s)\n", strings.Join(fieldAccesses, ", ")) + fmt.Fprintf(w, "self.write_(outstream, %s)\n", strings.Join(fieldAccesses, ", ")) }) w.WriteStringln("") - fmt.Fprintf(w, "function value = read(obj, instream)\n") + fmt.Fprintf(w, "function value = read(self, instream)\n") common.WriteBlockBody(w, func() { - w.WriteStringln("field_values = obj.read_(instream);") + w.WriteStringln("field_values = self.read_(instream);") fmt.Fprintf(w, "value = %s(field_values{:});\n", typeSyntax) }) }) diff --git a/tooling/internal/matlab/mocks/mocks.go b/tooling/internal/matlab/mocks/mocks.go index a6084979..8b579987 100644 --- a/tooling/internal/matlab/mocks/mocks.go +++ b/tooling/internal/matlab/mocks/mocks.go @@ -42,28 +42,28 @@ func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) e w.WriteStringln("methods") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "function obj = %s(testCase)\n", mockWriterName(p)) + fmt.Fprintf(w, "function self = %s(testCase)\n", mockWriterName(p)) common.WriteBlockBody(w, func() { - w.WriteStringln("obj.testCase_ = testCase;") + w.WriteStringln("self.testCase_ = testCase;") for _, step := range p.Sequence { if step.IsStream() { - fmt.Fprintf(w, "obj.%s = {};\n", expectedName(step)) + fmt.Fprintf(w, "self.%s = {};\n", expectedName(step)) } else { - fmt.Fprintf(w, "obj.%s = yardl.None;\n", expectedName(step)) + fmt.Fprintf(w, "self.%s = yardl.None;\n", expectedName(step)) } } }) w.WriteStringln("") for _, step := range p.Sequence { - fmt.Fprintf(w, "function expect_%s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "function expect_%s(self, value)\n", common.ProtocolWriteImplMethodName(step)) common.WriteBlockBody(w, func() { if step.IsStream() { w.WriteStringln("if iscell(value)") common.WriteBlockBody(w, func() { w.WriteStringln("for n = 1:numel(value)") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.%s{end+1} = value{n};\n", expectedName(step)) + fmt.Fprintf(w, "self.%s{end+1} = value{n};\n", expectedName(step)) }) w.WriteStringln("return;") }) @@ -74,23 +74,23 @@ func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) e w.WriteStringln("index = repelem({':'}, lastDim-1);") w.WriteStringln("for n = 1:count") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.%s{end+1} = value(index{:}, n);\n", expectedName(step)) + fmt.Fprintf(w, "self.%s{end+1} = value(index{:}, n);\n", expectedName(step)) }) } else { - fmt.Fprintf(w, "obj.%s = yardl.Optional(value);\n", expectedName(step)) + fmt.Fprintf(w, "self.%s = yardl.Optional(value);\n", expectedName(step)) } }) w.WriteStringln("") } - w.WriteStringln("function verify(obj)") + w.WriteStringln("function verify(self)") common.WriteBlockBody(w, func() { for _, step := range p.Sequence { diagnostic := fmt.Sprintf("Expected call to %s was not received", common.ProtocolWriteImplMethodName(step)) if step.IsStream() { - fmt.Fprintf(w, "obj.testCase_.verifyTrue(isempty(obj.%s), \"%s\");\n", expectedName(step), diagnostic) + fmt.Fprintf(w, "self.testCase_.verifyTrue(isempty(self.%s), \"%s\");\n", expectedName(step), diagnostic) } else { - fmt.Fprintf(w, "obj.testCase_.verifyEqual(obj.%s, yardl.None, \"%s\");\n", expectedName(step), diagnostic) + fmt.Fprintf(w, "self.testCase_.verifyEqual(self.%s, yardl.None, \"%s\");\n", expectedName(step), diagnostic) } } }) @@ -100,27 +100,27 @@ func writeProtocolMock(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition) e w.WriteStringln("methods (Access=protected)") common.WriteBlockBody(w, func() { for _, step := range p.Sequence { - fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "function %s(self, value)\n", common.ProtocolWriteImplMethodName(step)) common.WriteBlockBody(w, func() { if step.IsStream() { w.WriteStringln("assert(iscell(value));") w.WriteStringln("assert(isscalar(value));") - fmt.Fprintf(w, "obj.testCase_.verifyFalse(isempty(obj.%s), \"Unexpected call to %s\");\n", expectedName(step), common.ProtocolWriteImplMethodName(step)) - fmt.Fprintf(w, "obj.testCase_.verifyEqual(value{1}, obj.%s{1}, \"Unexpected argument value for call to %s\");\n", expectedName(step), common.ProtocolWriteImplMethodName(step)) - fmt.Fprintf(w, "obj.%s = obj.%s(2:end);\n", expectedName(step), expectedName(step)) + fmt.Fprintf(w, "self.testCase_.verifyFalse(isempty(self.%s), \"Unexpected call to %s\");\n", expectedName(step), common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "self.testCase_.verifyEqual(value{1}, self.%s{1}, \"Unexpected argument value for call to %s\");\n", expectedName(step), common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "self.%s = self.%s(2:end);\n", expectedName(step), expectedName(step)) } else { - fmt.Fprintf(w, "obj.testCase_.verifyTrue(obj.%s.has_value(), \"Unexpected call to %s\");\n", expectedName(step), common.ProtocolWriteImplMethodName(step)) - fmt.Fprintf(w, "obj.testCase_.verifyEqual(value, obj.%s.value, \"Unexpected argument value for call to %s\");\n", expectedName(step), common.ProtocolWriteImplMethodName(step)) - fmt.Fprintf(w, "obj.%s = yardl.None;\n", expectedName(step)) + fmt.Fprintf(w, "self.testCase_.verifyTrue(self.%s.has_value(), \"Unexpected call to %s\");\n", expectedName(step), common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "self.testCase_.verifyEqual(value, self.%s.value, \"Unexpected argument value for call to %s\");\n", expectedName(step), common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "self.%s = yardl.None;\n", expectedName(step)) } }) w.WriteStringln("") } - w.WriteStringln("function close_(obj)") + w.WriteStringln("function close_(self)") w.WriteStringln("end") - w.WriteStringln("function end_stream_(obj)") + w.WriteStringln("function end_stream_(self)") w.WriteStringln("end") }) }) @@ -145,22 +145,22 @@ func writeProtocolTestWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinit w.WriteStringln("methods") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "function obj = %s(testCase, format, create_writer, create_reader)\n", testWriterName(p)) + fmt.Fprintf(w, "function self = %s(testCase, format, create_writer, create_reader)\n", testWriterName(p)) common.WriteBlockBody(w, func() { - w.WriteStringln("obj.filename_ = tempname();") - w.WriteStringln("obj.format_ = format;") - w.WriteStringln("obj.writer_ = create_writer(obj.filename_);") - w.WriteStringln("obj.create_reader_ = create_reader;") + w.WriteStringln("self.filename_ = tempname();") + w.WriteStringln("self.format_ = format;") + w.WriteStringln("self.writer_ = create_writer(self.filename_);") + w.WriteStringln("self.create_reader_ = create_reader;") mockWriterName := fmt.Sprintf("%s.testing.%s", common.NamespaceIdentifierName(p.Namespace), mockWriterName(p)) - fmt.Fprintf(w, "obj.mock_writer_ = %s(testCase);\n", mockWriterName) - w.WriteStringln("obj.close_called_ = false;") + fmt.Fprintf(w, "self.mock_writer_ = %s(testCase);\n", mockWriterName) + w.WriteStringln("self.close_called_ = false;") }) w.WriteStringln("") - w.WriteStringln("function delete(obj)") + w.WriteStringln("function delete(self)") common.WriteBlockBody(w, func() { - w.WriteStringln("delete(obj.filename_);") - w.WriteStringln("if ~obj.close_called_") + w.WriteStringln("delete(self.filename_);") + w.WriteStringln("if ~self.close_called_") common.WriteBlockBody(w, func() { common.WriteComment(w, "ADD_FAILURE() << ...;") fmt.Fprintf(w, "throw(yardl.RuntimeError(\"Close() must be called on '%s' to verify mocks\"));\n", testWriterName(p)) @@ -169,10 +169,10 @@ func writeProtocolTestWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinit for _, step := range p.Sequence { if step.IsStream() { - fmt.Fprintf(w, "function %s(obj)\n", common.ProtocolEndMethodName(step)) + fmt.Fprintf(w, "function %s(self)\n", common.ProtocolEndMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "%s@%s(obj);\n", common.ProtocolEndMethodName(step), abstractWriterName) - fmt.Fprintf(w, "obj.writer_.%s();\n", common.ProtocolEndMethodName(step)) + fmt.Fprintf(w, "%s@%s(self);\n", common.ProtocolEndMethodName(step), abstractWriterName) + fmt.Fprintf(w, "self.writer_.%s();\n", common.ProtocolEndMethodName(step)) }) w.WriteStringln("") } @@ -183,30 +183,30 @@ func writeProtocolTestWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinit w.WriteStringln("methods (Access=protected)") common.WriteBlockBody(w, func() { for _, step := range p.Sequence { - fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "function %s(self, value)\n", common.ProtocolWriteImplMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.writer_.%s(value);\n", common.ProtocolWriteMethodName(step)) - fmt.Fprintf(w, "obj.mock_writer_.expect_%s(value);\n", common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "self.writer_.%s(value);\n", common.ProtocolWriteMethodName(step)) + fmt.Fprintf(w, "self.mock_writer_.expect_%s(value);\n", common.ProtocolWriteImplMethodName(step)) }) w.WriteStringln("") } - w.WriteStringln("function close_(obj)") + w.WriteStringln("function close_(self)") common.WriteBlockBody(w, func() { - w.WriteStringln("obj.close_called_ = true;") - w.WriteStringln("obj.writer_.close();") - w.WriteStringln("mock_copy = copy(obj.mock_writer_);") + w.WriteStringln("self.close_called_ = true;") + w.WriteStringln("self.writer_.close();") + w.WriteStringln("mock_copy = copy(self.mock_writer_);") w.WriteStringln("") - w.WriteStringln("reader = obj.create_reader_(obj.filename_);") - w.WriteStringln("reader.copy_to(obj.mock_writer_);") + w.WriteStringln("reader = self.create_reader_(self.filename_);") + w.WriteStringln("reader.copy_to(self.mock_writer_);") w.WriteStringln("reader.close();") - w.WriteStringln("obj.mock_writer_.verify();") - w.WriteStringln("obj.mock_writer_.close();") + w.WriteStringln("self.mock_writer_.verify();") + w.WriteStringln("self.mock_writer_.close();") w.WriteStringln("") - w.WriteStringln("translated = invoke_translator(obj.filename_, obj.format_, obj.format_);") - w.WriteStringln("reader = obj.create_reader_(translated);") + w.WriteStringln("translated = invoke_translator(self.filename_, self.format_, self.format_);") + w.WriteStringln("reader = self.create_reader_(translated);") w.WriteStringln("reader.copy_to(mock_copy);") w.WriteStringln("reader.close();") w.WriteStringln("mock_copy.verify();") @@ -215,7 +215,7 @@ func writeProtocolTestWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinit }) w.WriteStringln("") - w.WriteStringln("function end_stream_(obj)") + w.WriteStringln("function end_stream_(self)") common.WriteBlockBody(w, func() {}) }) }) diff --git a/tooling/internal/matlab/protocols/protocols.go b/tooling/internal/matlab/protocols/protocols.go index b251a11a..2a3bfc58 100644 --- a/tooling/internal/matlab/protocols/protocols.go +++ b/tooling/internal/matlab/protocols/protocols.go @@ -39,17 +39,17 @@ func writeAbstractWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, w.WriteStringln("methods") common.WriteBlockBody(w, func() { // Constructor - fmt.Fprintf(w, "function obj = %s()\n", common.AbstractWriterName(p)) - common.WriteBlockBody(w, func() { w.WriteStringln("obj.state_ = 0;") }) + fmt.Fprintf(w, "function self = %s()\n", common.AbstractWriterName(p)) + common.WriteBlockBody(w, func() { w.WriteStringln("self.state_ = 0;") }) w.WriteStringln("") // Close method - w.WriteStringln("function close(obj)") + w.WriteStringln("function close(self)") common.WriteBlockBody(w, func() { - w.WriteStringln("obj.close_();") - fmt.Fprintf(w, "if obj.state_ ~= %d\n", len(p.Sequence)) + w.WriteStringln("self.close_();") + fmt.Fprintf(w, "if self.state_ ~= %d\n", len(p.Sequence)) common.WriteBlockBody(w, func() { - w.WriteStringln("expected_method = obj.state_to_method_name_(bitand((int32(obj.state_) + 1), bitcmp(1, 'int8')));") + w.WriteStringln("expected_method = self.state_to_method_name_(self.state_);") w.WriteStringln(`throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method));`) }) }) @@ -59,30 +59,30 @@ func writeAbstractWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, for i, step := range p.Sequence { common.WriteComment(w, fmt.Sprintf("Ordinal %d", i)) common.WriteComment(w, step.Comment) - fmt.Fprintf(w, "function %s(obj, value)\n", common.ProtocolWriteMethodName(step)) + fmt.Fprintf(w, "function %s(self, value)\n", common.ProtocolWriteMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "if obj.state_ ~= %d\n", i) + fmt.Fprintf(w, "if self.state_ ~= %d\n", i) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i) + fmt.Fprintf(w, "self.raise_unexpected_state_(%d);\n", i) }) w.WriteStringln("") - fmt.Fprintf(w, "obj.%s(value);\n", common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "self.%s(value);\n", common.ProtocolWriteImplMethodName(step)) if !step.IsStream() { - fmt.Fprintf(w, "obj.state_ = %d;\n", i+1) + fmt.Fprintf(w, "self.state_ = %d;\n", i+1) } }) if step.IsStream() { w.WriteStringln("") - fmt.Fprintf(w, "function %s(obj)\n", common.ProtocolEndMethodName(step)) + fmt.Fprintf(w, "function %s(self)\n", common.ProtocolEndMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "if obj.state_ ~= %d\n", i) + fmt.Fprintf(w, "if self.state_ ~= %d\n", i) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i) + fmt.Fprintf(w, "self.raise_unexpected_state_(%d);\n", i) }) w.WriteStringln("") - fmt.Fprintf(w, "obj.end_stream_();\n") - fmt.Fprintf(w, "obj.state_ = %d;\n", i+1) + fmt.Fprintf(w, "self.end_stream_();\n") + fmt.Fprintf(w, "self.state_ = %d;\n", i+1) }) } @@ -106,14 +106,14 @@ func writeAbstractWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, w.WriteStringln("methods (Abstract, Access=protected)") common.WriteBlockBody(w, func() { for _, step := range p.Sequence { - fmt.Fprintf(w, "%s(obj, value)\n", common.ProtocolWriteImplMethodName(step)) + fmt.Fprintf(w, "%s(self, value)\n", common.ProtocolWriteImplMethodName(step)) } w.WriteStringln("") // end_stream method - w.WriteStringln("end_stream_(obj)") + w.WriteStringln("end_stream_(self)") // underlying close method - w.WriteStringln("close_(obj)") + w.WriteStringln("close_(self)") }) w.WriteStringln("") @@ -121,23 +121,23 @@ func writeAbstractWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, w.WriteStringln("methods (Access=private)") common.WriteBlockBody(w, func() { // raise_unexpected_state method - w.WriteStringln("function raise_unexpected_state_(obj, actual)") + w.WriteStringln("function raise_unexpected_state_(self, actual)") common.WriteBlockBody(w, func() { - w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") - w.WriteStringln("actual_method = obj.state_to_method_name_(actual);") + w.WriteStringln("expected_method = self.state_to_method_name_(self.state_);") + w.WriteStringln("actual_method = self.state_to_method_name_(actual);") w.WriteStringln(`throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method));`) }) w.WriteStringln("") - w.WriteStringln("function name = state_to_method_name_(obj, state)") + w.WriteStringln("function name = state_to_method_name_(self, state)") common.WriteBlockBody(w, func() { for i, step := range p.Sequence { fmt.Fprintf(w, "if state == %d\n", i) w.Indented(func() { if step.IsStream() { - fmt.Fprintf(w, "name = '%s or %s';\n", common.ProtocolWriteMethodName(step), common.ProtocolEndMethodName(step)) + fmt.Fprintf(w, "name = \"%s or %s\";\n", common.ProtocolWriteMethodName(step), common.ProtocolEndMethodName(step)) } else { - fmt.Fprintf(w, "name = '%s';\n", common.ProtocolWriteMethodName(step)) + fmt.Fprintf(w, "name = \"%s\";\n", common.ProtocolWriteMethodName(step)) } }) w.WriteString("else") @@ -168,19 +168,19 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, w.WriteStringln("methods") common.WriteBlockBody(w, func() { // Constructor - fmt.Fprintf(w, "function obj = %s()\n", common.AbstractReaderName(p)) + fmt.Fprintf(w, "function self = %s()\n", common.AbstractReaderName(p)) common.WriteBlockBody(w, func() { - w.WriteStringln("obj.state_ = 0;") + w.WriteStringln("self.state_ = 0;") }) w.WriteStringln("") // Close method - w.WriteStringln("function close(obj)") + w.WriteStringln("function close(self)") common.WriteBlockBody(w, func() { - w.WriteStringln("obj.close_();") - fmt.Fprintf(w, "if obj.state_ ~= %d\n", len(p.Sequence)) + w.WriteStringln("self.close_();") + fmt.Fprintf(w, "if self.state_ ~= %d\n", len(p.Sequence)) common.WriteBlockBody(w, func() { - w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") + w.WriteStringln("expected_method = self.state_to_method_name_(self.state_);") w.WriteStringln(`throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method));`) }) }) @@ -190,52 +190,52 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, for i, step := range p.Sequence { common.WriteComment(w, fmt.Sprintf("Ordinal %d", i)) if step.IsStream() { - fmt.Fprintf(w, "function more = %s(obj)\n", common.ProtocolHasMoreMethodName(step)) + fmt.Fprintf(w, "function more = %s(self)\n", common.ProtocolHasMoreMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "if obj.state_ ~= %d\n", i) + fmt.Fprintf(w, "if self.state_ ~= %d\n", i) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i) + fmt.Fprintf(w, "self.raise_unexpected_state_(%d);\n", i) }) w.WriteStringln("") - fmt.Fprintf(w, "more = obj.%s();\n", common.ProtocolHasMoreImplMethodName(step)) + fmt.Fprintf(w, "more = self.%s();\n", common.ProtocolHasMoreImplMethodName(step)) w.WriteStringln("if ~more") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.state_ = %d;\n", i+1) + fmt.Fprintf(w, "self.state_ = %d;\n", i+1) }) }) w.WriteStringln("") } common.WriteComment(w, step.Comment) - fmt.Fprintf(w, "function value = %s(obj)\n", common.ProtocolReadMethodName(step)) + fmt.Fprintf(w, "function value = %s(self)\n", common.ProtocolReadMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "if obj.state_ ~= %d\n", i) + fmt.Fprintf(w, "if self.state_ ~= %d\n", i) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "obj.raise_unexpected_state_(%d);\n", i) + fmt.Fprintf(w, "self.raise_unexpected_state_(%d);\n", i) }) w.WriteStringln("") - fmt.Fprintf(w, "value = obj.%s();\n", common.ProtocolReadImplMethodName(step)) + fmt.Fprintf(w, "value = self.%s();\n", common.ProtocolReadImplMethodName(step)) if !step.IsStream() { - fmt.Fprintf(w, "obj.state_ = %d;\n", i+1) + fmt.Fprintf(w, "self.state_ = %d;\n", i+1) } }) w.WriteStringln("") } // copy_to method - fmt.Fprintf(w, "function copy_to(obj, writer)\n") + fmt.Fprintf(w, "function copy_to(self, writer)\n") common.WriteBlockBody(w, func() { for _, step := range p.Sequence { if step.IsStream() { - fmt.Fprintf(w, "while obj.%s()\n", common.ProtocolHasMoreMethodName(step)) + fmt.Fprintf(w, "while self.%s()\n", common.ProtocolHasMoreMethodName(step)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "item = obj.%s();\n", common.ProtocolReadMethodName(step)) + fmt.Fprintf(w, "item = self.%s();\n", common.ProtocolReadMethodName(step)) fmt.Fprintf(w, "writer.%s({item});\n", common.ProtocolWriteMethodName(step)) }) fmt.Fprintf(w, "writer.%s();\n", common.ProtocolEndMethodName(step)) } else { - fmt.Fprintf(w, "writer.%s(obj.%s());\n", common.ProtocolWriteMethodName(step), common.ProtocolReadMethodName(step)) + fmt.Fprintf(w, "writer.%s(self.%s());\n", common.ProtocolWriteMethodName(step), common.ProtocolReadMethodName(step)) } } }) @@ -256,40 +256,40 @@ func writeAbstractReader(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, common.WriteBlockBody(w, func() { for _, step := range p.Sequence { if step.IsStream() { - fmt.Fprintf(w, "%s(obj)\n", common.ProtocolHasMoreImplMethodName(step)) + fmt.Fprintf(w, "%s(self)\n", common.ProtocolHasMoreImplMethodName(step)) } - fmt.Fprintf(w, "%s(obj)\n", common.ProtocolReadImplMethodName(step)) + fmt.Fprintf(w, "%s(self)\n", common.ProtocolReadImplMethodName(step)) } w.WriteStringln("") - w.WriteStringln("close_(obj)") + w.WriteStringln("close_(self)") }) w.WriteStringln("") w.WriteStringln("methods (Access=private)") common.WriteBlockBody(w, func() { // raise_unexpected_state method - w.WriteStringln("function raise_unexpected_state_(obj, actual)") + w.WriteStringln("function raise_unexpected_state_(self, actual)") common.WriteBlockBody(w, func() { - w.WriteStringln("actual_method = obj.state_to_method_name_(actual);") - w.WriteStringln("expected_method = obj.state_to_method_name_(obj.state_);") + w.WriteStringln("actual_method = self.state_to_method_name_(actual);") + w.WriteStringln("expected_method = self.state_to_method_name_(self.state_);") w.WriteStringln(`throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method));`) }) w.WriteStringln("") // state_to_method_name method - w.WriteStringln("function name = state_to_method_name_(obj, state)") + w.WriteStringln("function name = state_to_method_name_(self, state)") common.WriteBlockBody(w, func() { for i, step := range p.Sequence { fmt.Fprintf(w, "if state == %d\n", i) w.Indented(func() { - fmt.Fprintf(w, "name = '%s';\n", common.ProtocolReadMethodName(step)) + fmt.Fprintf(w, "name = \"%s\";\n", common.ProtocolReadMethodName(step)) }) w.WriteString("else") } w.WriteStringln("") common.WriteBlockBody(w, func() { - w.WriteStringln("name = '';") + w.WriteStringln("name = \"\";") }) }) }) diff --git a/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m b/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m index 605287f6..70353bf2 100755 --- a/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m +++ b/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m @@ -8,20 +8,20 @@ end methods - function obj = BinaryProtocolReader(input, expected_schema) - obj.stream_ = yardl.binary.CodedInputStream(input); - magic_bytes = obj.stream_.read(length(yardl.binary.MAGIC_BYTES)); + function self = BinaryProtocolReader(infile, expected_schema) + self.stream_ = yardl.binary.CodedInputStream(infile); + magic_bytes = self.stream_.read_bytes(length(yardl.binary.MAGIC_BYTES)); if magic_bytes ~= yardl.binary.MAGIC_BYTES throw(yardl.binary.Exception("Invalid magic bytes")); end - version = read_fixed_int32(obj.stream_); + version = read_fixed_int32(self.stream_); if version ~= yardl.binary.CURRENT_BINARY_FORMAT_VERSION throw(yardl.binary.Exception("Invalid binary format version")); end s = yardl.binary.StringSerializer(); - schema = s.read(obj.stream_); + schema = s.read(self.stream_); if ~isempty(expected_schema) & schema ~= expected_schema throw(yardl.binary.Exception("Invalid schema")); end @@ -29,12 +29,12 @@ end methods (Access=protected) - function close_(obj) - obj.stream_.close(); + function close_(self) + self.stream_.close(); end end end function res = read_fixed_int32(stream) - res = typecast(stream.read(4), "int32"); + res = typecast(stream.read_bytes(4), "int32"); end diff --git a/tooling/internal/matlab/static_files/+binary/BinaryProtocolWriter.m b/tooling/internal/matlab/static_files/+binary/BinaryProtocolWriter.m index 9a9b5a9d..4a5378a4 100755 --- a/tooling/internal/matlab/static_files/+binary/BinaryProtocolWriter.m +++ b/tooling/internal/matlab/static_files/+binary/BinaryProtocolWriter.m @@ -8,29 +8,30 @@ end methods - function obj = BinaryProtocolWriter(output, schema) - obj.stream_ = yardl.binary.CodedOutputStream(output); - obj.stream_.write_bytes(yardl.binary.MAGIC_BYTES); - write_fixed_int32(obj.stream_, yardl.binary.CURRENT_BINARY_FORMAT_VERSION); + function self = BinaryProtocolWriter(outfile, schema) + self.stream_ = yardl.binary.CodedOutputStream(outfile); + self.stream_.write_bytes(yardl.binary.MAGIC_BYTES); + write_fixed_int32(self.stream_, yardl.binary.CURRENT_BINARY_FORMAT_VERSION); s = yardl.binary.StringSerializer(); - s.write(obj.stream_, schema); + s.write(self.stream_, schema); end end methods (Access=protected) - function end_stream_(obj) - obj.stream_.write_byte_no_check(0); + function end_stream_(self) + self.stream_.write_byte(uint8(0)); end - function close_(obj) - obj.stream_.close(); + function close_(self) + self.stream_.close(); end end end function write_fixed_int32(stream, value) - assert(value >= intmin("int32")); - assert(value <= intmax("int32")); - value = int32(value); - stream.write(typecast(value, "uint8")); + arguments + stream (1,1) yardl.binary.CodedOutputStream + value (1,1) {mustBeA(value, "int32")} + end + stream.write_bytes(typecast(value, "uint8")); end diff --git a/tooling/internal/matlab/static_files/+binary/BoolSerializer.m b/tooling/internal/matlab/static_files/+binary/BoolSerializer.m index aad498cc..83112731 100755 --- a/tooling/internal/matlab/static_files/+binary/BoolSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/BoolSerializer.m @@ -3,8 +3,11 @@ classdef BoolSerializer < yardl.binary.TypeSerializer methods (Static) - function write( outstream, value) - assert(islogical(value)); + function write(outstream, value) + arguments + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) {mustBeInRange(value, 0, 1)} + end byte = cast(value, "uint8"); outstream.write_bytes(byte); end @@ -14,11 +17,11 @@ function write( outstream, value) res = cast(byte, "logical"); end - function c = getClass() - c = 'logical'; + function c = get_class() + c = "logical"; end - function trivial = isTriviallySerializable() + function trivial = is_trivially_serializable() trivial = true; end end diff --git a/tooling/internal/matlab/static_files/+binary/CodedInputStream.m b/tooling/internal/matlab/static_files/+binary/CodedInputStream.m index 214fe10a..6a770e6e 100755 --- a/tooling/internal/matlab/static_files/+binary/CodedInputStream.m +++ b/tooling/internal/matlab/static_files/+binary/CodedInputStream.m @@ -9,16 +9,16 @@ end methods - function self = CodedInputStream(input) - if isa(input, "string") || isa(input, "char") - [fileId, errMsg] = fopen(input, "r"); + function self = CodedInputStream(infile) + if isa(infile, "string") || isa(infile, "char") + [fileId, errMsg] = fopen(infile, "r"); if fileId < 0 throw(yardl.binary.Exception(errMsg)); end self.fid_ = fileId; self.owns_stream_ = true; else - self.fid_ = input; + self.fid_ = infile; self.owns_stream_ = false; end end @@ -30,8 +30,11 @@ function close(self) end end - function res = read(self, count) + function res = read_bytes(self, count) res = fread(self.fid_, count, "*uint8"); + if iscolumn(res) + res = transpose(res); + end end function res = read_byte(self) @@ -40,6 +43,9 @@ function close(self) function res = read_values_directly(self, shape, precision) res = fread(self.fid_, shape, "*"+precision); + if iscolumn(res) + res = transpose(res); + end end function res = read_unsigned_varint(self) @@ -64,6 +70,5 @@ function close(self) function res = read_signed_varint(self) res = self.zigzag_decode(self.read_unsigned_varint()); end - end end diff --git a/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m b/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m index d69c2e77..40055a6a 100755 --- a/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m +++ b/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m @@ -9,16 +9,16 @@ end methods - function self = CodedOutputStream(output) - if isa(output, "string") || isa(output, "char") - [fileId, errMsg] = fopen(output, "W"); + function self = CodedOutputStream(outfile) + if isa(outfile, "string") || isa(outfile, "char") + [fileId, errMsg] = fopen(outfile, "W"); if fileId < 0 throw(yardl.binary.Exception(errMsg)); end self.fid_ = fileId; self.owns_stream_ = true; else - self.fid_ = input; + self.fid_ = outfile; self.owns_stream_ = false; end end @@ -30,20 +30,19 @@ function close(self) end end - function write(self, value) - assert(isa(value, "uint8")); - fwrite(self.fid_, value, "uint8"); - end - function write_bytes(self, bytes) + arguments + self + bytes (1,:) {mustBeA(bytes, "uint8")} + end fwrite(self.fid_, bytes, "uint8"); end - function write_byte_no_check(self, value) - assert(isscalar(value)); - assert(all(value >= 0)); - assert(all(value <= intmax("uint8"))); - + function write_byte(self, value) + arguments + self + value (1,1) {mustBeA(value, "uint8")} + end fwrite(self.fid_, value, "uint8"); end @@ -52,16 +51,19 @@ function write_values_directly(self, values, precision) end function write_unsigned_varint(self, value) - assert(isscalar(value)); + arguments + self + value (1,1) {mustBeInteger,mustBeNonnegative} + end int_val = uint64(value); while true if int_val < 0x80 - self.write_byte_no_check(int_val); + self.write_byte(uint8(int_val)); return end - self.write_byte_no_check(bitor(bitand(int_val, uint64(0x7F)), uint64(0x80))); + self.write_byte(uint8(bitor(bitand(int_val, uint64(0x7F)), uint64(0x80)))); int_val = bitshift(int_val, -7); end end @@ -72,10 +74,11 @@ function write_unsigned_varint(self, value) end function write_signed_varint(self, value) - assert(isscalar(value)); - + arguments + self + value (1,1) {mustBeInteger} + end self.write_unsigned_varint(self.zigzag_encode(value)); end - end end diff --git a/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m b/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m index dd37f7e9..041edb84 100755 --- a/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Complexfloat32Serializer.m @@ -4,12 +4,10 @@ classdef Complexfloat32Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - % assert(class(value) == "single"); - assert(real(value) <= realmax('single')); - assert(imag(value) <= realmax('single')); - assert(real(value) >= -realmax('single')); - assert(imag(value) >= -realmax('single')); - + arguments + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) single + end real_bytes = typecast(single(real(value)), "uint8"); imag_bytes = typecast(single(imag(value)), "uint8"); outstream.write_bytes(real_bytes); @@ -17,33 +15,33 @@ function write(outstream, value) end function res = read(instream) - real_bytes = instream.read(4); - imag_bytes = instream.read(4); + real_bytes = instream.read_bytes(4); + imag_bytes = instream.read_bytes(4); res = complex(typecast(real_bytes, "single"), typecast(imag_bytes, "single")); end - function c = getClass() - c = 'single'; + function c = get_class() + c = "single"; end - function trivial = isTriviallySerializable() + function trivial = is_trivially_serializable() trivial = true; end end methods - function writeTrivially(self, stream, values) + function write_trivially(self, stream, values) rp = real(values); ip = imag(values); parts(1, :) = rp(:); parts(2, :) = ip(:); - stream.write_values_directly(parts, self.getClass()); + stream.write_values_directly(parts, self.get_class()); end - function res = readTrivially(obj, stream, shape) + function res = read_trivially(self, stream, shape) assert(ndims(shape) == 2); partshape = [2*shape(1) shape(2)]; - res = stream.read_values_directly(partshape, obj.getClass()); + res = stream.read_values_directly(partshape, self.get_class()); res = reshape(res, [2 shape]); res = squeeze(complex(res(1, :, :), res(2, :, :))); end diff --git a/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m b/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m index 895913a6..5f6fba6f 100755 --- a/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Complexfloat64Serializer.m @@ -4,7 +4,10 @@ classdef Complexfloat64Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - assert(class(value) == "double"); + arguments + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) double + end real_bytes = typecast(double(real(value)), "uint8"); imag_bytes = typecast(double(imag(value)), "uint8"); outstream.write_bytes(real_bytes); @@ -12,33 +15,33 @@ function write(outstream, value) end function res = read(instream) - real_bytes = instream.read(8); - imag_bytes = instream.read(8); + real_bytes = instream.read_bytes(8); + imag_bytes = instream.read_bytes(8); res = complex(typecast(real_bytes, "double"), typecast(imag_bytes, "double")); end - function c = getClass() - c = 'double'; + function c = get_class() + c = "double"; end - function trivial = isTriviallySerializable() + function trivial = is_trivially_serializable() trivial = true; end end methods - function writeTrivially(self, stream, values) + function write_trivially(self, stream, values) rp = real(values); ip = imag(values); parts(1, :) = rp(:); parts(2, :) = ip(:); - stream.write_values_directly(parts, self.getClass()); + stream.write_values_directly(parts, self.get_class()); end - function res = readTrivially(obj, stream, shape) + function res = read_trivially(self, stream, shape) assert(ndims(shape) == 2); partshape = [2*shape(1) shape(2)]; - res = stream.read_values_directly(partshape, obj.getClass()); + res = stream.read_values_directly(partshape, self.get_class()); res = reshape(res, [2 shape]); res = squeeze(complex(res(1, :, :), res(2, :, :))); end diff --git a/tooling/internal/matlab/static_files/+binary/DateSerializer.m b/tooling/internal/matlab/static_files/+binary/DateSerializer.m index c0760763..20f78c3e 100755 --- a/tooling/internal/matlab/static_files/+binary/DateSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/DateSerializer.m @@ -4,9 +4,9 @@ classdef DateSerializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - if isa(value, 'datetime') + if isa(value, "datetime") value = yardl.Date.from_datetime(value).value; - elseif isa(value, 'yardl.Date') + elseif isa(value, "yardl.Date") value = value.value; else throw(yardl.TypeError("Expected datetime or yardl.Date, got %s", class(value))); @@ -19,8 +19,8 @@ function write(outstream, value) res = yardl.Date(value); end - function c = getClass() - c = 'yardl.Date'; + function c = get_class() + c = "yardl.Date"; end end end diff --git a/tooling/internal/matlab/static_files/+binary/DatetimeSerializer.m b/tooling/internal/matlab/static_files/+binary/DatetimeSerializer.m index eada81ad..07f813bc 100755 --- a/tooling/internal/matlab/static_files/+binary/DatetimeSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/DatetimeSerializer.m @@ -4,9 +4,9 @@ classdef DatetimeSerializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - if isa(value, 'datetime') + if isa(value, "datetime") value = yardl.DateTime.from_datetime(value).value; - elseif isa(value, 'yardl.DateTime') + elseif isa(value, "yardl.DateTime") value = value.value; else throw(yardl.TypeError("Expected datetime or yardl.DateTime, got %s", class(value))); @@ -19,8 +19,8 @@ function write(outstream, value) res = yardl.DateTime(value); end - function c = getClass() - c = 'yardl.DateTime'; + function c = get_class() + c = "yardl.DateTime"; end end end diff --git a/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m index d67b9317..4f7f8c51 100644 --- a/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/DynamicNDArraySerializer.m @@ -9,18 +9,14 @@ end function write(self, outstream, values) - - item_shape = self.item_serializer_.getShape(); - + item_shape = self.item_serializer_.get_shape(); shape = size(values); if isempty(item_shape) % values is an array of variable-length vectors or arrays values = values(:); - elseif isscalar(item_shape) % values is an array of scalars values = values(:); - else % values is an array of fixed-length vectors or arrays item_shape = item_shape(item_shape > 1); diff --git a/tooling/internal/matlab/static_files/+binary/EnumSerializer.m b/tooling/internal/matlab/static_files/+binary/EnumSerializer.m index d3bdbc45..307eeb9b 100644 --- a/tooling/internal/matlab/static_files/+binary/EnumSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/EnumSerializer.m @@ -9,35 +9,35 @@ end methods - function obj = EnumSerializer(classname, classconstructor, integer_serializer) - obj.classname_ = classname; - obj.constructor_ = classconstructor; - obj.integer_serializer_ = integer_serializer; + function self = EnumSerializer(classname, classconstructor, integer_serializer) + self.classname_ = classname; + self.constructor_ = classconstructor; + self.integer_serializer_ = integer_serializer; end - function write(obj, outstream, value) - obj.integer_serializer_.write(outstream, value); + function write(self, outstream, value) + self.integer_serializer_.write(outstream, value); end - function res = read(obj, instream) - int_value = obj.integer_serializer_.read(instream); - res = obj.constructor_(int_value); + function res = read(self, instream) + int_value = self.integer_serializer_.read(instream); + res = self.constructor_(int_value); end - function c = getClass(obj) - c = obj.classname_; + function c = get_class(self) + c = self.classname_; end - function trivial = isTriviallySerializable(obj) - trivial = obj.integer_serializer_.isTriviallySerializable(); + function trivial = is_trivially_serializable(self) + trivial = self.integer_serializer_.is_trivially_serializable(); end - function writeTrivially(self, outstream, values) - self.integer_serializer_.writeTrivially(outstream, values); + function write_trivially(self, outstream, values) + self.integer_serializer_.write_trivially(outstream, values); end - function res = readTrivially(self, instream, shape) - res = self.integer_serializer_.readTrivially(instream, shape); + function res = read_trivially(self, instream, shape) + res = self.integer_serializer_.read_trivially(instream, shape); end end end diff --git a/tooling/internal/matlab/static_files/+binary/Error.m b/tooling/internal/matlab/static_files/+binary/Error.m deleted file mode 100755 index 212e7d83..00000000 --- a/tooling/internal/matlab/static_files/+binary/Error.m +++ /dev/null @@ -1,6 +0,0 @@ -% Copyright (c) Microsoft Corporation. -% Licensed under the MIT License. - -function err = Error(varargin) - err = yardl.Exception("yardl:binary:Error", varargin{:}); -end diff --git a/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m index 96cc47aa..b43faa60 100644 --- a/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m @@ -14,14 +14,13 @@ end function write(self, outstream, values) - sz = size(values); - if numel(values) == prod(self.shape_) % This is an NDArray of scalars self.write_data_(outstream, values(:)); return; end + sz = size(values); if length(sz) < length(self.shape_) expected = sprintf("%d ", self.shape_); actual = sprintf("%d ", sz); @@ -49,12 +48,12 @@ function write(self, outstream, values) end end - function s = getShape(obj) - item_shape = obj.item_serializer_.getShape(); + function s = get_shape(self) + item_shape = self.item_serializer_.get_shape(); if isempty(item_shape) - s = obj.shape_; + s = self.shape_; else - s = [item_shape obj.shape_]; + s = [item_shape self.shape_]; end if length(s) > 2 @@ -62,16 +61,16 @@ function write(self, outstream, values) end end - function trivial = isTriviallySerializable(obj) - trivial = obj.item_serializer_.isTriviallySerializable(); + function trivial = is_trivially_serializable(self) + trivial = self.item_serializer_.is_trivially_serializable(); end - function writeTrivially(self, outstream, values) - self.item_serializer_.writeTrivially(outstream, values); + function write_trivially(self, outstream, values) + self.item_serializer_.write_trivially(outstream, values); end - function res = readTrivially(self, instream, shape) - res = self.item_serializer_.readTrivially(instream, shape); + function res = read_trivially(self, instream, shape) + res = self.item_serializer_.read_trivially(instream, shape); end end end diff --git a/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m b/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m index ad3d7788..35dafc2b 100644 --- a/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/FixedVectorSerializer.m @@ -1,106 +1,51 @@ % Copyright (c) Microsoft Corporation. % Licensed under the MIT License. -classdef FixedVectorSerializer < yardl.binary.TypeSerializer +classdef FixedVectorSerializer < yardl.binary.VectorSerializerBase properties - item_serializer_; length_; end - methods - function obj = FixedVectorSerializer(item_serializer, length) - obj.item_serializer_ = item_serializer; - obj.length_ = length; - end - - function write(obj, outstream, values) - if iscolumn(values) - values = transpose(values); - end - s = size(values); - count = s(end); - - if count ~= obj.length_ - throw(yardl.ValueError("Expected an array of length %d, got %d", obj.length_, count)); - end - - if iscell(values) - assert(s(1) == 1); - for i = 1:count - obj.item_serializer_.write(outstream, values{i}); - end - else - if obj.item_serializer_.isTriviallySerializable() - obj.item_serializer_.writeTrivially(outstream, values); - return - end - - if ndims(values) > 2 - r = reshape(values, [], count); - for i = 1:count - val = reshape(r(:, i), s(1:end-1)); - obj.item_serializer_.write(outstream, val); - end - else - for i = 1:count - obj.item_serializer_.write(outstream, transpose(values(:, i))); - end - end + methods (Access=protected) + function handle_write_count_(self, ~, count) + if count ~= self.length_ + throw(yardl.ValueError("Expected an array of length %d, got %d", self.length_, count)); end end - function res = read(obj, instream) - item_shape = obj.item_serializer_.getShape(); - if isempty(item_shape) - res = cell(1, obj.length_); - for i = 1:obj.length_ - res{i} = obj.item_serializer_.read(instream); - end - return - end - - if obj.item_serializer_.isTriviallySerializable() - res = obj.item_serializer_.readTrivially(instream, [prod(item_shape), obj.length_]); - else - res = yardl.allocate(obj.getClass(), [prod(item_shape), obj.length_]); - for i = 1:obj.length_ - item = obj.item_serializer_.read(instream); - res(:, i) = item(:); - end - end - - res = squeeze(reshape(res, [item_shape, obj.length_])); - if iscolumn(res) - res = transpose(res); - end + function count = get_read_count_(self, ~) + count = self.length_; end + end - function c = getClass(obj) - c = obj.item_serializer_.getClass(); + methods + function self = FixedVectorSerializer(item_serializer, length) + self@yardl.binary.VectorSerializerBase(item_serializer); + self.length_ = length; end - function s = getShape(obj) - item_shape = obj.item_serializer_.getShape(); + function s = get_shape(self) + item_shape = self.item_serializer_.get_shape(); if isempty(item_shape) - s = [1, obj.length_]; + s = [1, self.length_]; elseif isscalar(item_shape) - s = [item_shape obj.length_]; + s = [item_shape self.length_]; else - s = [item_shape obj.length_]; + s = [item_shape self.length_]; s = s(s>1); end end - function trivial = isTriviallySerializable(obj) - trivial = obj.item_serializer_.isTriviallySerializable(); + function trivial = is_trivially_serializable(self) + trivial = self.item_serializer_.is_trivially_serializable(); end - function writeTrivially(self, outstream, values) - self.item_serializer_.writeTrivially(outstream, values); + function write_trivially(self, outstream, values) + self.item_serializer_.write_trivially(outstream, values); end - function res = readTrivially(self, instream, shape) - res = self.item_serializer_.readTrivially(instream, shape); + function res = read_trivially(self, instream, shape) + res = self.item_serializer_.read_trivially(instream, shape); end end end diff --git a/tooling/internal/matlab/static_files/+binary/Float32Serializer.m b/tooling/internal/matlab/static_files/+binary/Float32Serializer.m index 7dce00b2..021e6230 100755 --- a/tooling/internal/matlab/static_files/+binary/Float32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Float32Serializer.m @@ -4,24 +4,25 @@ classdef Float32Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - % assert(class(value) == "single"); - assert(value <= realmax('single')); - assert(value >= -realmax('single')); + arguments + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) single + end bytes = typecast(single(value), "uint8"); outstream.write_bytes(bytes); end function res = read(instream) - bytes = instream.read(4); + bytes = instream.read_bytes(4); res = typecast(bytes, "single"); end - function c = getClass() - c = 'single'; + function c = get_class() + c = "single"; end - function trivial = isTriviallySerializable() + function trivial = is_trivially_serializable() trivial = true; end end diff --git a/tooling/internal/matlab/static_files/+binary/Float64Serializer.m b/tooling/internal/matlab/static_files/+binary/Float64Serializer.m index 4a473873..4f583677 100755 --- a/tooling/internal/matlab/static_files/+binary/Float64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Float64Serializer.m @@ -4,21 +4,24 @@ classdef Float64Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - assert(class(value) == "double"); + arguments + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) double + end bytes = typecast(double(value), "uint8"); outstream.write_bytes(bytes); end function res = read(instream) - bytes = instream.read(8); + bytes = instream.read_bytes(8); res = typecast(bytes, "double"); end - function c = getClass() - c = 'double'; + function c = get_class() + c = "double"; end - function trivial = isTriviallySerializable() + function trivial = is_trivially_serializable() trivial = true; end end diff --git a/tooling/internal/matlab/static_files/+binary/Int16Serializer.m b/tooling/internal/matlab/static_files/+binary/Int16Serializer.m index 5a116938..8f140d8d 100755 --- a/tooling/internal/matlab/static_files/+binary/Int16Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int16Serializer.m @@ -4,9 +4,10 @@ classdef Int16Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - assert(value <= intmax("int16")); - assert(value >= intmin("int16")); - value = int16(value); + arguments + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) {mustBeInRange(value, -32768, 32767)} + end outstream.write_signed_varint(value); end @@ -14,8 +15,8 @@ function write(outstream, value) res = int16(instream.read_signed_varint()); end - function c = getClass() - c = 'int16'; + function c = get_class() + c = "int16"; end end end diff --git a/tooling/internal/matlab/static_files/+binary/Int32Serializer.m b/tooling/internal/matlab/static_files/+binary/Int32Serializer.m index cbe2eae3..20fc3d3c 100755 --- a/tooling/internal/matlab/static_files/+binary/Int32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int32Serializer.m @@ -4,9 +4,10 @@ classdef Int32Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - assert(value <= intmax("int32")); - assert(value >= intmin("int32")); - value = int32(value); + arguments + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) {mustBeInRange(value, -2147483648, 2147483647)} + end outstream.write_signed_varint(value); end @@ -14,8 +15,8 @@ function write(outstream, value) res = int32(instream.read_signed_varint()); end - function c = getClass() - c = 'int32'; + function c = get_class() + c = "int32"; end end end diff --git a/tooling/internal/matlab/static_files/+binary/Int64Serializer.m b/tooling/internal/matlab/static_files/+binary/Int64Serializer.m index f9f8658b..2176a933 100755 --- a/tooling/internal/matlab/static_files/+binary/Int64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int64Serializer.m @@ -4,9 +4,10 @@ classdef Int64Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - assert(value <= intmax("int64")); - assert(value >= intmin("int64")); - value = int64(value); + arguments + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) {mustBeInRange(value, -9223372036854775808, 9223372036854775807)} + end outstream.write_signed_varint(value); end @@ -14,8 +15,8 @@ function write(outstream, value) res = int64(instream.read_signed_varint()); end - function c = getClass() - c = 'int64'; + function c = get_class() + c = "int64"; end end end diff --git a/tooling/internal/matlab/static_files/+binary/Int8Serializer.m b/tooling/internal/matlab/static_files/+binary/Int8Serializer.m index 62ddecf0..ecf037c9 100755 --- a/tooling/internal/matlab/static_files/+binary/Int8Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Int8Serializer.m @@ -4,21 +4,23 @@ classdef Int8Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - assert(value <= intmax("int8")); - assert(value >= intmin("int8")); - bytes = typecast(int8(value), "uint8"); - outstream.write_bytes(bytes); + arguments + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) {mustBeInRange(value, -128, 127)} + end + byte = typecast(int8(value), "uint8"); + outstream.write_byte(byte); end function res = read(instream) res = typecast(instream.read_byte(), "int8"); end - function c = getClass() - c = 'int8'; + function c = get_class() + c = "int8"; end - function trivial = isTriviallySerializable() + function trivial = is_trivially_serializable() trivial = true; end end diff --git a/tooling/internal/matlab/static_files/+binary/MapSerializer.m b/tooling/internal/matlab/static_files/+binary/MapSerializer.m index 6bdf09e0..3e8f9000 100644 --- a/tooling/internal/matlab/static_files/+binary/MapSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/MapSerializer.m @@ -8,35 +8,39 @@ end methods - function obj = MapSerializer(key_serializer, value_serializer) - obj.key_serializer_ = key_serializer; - obj.value_serializer_ = value_serializer; + function self = MapSerializer(key_serializer, value_serializer) + self.key_serializer_ = key_serializer; + self.value_serializer_ = value_serializer; end - function write(obj, outstream, value) - assert(isa(value, 'dictionary')) + function write(self, outstream, value) + arguments + self (1,1) + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) dictionary + end count = numEntries(value); outstream.write_unsigned_varint(count); ks = keys(value); vs = values(value); for i = 1:count - obj.key_serializer_.write(outstream, ks(i)); - obj.value_serializer_.write(outstream, vs(i)); + self.key_serializer_.write(outstream, ks(i)); + self.value_serializer_.write(outstream, vs(i)); end end - function res = read(obj, instream) + function res = read(self, instream) count = instream.read_unsigned_varint(); res = dictionary(); for i = 1:count - k = obj.key_serializer_.read(instream); - v = obj.value_serializer_.read(instream); + k = self.key_serializer_.read(instream); + v = self.value_serializer_.read(instream); res(k) = v; end end - function c = getClass(obj) - c = 'dictionary'; + function c = get_class(~) + c = "dictionary"; end end end diff --git a/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m index 58bc487e..ed853fcc 100644 --- a/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m @@ -19,7 +19,6 @@ function write(self, outstream, values) end sz = size(values); - flipped_shape = flip(sz); for dim = 1: self.ndims_ len = flipped_shape(dim); @@ -46,7 +45,6 @@ function write(self, outstream, values) flipped_shape(dim) = instream.read_unsigned_varint(); end shape = flip(flipped_shape); - value = self.read_data_(instream, shape); end end diff --git a/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m b/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m index 3f1f28ad..9653980d 100644 --- a/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m +++ b/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m @@ -22,8 +22,8 @@ function write_data_(self, outstream, values) % N is the "flattened" dimension of the NDArray, and % A, B, ... are the dimensions of the inner items. - if ~iscell(values) && self.item_serializer_.isTriviallySerializable() - self.item_serializer_.writeTrivially(outstream, values); + if ~iscell(values) && self.item_serializer_.is_trivially_serializable() + self.item_serializer_.write_trivially(outstream, values); return; end @@ -49,7 +49,6 @@ function write_data_(self, outstream, values) end end else - assert(ismatrix(values)); count = sz(end); for i = 1:count self.item_serializer_.write(outstream, values(:, i)); @@ -60,7 +59,7 @@ function write_data_(self, outstream, values) function res = read_data_(self, instream, shape) flat_length = prod(shape); - item_shape = self.item_serializer_.getShape(); + item_shape = self.item_serializer_.get_shape(); if isempty(item_shape) res = cell(shape); @@ -70,10 +69,10 @@ function write_data_(self, outstream, values) return end - if self.item_serializer_.isTriviallySerializable() - res = self.item_serializer_.readTrivially(instream, [prod(item_shape), flat_length]); + if self.item_serializer_.is_trivially_serializable() + res = self.item_serializer_.read_trivially(instream, [prod(item_shape), flat_length]); else - res = yardl.allocate(self.getClass(), [prod(item_shape), flat_length]); + res = yardl.allocate(self.get_class(), [prod(item_shape), flat_length]); for i = 1:flat_length item = self.item_serializer_.read(instream); res(:, i) = item(:); @@ -88,11 +87,11 @@ function write_data_(self, outstream, values) end methods - function c = getClass(self) - c = self.item_serializer_.getClass(); + function c = get_class(self) + c = self.item_serializer_.get_class(); end - function s = getShape(~) + function s = get_shape(~) s = []; end end diff --git a/tooling/internal/matlab/static_files/+binary/NoneSerializer.m b/tooling/internal/matlab/static_files/+binary/NoneSerializer.m index 45bf88a0..99865941 100755 --- a/tooling/internal/matlab/static_files/+binary/NoneSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/NoneSerializer.m @@ -3,15 +3,15 @@ classdef NoneSerializer < yardl.binary.TypeSerializer methods (Static) - function write(outstream, value) + function write(~, ~) end - function res = read(instream) + function res = read(~) res = yardl.None; end - function c = getClass() - c = 'yardl.Optional'; + function c = get_class() + c = "yardl.Optional"; end end end diff --git a/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m b/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m index e19856fd..79d11c32 100644 --- a/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m @@ -7,36 +7,36 @@ end methods - function obj = OptionalSerializer(item_serializer) - obj.item_serializer_ = item_serializer; + function self = OptionalSerializer(item_serializer) + self.item_serializer_ = item_serializer; end - function write(obj, outstream, value) - if isa(value, 'yardl.Optional') + function write(self, outstream, value) + if isa(value, "yardl.Optional") if value.has_value() - outstream.write_byte_no_check(1); - obj.item_serializer_.write(outstream, value.value()); + outstream.write_byte(uint8(1)); + self.item_serializer_.write(outstream, value.value()); else - outstream.write_byte_no_check(0); + outstream.write_byte(uint8(0)); return end else - outstream.write_byte_no_check(1); - obj.item_serializer_.write(outstream, value); + outstream.write_byte(uint8(1)); + self.item_serializer_.write(outstream, value); end end - function res = read(obj, instream) + function res = read(self, instream) has_value = instream.read_byte(); if has_value == 0 res = yardl.None; else - res = obj.item_serializer_.read(instream); + res = self.item_serializer_.read(instream); end end - function c = getClass(obj) - c = 'yardl.Optional'; + function c = get_class(~) + c = "yardl.Optional"; end end end diff --git a/tooling/internal/matlab/static_files/+binary/RecordSerializer.m b/tooling/internal/matlab/static_files/+binary/RecordSerializer.m index 2a1dd7c9..d6a2fb59 100755 --- a/tooling/internal/matlab/static_files/+binary/RecordSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/RecordSerializer.m @@ -9,29 +9,29 @@ end methods - function obj = RecordSerializer(classname, field_serializers) - obj.classname = classname; - obj.field_serializers = field_serializers; + function self = RecordSerializer(classname, field_serializers) + self.classname = classname; + self.field_serializers = field_serializers; end - function c = getClass(obj) - c = obj.classname; + function c = get_class(self) + c = self.classname; end end methods (Access=protected) - function write_(obj, outstream, varargin) + function write_(self, outstream, varargin) for i = 1:nargin-2 - fs = obj.field_serializers{i}; + fs = self.field_serializers{i}; field_value = varargin{i}; fs.write(outstream, field_value); end end - function res = read_(obj, instream) - res = cell(size(obj.field_serializers)); - for i = 1:length(obj.field_serializers) - fs = obj.field_serializers{i}; + function res = read_(self, instream) + res = cell(size(self.field_serializers)); + for i = 1:length(self.field_serializers) + fs = self.field_serializers{i}; res{i} = fs.read(instream); end end diff --git a/tooling/internal/matlab/static_files/+binary/StreamSerializer.m b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m index f69b29fd..233bf2b6 100644 --- a/tooling/internal/matlab/static_files/+binary/StreamSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/StreamSerializer.m @@ -8,12 +8,12 @@ end methods - function obj = StreamSerializer(item_serializer) - obj.item_serializer_ = item_serializer; - obj.items_remaining_ = 0; + function self = StreamSerializer(item_serializer) + self.item_serializer_ = item_serializer; + self.items_remaining_ = 0; end - function write(obj, outstream, values) + function write(self, outstream, values) if isempty(values) return; end @@ -26,9 +26,11 @@ function write(obj, outstream, values) outstream.write_unsigned_varint(count); if iscell(values) - assert(s(1) == 1); + if ~isvector(s) + throw(yardl.ValueError("cell array must be a vector")); + end for i = 1:count - obj.item_serializer_.write(outstream, values{i}); + self.item_serializer_.write(outstream, values{i}); end else if ndims(values) > 2 @@ -36,20 +38,20 @@ function write(obj, outstream, values) inner_shape = s(1:end-1); for i = 1:count val = reshape(r(:, i), inner_shape); - obj.item_serializer_.write(outstream, val); + self.item_serializer_.write(outstream, val); end else for i = 1:count - obj.item_serializer_.write(outstream, transpose(values(:, i))); + self.item_serializer_.write(outstream, transpose(values(:, i))); end end end end - function res = hasnext(obj, instream) - if obj.items_remaining_ <= 0 - obj.items_remaining_ = instream.read_unsigned_varint(); - if obj.items_remaining_ <= 0 + function res = hasnext(self, instream) + if self.items_remaining_ <= 0 + self.items_remaining_ = instream.read_unsigned_varint(); + if self.items_remaining_ <= 0 res = false; return; end @@ -57,20 +59,20 @@ function write(obj, outstream, values) res = true; end - function res = read(obj, instream) - if obj.items_remaining_ <= 0 + function res = read(self, instream) + if self.items_remaining_ <= 0 throw(yardl.RuntimeError("Stream has been exhausted")); end - res = obj.item_serializer_.read(instream); - obj.items_remaining_ = obj.items_remaining_ - 1; + res = self.item_serializer_.read(instream); + self.items_remaining_ = self.items_remaining_ - 1; end - function c = getClass(obj) - c = obj.item_serializer_.getClass(); + function c = get_class(self) + c = self.item_serializer_.get_class(); end - function s = getShape(~) + function s = get_shape(~) s = []; end end diff --git a/tooling/internal/matlab/static_files/+binary/StringSerializer.m b/tooling/internal/matlab/static_files/+binary/StringSerializer.m index 14849a03..d96ff6c1 100755 --- a/tooling/internal/matlab/static_files/+binary/StringSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/StringSerializer.m @@ -4,6 +4,10 @@ classdef StringSerializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) + arguments + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) {mustBeTextScalar} + end bytes = unicode2native(value, "utf-8"); outstream.write_unsigned_varint(length(bytes)); outstream.write_bytes(bytes); @@ -11,12 +15,12 @@ function write(outstream, value) function res = read(instream) len = instream.read_unsigned_varint(); - bytes = instream.read(len); + bytes = instream.read_bytes(len); res = convertCharsToStrings(native2unicode(bytes, "utf-8")); end - function c = getClass() - c = 'string'; + function c = get_class() + c = "string"; end end end diff --git a/tooling/internal/matlab/static_files/+binary/TimeSerializer.m b/tooling/internal/matlab/static_files/+binary/TimeSerializer.m index bae74be9..e612d9fb 100755 --- a/tooling/internal/matlab/static_files/+binary/TimeSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/TimeSerializer.m @@ -4,9 +4,9 @@ classdef TimeSerializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - if isa(value, 'datetime') + if isa(value, "datetime") value = yardl.Time.from_datetime(value).value; - elseif isa(value, 'yardl.Time') + elseif isa(value, "yardl.Time") value = value.value; else throw(yardl.TypeError("Expected datetime or yardl.Time, got %s", class(value))); @@ -20,8 +20,8 @@ function write(outstream, value) res = yardl.Time(value); end - function c = getClass() - c = 'yardl.Time'; + function c = get_class() + c = "yardl.Time"; end end end diff --git a/tooling/internal/matlab/static_files/+binary/TypeSerializer.m b/tooling/internal/matlab/static_files/+binary/TypeSerializer.m index 8657bea3..0cbb6f15 100755 --- a/tooling/internal/matlab/static_files/+binary/TypeSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/TypeSerializer.m @@ -3,34 +3,34 @@ classdef TypeSerializer < handle methods (Static, Abstract) - write(obj, stream, value) - res = read(obj, stream) - c = getClass(obj) + write(self, stream, value) + res = read(self, stream) + c = get_class(self) end methods (Static) - function s = getShape() + function s = get_shape() s = 1; end - function trivial = isTriviallySerializable() + function trivial = is_trivially_serializable() trivial = false; end end methods - function writeTrivially(obj, stream, values) - if ~obj.isTriviallySerializable() - error("Not implemented for non-trivially-serializable types") + function write_trivially(self, stream, values) + if ~self.is_trivially_serializable() + throw(yardl.TypeError("Not implemented for non-trivially-serializable types")); end - stream.write_values_directly(values, obj.getClass()); + stream.write_values_directly(values, self.get_class()); end - function res = readTrivially(obj, stream, shape) - if ~obj.isTriviallySerializable() - error("Not implemented for non-trivially-serializable types") + function res = read_trivially(self, stream, shape) + if ~self.is_trivially_serializable() + throw(yardl.TypeError("Not implemented for non-trivially-serializable types")); end - res = stream.read_values_directly(shape, obj.getClass()); + res = stream.read_values_directly(shape, self.get_class()); end end end diff --git a/tooling/internal/matlab/static_files/+binary/Uint16Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint16Serializer.m index a909d929..5e33f7df 100755 --- a/tooling/internal/matlab/static_files/+binary/Uint16Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint16Serializer.m @@ -4,9 +4,10 @@ classdef Uint16Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - assert(value <= intmax("uint16")); - assert(value >= intmin("uint16")); - value = uint16(value); + arguments + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) {mustBeInRange(value, 0, 65535)} + end outstream.write_unsigned_varint(value); end @@ -14,8 +15,8 @@ function write(outstream, value) res = uint16(instream.read_unsigned_varint()); end - function c = getClass() - c = 'uint16'; + function c = get_class() + c = "uint16"; end end end diff --git a/tooling/internal/matlab/static_files/+binary/Uint32Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint32Serializer.m index dcb95c05..5bf4c543 100755 --- a/tooling/internal/matlab/static_files/+binary/Uint32Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint32Serializer.m @@ -4,9 +4,10 @@ classdef Uint32Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - assert(value <= intmax("uint32")); - assert(value >= intmin("uint32")); - value = uint32(value); + arguments + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) {mustBeInRange(value, 0, 4294967295)} + end outstream.write_unsigned_varint(value); end @@ -14,8 +15,8 @@ function write(outstream, value) res = uint32(instream.read_unsigned_varint()); end - function c = getClass() - c = 'uint32'; + function c = get_class() + c = "uint32"; end end end diff --git a/tooling/internal/matlab/static_files/+binary/Uint64Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint64Serializer.m index f387386a..3d51f625 100755 --- a/tooling/internal/matlab/static_files/+binary/Uint64Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint64Serializer.m @@ -4,9 +4,10 @@ classdef Uint64Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - assert(value <= intmax("uint64")); - assert(value >= intmin("uint64")); - value = uint64(value); + arguments + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) {mustBeInRange(value, 0, 18446744073709551615)} + end outstream.write_unsigned_varint(value); end @@ -14,8 +15,8 @@ function write(outstream, value) res = uint64(instream.read_unsigned_varint()); end - function c = getClass() - c = 'uint64'; + function c = get_class() + c = "uint64"; end end end diff --git a/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m b/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m index 8ee643db..28c873b2 100755 --- a/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m +++ b/tooling/internal/matlab/static_files/+binary/Uint8Serializer.m @@ -4,20 +4,22 @@ classdef Uint8Serializer < yardl.binary.TypeSerializer methods (Static) function write(outstream, value) - assert(value <= intmax("uint8")); - assert(value >= intmin("uint8")); - outstream.write_bytes(uint8(value)); + arguments + outstream (1,1) yardl.binary.CodedOutputStream + value (1,1) {mustBeInRange(value, 0, 255)} + end + outstream.write_byte(uint8(value)); end function res = read(instream) res = instream.read_byte(); end - function c = getClass() - c = 'uint8'; + function c = get_class() + c = "uint8"; end - function trivial = isTriviallySerializable() + function trivial = is_trivially_serializable() trivial = true; end end diff --git a/tooling/internal/matlab/static_files/+binary/UnionSerializer.m b/tooling/internal/matlab/static_files/+binary/UnionSerializer.m index 3deb9ed9..ba935c9b 100755 --- a/tooling/internal/matlab/static_files/+binary/UnionSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/UnionSerializer.m @@ -11,72 +11,70 @@ end methods + function self = UnionSerializer(union_class, case_serializers, case_factories) + self.classname_ = union_class; + self.case_serializers_ = case_serializers; + self.case_factories_ = case_factories; - function obj = UnionSerializer(union_class, case_serializers, case_factories) - obj.classname_ = union_class; - obj.case_serializers_ = case_serializers; - obj.case_factories_ = case_factories; - - if isa(case_serializers{1}, 'yardl.binary.NoneSerializer') - obj.offset_ = 1; + if isa(case_serializers{1}, "yardl.binary.NoneSerializer") + self.offset_ = 1; else - obj.offset_ = 0; + self.offset_ = 0; end end - function write(obj, outstream, value) - - if isa(value, 'yardl.Optional') - if ~isa(obj.case_serializers_{1}, 'yardl.binary.NoneSerializer') + function write(self, outstream, value) + if isa(value, "yardl.Optional") + if ~isa(self.case_serializers_{1}, "yardl.binary.NoneSerializer") throw(yardl.TypeError("Optional is not valid for this union type")) end if value.has_value() value = value.value; else - outstream.write_byte_no_check(0); + outstream.write_byte(uint8(0)); return; end end - if ~isa(value, obj.classname_) - throw(yardl.TypeError("Expected union value of type %s, got %s", obj.classname_, class(value))) + if ~isa(value, self.classname_) + throw(yardl.TypeError("Expected union value of type %s, got %s", self.classname_, class(value))) end - tag_index = uint8(value.index + obj.offset_); - outstream.write_byte_no_check(tag_index-1); + tag_index = uint8(value.index + self.offset_); + outstream.write_byte(tag_index-1); - serializer = obj.case_serializers_{tag_index}; + serializer = self.case_serializers_{tag_index}; serializer.write(outstream, value.value); end - function res = read(obj, instream) + function res = read(self, instream) case_index = instream.read_byte() + 1; - if case_index == 1 && obj.offset_ == 1 + if case_index == 1 && self.offset_ == 1 res = yardl.None; return end - serializer = obj.case_serializers_{case_index}; + serializer = self.case_serializers_{case_index}; value = serializer.read(instream); - factory = obj.case_factories_{case_index}; + factory = self.case_factories_{case_index}; res = factory(value); end - function c = getClass(obj) - if isa(obj.case_serializers_{1}, 'yardl.binary.NoneSerializer') - c = 'yardl.Optional'; + function c = get_class(self) + if isa(self.case_serializers_{1}, "yardl.binary.NoneSerializer") + c = "yardl.Optional"; else - c = obj.classname_; + c = self.classname_; end end end methods (Static) - function s = getShape() + function s = get_shape() s = 1; end end diff --git a/tooling/internal/matlab/static_files/+binary/VectorSerializer.m b/tooling/internal/matlab/static_files/+binary/VectorSerializer.m index 2631d815..04982eff 100644 --- a/tooling/internal/matlab/static_files/+binary/VectorSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/VectorSerializer.m @@ -1,88 +1,24 @@ % Copyright (c) Microsoft Corporation. % Licensed under the MIT License. -classdef VectorSerializer < yardl.binary.TypeSerializer - properties - item_serializer_; - end - - methods - function obj = VectorSerializer(item_serializer) - obj.item_serializer_ = item_serializer; - end +classdef VectorSerializer < yardl.binary.VectorSerializerBase - function write(obj, outstream, values) - if iscolumn(values) - values = transpose(values); - end - s = size(values); - count = s(end); + methods (Access=protected) + function handle_write_count_(~, outstream, count) outstream.write_unsigned_varint(count); - - if iscell(values) - % values is a cell array, so must be a vector of shape [1, COUNT] - assert(s(1) == 1); - for i = 1:count - obj.item_serializer_.write(obj, values{i}); - end - else - % values is an array, so must have shape [A, B, ..., COUNT] - if obj.item_serializer_.isTriviallySerializable() - obj.item_serializer_.writeTrivially(outstream, values); - return - end - - if ndims(values) > 2 - r = reshape(values, [], count); - for i = 1:count - val = reshape(r(:, i), s(1:end-1)); - obj.item_serializer_.write(outstream, val); - end - else - for i = 1:count - obj.item_serializer_.write(outstream, transpose(values(:, i))); - end - end - end end - function res = read(obj, instream) + function count = get_read_count_(~, instream) count = instream.read_unsigned_varint(); - if count == 0 - res = yardl.allocate(obj.getClass(), 0); - return; - end - - item_shape = obj.item_serializer_.getShape(); - if isempty(item_shape) - res = cell(1, count); - for i = 1:count - res{i} = obj.item_serializer_.read(instream); - end - return - end - - if obj.item_serializer_.isTriviallySerializable() - res = obj.item_serializer_.readTrivially(instream, [prod(item_shape), count]); - else - res = yardl.allocate(obj.getClass(), [prod(item_shape), count]); - for i = 1:count - item = obj.item_serializer_.read(instream); - res(:, i) = item(:); - end - end - - res = squeeze(reshape(res, [item_shape, count])); - if iscolumn(res) - res = transpose(res); - end end + end - function c = getClass(obj) - c = obj.item_serializer_.getClass; + methods + function self = VectorSerializer(item_serializer) + self@yardl.binary.VectorSerializerBase(item_serializer); end - function s = getShape(~) + function s = get_shape(~) s = []; end end diff --git a/tooling/internal/matlab/static_files/+binary/VectorSerializerBase.m b/tooling/internal/matlab/static_files/+binary/VectorSerializerBase.m new file mode 100644 index 00000000..dbe1694b --- /dev/null +++ b/tooling/internal/matlab/static_files/+binary/VectorSerializerBase.m @@ -0,0 +1,95 @@ +% Copyright (c) Microsoft Corporation. +% Licensed under the MIT License. + +classdef VectorSerializerBase < yardl.binary.TypeSerializer + properties + item_serializer_; + end + + methods (Abstract, Access=protected) + handle_write_count_(self, outstream, values) + get_read_count_(self, instream) + end + + methods (Access=protected) + function self = VectorSerializerBase(item_serializer) + self.item_serializer_ = item_serializer; + end + end + + methods + function write(self, outstream, values) + if iscolumn(values) + values = transpose(values); + end + s = size(values); + count = s(end); + + self.handle_write_count_(outstream, count); + + if iscell(values) + % values is a cell array, so must be a vector of shape [1, COUNT] + if ~isvector(s) + throw(yardl.ValueError("cell array must be a vector")); + end + for i = 1:count + self.item_serializer_.write(outstream, values{i}); + end + else + % values is an array, so must have shape [A, B, ..., COUNT] + if self.item_serializer_.is_trivially_serializable() + self.item_serializer_.write_trivially(outstream, values); + return + end + + if ndims(values) > 2 + r = reshape(values, [], count); + for i = 1:count + val = reshape(r(:, i), s(1:end-1)); + self.item_serializer_.write(outstream, val); + end + else + for i = 1:count + self.item_serializer_.write(outstream, transpose(values(:, i))); + end + end + end + end + + function res = read(self, instream) + count = self.get_read_count_(instream); + if count == 0 + res = yardl.allocate(self.get_class(), 0); + return; + end + + item_shape = self.item_serializer_.get_shape(); + if isempty(item_shape) + res = cell(1, count); + for i = 1:count + res{i} = self.item_serializer_.read(instream); + end + return + end + + if self.item_serializer_.is_trivially_serializable() + res = self.item_serializer_.read_trivially(instream, [prod(item_shape), count]); + else + res = yardl.allocate(self.get_class(), [prod(item_shape), count]); + for i = 1:count + item = self.item_serializer_.read(instream); + res(:, i) = item(:); + end + end + + res = squeeze(reshape(res, [item_shape, count])); + if iscolumn(res) + res = transpose(res); + end + end + + function c = get_class(self) + c = self.item_serializer_.get_class(); + end + end +end diff --git a/tooling/internal/matlab/static_files/Date.m b/tooling/internal/matlab/static_files/Date.m index 6ef0cf9f..fdf30c6a 100644 --- a/tooling/internal/matlab/static_files/Date.m +++ b/tooling/internal/matlab/static_files/Date.m @@ -8,33 +8,33 @@ end methods - function obj = Date(days_since_epoch) + function self = Date(days_since_epoch) if nargin > 0 - obj.days_since_epoch_ = days_since_epoch; + self.days_since_epoch_ = days_since_epoch; else - obj.days_since_epoch_ = 0; + self.days_since_epoch_ = 0; end end - function value = value(obj) - value = obj.days_since_epoch_; + function value = value(self) + value = self.days_since_epoch_; end - function dt = to_datetime(obj) - dt = datetime(0, 'ConvertFrom', 'epochtime') + days(obj.days_since_epoch_); + function dt = to_datetime(self) + dt = datetime(0, 'ConvertFrom', 'epochtime') + days(self.days_since_epoch_); end - function eq = eq(obj, other) + function eq = eq(self, other) if isa(other, 'datetime') other = yardl.Date.from_datetime(other); end eq = isa(other, 'yardl.Date') && ... - all([obj.value] == [other.value]); + all([self.value] == [other.value]); end - function ne = new(obj, other) - ne = ~obj.eq(other); + function ne = new(self, other) + ne = ~self.eq(other); end end diff --git a/tooling/internal/matlab/static_files/DateTime.m b/tooling/internal/matlab/static_files/DateTime.m index 6098c193..4a9c2346 100644 --- a/tooling/internal/matlab/static_files/DateTime.m +++ b/tooling/internal/matlab/static_files/DateTime.m @@ -9,33 +9,33 @@ end methods - function obj = DateTime(nanoseconds_since_epoch) + function self = DateTime(nanoseconds_since_epoch) if nargin > 0 - obj.nanoseconds_since_epoch_ = nanoseconds_since_epoch; + self.nanoseconds_since_epoch_ = nanoseconds_since_epoch; else - obj.nanoseconds_since_epoch_ = 0; + self.nanoseconds_since_epoch_ = 0; end end - function value = value(obj) - value = obj.nanoseconds_since_epoch_; + function value = value(self) + value = self.nanoseconds_since_epoch_; end - function dt = to_datetime(obj) - dt = datetime(obj.nanoseconds_since_epoch_, 'ConvertFrom', 'epochtime', 'TicksPerSecond', 1e9); + function dt = to_datetime(self) + dt = datetime(self.nanoseconds_since_epoch_, 'ConvertFrom', 'epochtime', 'TicksPerSecond', 1e9); end - function eq = eq(obj, other) + function eq = eq(self, other) if isa(other, 'datetime') other = yardl.DateTime.from_datetime(other); end eq = isa(other, 'yardl.DateTime') && ... - all([obj.value] == [other.value]); + all([self.value] == [other.value]); end - function ne = new(obj, other) - ne = ~obj.eq(other); + function ne = new(self, other) + ne = ~self.eq(other); end end @@ -55,6 +55,10 @@ dt = yardl.DateTime(seconds_since_epoch * 1e9 + nanosecond); end + function dt = now(~) + dt = yardl.DateTime.from_datetime(datetime('now')); + end + function z = zeros(varargin) elem = yardl.DateTime(0); if nargin == 0 diff --git a/tooling/internal/matlab/static_files/KeyError.m b/tooling/internal/matlab/static_files/KeyError.m deleted file mode 100644 index 0e6dfb45..00000000 --- a/tooling/internal/matlab/static_files/KeyError.m +++ /dev/null @@ -1,6 +0,0 @@ -% Copyright (c) Microsoft Corporation. -% Licensed under the MIT License. - -function err = KeyError(varargin) - err = yardl.Exception("yardl:KeyError", varargin{:}); -end diff --git a/tooling/internal/matlab/static_files/Optional.m b/tooling/internal/matlab/static_files/Optional.m index bd21058c..fa0ec206 100644 --- a/tooling/internal/matlab/static_files/Optional.m +++ b/tooling/internal/matlab/static_files/Optional.m @@ -8,21 +8,21 @@ end methods - function obj = Optional(varargin) + function self = Optional(varargin) if nargin > 0 - obj.value = varargin{1}; - obj.has_value = true; + self.value = varargin{1}; + self.has_value = true; else - obj.value = NaN; - obj.has_value = false; + self.value = NaN; + self.has_value = false; end end - function v = get.value(obj) - if ~obj.has_value + function v = get.value(self) + if ~self.has_value throw(yardl.ValueError("Optional type does not have a value")); end - v = obj.value; + v = self.value; end function eq = eq(a, b) diff --git a/tooling/internal/matlab/static_files/Time.m b/tooling/internal/matlab/static_files/Time.m index 37586d07..eedcce66 100644 --- a/tooling/internal/matlab/static_files/Time.m +++ b/tooling/internal/matlab/static_files/Time.m @@ -10,36 +10,36 @@ end methods - function obj = Time(nanoseconds_since_midnight) + function self = Time(nanoseconds_since_midnight) if nargin > 0 if nanoseconds_since_midnight < 0 || nanoseconds_since_midnight >= 24*60*60*1e9 throw(yardl.ValuError("Time must be between 00:00:00 and 23:59:59.999999999")); end - obj.nanoseconds_since_midnight_ = nanoseconds_since_midnight; + self.nanoseconds_since_midnight_ = nanoseconds_since_midnight; else - obj.nanoseconds_since_midnight_ = 0; + self.nanoseconds_since_midnight_ = 0; end end - function value = value(obj) - value = obj.nanoseconds_since_midnight_; + function value = value(self) + value = self.nanoseconds_since_midnight_; end - function dt = to_datetime(obj) - dt = datetime(obj.nanoseconds_since_midnight_, 'ConvertFrom', 'epochtime', 'Epoch', datetime('today'), 'TicksPerSecond', 1e9); + function dt = to_datetime(self) + dt = datetime(self.nanoseconds_since_midnight_, 'ConvertFrom', 'epochtime', 'Epoch', datetime('today'), 'TicksPerSecond', 1e9); end - function eq = eq(obj, other) + function eq = eq(self, other) if isa(other, 'datetime') other = yardl.Time.from_datetime(other); end eq = isa(other, 'yardl.Time') && ... - all([obj.value] == [other.value]); + all([self.value] == [other.value]); end - function ne = new(obj, other) - ne = ~obj.eq(other); + function ne = new(self, other) + ne = ~self.eq(other); end end diff --git a/tooling/internal/matlab/static_files/Union.m b/tooling/internal/matlab/static_files/Union.m index 9bc89ae4..fa802add 100644 --- a/tooling/internal/matlab/static_files/Union.m +++ b/tooling/internal/matlab/static_files/Union.m @@ -8,17 +8,17 @@ end methods - function obj = Union(index, value) - obj.index_ = index; - obj.value_ = value; + function self = Union(index, value) + self.index_ = index; + self.value_ = value; end - function i = index(obj) - i = obj.index_; + function i = index(self) + i = self.index_; end - function v = value(obj) - v = obj.value_; + function v = value(self) + v = self.value_; end end end diff --git a/tooling/internal/matlab/types/types.go b/tooling/internal/matlab/types/types.go index c2cc6488..eb8d11e4 100644 --- a/tooling/internal/matlab/types/types.go +++ b/tooling/internal/matlab/types/types.go @@ -105,6 +105,19 @@ func writeUnionClass(w *formatting.IndentedWriter, className string, generalized w.WriteStringln("methods") common.WriteBlockBody(w, func() { + index := 1 + for _, tc := range generalizedType.Cases { + if tc.Type == nil { + continue + } + fmt.Fprintf(w, "function res = is%s(self)\n", formatting.ToPascalCase(tc.Tag)) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "res = self.index == %d;\n", index) + }) + index += 1 + w.WriteStringln("") + } + w.WriteStringln("function eq = eq(self, other)") common.WriteBlockBody(w, func() { fmt.Fprintf(w, "eq = isa(other, '%s') && other.index == self.index && other.value == self.value;\n", qualifiedClassName) @@ -141,7 +154,10 @@ func writeNamedType(fw *common.MatlabFileWriter, td *dsl.NamedType) error { common.WriteBlockBody(w, func() { common.WriteComment(w, td.Comment) if !dsl.TypeContainsGenericTypeParameter(innerType) { - fmt.Fprintf(w, "assert(isa(value, '%s'));\n", common.TypeSyntax(innerType, td.Namespace)) + w.WriteStringln("arguments") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "value %s\n", common.TypeSyntax(innerType, td.Namespace)) + }) } fmt.Fprintf(w, "o = %s(value);\n", common.TypeSyntax(td.Type, td.Namespace)) }) @@ -155,7 +171,10 @@ func writeNamedType(fw *common.MatlabFileWriter, td *dsl.NamedType) error { common.WriteBlockBody(w, func() { common.WriteComment(w, td.Comment) if !dsl.TypeContainsGenericTypeParameter(scalar) { - fmt.Fprintf(w, "assert(isa(array, '%s'));\n", common.TypeSyntax(scalar, td.Namespace)) + w.WriteStringln("arguments") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "array %s\n", common.TypeSyntax(scalar, td.Namespace)) + }) } w.WriteStringln("a = array;") }) @@ -233,17 +252,17 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. common.WriteBlockBody(w, func() { // Record Constructor - fmt.Fprintf(w, "function obj = %s(%s)\n", recordName, strings.Join(fieldNames, ", ")) + fmt.Fprintf(w, "function self = %s(%s)\n", recordName, strings.Join(fieldNames, ", ")) common.WriteBlockBody(w, func() { if requireConstructorArgs { for _, field := range rec.Fields { - fmt.Fprintf(w, "obj.%s = %s;\n", common.FieldIdentifierName(field.Name), common.FieldIdentifierName(field.Name)) + fmt.Fprintf(w, "self.%s = %s;\n", common.FieldIdentifierName(field.Name), common.FieldIdentifierName(field.Name)) } } else { w.WriteStringln("if nargin > 0") w.Indented(func() { for _, field := range rec.Fields { - fmt.Fprintf(w, "obj.%s = %s;\n", common.FieldIdentifierName(field.Name), common.FieldIdentifierName(field.Name)) + fmt.Fprintf(w, "self.%s = %s;\n", common.FieldIdentifierName(field.Name), common.FieldIdentifierName(field.Name)) } }) w.WriteStringln("else") @@ -255,7 +274,7 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. case defaultValueKindNone: w.WriteStringln(fieldName) case defaultValueKindImmutable, defaultValueKindMutable: - fmt.Fprintf(w, "obj.%s = %s;\n", fieldName, defaultExpression) + fmt.Fprintf(w, "self.%s = %s;\n", fieldName, defaultExpression) } } }) @@ -279,7 +298,7 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. } // eq method - w.WriteStringln("function res = eq(obj, other)") + w.WriteStringln("function res = eq(self, other)") common.WriteBlockBody(w, func() { w.WriteStringln("res = ...") w.Indented(func() { @@ -287,7 +306,7 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. for _, field := range rec.Fields { w.WriteStringln(" && ...") fieldIdentifier := common.FieldIdentifierName(field.Name) - w.WriteString(typeEqualityExpression(field.Type, "obj."+fieldIdentifier, "other."+fieldIdentifier)) + w.WriteString(typeEqualityExpression(field.Type, "self."+fieldIdentifier, "other."+fieldIdentifier)) } w.WriteStringln(";") }) @@ -295,9 +314,9 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. w.WriteStringln("") // neq method - w.WriteStringln("function res = ne(obj, other)") + w.WriteStringln("function res = ne(self, other)") common.WriteBlockBody(w, func() { - w.WriteStringln("res = ~obj.eq(other);") + w.WriteStringln("res = ~self.eq(other);") }) }) w.WriteStringln("") @@ -408,7 +427,7 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E } w.WriteStringln("") common.WriteBlockBody(w, func() { - w.WriteStringln(`throw(yardl.KeyError("Unknown dimension name: '%s'", dim_name));`) + w.WriteStringln(`throw(yardl.ValueError("Unknown dimension name: '%s'", dim_name));`) }) w.WriteStringln("") }) diff --git a/tooling/internal/python/static_files/_binary.py b/tooling/internal/python/static_files/_binary.py index 7d67d4d0..ad67ca34 100644 --- a/tooling/internal/python/static_files/_binary.py +++ b/tooling/internal/python/static_files/_binary.py @@ -77,7 +77,7 @@ def __init__( ) -> None: self._stream = CodedInputStream(stream) magic_bytes = self._stream.read_view(len(MAGIC_BYTES)) - if magic_bytes != MAGIC_BYTES: # pyright: ignore [reportUnnecessaryComparison] + if magic_bytes != MAGIC_BYTES: # pyright: ignore [reportUnnecessaryComparison] raise RuntimeError("Invalid magic bytes") version = read_fixed_int32(self._stream) @@ -408,7 +408,7 @@ def write(self, stream: CodedOutputStream, value: Int16) -> None: f"Value {value} is outside the range of a signed 16-bit integer" ) elif not isinstance(value, cast(type, np.int16)): - raise ValueError(f"Value in not an signed 16-bit integer: {value}") + raise ValueError(f"Value is not an signed 16-bit integer: {value}") stream.write_signed_varint(value) @@ -436,7 +436,7 @@ def write(self, stream: CodedOutputStream, value: UInt16) -> None: f"Value {value} is outside the range of an unsigned 16-bit integer" ) elif not isinstance(value, cast(type, np.uint16)): - raise ValueError(f"Value in not an unsigned 16-bit integer: {value}") + raise ValueError(f"Value is not an unsigned 16-bit integer: {value}") stream.write_unsigned_varint(value) @@ -464,7 +464,7 @@ def write(self, stream: CodedOutputStream, value: Int32) -> None: f"Value {value} is outside the range of a signed 32-bit integer" ) elif not isinstance(value, cast(type, np.int32)): - raise ValueError(f"Value in not a signed 32-bit integer: {value}") + raise ValueError(f"Value is not a signed 32-bit integer: {value}") stream.write_signed_varint(value) @@ -492,7 +492,7 @@ def write(self, stream: CodedOutputStream, value: UInt32) -> None: f"Value {value} is outside the range of an unsigned 32-bit integer" ) elif not isinstance(value, cast(type, np.uint32)): - raise ValueError(f"Value in not an unsigned 32-bit integer: {value}") + raise ValueError(f"Value is not an unsigned 32-bit integer: {value}") stream.write_unsigned_varint(value) @@ -520,7 +520,7 @@ def write(self, stream: CodedOutputStream, value: Int64) -> None: f"Value {value} is outside the range of a signed 64-bit integer" ) elif not isinstance(value, cast(type, np.int64)): - raise ValueError(f"Value in not a signed 64-bit integer: {value}") + raise ValueError(f"Value is not a signed 64-bit integer: {value}") stream.write_signed_varint(value) @@ -548,7 +548,7 @@ def write(self, stream: CodedOutputStream, value: UInt64) -> None: f"Value {value} is outside the range of an unsigned 64-bit integer" ) elif not isinstance(value, cast(type, np.uint64)): - raise ValueError(f"Value in not an unsigned 64-bit integer: {value}") + raise ValueError(f"Value is not an unsigned 64-bit integer: {value}") stream.write_unsigned_varint(value) @@ -576,7 +576,7 @@ def write(self, stream: CodedOutputStream, value: Size) -> None: f"Value {value} is outside the range of an unsigned 64-bit integer" ) elif not isinstance(value, cast(type, np.uint64)): - raise ValueError(f"Value in not an unsigned 64-bit integer: {value}") + raise ValueError(f"Value is not an unsigned 64-bit integer: {value}") stream.write_unsigned_varint(value) From c753e00af337a226af9b942c7b75e7f315680f77 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Mon, 15 Apr 2024 16:26:51 +0000 Subject: [PATCH 19/32] Fix minor Matlab documentation issues --- docs/matlab/language.md | 43 +++++++++++++------ docs/matlab/quickstart.md | 27 ------------ .../+basic_types/GenericNullableUnion2.m | 2 +- .../GenericRecordWithComputedFields.m | 6 +-- matlab/generated/+basic_types/GenericUnion2.m | 2 +- matlab/generated/+basic_types/Int32OrString.m | 2 +- .../generated/+basic_types/RecordWithUnions.m | 2 +- matlab/generated/+basic_types/T0OrT1.m | 2 +- .../generated/+basic_types/TimeOrDatetime.m | 2 +- .../+test_model/AcquisitionOrImage.m | 2 +- .../+test_model/AliasedIntOrSimpleRecord.m | 2 +- .../+test_model/AliasedMultiGenericOptional.m | 2 +- .../AliasedNullableIntSimpleRecord.m | 2 +- matlab/generated/+test_model/ArrayOrScalar.m | 2 +- matlab/generated/+test_model/GenericRecord.m | 2 +- matlab/generated/+test_model/GenericUnion3.m | 2 +- .../+test_model/GenericUnion3Alternate.m | 2 +- .../GenericUnionWithRepeatedTypeParameters.m | 2 +- .../+test_model/ImageFloatOrImageDouble.m | 2 +- matlab/generated/+test_model/Int32OrFloat32.m | 2 +- .../+test_model/Int32OrRecordWithVlens.m | 2 +- .../+test_model/Int32OrSimpleRecord.m | 2 +- .../IntOrGenericRecordWithComputedFields.m | 2 +- matlab/generated/+test_model/MapOrScalar.m | 2 +- .../RecordContainingGenericRecords.m | 2 +- .../RecordContainingNestedGenericRecords.m | 2 +- .../+test_model/RecordNotUsedInProtocol.m | 2 +- .../+test_model/RecordWithAliasedGenerics.m | 2 +- .../RecordWithAliasedOptionalGenericField.m | 2 +- ...cordWithAliasedOptionalGenericUnionField.m | 2 +- .../generated/+test_model/RecordWithArrays.m | 2 +- .../RecordWithArraysSimpleSyntax.m | 2 +- .../+test_model/RecordWithComputedFields.m | 20 ++++----- .../+test_model/RecordWithDynamicNDArrays.m | 2 +- .../generated/+test_model/RecordWithEnums.m | 2 +- .../+test_model/RecordWithFixedArrays.m | 2 +- .../+test_model/RecordWithFixedCollections.m | 2 +- .../+test_model/RecordWithFixedVectors.m | 2 +- .../+test_model/RecordWithGenericArrays.m | 2 +- .../RecordWithGenericFixedVectors.m | 2 +- .../+test_model/RecordWithGenericMaps.m | 2 +- .../RecordWithGenericVectorOfRecords.m | 2 +- .../+test_model/RecordWithGenericVectors.m | 2 +- .../+test_model/RecordWithKeywordFields.m | 2 +- .../+test_model/RecordWithNDArrays.m | 2 +- .../RecordWithNDArraysSingleDimension.m | 2 +- .../+test_model/RecordWithNamedFixedArrays.m | 2 +- .../+test_model/RecordWithOptionalFields.m | 2 +- .../RecordWithOptionalGenericField.m | 2 +- .../RecordWithOptionalGenericUnionField.m | 2 +- .../+test_model/RecordWithOptionalVector.m | 2 +- .../+test_model/RecordWithPrimitiveAliases.m | 2 +- .../+test_model/RecordWithPrimitives.m | 2 +- .../generated/+test_model/RecordWithStrings.m | 2 +- .../RecordWithUnionsOfContainers.m | 2 +- .../+test_model/RecordWithVectorOfTimes.m | 2 +- .../generated/+test_model/RecordWithVectors.m | 2 +- .../+test_model/RecordWithVlenCollections.m | 2 +- .../generated/+test_model/RecordWithVlens.m | 2 +- .../generated/+test_model/SimpleAcquisition.m | 2 +- .../+test_model/SimpleEncodingCounters.m | 2 +- matlab/generated/+test_model/SimpleRecord.m | 2 +- .../+test_model/SmallBenchmarkRecord.m | 2 +- matlab/generated/+test_model/StringOrInt32.m | 2 +- .../generated/+test_model/TupleWithRecords.m | 2 +- matlab/generated/+test_model/UOrV.m | 2 +- matlab/generated/+test_model/VectorOrScalar.m | 2 +- matlab/generated/+tuples/Tuple.m | 2 +- tooling/internal/matlab/types/types.go | 17 +++----- 69 files changed, 115 insertions(+), 126 deletions(-) diff --git a/docs/matlab/language.md b/docs/matlab/language.md index 3adc466a..90183028 100644 --- a/docs/matlab/language.md +++ b/docs/matlab/language.md @@ -166,7 +166,8 @@ Yardl has the following primitive types: `yardl.Date`, `yardl.Time`, and `yardl.DateTime` are custom classes because Yardl uses nanosecond precision and Matlab's `datetime` has only microsecond precision. -Each of them can be easily converted to a Matlab `datetime` by calling its static `to_datetime()` method. +Each of them can be easily converted to/from a Matlab `datetime` by calling +the corresponding `to_datetime()` or `from_datetime()` method. ## Optional Types @@ -370,9 +371,9 @@ Example usage: ```matlab permissions = bitor(sandbox.Permissions.READ, sandbox.Permissions.EXECUTE); -# ... +% ... if bitand(sandbox.Permissions.READ, permissions) - # ... + % ... end ``` @@ -524,10 +525,13 @@ dimensions: `int[()]`. In Matlab, arrays are always created with dimensions reversed with respect to the model definition. This means that an array defined as `Image: double[x, y, z]` has the shape `[z, y, x]` in Matlab. -This convention maintains consistency across yardl with respect to indexing -multi-dimensional arrays, and provides the best serialization performance, since -Yardl currently supports only C-order when serializing multi-dimensional arrays. -Matlab, however, uses Fortran-order to store and serialize multi-dimensional arrays. +Yardl currently supports serializing multi-dimensional arrays only in +C-continguous order, where the last dimension increases most rapidly. +Matlab, however, uses Fortran-order to store and serialize multi-dimensional +arrays, where the first dimension increases most rapidly. + +By reversing Matlab array dimensions, yardl maintains consistency with Matlab's +support for multi-dimensional array indexing, and provides optimal serialization performance. As a side effect, if you define a *matrix* in yardl as `matrix: double[row, col]`, you will need to transpose the array in Matlab. @@ -549,7 +553,6 @@ ans = 4 2 ->> r.close(); ``` To create an array with more than two dimensions, use Matlab pages: @@ -654,12 +657,28 @@ Computed fields become parameterless methods on the generated Python class. Here is an example of invoking the field from the preceding Yardl definition: ```matlab ->>> rec = sandbox.MyRec(sandbox.Int32OrNamedArray.Int32(4)); ->>> rec.my_union_size() +>> rec = sandbox.MyRec(sandbox.Int32OrNamedArray.Int32(4)); +>> rec.my_union_size() + +ans = + + 1 + +>> arr = sandbox.NamedArray(int32(ones(7))); +>> rec = sandbox.MyRec(sandbox.Int32OrNamedArray.NamedArray(arr)); +>> rec.my_union_size() + +ans = + + 49 + +>> rec = sandbox.MyRec(yardl.None); +>> rec.my_union_size() + +ans = - ans = + 0 - 1 ``` ## Generics diff --git a/docs/matlab/quickstart.md b/docs/matlab/quickstart.md index b01d4db9..0ea35fc2 100644 --- a/docs/matlab/quickstart.md +++ b/docs/matlab/quickstart.md @@ -176,30 +176,3 @@ hexdump -C playground.bin Note that the binary file contains a JSON representation of the protocol's schema. This allows code that was not previously aware of this protocol to deserialize the contents. - - diff --git a/matlab/generated/+basic_types/GenericNullableUnion2.m b/matlab/generated/+basic_types/GenericNullableUnion2.m index a89ab11c..1f2ff2ee 100644 --- a/matlab/generated/+basic_types/GenericNullableUnion2.m +++ b/matlab/generated/+basic_types/GenericNullableUnion2.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'basic_types.GenericNullableUnion2') && other.index == self.index && other.value == self.value; + eq = isa(other, "basic_types.GenericNullableUnion2") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+basic_types/GenericRecordWithComputedFields.m b/matlab/generated/+basic_types/GenericRecordWithComputedFields.m index bd7af45b..c5bc5f2e 100644 --- a/matlab/generated/+basic_types/GenericRecordWithComputedFields.m +++ b/matlab/generated/+basic_types/GenericRecordWithComputedFields.m @@ -12,11 +12,11 @@ function res = type_index(self) var1 = self.f1; - if var1.index == 1 + if isa(var1, "basic_types.T0OrT1") && var1.index == 1 res = 0; return end - if var1.index == 2 + if isa(var1, "basic_types.T0OrT1") && var1.index == 2 res = 1; return end @@ -26,7 +26,7 @@ function res = eq(self, other) res = ... - isa(other, 'basic_types.GenericRecordWithComputedFields') && ... + isa(other, "basic_types.GenericRecordWithComputedFields") && ... isequal(self.f1, other.f1); end diff --git a/matlab/generated/+basic_types/GenericUnion2.m b/matlab/generated/+basic_types/GenericUnion2.m index 9261589c..784a55a5 100644 --- a/matlab/generated/+basic_types/GenericUnion2.m +++ b/matlab/generated/+basic_types/GenericUnion2.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'basic_types.GenericUnion2') && other.index == self.index && other.value == self.value; + eq = isa(other, "basic_types.GenericUnion2") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+basic_types/Int32OrString.m b/matlab/generated/+basic_types/Int32OrString.m index 819da9e5..f61f00e0 100644 --- a/matlab/generated/+basic_types/Int32OrString.m +++ b/matlab/generated/+basic_types/Int32OrString.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'basic_types.Int32OrString') && other.index == self.index && other.value == self.value; + eq = isa(other, "basic_types.Int32OrString") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+basic_types/RecordWithUnions.m b/matlab/generated/+basic_types/RecordWithUnions.m index 10b4d81b..0b3510d7 100644 --- a/matlab/generated/+basic_types/RecordWithUnions.m +++ b/matlab/generated/+basic_types/RecordWithUnions.m @@ -22,7 +22,7 @@ function res = eq(self, other) res = ... - isa(other, 'basic_types.RecordWithUnions') && ... + isa(other, "basic_types.RecordWithUnions") && ... all([self.null_or_int_or_string] == [other.null_or_int_or_string]) && ... all([self.date_or_datetime] == [other.date_or_datetime]) && ... all([self.null_or_fruits_or_days_of_week] == [other.null_or_fruits_or_days_of_week]); diff --git a/matlab/generated/+basic_types/T0OrT1.m b/matlab/generated/+basic_types/T0OrT1.m index 3115edea..d7f998ab 100644 --- a/matlab/generated/+basic_types/T0OrT1.m +++ b/matlab/generated/+basic_types/T0OrT1.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'basic_types.T0OrT1') && other.index == self.index && other.value == self.value; + eq = isa(other, "basic_types.T0OrT1") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+basic_types/TimeOrDatetime.m b/matlab/generated/+basic_types/TimeOrDatetime.m index c1951beb..67f45ab2 100644 --- a/matlab/generated/+basic_types/TimeOrDatetime.m +++ b/matlab/generated/+basic_types/TimeOrDatetime.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'basic_types.TimeOrDatetime') && other.index == self.index && other.value == self.value; + eq = isa(other, "basic_types.TimeOrDatetime") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/AcquisitionOrImage.m b/matlab/generated/+test_model/AcquisitionOrImage.m index 9a464604..b50c81fc 100644 --- a/matlab/generated/+test_model/AcquisitionOrImage.m +++ b/matlab/generated/+test_model/AcquisitionOrImage.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.AcquisitionOrImage') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.AcquisitionOrImage") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m b/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m index edd8bc17..aef0b3ff 100644 --- a/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m +++ b/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.AliasedIntOrSimpleRecord') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.AliasedIntOrSimpleRecord") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/AliasedMultiGenericOptional.m b/matlab/generated/+test_model/AliasedMultiGenericOptional.m index ca211257..3def7bd0 100644 --- a/matlab/generated/+test_model/AliasedMultiGenericOptional.m +++ b/matlab/generated/+test_model/AliasedMultiGenericOptional.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.AliasedMultiGenericOptional') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.AliasedMultiGenericOptional") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m b/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m index 22f3420a..103e5c36 100644 --- a/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m +++ b/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.AliasedNullableIntSimpleRecord') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.AliasedNullableIntSimpleRecord") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/ArrayOrScalar.m b/matlab/generated/+test_model/ArrayOrScalar.m index c8587b7c..b67a4457 100644 --- a/matlab/generated/+test_model/ArrayOrScalar.m +++ b/matlab/generated/+test_model/ArrayOrScalar.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.ArrayOrScalar') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.ArrayOrScalar") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/GenericRecord.m b/matlab/generated/+test_model/GenericRecord.m index c23e56f5..412e084d 100644 --- a/matlab/generated/+test_model/GenericRecord.m +++ b/matlab/generated/+test_model/GenericRecord.m @@ -18,7 +18,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.GenericRecord') && ... + isa(other, "test_model.GenericRecord") && ... isequal(self.scalar_1, other.scalar_1) && ... isequal(self.scalar_2, other.scalar_2) && ... isequal(self.vector_1, other.vector_1) && ... diff --git a/matlab/generated/+test_model/GenericUnion3.m b/matlab/generated/+test_model/GenericUnion3.m index f82bbeb4..8c1490c5 100644 --- a/matlab/generated/+test_model/GenericUnion3.m +++ b/matlab/generated/+test_model/GenericUnion3.m @@ -42,7 +42,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.GenericUnion3') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.GenericUnion3") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/GenericUnion3Alternate.m b/matlab/generated/+test_model/GenericUnion3Alternate.m index 6ab24e60..bf444e97 100644 --- a/matlab/generated/+test_model/GenericUnion3Alternate.m +++ b/matlab/generated/+test_model/GenericUnion3Alternate.m @@ -42,7 +42,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.GenericUnion3Alternate') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.GenericUnion3Alternate") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m b/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m index f26fa7a5..acc5200e 100644 --- a/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m +++ b/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m @@ -42,7 +42,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.GenericUnionWithRepeatedTypeParameters') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.GenericUnionWithRepeatedTypeParameters") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/ImageFloatOrImageDouble.m b/matlab/generated/+test_model/ImageFloatOrImageDouble.m index 4276ef37..1d2c5543 100644 --- a/matlab/generated/+test_model/ImageFloatOrImageDouble.m +++ b/matlab/generated/+test_model/ImageFloatOrImageDouble.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.ImageFloatOrImageDouble') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.ImageFloatOrImageDouble") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/Int32OrFloat32.m b/matlab/generated/+test_model/Int32OrFloat32.m index 6f5edf3e..8044a248 100644 --- a/matlab/generated/+test_model/Int32OrFloat32.m +++ b/matlab/generated/+test_model/Int32OrFloat32.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.Int32OrFloat32') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.Int32OrFloat32") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/Int32OrRecordWithVlens.m b/matlab/generated/+test_model/Int32OrRecordWithVlens.m index 79ce155f..90c0f9e3 100644 --- a/matlab/generated/+test_model/Int32OrRecordWithVlens.m +++ b/matlab/generated/+test_model/Int32OrRecordWithVlens.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.Int32OrRecordWithVlens') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.Int32OrRecordWithVlens") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/Int32OrSimpleRecord.m b/matlab/generated/+test_model/Int32OrSimpleRecord.m index 0533ad08..08527043 100644 --- a/matlab/generated/+test_model/Int32OrSimpleRecord.m +++ b/matlab/generated/+test_model/Int32OrSimpleRecord.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.Int32OrSimpleRecord') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.Int32OrSimpleRecord") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m b/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m index 55bdeccc..9cd41947 100644 --- a/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m +++ b/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.IntOrGenericRecordWithComputedFields') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.IntOrGenericRecordWithComputedFields") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/MapOrScalar.m b/matlab/generated/+test_model/MapOrScalar.m index 4d129afa..fff69de4 100644 --- a/matlab/generated/+test_model/MapOrScalar.m +++ b/matlab/generated/+test_model/MapOrScalar.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.MapOrScalar') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.MapOrScalar") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/RecordContainingGenericRecords.m b/matlab/generated/+test_model/RecordContainingGenericRecords.m index 15dc2531..07f3eb3a 100644 --- a/matlab/generated/+test_model/RecordContainingGenericRecords.m +++ b/matlab/generated/+test_model/RecordContainingGenericRecords.m @@ -30,7 +30,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordContainingGenericRecords') && ... + isa(other, "test_model.RecordContainingGenericRecords") && ... isequal(self.g1, other.g1) && ... isequal(self.g1a, other.g1a) && ... isequal(self.g2, other.g2) && ... diff --git a/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m b/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m index 200f79bf..fa56c634 100644 --- a/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m +++ b/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m @@ -28,7 +28,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordContainingNestedGenericRecords') && ... + isa(other, "test_model.RecordContainingNestedGenericRecords") && ... all([self.f1] == [other.f1]) && ... isequal(self.f1a, other.f1a) && ... all([self.f2] == [other.f2]) && ... diff --git a/matlab/generated/+test_model/RecordNotUsedInProtocol.m b/matlab/generated/+test_model/RecordNotUsedInProtocol.m index b49dbc75..c5ecfe52 100644 --- a/matlab/generated/+test_model/RecordNotUsedInProtocol.m +++ b/matlab/generated/+test_model/RecordNotUsedInProtocol.m @@ -19,7 +19,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordNotUsedInProtocol') && ... + isa(other, "test_model.RecordNotUsedInProtocol") && ... all([self.u1] == [other.u1]) && ... all([self.u2] == [other.u2]); end diff --git a/matlab/generated/+test_model/RecordWithAliasedGenerics.m b/matlab/generated/+test_model/RecordWithAliasedGenerics.m index 4736bee9..c612c232 100644 --- a/matlab/generated/+test_model/RecordWithAliasedGenerics.m +++ b/matlab/generated/+test_model/RecordWithAliasedGenerics.m @@ -19,7 +19,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithAliasedGenerics') && ... + isa(other, "test_model.RecordWithAliasedGenerics") && ... isequal(self.my_strings, other.my_strings) && ... isequal(self.aliased_strings, other.aliased_strings); end diff --git a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m index 52bf3bf4..2c698a36 100644 --- a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m +++ b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m @@ -16,7 +16,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithAliasedOptionalGenericField') && ... + isa(other, "test_model.RecordWithAliasedOptionalGenericField") && ... isequal(self.v, other.v); end diff --git a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m index cf980ec2..2890b48b 100644 --- a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m +++ b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m @@ -16,7 +16,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithAliasedOptionalGenericUnionField') && ... + isa(other, "test_model.RecordWithAliasedOptionalGenericUnionField") && ... isequal(self.v, other.v); end diff --git a/matlab/generated/+test_model/RecordWithArrays.m b/matlab/generated/+test_model/RecordWithArrays.m index b878a086..eb28a8f4 100644 --- a/matlab/generated/+test_model/RecordWithArrays.m +++ b/matlab/generated/+test_model/RecordWithArrays.m @@ -40,7 +40,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithArrays') && ... + isa(other, "test_model.RecordWithArrays") && ... isequal(self.default_array, other.default_array) && ... isequal(self.default_array_with_empty_dimension, other.default_array_with_empty_dimension) && ... isequal(self.rank_1_array, other.rank_1_array) && ... diff --git a/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m b/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m index a85b2cb6..f25fd99d 100644 --- a/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m +++ b/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m @@ -40,7 +40,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithArraysSimpleSyntax') && ... + isa(other, "test_model.RecordWithArraysSimpleSyntax") && ... isequal(self.default_array, other.default_array) && ... isequal(self.default_array_with_empty_dimension, other.default_array_with_empty_dimension) && ... isequal(self.rank_1_array, other.rank_1_array) && ... diff --git a/matlab/generated/+test_model/RecordWithComputedFields.m b/matlab/generated/+test_model/RecordWithComputedFields.m index 5fac958b..15037ad5 100644 --- a/matlab/generated/+test_model/RecordWithComputedFields.m +++ b/matlab/generated/+test_model/RecordWithComputedFields.m @@ -369,12 +369,12 @@ function res = int_float_union_as_float(self) var1 = self.int_float_union; - if var1.index == 1 + if isa(var1, "test_model.Int32OrFloat32") && var1.index == 1 i_foo = var1.value; res = single(i_foo); return end - if var1.index == 2 + if isa(var1, "test_model.Int32OrFloat32") && var1.index == 2 f = var1.value; res = f; return @@ -388,7 +388,7 @@ res = "null"; return end - if var1.index == 1 + if isa(var1, "test_model.Int32OrFloat32") && var1.index == 1 res = "int"; return end @@ -398,18 +398,18 @@ function res = nested_switch(self) var1 = self.union_with_nested_generic_union; - if var1.index == 1 + if isa(var1, "test_model.IntOrGenericRecordWithComputedFields") && var1.index == 1 res = -1; return end - if var1.index == 2 + if isa(var1, "test_model.IntOrGenericRecordWithComputedFields") && var1.index == 2 rec = var1.value; var2 = rec.f1; - if var2.index == 2 + if isa(var2, "basic_types.T0OrT1") && var2.index == 2 res = int32(20); return end - if var2.index == 1 + if isa(var2, "basic_types.T0OrT1") && var2.index == 1 res = int32(10); return end @@ -420,11 +420,11 @@ function res = use_nested_computed_field(self) var1 = self.union_with_nested_generic_union; - if var1.index == 1 + if isa(var1, "test_model.IntOrGenericRecordWithComputedFields") && var1.index == 1 res = -1; return end - if var1.index == 2 + if isa(var1, "test_model.IntOrGenericRecordWithComputedFields") && var1.index == 2 rec = var1.value; res = int32(rec.type_index()); return @@ -527,7 +527,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithComputedFields') && ... + isa(other, "test_model.RecordWithComputedFields") && ... isequal(self.array_field, other.array_field) && ... isequal(self.array_field_map_dimensions, other.array_field_map_dimensions) && ... isequal(self.dynamic_array_field, other.dynamic_array_field) && ... diff --git a/matlab/generated/+test_model/RecordWithDynamicNDArrays.m b/matlab/generated/+test_model/RecordWithDynamicNDArrays.m index 862484ef..0091d4b4 100644 --- a/matlab/generated/+test_model/RecordWithDynamicNDArrays.m +++ b/matlab/generated/+test_model/RecordWithDynamicNDArrays.m @@ -22,7 +22,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithDynamicNDArrays') && ... + isa(other, "test_model.RecordWithDynamicNDArrays") && ... isequal(self.ints, other.ints) && ... isequal(self.simple_record_array, other.simple_record_array) && ... isequal(self.record_with_vlens_array, other.record_with_vlens_array); diff --git a/matlab/generated/+test_model/RecordWithEnums.m b/matlab/generated/+test_model/RecordWithEnums.m index c8976891..c30b24e0 100644 --- a/matlab/generated/+test_model/RecordWithEnums.m +++ b/matlab/generated/+test_model/RecordWithEnums.m @@ -22,7 +22,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithEnums') && ... + isa(other, "test_model.RecordWithEnums") && ... all([self.enum] == [other.enum]) && ... all([self.flags] == [other.flags]) && ... all([self.flags_2] == [other.flags_2]); diff --git a/matlab/generated/+test_model/RecordWithFixedArrays.m b/matlab/generated/+test_model/RecordWithFixedArrays.m index 93f4575c..1e7009df 100644 --- a/matlab/generated/+test_model/RecordWithFixedArrays.m +++ b/matlab/generated/+test_model/RecordWithFixedArrays.m @@ -22,7 +22,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithFixedArrays') && ... + isa(other, "test_model.RecordWithFixedArrays") && ... isequal(self.ints, other.ints) && ... isequal(self.fixed_simple_record_array, other.fixed_simple_record_array) && ... isequal(self.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); diff --git a/matlab/generated/+test_model/RecordWithFixedCollections.m b/matlab/generated/+test_model/RecordWithFixedCollections.m index c0d06ddd..9ef0c4ce 100644 --- a/matlab/generated/+test_model/RecordWithFixedCollections.m +++ b/matlab/generated/+test_model/RecordWithFixedCollections.m @@ -19,7 +19,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithFixedCollections') && ... + isa(other, "test_model.RecordWithFixedCollections") && ... all([self.fixed_vector] == [other.fixed_vector]) && ... isequal(self.fixed_array, other.fixed_array); end diff --git a/matlab/generated/+test_model/RecordWithFixedVectors.m b/matlab/generated/+test_model/RecordWithFixedVectors.m index abf1302d..43b302fd 100644 --- a/matlab/generated/+test_model/RecordWithFixedVectors.m +++ b/matlab/generated/+test_model/RecordWithFixedVectors.m @@ -22,7 +22,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithFixedVectors') && ... + isa(other, "test_model.RecordWithFixedVectors") && ... all([self.fixed_int_vector] == [other.fixed_int_vector]) && ... all([self.fixed_simple_record_vector] == [other.fixed_simple_record_vector]) && ... all([self.fixed_record_with_vlens_vector] == [other.fixed_record_with_vlens_vector]); diff --git a/matlab/generated/+test_model/RecordWithGenericArrays.m b/matlab/generated/+test_model/RecordWithGenericArrays.m index db12b66a..1df3d1de 100644 --- a/matlab/generated/+test_model/RecordWithGenericArrays.m +++ b/matlab/generated/+test_model/RecordWithGenericArrays.m @@ -22,7 +22,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithGenericArrays') && ... + isa(other, "test_model.RecordWithGenericArrays") && ... isequal(self.nd, other.nd) && ... isequal(self.fixed_nd, other.fixed_nd) && ... isequal(self.dynamic_nd, other.dynamic_nd) && ... diff --git a/matlab/generated/+test_model/RecordWithGenericFixedVectors.m b/matlab/generated/+test_model/RecordWithGenericFixedVectors.m index 7bfedc7a..869726bf 100644 --- a/matlab/generated/+test_model/RecordWithGenericFixedVectors.m +++ b/matlab/generated/+test_model/RecordWithGenericFixedVectors.m @@ -14,7 +14,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithGenericFixedVectors') && ... + isa(other, "test_model.RecordWithGenericFixedVectors") && ... isequal(self.fv, other.fv) && ... isequal(self.afv, other.afv); end diff --git a/matlab/generated/+test_model/RecordWithGenericMaps.m b/matlab/generated/+test_model/RecordWithGenericMaps.m index 28a282aa..95a54fb4 100644 --- a/matlab/generated/+test_model/RecordWithGenericMaps.m +++ b/matlab/generated/+test_model/RecordWithGenericMaps.m @@ -19,7 +19,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithGenericMaps') && ... + isa(other, "test_model.RecordWithGenericMaps") && ... isequal(self.m, other.m) && ... isequal(self.am, other.am); end diff --git a/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m b/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m index cdd3afb2..65219711 100644 --- a/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m +++ b/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m @@ -12,7 +12,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithGenericVectorOfRecords') && ... + isa(other, "test_model.RecordWithGenericVectorOfRecords") && ... isequal(self.v, other.v); end diff --git a/matlab/generated/+test_model/RecordWithGenericVectors.m b/matlab/generated/+test_model/RecordWithGenericVectors.m index 9e6be939..ed7ebcb0 100644 --- a/matlab/generated/+test_model/RecordWithGenericVectors.m +++ b/matlab/generated/+test_model/RecordWithGenericVectors.m @@ -14,7 +14,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithGenericVectors') && ... + isa(other, "test_model.RecordWithGenericVectors") && ... isequal(self.v, other.v) && ... isequal(self.av, other.av); end diff --git a/matlab/generated/+test_model/RecordWithKeywordFields.m b/matlab/generated/+test_model/RecordWithKeywordFields.m index 9f310072..5d318541 100644 --- a/matlab/generated/+test_model/RecordWithKeywordFields.m +++ b/matlab/generated/+test_model/RecordWithKeywordFields.m @@ -32,7 +32,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithKeywordFields') && ... + isa(other, "test_model.RecordWithKeywordFields") && ... all([self.int] == [other.int]) && ... isequal(self.sizeof, other.sizeof) && ... all([self.if_] == [other.if_]); diff --git a/matlab/generated/+test_model/RecordWithNDArrays.m b/matlab/generated/+test_model/RecordWithNDArrays.m index 1b054102..b2c3e366 100644 --- a/matlab/generated/+test_model/RecordWithNDArrays.m +++ b/matlab/generated/+test_model/RecordWithNDArrays.m @@ -22,7 +22,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithNDArrays') && ... + isa(other, "test_model.RecordWithNDArrays") && ... isequal(self.ints, other.ints) && ... isequal(self.fixed_simple_record_array, other.fixed_simple_record_array) && ... isequal(self.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); diff --git a/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m b/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m index 263a7107..6cbaed86 100644 --- a/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m +++ b/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m @@ -22,7 +22,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithNDArraysSingleDimension') && ... + isa(other, "test_model.RecordWithNDArraysSingleDimension") && ... isequal(self.ints, other.ints) && ... isequal(self.fixed_simple_record_array, other.fixed_simple_record_array) && ... isequal(self.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); diff --git a/matlab/generated/+test_model/RecordWithNamedFixedArrays.m b/matlab/generated/+test_model/RecordWithNamedFixedArrays.m index 7ffc2b35..00a81e27 100644 --- a/matlab/generated/+test_model/RecordWithNamedFixedArrays.m +++ b/matlab/generated/+test_model/RecordWithNamedFixedArrays.m @@ -22,7 +22,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithNamedFixedArrays') && ... + isa(other, "test_model.RecordWithNamedFixedArrays") && ... isequal(self.ints, other.ints) && ... isequal(self.fixed_simple_record_array, other.fixed_simple_record_array) && ... isequal(self.fixed_record_with_vlens_array, other.fixed_record_with_vlens_array); diff --git a/matlab/generated/+test_model/RecordWithOptionalFields.m b/matlab/generated/+test_model/RecordWithOptionalFields.m index b4359d52..70b89199 100644 --- a/matlab/generated/+test_model/RecordWithOptionalFields.m +++ b/matlab/generated/+test_model/RecordWithOptionalFields.m @@ -22,7 +22,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithOptionalFields') && ... + isa(other, "test_model.RecordWithOptionalFields") && ... all([self.optional_int] == [other.optional_int]) && ... all([self.optional_int_alternate_syntax] == [other.optional_int_alternate_syntax]) && ... all([self.optional_time] == [other.optional_time]); diff --git a/matlab/generated/+test_model/RecordWithOptionalGenericField.m b/matlab/generated/+test_model/RecordWithOptionalGenericField.m index e2b51e96..b12bc6da 100644 --- a/matlab/generated/+test_model/RecordWithOptionalGenericField.m +++ b/matlab/generated/+test_model/RecordWithOptionalGenericField.m @@ -16,7 +16,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithOptionalGenericField') && ... + isa(other, "test_model.RecordWithOptionalGenericField") && ... isequal(self.v, other.v); end diff --git a/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m b/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m index 06928b69..4b579e8b 100644 --- a/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m +++ b/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m @@ -16,7 +16,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithOptionalGenericUnionField') && ... + isa(other, "test_model.RecordWithOptionalGenericUnionField") && ... isequal(self.v, other.v); end diff --git a/matlab/generated/+test_model/RecordWithOptionalVector.m b/matlab/generated/+test_model/RecordWithOptionalVector.m index c6235943..62280015 100644 --- a/matlab/generated/+test_model/RecordWithOptionalVector.m +++ b/matlab/generated/+test_model/RecordWithOptionalVector.m @@ -16,7 +16,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithOptionalVector') && ... + isa(other, "test_model.RecordWithOptionalVector") && ... all([self.optional_vector] == [other.optional_vector]); end diff --git a/matlab/generated/+test_model/RecordWithPrimitiveAliases.m b/matlab/generated/+test_model/RecordWithPrimitiveAliases.m index cc4f84ac..88ff1226 100644 --- a/matlab/generated/+test_model/RecordWithPrimitiveAliases.m +++ b/matlab/generated/+test_model/RecordWithPrimitiveAliases.m @@ -40,7 +40,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithPrimitiveAliases') && ... + isa(other, "test_model.RecordWithPrimitiveAliases") && ... all([self.byte_field] == [other.byte_field]) && ... all([self.int_field] == [other.int_field]) && ... all([self.uint_field] == [other.uint_field]) && ... diff --git a/matlab/generated/+test_model/RecordWithPrimitives.m b/matlab/generated/+test_model/RecordWithPrimitives.m index 22a59ae3..7023e8fe 100644 --- a/matlab/generated/+test_model/RecordWithPrimitives.m +++ b/matlab/generated/+test_model/RecordWithPrimitives.m @@ -64,7 +64,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithPrimitives') && ... + isa(other, "test_model.RecordWithPrimitives") && ... all([self.bool_field] == [other.bool_field]) && ... all([self.int8_field] == [other.int8_field]) && ... all([self.uint8_field] == [other.uint8_field]) && ... diff --git a/matlab/generated/+test_model/RecordWithStrings.m b/matlab/generated/+test_model/RecordWithStrings.m index a394bde6..15f4fc54 100644 --- a/matlab/generated/+test_model/RecordWithStrings.m +++ b/matlab/generated/+test_model/RecordWithStrings.m @@ -19,7 +19,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithStrings') && ... + isa(other, "test_model.RecordWithStrings") && ... all([self.a] == [other.a]) && ... all([self.b] == [other.b]); end diff --git a/matlab/generated/+test_model/RecordWithUnionsOfContainers.m b/matlab/generated/+test_model/RecordWithUnionsOfContainers.m index b6b71c76..8f6ea691 100644 --- a/matlab/generated/+test_model/RecordWithUnionsOfContainers.m +++ b/matlab/generated/+test_model/RecordWithUnionsOfContainers.m @@ -22,7 +22,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithUnionsOfContainers') && ... + isa(other, "test_model.RecordWithUnionsOfContainers") && ... all([self.map_or_scalar] == [other.map_or_scalar]) && ... all([self.vector_or_scalar] == [other.vector_or_scalar]) && ... isequal(self.array_or_scalar, other.array_or_scalar); diff --git a/matlab/generated/+test_model/RecordWithVectorOfTimes.m b/matlab/generated/+test_model/RecordWithVectorOfTimes.m index 6c87279b..5126af1a 100644 --- a/matlab/generated/+test_model/RecordWithVectorOfTimes.m +++ b/matlab/generated/+test_model/RecordWithVectorOfTimes.m @@ -16,7 +16,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithVectorOfTimes') && ... + isa(other, "test_model.RecordWithVectorOfTimes") && ... all([self.times] == [other.times]); end diff --git a/matlab/generated/+test_model/RecordWithVectors.m b/matlab/generated/+test_model/RecordWithVectors.m index 691da897..fa667a04 100644 --- a/matlab/generated/+test_model/RecordWithVectors.m +++ b/matlab/generated/+test_model/RecordWithVectors.m @@ -22,7 +22,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithVectors') && ... + isa(other, "test_model.RecordWithVectors") && ... all([self.default_vector] == [other.default_vector]) && ... all([self.default_vector_fixed_length] == [other.default_vector_fixed_length]) && ... all([self.vector_of_vectors] == [other.vector_of_vectors]); diff --git a/matlab/generated/+test_model/RecordWithVlenCollections.m b/matlab/generated/+test_model/RecordWithVlenCollections.m index 61b958a5..4cfb7b0c 100644 --- a/matlab/generated/+test_model/RecordWithVlenCollections.m +++ b/matlab/generated/+test_model/RecordWithVlenCollections.m @@ -19,7 +19,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithVlenCollections') && ... + isa(other, "test_model.RecordWithVlenCollections") && ... all([self.vector] == [other.vector]) && ... isequal(self.array, other.array); end diff --git a/matlab/generated/+test_model/RecordWithVlens.m b/matlab/generated/+test_model/RecordWithVlens.m index ab6c8f77..698b7e10 100644 --- a/matlab/generated/+test_model/RecordWithVlens.m +++ b/matlab/generated/+test_model/RecordWithVlens.m @@ -22,7 +22,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.RecordWithVlens') && ... + isa(other, "test_model.RecordWithVlens") && ... all([self.a] == [other.a]) && ... all([self.b] == [other.b]) && ... all([self.c] == [other.c]); diff --git a/matlab/generated/+test_model/SimpleAcquisition.m b/matlab/generated/+test_model/SimpleAcquisition.m index 584e9dcb..fed07d27 100644 --- a/matlab/generated/+test_model/SimpleAcquisition.m +++ b/matlab/generated/+test_model/SimpleAcquisition.m @@ -25,7 +25,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.SimpleAcquisition') && ... + isa(other, "test_model.SimpleAcquisition") && ... all([self.flags] == [other.flags]) && ... all([self.idx] == [other.idx]) && ... isequal(self.data, other.data) && ... diff --git a/matlab/generated/+test_model/SimpleEncodingCounters.m b/matlab/generated/+test_model/SimpleEncodingCounters.m index c248d969..ab7e4780 100644 --- a/matlab/generated/+test_model/SimpleEncodingCounters.m +++ b/matlab/generated/+test_model/SimpleEncodingCounters.m @@ -25,7 +25,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.SimpleEncodingCounters') && ... + isa(other, "test_model.SimpleEncodingCounters") && ... all([self.e1] == [other.e1]) && ... all([self.e2] == [other.e2]) && ... all([self.slice] == [other.slice]) && ... diff --git a/matlab/generated/+test_model/SimpleRecord.m b/matlab/generated/+test_model/SimpleRecord.m index 1c54c310..51ecb8fc 100644 --- a/matlab/generated/+test_model/SimpleRecord.m +++ b/matlab/generated/+test_model/SimpleRecord.m @@ -22,7 +22,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.SimpleRecord') && ... + isa(other, "test_model.SimpleRecord") && ... all([self.x] == [other.x]) && ... all([self.y] == [other.y]) && ... all([self.z] == [other.z]); diff --git a/matlab/generated/+test_model/SmallBenchmarkRecord.m b/matlab/generated/+test_model/SmallBenchmarkRecord.m index f27c0e8d..55c1e5a4 100644 --- a/matlab/generated/+test_model/SmallBenchmarkRecord.m +++ b/matlab/generated/+test_model/SmallBenchmarkRecord.m @@ -22,7 +22,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.SmallBenchmarkRecord') && ... + isa(other, "test_model.SmallBenchmarkRecord") && ... all([self.a] == [other.a]) && ... all([self.b] == [other.b]) && ... all([self.c] == [other.c]); diff --git a/matlab/generated/+test_model/StringOrInt32.m b/matlab/generated/+test_model/StringOrInt32.m index ae06927e..325e86c0 100644 --- a/matlab/generated/+test_model/StringOrInt32.m +++ b/matlab/generated/+test_model/StringOrInt32.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.StringOrInt32') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.StringOrInt32") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/TupleWithRecords.m b/matlab/generated/+test_model/TupleWithRecords.m index 36ebfa6f..96edbdf8 100644 --- a/matlab/generated/+test_model/TupleWithRecords.m +++ b/matlab/generated/+test_model/TupleWithRecords.m @@ -19,7 +19,7 @@ function res = eq(self, other) res = ... - isa(other, 'test_model.TupleWithRecords') && ... + isa(other, "test_model.TupleWithRecords") && ... all([self.a] == [other.a]) && ... all([self.b] == [other.b]); end diff --git a/matlab/generated/+test_model/UOrV.m b/matlab/generated/+test_model/UOrV.m index a609b1ea..5acb477e 100644 --- a/matlab/generated/+test_model/UOrV.m +++ b/matlab/generated/+test_model/UOrV.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.UOrV') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.UOrV") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/VectorOrScalar.m b/matlab/generated/+test_model/VectorOrScalar.m index b1bf0fd5..56505a1d 100644 --- a/matlab/generated/+test_model/VectorOrScalar.m +++ b/matlab/generated/+test_model/VectorOrScalar.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, 'test_model.VectorOrScalar') && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.VectorOrScalar") && other.index == self.index && other.value == self.value; end function ne = ne(self, other) diff --git a/matlab/generated/+tuples/Tuple.m b/matlab/generated/+tuples/Tuple.m index 7d578b07..965e3463 100644 --- a/matlab/generated/+tuples/Tuple.m +++ b/matlab/generated/+tuples/Tuple.m @@ -14,7 +14,7 @@ function res = eq(self, other) res = ... - isa(other, 'tuples.Tuple') && ... + isa(other, "tuples.Tuple") && ... isequal(self.v1, other.v1) && ... isequal(self.v2, other.v2); end diff --git a/tooling/internal/matlab/types/types.go b/tooling/internal/matlab/types/types.go index eb8d11e4..7f492577 100644 --- a/tooling/internal/matlab/types/types.go +++ b/tooling/internal/matlab/types/types.go @@ -120,7 +120,7 @@ func writeUnionClass(w *formatting.IndentedWriter, className string, generalized w.WriteStringln("function eq = eq(self, other)") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "eq = isa(other, '%s') && other.index == self.index && other.value == self.value;\n", qualifiedClassName) + fmt.Fprintf(w, "eq = isa(other, \"%s\") && other.index == self.index && other.value == self.value;\n", qualifiedClassName) }) w.WriteStringln("") w.WriteStringln("function ne = ne(self, other)") @@ -302,7 +302,7 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. common.WriteBlockBody(w, func() { w.WriteStringln("res = ...") w.Indented(func() { - fmt.Fprintf(w, "isa(other, '%s')", common.TypeSyntax(rec, rec.Namespace)) + fmt.Fprintf(w, "isa(other, \"%s\")", common.TypeSyntax(rec, rec.Namespace)) for _, field := range rec.Fields { w.WriteStringln(" && ...") fieldIdentifier := common.FieldIdentifierName(field.Name) @@ -671,12 +671,11 @@ func writeComputedFieldExpression(w *formatting.IndentedWriter, expression dsl.E } self.VisitChildren(node) }) - - unionClassName := common.UnionClassName(targetType) - if targetTypeNamespace != "" && targetTypeNamespace != contextNamespace { - unionClassName = fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(targetTypeNamespace), unionClassName) + if targetTypeNamespace == "" { + targetTypeNamespace = contextNamespace } + unionClassName := fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(targetTypeNamespace), common.UnionClassName(targetType)) for _, switchCase := range t.Cases { writeSwitchCaseOverUnion(w, targetType, unionClassName, switchCase, unionVariableName, self, tail) } @@ -767,7 +766,7 @@ func writeSwitchCaseOverUnion(w *formatting.IndentedWriter, unionType *dsl.Gener visitor.Visit(switchCase.Expression, tail) }) } else { - fmt.Fprintf(w, "if %s.index == %d\n", variableName, i+caseIndexOffset) + fmt.Fprintf(w, "if isa(%s, \"%s\") && %s.index == %d\n", variableName, unionClassName, variableName, i+caseIndexOffset) common.WriteBlockBody(w, func() { if declarationIdentifier != "" { fmt.Fprintf(w, "%s = %s.value;\n", declarationIdentifier, variableName) @@ -872,9 +871,7 @@ func typeDefault(t dsl.Type, contextNamespace string, namedType string, st dsl.S if namedType != "" { unionClassName = namedType } else { - unionClassName = common.UnionClassName(t) - - unionClassName = fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(contextNamespace), unionClassName) + unionClassName = fmt.Sprintf("%s.%s", common.NamespaceIdentifierName(contextNamespace), common.UnionClassName(t)) } unionCaseConstructor := fmt.Sprintf("%s.%s", unionClassName, formatting.ToPascalCase(t.Cases[0].Tag)) From 6e5ee39431645c85ddfa8c214a36b05f893fd9c5 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Mon, 15 Apr 2024 19:38:04 +0000 Subject: [PATCH 20/32] Update CI to include Matlab tests and benchmarks --- .devcontainer/Dockerfile | 5 +++ .../actions/configure-environment/action.yml | 16 ++++++- .github/workflows/ci.yml | 2 +- README.md | 10 +++++ justfile | 13 +++++- matlab/test/{run.m => runTests.m} | 2 +- python/benchmark.py | 42 ++++++++++++++----- 7 files changed, 74 insertions(+), 16 deletions(-) rename matlab/test/{run.m => runTests.m} (76%) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 25b11af1..298e5e35 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -169,3 +169,8 @@ RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm \ && sudo rm -f mpm /tmp/mathworks_root.log \ && sudo ln -s ${MATLAB_INSTALL_LOCATION}/bin/matlab /usr/local/bin/matlab \ && sudo ln -s ${MATLAB_INSTALL_LOCATION} /opt/matlab/latest + +# Install workaround run-matlab-command script to unify local and CI invocations of `matlab -batch` +# See https://github.com/matlab-actions/run-command/issues/53 +RUN sudo wget -O /usr/local/bin/run-matlab-command https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/glnxa64/run-matlab-command \ + && sudo chmod +x /usr/local/bin/run-matlab-command diff --git a/.github/actions/configure-environment/action.yml b/.github/actions/configure-environment/action.yml index 03fd2377..1ce24265 100644 --- a/.github/actions/configure-environment/action.yml +++ b/.github/actions/configure-environment/action.yml @@ -44,7 +44,21 @@ runs: if: steps.cache-conda.outputs.cache-hit != 'true' - - uses: actions/setup-go@v4 + - name: Setup Go + uses: actions/setup-go@v4 with: go-version: '1.21.3' cache-dependency-path: tooling/go.sum + + - name: Setup Matlab + uses: matlab-actions/setup-matlab@v2 + with: + release: R2022b + cache: true + + # Workaround to running `matlab -batch` from within justfile and Python + # See: https://github.com/matlab-actions/run-command/issues/53 + - name: Get run-matlab-command + run: | + wget -O /usr/local/bin/run-matlab-command https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/glnxa64/run-matlab-command + chmod +x /usr/local/bin/run-matlab-command diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef4f1cad..90c5a663 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: uses: ./.github/actions/configure-environment - name: Build and test - run: just cpp_version=${{ matrix.cppVersion }} validate-with-no-changes + run: just cpp_version=${{ matrix.cppVersion }} matlab=enabled validate-with-no-changes buildBinaries: name: Build yardl binaries diff --git a/README.md b/README.md index 7aba2871..bb950242 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,16 @@ $ just from the repo root. +To enable support for Matlab, you must provide a Matlab license file to the devcontainer. +In your HOST environment, export the environment variable `MATLAB_LICENSE_FILE`, +e.g. in `$HOME/.profile` + +```bash +export MATLAB_LICENSE_FILE=/mnt/c/Users/username/Documents/MATLAB/license.lic +``` + +Then invoke `just matlab=enabled ...`. + ## Contributing This project welcomes contributions and suggestions. Most contributions require diff --git a/justfile b/justfile index bcbacff4..cbd59c77 100644 --- a/justfile +++ b/justfile @@ -2,6 +2,11 @@ set shell := ['bash', '-ceuo', 'pipefail'] cpp_version := "17" +matlab := "disabled" +matlab-test-cmd := if matlab != "disabled" { "run-matlab-command runTests" } else { "echo Skipping Matlab tests..." } +benchmark-cmd := if matlab != "disabled" { "python python/benchmark.py --include-matlab" } else { "python python/benchmark.py" } + + @default: validate echo $'\n\e[1;34mNote: you can run \'just test\' to a run an inner-loop subset of the complete validation' @@ -69,18 +74,22 @@ cpp_version := "17" ninja tests; \ ./tests --gtest_brief=1 +@matlab-test: generate build-translator + cd matlab/test; \ + {{ matlab-test-cmd }} + @evolution-test: generate-evolution ensure-build-dir cd cpp/build; \ ninja evolution/all; \ python ../evolution/test-evolution.py -@test: tooling-test cpp-test python-test evolution-test +@test: tooling-test cpp-test python-test matlab-test evolution-test @benchmark: generate ensure-build-dir cd cpp/build; \ ninja benchmark; \ cd ../..; \ - python python/benchmark.py + {{ benchmark-cmd }} @watch-generate-test: install watchexec -r -c -w tooling/ -- "just install && cd models/test && yardl generate --watch" diff --git a/matlab/test/run.m b/matlab/test/runTests.m similarity index 76% rename from matlab/test/run.m rename to matlab/test/runTests.m index df937d45..d764d132 100644 --- a/matlab/test/run.m +++ b/matlab/test/runTests.m @@ -2,4 +2,4 @@ % Licensed under the MIT License. addpath("../generated/"); -runtests(pwd) +assertSuccess(runtests(pwd)); diff --git a/python/benchmark.py b/python/benchmark.py index 5912e020..555eee58 100755 --- a/python/benchmark.py +++ b/python/benchmark.py @@ -1,6 +1,7 @@ #! /usr/bin/env python3 from dataclasses import dataclass +import argparse import inspect import json import os @@ -24,10 +25,6 @@ OUTPUT_FILE = "/tmp/benchmark_data.dat" -# Setting this to True will display the roundtrip duration instead of the throughput -# and should only be done to calibrate the scales of each scenario and format. -DISPLAY_DURATIONS = False - @dataclass class Result: @@ -263,7 +260,9 @@ def invoke_cpp_benchmark(scenario: str, format: Format) -> Optional[Result]: def invoke_matlab_benchmark(scenario: str, format: Format) -> Optional[Result]: res = subprocess.run( - ["matlab", "-batch", f"benchmark('{scenario}', '{format}')"], + # Workaround for CI: run-matlab-command is a wrapper around `matlab -batch` + # See https://github.com/matlab-actions/run-command/issues/53 + ["run-matlab-command", f"benchmark('{scenario}', '{format}')"], cwd=_matlab_benchmark_path, stdout=subprocess.PIPE, check=True, @@ -279,11 +278,15 @@ def scenario_name(scenario_func: Callable[[Format], Optional[Result]]) -> str: def invoke_benchmark( - scenario_func: Callable[[Format], Optional[Result]], format: Format + scenario_func: Callable[[Format], Optional[Result]], + format: Format, + include_matlab: bool, ) -> MutlitingualResults: cpp_res = invoke_cpp_benchmark(scenario_name(scenario_func), format) python_res = scenario_func(format) - matlab_res = invoke_matlab_benchmark(scenario_name(scenario_func), format) + matlab_res = None + if include_matlab: + matlab_res = invoke_matlab_benchmark(scenario_name(scenario_func), format) return MutlitingualResults(cpp=cpp_res, python=python_res, matlab=matlab_res) @@ -293,6 +296,7 @@ def update_table( scenario_func: Callable[[Format], Optional[Result]], format: Format, results: MutlitingualResults, + display_durations: bool, ): def format_float(thoughput: float) -> str: return f"{thoughput:,.2f}" @@ -306,7 +310,7 @@ def color(): return "green" return None - if DISPLAY_DURATIONS: + if display_durations: table.add_row( scenario_name(scenario_func), str(format), @@ -367,8 +371,22 @@ def color(): if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument( + "--display-durations", + action="store_true", + help="Display the roundtrip duration instead of the throughput. " + "Use only to calibrate the scales of each scenario and format", + ) + parser.add_argument( + "--include-matlab", + action="store_true", + help="Include Matlab benchmarking results", + ) + args = parser.parse_args() + table = Table() - if DISPLAY_DURATIONS: + if args.display_durations: table.title = "Roundtrip duration" table.add_column("Scenario") table.add_column("Format") @@ -393,5 +411,7 @@ def color(): ): table.add_section() for format in [Format.HDF5, Format.BINARY, Format.NDJSON]: - res = invoke_benchmark(benchmark_func, format) - update_table(table, live, benchmark_func, format, res) + res = invoke_benchmark(benchmark_func, format, args.include_matlab) + update_table( + table, live, benchmark_func, format, res, args.display_durations + ) From 3659c9199053a3c3b5fdf9decaeb58c1abf3a34e Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Mon, 15 Apr 2024 19:51:30 +0000 Subject: [PATCH 21/32] Add required Github action 'shell' property --- .github/actions/configure-environment/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/configure-environment/action.yml b/.github/actions/configure-environment/action.yml index 1ce24265..9b03f338 100644 --- a/.github/actions/configure-environment/action.yml +++ b/.github/actions/configure-environment/action.yml @@ -59,6 +59,7 @@ runs: # Workaround to running `matlab -batch` from within justfile and Python # See: https://github.com/matlab-actions/run-command/issues/53 - name: Get run-matlab-command + shell: bash run: | wget -O /usr/local/bin/run-matlab-command https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/glnxa64/run-matlab-command chmod +x /usr/local/bin/run-matlab-command From fac90ef2b86e039130067912f13e6e084de6b56c Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Mon, 15 Apr 2024 20:11:10 +0000 Subject: [PATCH 22/32] Remove generated static Matlab files from git --- matlab/.gitignore | 1 + matlab/generated/+yardl | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 matlab/.gitignore delete mode 120000 matlab/generated/+yardl diff --git a/matlab/.gitignore b/matlab/.gitignore new file mode 100644 index 00000000..6316f0cf --- /dev/null +++ b/matlab/.gitignore @@ -0,0 +1 @@ +generated/+yardl diff --git a/matlab/generated/+yardl b/matlab/generated/+yardl deleted file mode 120000 index 7869ca3f..00000000 --- a/matlab/generated/+yardl +++ /dev/null @@ -1 +0,0 @@ -/workspaces/yardl/tooling/internal/matlab/static_files \ No newline at end of file From ae77750f37f13da702d4b92ccc1e1ed8fffd2887 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Mon, 6 May 2024 12:54:29 +0000 Subject: [PATCH 23/32] Add MATLAB fixes and Flags utility methods --- matlab/generated/+basic_types/DaysOfWeek.m | 56 ++++++++++++++----- matlab/generated/+basic_types/Fruits.m | 12 ++-- matlab/generated/+basic_types/TextFormat.m | 48 ++++++++++++---- .../+test_model/EnumWithKeywordSymbols.m | 8 +-- matlab/generated/+test_model/Int64Enum.m | 4 +- matlab/generated/+test_model/SizeBasedEnum.m | 12 ++-- matlab/generated/+test_model/UInt64Enum.m | 4 +- matlab/test/GeneratedTypesTest.m | 32 +++++++++++ matlab/test/RoundTripTest.m | 11 +++- .../internal/matlab/protocols/protocols.go | 2 + .../+binary/BinaryProtocolReader.m | 6 +- .../static_files/+binary/CodedInputStream.m | 2 +- .../static_files/+binary/CodedOutputStream.m | 2 +- .../static_files/+binary/MapSerializer.m | 5 ++ .../static_files/+binary/OptionalSerializer.m | 1 + tooling/internal/matlab/types/types.go | 47 +++++++++++++++- 16 files changed, 198 insertions(+), 54 deletions(-) diff --git a/matlab/generated/+basic_types/DaysOfWeek.m b/matlab/generated/+basic_types/DaysOfWeek.m index 32df781c..f017a5d5 100644 --- a/matlab/generated/+basic_types/DaysOfWeek.m +++ b/matlab/generated/+basic_types/DaysOfWeek.m @@ -2,26 +2,26 @@ classdef DaysOfWeek < uint64 methods (Static) - function e = MONDAY - e = basic_types.DaysOfWeek(1); + function v = MONDAY + v = basic_types.DaysOfWeek(1); end - function e = TUESDAY - e = basic_types.DaysOfWeek(2); + function v = TUESDAY + v = basic_types.DaysOfWeek(2); end - function e = WEDNESDAY - e = basic_types.DaysOfWeek(4); + function v = WEDNESDAY + v = basic_types.DaysOfWeek(4); end - function e = THURSDAY - e = basic_types.DaysOfWeek(8); + function v = THURSDAY + v = basic_types.DaysOfWeek(8); end - function e = FRIDAY - e = basic_types.DaysOfWeek(16); + function v = FRIDAY + v = basic_types.DaysOfWeek(16); end - function e = SATURDAY - e = basic_types.DaysOfWeek(32); + function v = SATURDAY + v = basic_types.DaysOfWeek(32); end - function e = SUNDAY - e = basic_types.DaysOfWeek(64); + function v = SUNDAY + v = basic_types.DaysOfWeek(64); end function z = zeros(varargin) @@ -37,4 +37,32 @@ z = reshape(repelem(elem, prod(sz)), sz); end end + + methods + function self = DaysOfWeek(varargin) + if nargin == 0 + value = 0; + elseif nargin == 1 + value = varargin{1}; + else + value = 0; + for i = 1:nargin + value = bitor(value, varargin{i}); + end + end + self@uint64(value); + end + + function res = has_flags(self, flag) + res = bitand(self, flag) == flag; + end + + function res = with_flags(self, flag) + res = basic_types.DaysOfWeek(bitor(self, flag)); + end + + function res = without_flags(self, flag) + res = basic_types.DaysOfWeek(bitand(self, bitcmp(flag))); + end + end end diff --git a/matlab/generated/+basic_types/Fruits.m b/matlab/generated/+basic_types/Fruits.m index e53ec8c7..684ff6a7 100644 --- a/matlab/generated/+basic_types/Fruits.m +++ b/matlab/generated/+basic_types/Fruits.m @@ -2,14 +2,14 @@ classdef Fruits < uint64 methods (Static) - function e = APPLE - e = basic_types.Fruits(0); + function v = APPLE + v = basic_types.Fruits(0); end - function e = BANANA - e = basic_types.Fruits(1); + function v = BANANA + v = basic_types.Fruits(1); end - function e = PEAR - e = basic_types.Fruits(2); + function v = PEAR + v = basic_types.Fruits(2); end function z = zeros(varargin) diff --git a/matlab/generated/+basic_types/TextFormat.m b/matlab/generated/+basic_types/TextFormat.m index 69c9010d..526bad3d 100644 --- a/matlab/generated/+basic_types/TextFormat.m +++ b/matlab/generated/+basic_types/TextFormat.m @@ -2,20 +2,20 @@ classdef TextFormat < uint64 methods (Static) - function e = REGULAR - e = basic_types.TextFormat(0); + function v = REGULAR + v = basic_types.TextFormat(0); end - function e = BOLD - e = basic_types.TextFormat(1); + function v = BOLD + v = basic_types.TextFormat(1); end - function e = ITALIC - e = basic_types.TextFormat(2); + function v = ITALIC + v = basic_types.TextFormat(2); end - function e = UNDERLINE - e = basic_types.TextFormat(4); + function v = UNDERLINE + v = basic_types.TextFormat(4); end - function e = STRIKETHROUGH - e = basic_types.TextFormat(8); + function v = STRIKETHROUGH + v = basic_types.TextFormat(8); end function z = zeros(varargin) @@ -31,4 +31,32 @@ z = reshape(repelem(elem, prod(sz)), sz); end end + + methods + function self = TextFormat(varargin) + if nargin == 0 + value = 0; + elseif nargin == 1 + value = varargin{1}; + else + value = 0; + for i = 1:nargin + value = bitor(value, varargin{i}); + end + end + self@uint64(value); + end + + function res = has_flags(self, flag) + res = bitand(self, flag) == flag; + end + + function res = with_flags(self, flag) + res = basic_types.TextFormat(bitor(self, flag)); + end + + function res = without_flags(self, flag) + res = basic_types.TextFormat(bitand(self, bitcmp(flag))); + end + end end diff --git a/matlab/generated/+test_model/EnumWithKeywordSymbols.m b/matlab/generated/+test_model/EnumWithKeywordSymbols.m index e5a00901..e8fe230c 100644 --- a/matlab/generated/+test_model/EnumWithKeywordSymbols.m +++ b/matlab/generated/+test_model/EnumWithKeywordSymbols.m @@ -2,11 +2,11 @@ classdef EnumWithKeywordSymbols < uint64 methods (Static) - function e = TRY - e = test_model.EnumWithKeywordSymbols(2); + function v = TRY + v = test_model.EnumWithKeywordSymbols(2); end - function e = CATCH - e = test_model.EnumWithKeywordSymbols(1); + function v = CATCH + v = test_model.EnumWithKeywordSymbols(1); end function z = zeros(varargin) diff --git a/matlab/generated/+test_model/Int64Enum.m b/matlab/generated/+test_model/Int64Enum.m index 231b99e7..da7457c6 100644 --- a/matlab/generated/+test_model/Int64Enum.m +++ b/matlab/generated/+test_model/Int64Enum.m @@ -2,8 +2,8 @@ classdef Int64Enum < int64 methods (Static) - function e = B - e = test_model.Int64Enum(-4611686018427387904); + function v = B + v = test_model.Int64Enum(-4611686018427387904); end function z = zeros(varargin) diff --git a/matlab/generated/+test_model/SizeBasedEnum.m b/matlab/generated/+test_model/SizeBasedEnum.m index 37fd5381..2971730d 100644 --- a/matlab/generated/+test_model/SizeBasedEnum.m +++ b/matlab/generated/+test_model/SizeBasedEnum.m @@ -2,14 +2,14 @@ classdef SizeBasedEnum < uint64 methods (Static) - function e = A - e = test_model.SizeBasedEnum(0); + function v = A + v = test_model.SizeBasedEnum(0); end - function e = B - e = test_model.SizeBasedEnum(1); + function v = B + v = test_model.SizeBasedEnum(1); end - function e = C - e = test_model.SizeBasedEnum(2); + function v = C + v = test_model.SizeBasedEnum(2); end function z = zeros(varargin) diff --git a/matlab/generated/+test_model/UInt64Enum.m b/matlab/generated/+test_model/UInt64Enum.m index 7a002e59..41a5c10f 100644 --- a/matlab/generated/+test_model/UInt64Enum.m +++ b/matlab/generated/+test_model/UInt64Enum.m @@ -2,8 +2,8 @@ classdef UInt64Enum < uint64 methods (Static) - function e = A - e = test_model.UInt64Enum(9223372036854775808); + function v = A + v = test_model.UInt64Enum(9223372036854775808); end function z = zeros(varargin) diff --git a/matlab/test/GeneratedTypesTest.m b/matlab/test/GeneratedTypesTest.m index 00de0ce4..16c0a2a2 100644 --- a/matlab/test/GeneratedTypesTest.m +++ b/matlab/test/GeneratedTypesTest.m @@ -177,5 +177,37 @@ function testYardlAllocate(testCase) testCase.verifyTrue(all(dts == yardl.DateTime(0))); end + function testFlags(testCase) + zero = test_model.TextFormat(0); + regular = test_model.TextFormat.REGULAR; + bold = test_model.TextFormat.BOLD; + underline = test_model.TextFormat.UNDERLINE; + bold_underline = bold.with_flags(underline); + bold_underline2 = test_model.TextFormat(bold, underline); + everything = regular.with_flags(test_model.TextFormat(bold, underline, 2, 8)); + + testCase.verifyEqual(zero, regular); + + testCase.verifyEqual(everything, test_model.TextFormat(0b1111)); + + testCase.verifyEqual(regular.with_flags(test_model.TextFormat.BOLD), test_model.TextFormat.BOLD); + testCase.verifyEqual(regular.with_flags(uint64(1)), test_model.TextFormat.BOLD); + testCase.verifyEqual(bold.with_flags(underline), bold_underline); + testCase.verifyEqual(bold.with_flags(underline), bold_underline2); + + testCase.verifyEqual(bold_underline.without_flags(bold), underline); + testCase.verifyEqual(bold_underline.without_flags(uint64(1)), underline); + testCase.verifyEqual(bold_underline2.without_flags(bold), underline); + testCase.verifyEqual(bold_underline2.without_flags(uint64(1)), underline); + + testCase.verifyTrue(bold.has_flags(uint64(1))); + testCase.verifyTrue(bold.has_flags(bold)); + testCase.verifyTrue(bold_underline.has_flags(bold)); + testCase.verifyTrue(bold_underline.has_flags(underline)); + testCase.verifyTrue(bold_underline.has_flags(bold_underline)); + testCase.verifyTrue(bold_underline2.has_flags(bold)); + testCase.verifyTrue(bold_underline2.has_flags(underline)); + testCase.verifyTrue(bold_underline2.has_flags(bold_underline)); + end end end diff --git a/matlab/test/RoundTripTest.m b/matlab/test/RoundTripTest.m index ee9d1d6e..6988f9df 100644 --- a/matlab/test/RoundTripTest.m +++ b/matlab/test/RoundTripTest.m @@ -265,18 +265,23 @@ function testMaps(testCase, format) w = create_validating_writer(testCase, format, 'Maps'); w.write_string_to_int(d); - w.write_int_to_string(dictionary(int32([1, 2, 3]), ["a", "b", "c"])); - w.write_string_to_union(... dictionary(... ["a", "b"], ... [test_model.StringOrInt32.Int32(1), test_model.StringOrInt32.String("2")] ... ) ... ); - w.write_aliased_generic(d); w.close(); + + % Now again for "empty" maps + w = create_validating_writer(testCase, format, 'Maps'); + w.write_string_to_int(dictionary()); + w.write_int_to_string(dictionary()); + w.write_string_to_union(dictionary()); + w.write_aliased_generic(dictionary()); + w.close(); end function testUnions(testCase, format) diff --git a/tooling/internal/matlab/protocols/protocols.go b/tooling/internal/matlab/protocols/protocols.go index 2a3bfc58..3844d06d 100644 --- a/tooling/internal/matlab/protocols/protocols.go +++ b/tooling/internal/matlab/protocols/protocols.go @@ -66,6 +66,7 @@ func writeAbstractWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, fmt.Fprintf(w, "self.raise_unexpected_state_(%d);\n", i) }) w.WriteStringln("") + fmt.Fprintf(w, "self.%s(value);\n", common.ProtocolWriteImplMethodName(step)) if !step.IsStream() { fmt.Fprintf(w, "self.state_ = %d;\n", i+1) @@ -73,6 +74,7 @@ func writeAbstractWriter(fw *common.MatlabFileWriter, p *dsl.ProtocolDefinition, }) if step.IsStream() { + // End stream method w.WriteStringln("") fmt.Fprintf(w, "function %s(self)\n", common.ProtocolEndMethodName(step)) common.WriteBlockBody(w, func() { diff --git a/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m b/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m index 70353bf2..11802692 100755 --- a/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m +++ b/tooling/internal/matlab/static_files/+binary/BinaryProtocolReader.m @@ -12,18 +12,18 @@ self.stream_ = yardl.binary.CodedInputStream(infile); magic_bytes = self.stream_.read_bytes(length(yardl.binary.MAGIC_BYTES)); if magic_bytes ~= yardl.binary.MAGIC_BYTES - throw(yardl.binary.Exception("Invalid magic bytes")); + throw(yardl.ProtocolError("Invalid magic bytes")); end version = read_fixed_int32(self.stream_); if version ~= yardl.binary.CURRENT_BINARY_FORMAT_VERSION - throw(yardl.binary.Exception("Invalid binary format version")); + throw(yardl.ProtocolError("Invalid binary format version")); end s = yardl.binary.StringSerializer(); schema = s.read(self.stream_); if ~isempty(expected_schema) & schema ~= expected_schema - throw(yardl.binary.Exception("Invalid schema")); + throw(yardl.ProtocolError("Invalid schema")); end end end diff --git a/tooling/internal/matlab/static_files/+binary/CodedInputStream.m b/tooling/internal/matlab/static_files/+binary/CodedInputStream.m index 6a770e6e..8479dd0e 100755 --- a/tooling/internal/matlab/static_files/+binary/CodedInputStream.m +++ b/tooling/internal/matlab/static_files/+binary/CodedInputStream.m @@ -13,7 +13,7 @@ if isa(infile, "string") || isa(infile, "char") [fileId, errMsg] = fopen(infile, "r"); if fileId < 0 - throw(yardl.binary.Exception(errMsg)); + throw(yardl.RuntimError(errMsg)); end self.fid_ = fileId; self.owns_stream_ = true; diff --git a/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m b/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m index 40055a6a..235e0dcc 100755 --- a/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m +++ b/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m @@ -13,7 +13,7 @@ if isa(outfile, "string") || isa(outfile, "char") [fileId, errMsg] = fopen(outfile, "W"); if fileId < 0 - throw(yardl.binary.Exception(errMsg)); + throw(yardl.RuntimError(errMsg)); end self.fid_ = fileId; self.owns_stream_ = true; diff --git a/tooling/internal/matlab/static_files/+binary/MapSerializer.m b/tooling/internal/matlab/static_files/+binary/MapSerializer.m index 3e8f9000..73ad04d4 100644 --- a/tooling/internal/matlab/static_files/+binary/MapSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/MapSerializer.m @@ -19,8 +19,13 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) dictionary end + count = numEntries(value); outstream.write_unsigned_varint(count); + if count == 0 + return + end + ks = keys(value); vs = values(value); for i = 1:count diff --git a/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m b/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m index 79d11c32..a4f7960d 100644 --- a/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m +++ b/tooling/internal/matlab/static_files/+binary/OptionalSerializer.m @@ -27,6 +27,7 @@ function write(self, outstream, value) end function res = read(self, instream) + % Returns either yardl.None or the inner optional value has_value = instream.read_byte(); if has_value == 0 res = yardl.None; diff --git a/tooling/internal/matlab/types/types.go b/tooling/internal/matlab/types/types.go index 7f492577..7507c8a6 100644 --- a/tooling/internal/matlab/types/types.go +++ b/tooling/internal/matlab/types/types.go @@ -210,14 +210,57 @@ func writeEnum(fw *common.MatlabFileWriter, enum *dsl.EnumDefinition, namedType common.WriteBlockBody(w, func() { for _, value := range enum.Values { common.WriteComment(w, value.Comment) - fmt.Fprintf(w, "function e = %s\n", common.EnumValueIdentifierName(value.Symbol)) + fmt.Fprintf(w, "function v = %s\n", common.EnumValueIdentifierName(value.Symbol)) common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "e = %s(%d);\n", common.TypeSyntax(enum, enum.Namespace), &value.IntegerValue) + fmt.Fprintf(w, "v = %s(%d);\n", common.TypeSyntax(enum, enum.Namespace), &value.IntegerValue) }) } w.WriteStringln("") writeZerosStaticMethod(w, common.TypeSyntax(enum, enum.Namespace), []string{"0"}) }) + + if enum.IsFlags { + // Additional methods for flag checks + w.WriteStringln("") + w.WriteStringln("methods") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "function self = %s(varargin)\n", enumName) + common.WriteBlockBody(w, func() { + w.WriteStringln("if nargin == 0") + w.Indented(func() { + w.WriteStringln("value = 0;") + }) + w.WriteStringln("elseif nargin == 1") + w.Indented(func() { + w.WriteStringln("value = varargin{1};") + }) + w.WriteStringln("else") + common.WriteBlockBody(w, func() { + w.WriteStringln("value = 0;") + w.WriteStringln("for i = 1:nargin") + common.WriteBlockBody(w, func() { + w.WriteStringln("value = bitor(value, varargin{i});") + }) + }) + fmt.Fprintf(w, "self@%s(value);\n", base) + }) + w.WriteStringln("") + w.WriteStringln("function res = has_flags(self, flag)") + common.WriteBlockBody(w, func() { + w.WriteStringln("res = bitand(self, flag) == flag;") + }) + w.WriteStringln("") + w.WriteStringln("function res = with_flags(self, flag)") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "res = %s(bitor(self, flag));\n", common.TypeSyntax(enum, enum.Namespace)) + }) + w.WriteStringln("") + w.WriteStringln("function res = without_flags(self, flag)") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "res = %s(bitand(self, bitcmp(flag)));\n", common.TypeSyntax(enum, enum.Namespace)) + }) + }) + } }) }) } From 684ec671d6b3ea4bb330739e516265023b7216f9 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Mon, 6 May 2024 17:01:57 +0000 Subject: [PATCH 24/32] Fix MATLAB nd-arrays with singleton dimensions --- cpp/test/generated/binary/protocols.cc | 62 ++++ cpp/test/generated/binary/protocols.h | 47 +++ cpp/test/generated/factories.cc | 28 ++ cpp/test/generated/hdf5/protocols.cc | 108 +++++++ cpp/test/generated/hdf5/protocols.h | 41 +++ cpp/test/generated/mocks.cc | 143 +++++++++ cpp/test/generated/model.json | 61 ++++ cpp/test/generated/ndjson/protocols.cc | 28 ++ cpp/test/generated/ndjson/protocols.h | 38 +++ cpp/test/generated/protocols.cc | 282 ++++++++++++++++++ cpp/test/generated/protocols.h | 92 ++++++ cpp/test/generated/translator_impl.cc | 11 + .../+test_model/+binary/MultiDArraysReader.m | 36 +++ .../+test_model/+binary/MultiDArraysWriter.m | 28 ++ .../+testing/MockMultiDArraysWriter.m | 77 +++++ .../+testing/TestMultiDArraysWriter.m | 76 +++++ .../+test_model/MultiDArraysReaderBase.m | 107 +++++++ .../+test_model/MultiDArraysWriterBase.m | 90 ++++++ matlab/test/RoundTripTest.m | 22 ++ models/test/unittests.yml | 7 + python/test_model/__init__.py | 6 + python/test_model/binary.py | 29 ++ python/test_model/ndjson.py | 39 +++ python/test_model/protocols.py | 167 +++++++++++ .../+binary/FixedNDArraySerializer.m | 6 +- .../static_files/+binary/NDArraySerializer.m | 8 +- .../+binary/NDArraySerializerBase.m | 10 +- 27 files changed, 1639 insertions(+), 10 deletions(-) create mode 100644 matlab/generated/+test_model/+binary/MultiDArraysReader.m create mode 100644 matlab/generated/+test_model/+binary/MultiDArraysWriter.m create mode 100644 matlab/generated/+test_model/+testing/MockMultiDArraysWriter.m create mode 100644 matlab/generated/+test_model/+testing/TestMultiDArraysWriter.m create mode 100644 matlab/generated/+test_model/MultiDArraysReaderBase.m create mode 100644 matlab/generated/+test_model/MultiDArraysWriterBase.m diff --git a/cpp/test/generated/binary/protocols.cc b/cpp/test/generated/binary/protocols.cc index 52603b1b..75a664d2 100644 --- a/cpp/test/generated/binary/protocols.cc +++ b/cpp/test/generated/binary/protocols.cc @@ -3472,6 +3472,68 @@ void DynamicNDArraysReader::CloseImpl() { stream_.VerifyFinished(); } +void MultiDArraysWriter::WriteImagesImpl(yardl::NDArray const& value) { + yardl::binary::WriteBlock, yardl::binary::WriteNDArray>(stream_, value); +} + +void MultiDArraysWriter::WriteImagesImpl(std::vector> const& values) { + if (!values.empty()) { + yardl::binary::WriteVector, yardl::binary::WriteNDArray>(stream_, values); + } +} + +void MultiDArraysWriter::EndImagesImpl() { + yardl::binary::WriteInteger(stream_, 0U); +} + +void MultiDArraysWriter::WriteFramesImpl(yardl::FixedNDArray const& value) { + yardl::binary::WriteBlock, yardl::binary::WriteFixedNDArray>(stream_, value); +} + +void MultiDArraysWriter::WriteFramesImpl(std::vector> const& values) { + if (!values.empty()) { + yardl::binary::WriteVector, yardl::binary::WriteFixedNDArray>(stream_, values); + } +} + +void MultiDArraysWriter::EndFramesImpl() { + yardl::binary::WriteInteger(stream_, 0U); +} + +void MultiDArraysWriter::Flush() { + stream_.Flush(); +} + +void MultiDArraysWriter::CloseImpl() { + stream_.Flush(); +} + +bool MultiDArraysReader::ReadImagesImpl(yardl::NDArray& value) { + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadNDArray>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool MultiDArraysReader::ReadImagesImpl(std::vector>& values) { + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadNDArray>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +bool MultiDArraysReader::ReadFramesImpl(yardl::FixedNDArray& value) { + bool read_block_successful = false; + read_block_successful = yardl::binary::ReadBlock, yardl::binary::ReadFixedNDArray>(stream_, current_block_remaining_, value); + return read_block_successful; +} + +bool MultiDArraysReader::ReadFramesImpl(std::vector>& values) { + yardl::binary::ReadBlocksIntoVector, yardl::binary::ReadFixedNDArray>(stream_, current_block_remaining_, values); + return current_block_remaining_ != 0; +} + +void MultiDArraysReader::CloseImpl() { + stream_.VerifyFinished(); +} + void MapsWriter::WriteStringToIntImpl(std::unordered_map const& value) { yardl::binary::WriteMap(stream_, value); } diff --git a/cpp/test/generated/binary/protocols.h b/cpp/test/generated/binary/protocols.h index cd5ca2c4..e088180b 100644 --- a/cpp/test/generated/binary/protocols.h +++ b/cpp/test/generated/binary/protocols.h @@ -858,6 +858,53 @@ class DynamicNDArraysReader : public test_model::DynamicNDArraysReaderBase, yard Version version_; }; +// Binary writer for the MultiDArrays protocol. +class MultiDArraysWriter : public test_model::MultiDArraysWriterBase, yardl::binary::BinaryWriter { + public: + MultiDArraysWriter(std::ostream& stream, Version version = Version::Current) + : yardl::binary::BinaryWriter(stream, test_model::MultiDArraysWriterBase::SchemaFromVersion(version)), version_(version) {} + + MultiDArraysWriter(std::string file_name, Version version = Version::Current) + : yardl::binary::BinaryWriter(file_name, test_model::MultiDArraysWriterBase::SchemaFromVersion(version)), version_(version) {} + + void Flush() override; + + protected: + void WriteImagesImpl(yardl::NDArray const& value) override; + void WriteImagesImpl(std::vector> const& values) override; + void EndImagesImpl() override; + void WriteFramesImpl(yardl::FixedNDArray const& value) override; + void WriteFramesImpl(std::vector> const& values) override; + void EndFramesImpl() override; + void CloseImpl() override; + + Version version_; +}; + +// Binary reader for the MultiDArrays protocol. +class MultiDArraysReader : public test_model::MultiDArraysReaderBase, yardl::binary::BinaryReader { + public: + MultiDArraysReader(std::istream& stream) + : yardl::binary::BinaryReader(stream), version_(test_model::MultiDArraysReaderBase::VersionFromSchema(schema_read_)) {} + + MultiDArraysReader(std::string file_name) + : yardl::binary::BinaryReader(file_name), version_(test_model::MultiDArraysReaderBase::VersionFromSchema(schema_read_)) {} + + Version GetVersion() { return version_; } + + protected: + bool ReadImagesImpl(yardl::NDArray& value) override; + bool ReadImagesImpl(std::vector>& values) override; + bool ReadFramesImpl(yardl::FixedNDArray& value) override; + bool ReadFramesImpl(std::vector>& values) override; + void CloseImpl() override; + + Version version_; + + private: + size_t current_block_remaining_ = 0; +}; + // Binary writer for the Maps protocol. class MapsWriter : public test_model::MapsWriterBase, yardl::binary::BinaryWriter { public: diff --git a/cpp/test/generated/factories.cc b/cpp/test/generated/factories.cc index cc5a2367..2f94b6ee 100644 --- a/cpp/test/generated/factories.cc +++ b/cpp/test/generated/factories.cc @@ -567,6 +567,34 @@ std::unique_ptr CreateReader +std::unique_ptr CreateWriter(Format format, std::string const& filename) { + switch (format) { + case Format::kHdf5: + return std::make_unique(filename); + case Format::kBinary: + return std::make_unique(filename); + case Format::kNDJson: + return std::make_unique(filename); + default: + throw std::runtime_error("Unknown format"); + } +} + +template<> +std::unique_ptr CreateReader(Format format, std::string const& filename) { + switch (format) { + case Format::kHdf5: + return std::make_unique(filename); + case Format::kBinary: + return std::make_unique(filename); + case Format::kNDJson: + return std::make_unique(filename); + default: + throw std::runtime_error("Unknown format"); + } +} + template<> std::unique_ptr CreateWriter(Format format, std::string const& filename) { switch (format) { diff --git a/cpp/test/generated/hdf5/protocols.cc b/cpp/test/generated/hdf5/protocols.cc index 3fbc74b8..6723854c 100644 --- a/cpp/test/generated/hdf5/protocols.cc +++ b/cpp/test/generated/hdf5/protocols.cc @@ -2591,6 +2591,114 @@ void DynamicNDArraysReader::ReadRecordWithDynamicNDArraysImpl(test_model::Record yardl::hdf5::ReadScalarDataset(group_, "recordWithDynamicNDArrays", test_model::hdf5::GetRecordWithDynamicNDArraysHdf5Ddl(), value); } +MultiDArraysWriter::MultiDArraysWriter(std::string path) + : yardl::hdf5::Hdf5Writer::Hdf5Writer(path, "MultiDArrays", schema_) { +} + +void MultiDArraysWriter::WriteImagesImpl(yardl::NDArray const& value) { + if (!images_dataset_state_) { + images_dataset_state_ = std::make_unique(group_, "images", yardl::hdf5::NDArrayDdl(H5::PredType::NATIVE_FLOAT), std::max(sizeof(yardl::hdf5::InnerNdArray), sizeof(yardl::NDArray))); + } + + images_dataset_state_->Append, yardl::NDArray>(value); +} + +void MultiDArraysWriter::WriteImagesImpl(std::vector> const& values) { + if (!images_dataset_state_) { + images_dataset_state_ = std::make_unique(group_, "images", yardl::hdf5::NDArrayDdl(H5::PredType::NATIVE_FLOAT), std::max(sizeof(yardl::hdf5::InnerNdArray), sizeof(yardl::NDArray))); + } + + images_dataset_state_->AppendBatch, yardl::NDArray>(values); +} + +void MultiDArraysWriter::EndImagesImpl() { + if (!images_dataset_state_) { + images_dataset_state_ = std::make_unique(group_, "images", yardl::hdf5::NDArrayDdl(H5::PredType::NATIVE_FLOAT), std::max(sizeof(yardl::hdf5::InnerNdArray), sizeof(yardl::NDArray))); + } + + images_dataset_state_.reset(); +} + +void MultiDArraysWriter::WriteFramesImpl(yardl::FixedNDArray const& value) { + if (!frames_dataset_state_) { + frames_dataset_state_ = std::make_unique(group_, "frames", yardl::hdf5::FixedNDArrayDdl(H5::PredType::NATIVE_FLOAT, {1, 1, 64, 32}), 0); + } + + frames_dataset_state_->Append, yardl::FixedNDArray>(value); +} + +void MultiDArraysWriter::WriteFramesImpl(std::vector> const& values) { + if (!frames_dataset_state_) { + frames_dataset_state_ = std::make_unique(group_, "frames", yardl::hdf5::FixedNDArrayDdl(H5::PredType::NATIVE_FLOAT, {1, 1, 64, 32}), 0); + } + + frames_dataset_state_->AppendBatch, yardl::FixedNDArray>(values); +} + +void MultiDArraysWriter::EndFramesImpl() { + if (!frames_dataset_state_) { + frames_dataset_state_ = std::make_unique(group_, "frames", yardl::hdf5::FixedNDArrayDdl(H5::PredType::NATIVE_FLOAT, {1, 1, 64, 32}), 0); + } + + frames_dataset_state_.reset(); +} + +MultiDArraysReader::MultiDArraysReader(std::string path) + : yardl::hdf5::Hdf5Reader::Hdf5Reader(path, "MultiDArrays", schema_) { +} + +bool MultiDArraysReader::ReadImagesImpl(yardl::NDArray& value) { + if (!images_dataset_state_) { + images_dataset_state_ = std::make_unique(group_, "images", yardl::hdf5::NDArrayDdl(H5::PredType::NATIVE_FLOAT), std::max(sizeof(yardl::hdf5::InnerNdArray), sizeof(yardl::NDArray))); + } + + bool has_value = images_dataset_state_->Read, yardl::NDArray>(value); + if (!has_value) { + images_dataset_state_.reset(); + } + + return has_value; +} + +bool MultiDArraysReader::ReadImagesImpl(std::vector>& values) { + if (!images_dataset_state_) { + images_dataset_state_ = std::make_unique(group_, "images", yardl::hdf5::NDArrayDdl(H5::PredType::NATIVE_FLOAT)); + } + + bool has_more = images_dataset_state_->ReadBatch, yardl::NDArray>(values); + if (!has_more) { + images_dataset_state_.reset(); + } + + return has_more; +} + +bool MultiDArraysReader::ReadFramesImpl(yardl::FixedNDArray& value) { + if (!frames_dataset_state_) { + frames_dataset_state_ = std::make_unique(group_, "frames", yardl::hdf5::FixedNDArrayDdl(H5::PredType::NATIVE_FLOAT, {1, 1, 64, 32}), 0); + } + + bool has_value = frames_dataset_state_->Read, yardl::FixedNDArray>(value); + if (!has_value) { + frames_dataset_state_.reset(); + } + + return has_value; +} + +bool MultiDArraysReader::ReadFramesImpl(std::vector>& values) { + if (!frames_dataset_state_) { + frames_dataset_state_ = std::make_unique(group_, "frames", yardl::hdf5::FixedNDArrayDdl(H5::PredType::NATIVE_FLOAT, {1, 1, 64, 32})); + } + + bool has_more = frames_dataset_state_->ReadBatch, yardl::FixedNDArray>(values); + if (!has_more) { + frames_dataset_state_.reset(); + } + + return has_more; +} + MapsWriter::MapsWriter(std::string path) : yardl::hdf5::Hdf5Writer::Hdf5Writer(path, "Maps", schema_) { } diff --git a/cpp/test/generated/hdf5/protocols.h b/cpp/test/generated/hdf5/protocols.h index 15988c68..29abd127 100644 --- a/cpp/test/generated/hdf5/protocols.h +++ b/cpp/test/generated/hdf5/protocols.h @@ -659,6 +659,47 @@ class DynamicNDArraysReader : public test_model::DynamicNDArraysReaderBase, publ private: }; +// HDF5 writer for the MultiDArrays protocol. +class MultiDArraysWriter : public test_model::MultiDArraysWriterBase, public yardl::hdf5::Hdf5Writer { + public: + MultiDArraysWriter(std::string path); + + protected: + void WriteImagesImpl(yardl::NDArray const& value) override; + + void WriteImagesImpl(std::vector> const& values) override; + + void EndImagesImpl() override; + + void WriteFramesImpl(yardl::FixedNDArray const& value) override; + + void WriteFramesImpl(std::vector> const& values) override; + + void EndFramesImpl() override; + + private: + std::unique_ptr images_dataset_state_; + std::unique_ptr frames_dataset_state_; +}; + +// HDF5 reader for the MultiDArrays protocol. +class MultiDArraysReader : public test_model::MultiDArraysReaderBase, public yardl::hdf5::Hdf5Reader { + public: + MultiDArraysReader(std::string path); + + bool ReadImagesImpl(yardl::NDArray& value) override; + + bool ReadImagesImpl(std::vector>& values) override; + + bool ReadFramesImpl(yardl::FixedNDArray& value) override; + + bool ReadFramesImpl(std::vector>& values) override; + + private: + std::unique_ptr images_dataset_state_; + std::unique_ptr frames_dataset_state_; +}; + // HDF5 writer for the Maps protocol. class MapsWriter : public test_model::MapsWriterBase, public yardl::hdf5::Hdf5Writer { public: diff --git a/cpp/test/generated/mocks.cc b/cpp/test/generated/mocks.cc index 1afea04e..7234b5ed 100644 --- a/cpp/test/generated/mocks.cc +++ b/cpp/test/generated/mocks.cc @@ -2311,6 +2311,141 @@ class TestDynamicNDArraysWriterBase : public DynamicNDArraysWriterBase { bool close_called_ = false; }; +class MockMultiDArraysWriter : public MultiDArraysWriterBase { + public: + void WriteImagesImpl (yardl::NDArray const& value) override { + if (WriteImagesImpl_expected_values_.empty()) { + throw std::runtime_error("Unexpected call to WriteImagesImpl"); + } + if (WriteImagesImpl_expected_values_.front() != value) { + throw std::runtime_error("Unexpected argument value for call to WriteImagesImpl"); + } + WriteImagesImpl_expected_values_.pop(); + } + + std::queue> WriteImagesImpl_expected_values_; + + void ExpectWriteImagesImpl (yardl::NDArray const& value) { + WriteImagesImpl_expected_values_.push(value); + } + + void EndImagesImpl () override { + if (--EndImagesImpl_expected_call_count_ < 0) { + throw std::runtime_error("Unexpected call to EndImagesImpl"); + } + } + + int EndImagesImpl_expected_call_count_ = 0; + + void ExpectEndImagesImpl () { + EndImagesImpl_expected_call_count_++; + } + + void WriteFramesImpl (yardl::FixedNDArray const& value) override { + if (WriteFramesImpl_expected_values_.empty()) { + throw std::runtime_error("Unexpected call to WriteFramesImpl"); + } + if (WriteFramesImpl_expected_values_.front() != value) { + throw std::runtime_error("Unexpected argument value for call to WriteFramesImpl"); + } + WriteFramesImpl_expected_values_.pop(); + } + + std::queue> WriteFramesImpl_expected_values_; + + void ExpectWriteFramesImpl (yardl::FixedNDArray const& value) { + WriteFramesImpl_expected_values_.push(value); + } + + void EndFramesImpl () override { + if (--EndFramesImpl_expected_call_count_ < 0) { + throw std::runtime_error("Unexpected call to EndFramesImpl"); + } + } + + int EndFramesImpl_expected_call_count_ = 0; + + void ExpectEndFramesImpl () { + EndFramesImpl_expected_call_count_++; + } + + void Verify() { + if (!WriteImagesImpl_expected_values_.empty()) { + throw std::runtime_error("Expected call to WriteImagesImpl was not received"); + } + if (EndImagesImpl_expected_call_count_ > 0) { + throw std::runtime_error("Expected call to EndImagesImpl was not received"); + } + if (!WriteFramesImpl_expected_values_.empty()) { + throw std::runtime_error("Expected call to WriteFramesImpl was not received"); + } + if (EndFramesImpl_expected_call_count_ > 0) { + throw std::runtime_error("Expected call to EndFramesImpl was not received"); + } + } +}; + +class TestMultiDArraysWriterBase : public MultiDArraysWriterBase { + public: + TestMultiDArraysWriterBase(std::unique_ptr writer, std::function()> create_reader) : writer_(std::move(writer)), create_reader_(create_reader) { + } + + ~TestMultiDArraysWriterBase() { + if (!close_called_ && !std::uncaught_exceptions()) { + ADD_FAILURE() << "Close() needs to be called on 'TestMultiDArraysWriterBase' to verify mocks"; + } + } + + protected: + void WriteImagesImpl(yardl::NDArray const& value) override { + writer_->WriteImages(value); + mock_writer_.ExpectWriteImagesImpl(value); + } + + void WriteImagesImpl(std::vector> const& values) override { + writer_->WriteImages(values); + for (auto const& v : values) { + mock_writer_.ExpectWriteImagesImpl(v); + } + } + + void EndImagesImpl() override { + writer_->EndImages(); + mock_writer_.ExpectEndImagesImpl(); + } + + void WriteFramesImpl(yardl::FixedNDArray const& value) override { + writer_->WriteFrames(value); + mock_writer_.ExpectWriteFramesImpl(value); + } + + void WriteFramesImpl(std::vector> const& values) override { + writer_->WriteFrames(values); + for (auto const& v : values) { + mock_writer_.ExpectWriteFramesImpl(v); + } + } + + void EndFramesImpl() override { + writer_->EndFrames(); + mock_writer_.ExpectEndFramesImpl(); + } + + void CloseImpl() override { + close_called_ = true; + writer_->Close(); + std::unique_ptr reader = create_reader_(); + reader->CopyTo(mock_writer_, 2, 1); + mock_writer_.Verify(); + } + + private: + std::unique_ptr writer_; + std::function()> create_reader_; + MockMultiDArraysWriter mock_writer_; + bool close_called_ = false; +}; + class MockMapsWriter : public MapsWriterBase { public: void WriteStringToIntImpl (std::unordered_map const& value) override { @@ -4268,6 +4403,14 @@ std::unique_ptr CreateValidatingWriter +std::unique_ptr CreateValidatingWriter(Format format, std::string const& filename) { + return std::make_unique( + CreateWriter(format, filename), + [format, filename](){ return CreateReader(format, filename);} + ); +} + template<> std::unique_ptr CreateValidatingWriter(Format format, std::string const& filename) { return std::make_unique( diff --git a/cpp/test/generated/model.json b/cpp/test/generated/model.json index bd5df2a0..047e650a 100644 --- a/cpp/test/generated/model.json +++ b/cpp/test/generated/model.json @@ -4719,6 +4719,67 @@ } ] }, + { + "name": "MultiDArrays", + "sequence": [ + { + "name": "images", + "type": { + "stream": { + "items": { + "array": { + "items": "float32", + "dimensions": [ + { + "name": "ch" + }, + { + "name": "z" + }, + { + "name": "y" + }, + { + "name": "x" + } + ] + } + } + } + } + }, + { + "name": "frames", + "type": { + "stream": { + "items": { + "array": { + "items": "float32", + "dimensions": [ + { + "name": "ch", + "length": 1 + }, + { + "name": "z", + "length": 1 + }, + { + "name": "y", + "length": 64 + }, + { + "name": "x", + "length": 32 + } + ] + } + } + } + } + } + ] + }, { "name": "Maps", "sequence": [ diff --git a/cpp/test/generated/ndjson/protocols.cc b/cpp/test/generated/ndjson/protocols.cc index 9e6c84dc..2d3ad6de 100644 --- a/cpp/test/generated/ndjson/protocols.cc +++ b/cpp/test/generated/ndjson/protocols.cc @@ -3263,6 +3263,34 @@ void DynamicNDArraysReader::CloseImpl() { VerifyFinished(); } +void MultiDArraysWriter::WriteImagesImpl(yardl::NDArray const& value) { + ordered_json json_value = value; + yardl::ndjson::WriteProtocolValue(stream_, "images", json_value);} + +void MultiDArraysWriter::WriteFramesImpl(yardl::FixedNDArray const& value) { + ordered_json json_value = value; + yardl::ndjson::WriteProtocolValue(stream_, "frames", json_value);} + +void MultiDArraysWriter::Flush() { + stream_.flush(); +} + +void MultiDArraysWriter::CloseImpl() { + stream_.flush(); +} + +bool MultiDArraysReader::ReadImagesImpl(yardl::NDArray& value) { + return yardl::ndjson::ReadProtocolValue(stream_, line_, "images", false, unused_step_, value); +} + +bool MultiDArraysReader::ReadFramesImpl(yardl::FixedNDArray& value) { + return yardl::ndjson::ReadProtocolValue(stream_, line_, "frames", false, unused_step_, value); +} + +void MultiDArraysReader::CloseImpl() { + VerifyFinished(); +} + void MapsWriter::WriteStringToIntImpl(std::unordered_map const& value) { ordered_json json_value = value; yardl::ndjson::WriteProtocolValue(stream_, "stringToInt", json_value);} diff --git a/cpp/test/generated/ndjson/protocols.h b/cpp/test/generated/ndjson/protocols.h index 72ad96ac..d1b50b62 100644 --- a/cpp/test/generated/ndjson/protocols.h +++ b/cpp/test/generated/ndjson/protocols.h @@ -777,6 +777,44 @@ class DynamicNDArraysReader : public test_model::DynamicNDArraysReaderBase, yard void CloseImpl() override; }; +// NDJSON writer for the MultiDArrays protocol. +class MultiDArraysWriter : public test_model::MultiDArraysWriterBase, yardl::ndjson::NDJsonWriter { + public: + MultiDArraysWriter(std::ostream& stream) + : yardl::ndjson::NDJsonWriter(stream, schema_) { + } + + MultiDArraysWriter(std::string file_name) + : yardl::ndjson::NDJsonWriter(file_name, schema_) { + } + + void Flush() override; + + protected: + void WriteImagesImpl(yardl::NDArray const& value) override; + void EndImagesImpl() override {} + void WriteFramesImpl(yardl::FixedNDArray const& value) override; + void EndFramesImpl() override {} + void CloseImpl() override; +}; + +// NDJSON reader for the MultiDArrays protocol. +class MultiDArraysReader : public test_model::MultiDArraysReaderBase, yardl::ndjson::NDJsonReader { + public: + MultiDArraysReader(std::istream& stream) + : yardl::ndjson::NDJsonReader(stream, schema_) { + } + + MultiDArraysReader(std::string file_name) + : yardl::ndjson::NDJsonReader(file_name, schema_) { + } + + protected: + bool ReadImagesImpl(yardl::NDArray& value) override; + bool ReadFramesImpl(yardl::FixedNDArray& value) override; + void CloseImpl() override; +}; + // NDJSON writer for the Maps protocol. class MapsWriter : public test_model::MapsWriterBase, yardl::ndjson::NDJsonWriter { public: diff --git a/cpp/test/generated/protocols.cc b/cpp/test/generated/protocols.cc index b4e6f4a0..cff90358 100644 --- a/cpp/test/generated/protocols.cc +++ b/cpp/test/generated/protocols.cc @@ -3593,6 +3593,288 @@ void DynamicNDArraysReaderBase::CopyTo(DynamicNDArraysWriterBase& writer) { } } +namespace { +void MultiDArraysWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { + std::string expected_method; + switch (current) { + case 0: expected_method = "WriteImages() or EndImages()"; break; + case 1: expected_method = "WriteFrames() or EndFrames()"; break; + } + std::string attempted_method; + switch (attempted) { + case 0: attempted_method = end ? "EndImages()" : "WriteImages()"; break; + case 1: attempted_method = end ? "EndFrames()" : "WriteFrames()"; break; + case 2: attempted_method = "Close()"; break; + } + throw std::runtime_error("Expected call to " + expected_method + " but received call to " + attempted_method + " instead."); +} + +void MultiDArraysReaderBaseInvalidState(uint8_t attempted, uint8_t current) { + auto f = [](uint8_t i) -> std::string { + switch (i/2) { + case 0: return "ReadImages()"; + case 1: return "ReadFrames()"; + case 2: return "Close()"; + default: return ""; + } + }; + throw std::runtime_error("Expected call to " + f(current) + " but received call to " + f(attempted) + " instead."); +} + +} // namespace + +std::string MultiDArraysWriterBase::schema_ = R"({"protocol":{"name":"MultiDArrays","sequence":[{"name":"images","type":{"stream":{"items":{"array":{"items":"float32","dimensions":[{"name":"ch"},{"name":"z"},{"name":"y"},{"name":"x"}]}}}}},{"name":"frames","type":{"stream":{"items":{"array":{"items":"float32","dimensions":[{"name":"ch","length":1},{"name":"z","length":1},{"name":"y","length":64},{"name":"x","length":32}]}}}}}]},"types":null})"; + +std::vector MultiDArraysWriterBase::previous_schemas_ = { +}; + +std::string MultiDArraysWriterBase::SchemaFromVersion(Version version) { + switch (version) { + case Version::Current: return MultiDArraysWriterBase::schema_; break; + default: throw std::runtime_error("The version does not correspond to any schema supported by protocol MultiDArrays."); + } + +} +void MultiDArraysWriterBase::WriteImages(yardl::NDArray const& value) { + if (unlikely(state_ != 0)) { + MultiDArraysWriterBaseInvalidState(0, false, state_); + } + + WriteImagesImpl(value); +} + +void MultiDArraysWriterBase::WriteImages(std::vector> const& values) { + if (unlikely(state_ != 0)) { + MultiDArraysWriterBaseInvalidState(0, false, state_); + } + + WriteImagesImpl(values); +} + +void MultiDArraysWriterBase::EndImages() { + if (unlikely(state_ != 0)) { + MultiDArraysWriterBaseInvalidState(0, true, state_); + } + + EndImagesImpl(); + state_ = 1; +} + +// fallback implementation +void MultiDArraysWriterBase::WriteImagesImpl(std::vector> const& values) { + for (auto const& v : values) { + WriteImagesImpl(v); + } +} + +void MultiDArraysWriterBase::WriteFrames(yardl::FixedNDArray const& value) { + if (unlikely(state_ != 1)) { + MultiDArraysWriterBaseInvalidState(1, false, state_); + } + + WriteFramesImpl(value); +} + +void MultiDArraysWriterBase::WriteFrames(std::vector> const& values) { + if (unlikely(state_ != 1)) { + MultiDArraysWriterBaseInvalidState(1, false, state_); + } + + WriteFramesImpl(values); +} + +void MultiDArraysWriterBase::EndFrames() { + if (unlikely(state_ != 1)) { + MultiDArraysWriterBaseInvalidState(1, true, state_); + } + + EndFramesImpl(); + state_ = 2; +} + +// fallback implementation +void MultiDArraysWriterBase::WriteFramesImpl(std::vector> const& values) { + for (auto const& v : values) { + WriteFramesImpl(v); + } +} + +void MultiDArraysWriterBase::Close() { + if (unlikely(state_ != 2)) { + MultiDArraysWriterBaseInvalidState(2, false, state_); + } + + CloseImpl(); +} + +std::string MultiDArraysReaderBase::schema_ = MultiDArraysWriterBase::schema_; + +std::vector MultiDArraysReaderBase::previous_schemas_ = MultiDArraysWriterBase::previous_schemas_; + +Version MultiDArraysReaderBase::VersionFromSchema(std::string const& schema) { + if (schema == MultiDArraysWriterBase::schema_) { + return Version::Current; + } + throw std::runtime_error("The schema does not match any version supported by protocol MultiDArrays."); +} +bool MultiDArraysReaderBase::ReadImages(yardl::NDArray& value) { + if (unlikely(state_ != 0)) { + if (state_ == 1) { + state_ = 2; + return false; + } + MultiDArraysReaderBaseInvalidState(0, state_); + } + + bool result = ReadImagesImpl(value); + if (!result) { + state_ = 2; + } + return result; +} + +bool MultiDArraysReaderBase::ReadImages(std::vector>& values) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (unlikely(state_ != 0)) { + if (state_ == 1) { + state_ = 2; + values.clear(); + return false; + } + MultiDArraysReaderBaseInvalidState(0, state_); + } + + if (!ReadImagesImpl(values)) { + state_ = 1; + return values.size() > 0; + } + return true; +} + +// fallback implementation +bool MultiDArraysReaderBase::ReadImagesImpl(std::vector>& values) { + size_t i = 0; + while (true) { + if (i == values.size()) { + values.resize(i + 1); + } + if (!ReadImagesImpl(values[i])) { + values.resize(i); + return false; + } + i++; + if (i == values.capacity()) { + return true; + } + } +} + +bool MultiDArraysReaderBase::ReadFrames(yardl::FixedNDArray& value) { + if (unlikely(state_ != 2)) { + if (state_ == 3) { + state_ = 4; + return false; + } + if (state_ == 1) { + state_ = 2; + } else { + MultiDArraysReaderBaseInvalidState(2, state_); + } + } + + bool result = ReadFramesImpl(value); + if (!result) { + state_ = 4; + } + return result; +} + +bool MultiDArraysReaderBase::ReadFrames(std::vector>& values) { + if (values.capacity() == 0) { + throw std::runtime_error("vector must have a nonzero capacity."); + } + if (unlikely(state_ != 2)) { + if (state_ == 3) { + state_ = 4; + values.clear(); + return false; + } + if (state_ == 1) { + state_ = 2; + } else { + MultiDArraysReaderBaseInvalidState(2, state_); + } + } + + if (!ReadFramesImpl(values)) { + state_ = 3; + return values.size() > 0; + } + return true; +} + +// fallback implementation +bool MultiDArraysReaderBase::ReadFramesImpl(std::vector>& values) { + size_t i = 0; + while (true) { + if (i == values.size()) { + values.resize(i + 1); + } + if (!ReadFramesImpl(values[i])) { + values.resize(i); + return false; + } + i++; + if (i == values.capacity()) { + return true; + } + } +} + +void MultiDArraysReaderBase::Close() { + if (unlikely(state_ != 4)) { + if (state_ == 3) { + state_ = 4; + } else { + MultiDArraysReaderBaseInvalidState(4, state_); + } + } + + CloseImpl(); +} +void MultiDArraysReaderBase::CopyTo(MultiDArraysWriterBase& writer, size_t images_buffer_size, size_t frames_buffer_size) { + if (images_buffer_size > 1) { + std::vector> values; + values.reserve(images_buffer_size); + while(ReadImages(values)) { + writer.WriteImages(values); + } + writer.EndImages(); + } else { + yardl::NDArray value; + while(ReadImages(value)) { + writer.WriteImages(value); + } + writer.EndImages(); + } + if (frames_buffer_size > 1) { + std::vector> values; + values.reserve(frames_buffer_size); + while(ReadFrames(values)) { + writer.WriteFrames(values); + } + writer.EndFrames(); + } else { + yardl::FixedNDArray value; + while(ReadFrames(value)) { + writer.WriteFrames(value); + } + writer.EndFrames(); + } +} + namespace { void MapsWriterBaseInvalidState(uint8_t attempted, [[maybe_unused]] bool end, uint8_t current) { std::string expected_method; diff --git a/cpp/test/generated/protocols.h b/cpp/test/generated/protocols.h index ebea114d..f3decd7c 100644 --- a/cpp/test/generated/protocols.h +++ b/cpp/test/generated/protocols.h @@ -1563,6 +1563,98 @@ class DynamicNDArraysReaderBase { uint8_t state_ = 0; }; +// Abstract writer for the MultiDArrays protocol. +class MultiDArraysWriterBase { + public: + // Ordinal 0. + // Call this method for each element of the `images` stream, then call `EndImages() when done.` + void WriteImages(yardl::NDArray const& value); + + // Ordinal 0. + // Call this method to write many values to the `images` stream, then call `EndImages()` when done. + void WriteImages(std::vector> const& values); + + // Marks the end of the `images` stream. + void EndImages(); + + // Ordinal 1. + // Call this method for each element of the `frames` stream, then call `EndFrames() when done.` + void WriteFrames(yardl::FixedNDArray const& value); + + // Ordinal 1. + // Call this method to write many values to the `frames` stream, then call `EndFrames()` when done. + void WriteFrames(std::vector> const& values); + + // Marks the end of the `frames` stream. + void EndFrames(); + + // Optionaly close this writer before destructing. Validates that all steps were completed. + void Close(); + + virtual ~MultiDArraysWriterBase() = default; + + // Flushes all buffered data. + virtual void Flush() {} + + protected: + virtual void WriteImagesImpl(yardl::NDArray const& value) = 0; + virtual void WriteImagesImpl(std::vector> const& value); + virtual void EndImagesImpl() = 0; + virtual void WriteFramesImpl(yardl::FixedNDArray const& value) = 0; + virtual void WriteFramesImpl(std::vector> const& value); + virtual void EndFramesImpl() = 0; + virtual void CloseImpl() {} + + static std::string schema_; + + static std::vector previous_schemas_; + + static std::string SchemaFromVersion(Version version); + + private: + uint8_t state_ = 0; + + friend class MultiDArraysReaderBase; +}; + +// Abstract reader for the MultiDArrays protocol. +class MultiDArraysReaderBase { + public: + // Ordinal 0. + [[nodiscard]] bool ReadImages(yardl::NDArray& value); + + // Ordinal 0. + [[nodiscard]] bool ReadImages(std::vector>& values); + + // Ordinal 1. + [[nodiscard]] bool ReadFrames(yardl::FixedNDArray& value); + + // Ordinal 1. + [[nodiscard]] bool ReadFrames(std::vector>& values); + + // Optionaly close this writer before destructing. Validates that all steps were completely read. + void Close(); + + void CopyTo(MultiDArraysWriterBase& writer, size_t images_buffer_size = 1, size_t frames_buffer_size = 1); + + virtual ~MultiDArraysReaderBase() = default; + + protected: + virtual bool ReadImagesImpl(yardl::NDArray& value) = 0; + virtual bool ReadImagesImpl(std::vector>& values); + virtual bool ReadFramesImpl(yardl::FixedNDArray& value) = 0; + virtual bool ReadFramesImpl(std::vector>& values); + virtual void CloseImpl() {} + static std::string schema_; + + static std::vector previous_schemas_; + + static Version VersionFromSchema(const std::string& schema); + + private: + uint8_t state_ = 0; +}; + // Abstract writer for the Maps protocol. class MapsWriterBase { public: diff --git a/cpp/test/generated/translator_impl.cc b/cpp/test/generated/translator_impl.cc index dee84daa..8fab9a21 100644 --- a/cpp/test/generated/translator_impl.cc +++ b/cpp/test/generated/translator_impl.cc @@ -238,6 +238,17 @@ void TranslateStream(std::string const& protocol_name, yardl::testing::Format in reader->CopyTo(*writer); return; } + if (protocol_name == "MultiDArrays") { + auto reader = input_format == yardl::testing::Format::kBinary + ? std::unique_ptr(new test_model::binary::MultiDArraysReader(input)) + : std::unique_ptr(new test_model::ndjson::MultiDArraysReader(input)); + + auto writer = output_format == yardl::testing::Format::kBinary + ? std::unique_ptr(new test_model::binary::MultiDArraysWriter(output)) + : std::unique_ptr(new test_model::ndjson::MultiDArraysWriter(output)); + reader->CopyTo(*writer); + return; + } if (protocol_name == "Maps") { auto reader = input_format == yardl::testing::Format::kBinary ? std::unique_ptr(new test_model::binary::MapsReader(input)) diff --git a/matlab/generated/+test_model/+binary/MultiDArraysReader.m b/matlab/generated/+test_model/+binary/MultiDArraysReader.m new file mode 100644 index 00000000..0bbb3409 --- /dev/null +++ b/matlab/generated/+test_model/+binary/MultiDArraysReader.m @@ -0,0 +1,36 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + +classdef MultiDArraysReader < yardl.binary.BinaryProtocolReader & test_model.MultiDArraysReaderBase + % Binary reader for the MultiDArrays protocol + properties (Access=protected) + images_serializer + frames_serializer + end + + methods + function self = MultiDArraysReader(filename) + self@test_model.MultiDArraysReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, test_model.MultiDArraysReaderBase.schema); + self.images_serializer = yardl.binary.StreamSerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 4)); + self.frames_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [32, 64, 1, 1])); + end + end + + methods (Access=protected) + function more = has_images_(self) + more = self.images_serializer.hasnext(self.stream_); + end + + function value = read_images_(self) + value = self.images_serializer.read(self.stream_); + end + + function more = has_frames_(self) + more = self.frames_serializer.hasnext(self.stream_); + end + + function value = read_frames_(self) + value = self.frames_serializer.read(self.stream_); + end + end +end diff --git a/matlab/generated/+test_model/+binary/MultiDArraysWriter.m b/matlab/generated/+test_model/+binary/MultiDArraysWriter.m new file mode 100644 index 00000000..40fd424e --- /dev/null +++ b/matlab/generated/+test_model/+binary/MultiDArraysWriter.m @@ -0,0 +1,28 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + +classdef MultiDArraysWriter < yardl.binary.BinaryProtocolWriter & test_model.MultiDArraysWriterBase + % Binary writer for the MultiDArrays protocol + properties (Access=protected) + images_serializer + frames_serializer + end + + methods + function self = MultiDArraysWriter(filename) + self@test_model.MultiDArraysWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, test_model.MultiDArraysWriterBase.schema); + self.images_serializer = yardl.binary.StreamSerializer(yardl.binary.NDArraySerializer(yardl.binary.Float32Serializer, 4)); + self.frames_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Float32Serializer, [32, 64, 1, 1])); + end + end + + methods (Access=protected) + function write_images_(self, value) + self.images_serializer.write(self.stream_, value); + end + + function write_frames_(self, value) + self.frames_serializer.write(self.stream_, value); + end + end +end diff --git a/matlab/generated/+test_model/+testing/MockMultiDArraysWriter.m b/matlab/generated/+test_model/+testing/MockMultiDArraysWriter.m new file mode 100644 index 00000000..1286c0df --- /dev/null +++ b/matlab/generated/+test_model/+testing/MockMultiDArraysWriter.m @@ -0,0 +1,77 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + +classdef MockMultiDArraysWriter < matlab.mixin.Copyable & test_model.MultiDArraysWriterBase + properties + testCase_ + expected_images + expected_frames + end + + methods + function self = MockMultiDArraysWriter(testCase) + self.testCase_ = testCase; + self.expected_images = {}; + self.expected_frames = {}; + end + + function expect_write_images_(self, value) + if iscell(value) + for n = 1:numel(value) + self.expected_images{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + self.expected_images{end+1} = value(index{:}, n); + end + end + + function expect_write_frames_(self, value) + if iscell(value) + for n = 1:numel(value) + self.expected_frames{end+1} = value{n}; + end + return; + end + shape = size(value); + lastDim = ndims(value); + count = shape(lastDim); + index = repelem({':'}, lastDim-1); + for n = 1:count + self.expected_frames{end+1} = value(index{:}, n); + end + end + + function verify(self) + self.testCase_.verifyTrue(isempty(self.expected_images), "Expected call to write_images_ was not received"); + self.testCase_.verifyTrue(isempty(self.expected_frames), "Expected call to write_frames_ was not received"); + end + end + + methods (Access=protected) + function write_images_(self, value) + assert(iscell(value)); + assert(isscalar(value)); + self.testCase_.verifyFalse(isempty(self.expected_images), "Unexpected call to write_images_"); + self.testCase_.verifyEqual(value{1}, self.expected_images{1}, "Unexpected argument value for call to write_images_"); + self.expected_images = self.expected_images(2:end); + end + + function write_frames_(self, value) + assert(iscell(value)); + assert(isscalar(value)); + self.testCase_.verifyFalse(isempty(self.expected_frames), "Unexpected call to write_frames_"); + self.testCase_.verifyEqual(value{1}, self.expected_frames{1}, "Unexpected argument value for call to write_frames_"); + self.expected_frames = self.expected_frames(2:end); + end + + function close_(self) + end + function end_stream_(self) + end + end +end diff --git a/matlab/generated/+test_model/+testing/TestMultiDArraysWriter.m b/matlab/generated/+test_model/+testing/TestMultiDArraysWriter.m new file mode 100644 index 00000000..7b1ada06 --- /dev/null +++ b/matlab/generated/+test_model/+testing/TestMultiDArraysWriter.m @@ -0,0 +1,76 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + +classdef TestMultiDArraysWriter < test_model.MultiDArraysWriterBase + properties (Access = private) + writer_ + create_reader_ + mock_writer_ + close_called_ + filename_ + format_ + end + + methods + function self = TestMultiDArraysWriter(testCase, format, create_writer, create_reader) + self.filename_ = tempname(); + self.format_ = format; + self.writer_ = create_writer(self.filename_); + self.create_reader_ = create_reader; + self.mock_writer_ = test_model.testing.MockMultiDArraysWriter(testCase); + self.close_called_ = false; + end + + function delete(self) + delete(self.filename_); + if ~self.close_called_ + % ADD_FAILURE() << ...; + throw(yardl.RuntimeError("Close() must be called on 'TestMultiDArraysWriter' to verify mocks")); + end + end + function end_images(self) + end_images@test_model.MultiDArraysWriterBase(self); + self.writer_.end_images(); + end + + function end_frames(self) + end_frames@test_model.MultiDArraysWriterBase(self); + self.writer_.end_frames(); + end + + end + + methods (Access=protected) + function write_images_(self, value) + self.writer_.write_images(value); + self.mock_writer_.expect_write_images_(value); + end + + function write_frames_(self, value) + self.writer_.write_frames(value); + self.mock_writer_.expect_write_frames_(value); + end + + function close_(self) + self.close_called_ = true; + self.writer_.close(); + mock_copy = copy(self.mock_writer_); + + reader = self.create_reader_(self.filename_); + reader.copy_to(self.mock_writer_); + reader.close(); + self.mock_writer_.verify(); + self.mock_writer_.close(); + + translated = invoke_translator(self.filename_, self.format_, self.format_); + reader = self.create_reader_(translated); + reader.copy_to(mock_copy); + reader.close(); + mock_copy.verify(); + mock_copy.close(); + delete(translated); + end + + function end_stream_(self) + end + end +end diff --git a/matlab/generated/+test_model/MultiDArraysReaderBase.m b/matlab/generated/+test_model/MultiDArraysReaderBase.m new file mode 100644 index 00000000..b6f4fe52 --- /dev/null +++ b/matlab/generated/+test_model/MultiDArraysReaderBase.m @@ -0,0 +1,107 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + +classdef MultiDArraysReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function self = MultiDArraysReaderBase() + self.state_ = 0; + end + + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function more = has_images(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); + end + + more = self.has_images_(); + if ~more + self.state_ = 1; + end + end + + function value = read_images(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); + end + + value = self.read_images_(); + end + + % Ordinal 1 + function more = has_frames(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); + end + + more = self.has_frames_(); + if ~more + self.state_ = 2; + end + end + + function value = read_frames(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); + end + + value = self.read_frames_(); + end + + function copy_to(self, writer) + while self.has_images() + item = self.read_images(); + writer.write_images({item}); + end + writer.end_images(); + while self.has_frames() + item = self.read_frames(); + writer.write_frames({item}); + end + writer.end_frames(); + end + end + + methods (Static) + function res = schema() + res = test_model.MultiDArraysWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + has_images_(self) + read_images_(self) + has_frames_(self) + read_frames_(self) + + close_(self) + end + + methods (Access=private) + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(self, state) + if state == 0 + name = "read_images"; + elseif state == 1 + name = "read_frames"; + else + name = ""; + end + end + end +end diff --git a/matlab/generated/+test_model/MultiDArraysWriterBase.m b/matlab/generated/+test_model/MultiDArraysWriterBase.m new file mode 100644 index 00000000..56d68085 --- /dev/null +++ b/matlab/generated/+test_model/MultiDArraysWriterBase.m @@ -0,0 +1,90 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + +% Abstract writer for protocol MultiDArrays +classdef (Abstract) MultiDArraysWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function self = MultiDArraysWriterBase() + self.state_ = 0; + end + + function close(self) + self.close_(); + if self.state_ ~= 2 + expected_method = self.state_to_method_name_(self.state_); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_images(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); + end + + self.write_images_(value); + end + + function end_images(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); + end + + self.end_stream_(); + self.state_ = 1; + end + + % Ordinal 1 + function write_frames(self, value) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); + end + + self.write_frames_(value); + end + + function end_frames(self) + if self.state_ ~= 1 + self.raise_unexpected_state_(1); + end + + self.end_stream_(); + self.state_ = 2; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"MultiDArrays","sequence":[{"name":"images","type":{"stream":{"items":{"array":{"items":"float32","dimensions":[{"name":"ch"},{"name":"z"},{"name":"y"},{"name":"x"}]}}}}},{"name":"frames","type":{"stream":{"items":{"array":{"items":"float32","dimensions":[{"name":"ch","length":1},{"name":"z","length":1},{"name":"y","length":64},{"name":"x","length":32}]}}}}}]},"types":null}'); + end + end + + methods (Abstract, Access=protected) + write_images_(self, value) + write_frames_(self, value) + + end_stream_(self) + close_(self) + end + + methods (Access=private) + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(self, state) + if state == 0 + name = "write_images or end_images"; + elseif state == 1 + name = "write_frames or end_frames"; + else + name = ''; + end + end + end +end diff --git a/matlab/test/RoundTripTest.m b/matlab/test/RoundTripTest.m index 6988f9df..c0558e32 100644 --- a/matlab/test/RoundTripTest.m +++ b/matlab/test/RoundTripTest.m @@ -257,6 +257,28 @@ function testDynamicNDArrays(testCase, format) w.close(); end + function testMultiDArrays(testCase, format) + % ch=8, z=2, y=64, x=32 + img = zeros(32, 64, 2, 8, 'single'); + w = create_validating_writer(testCase, format, 'MultiDArrays'); + + w.write_images({... + img(:,:,:,1), ... + img(:,:,1,1), ... + img(:,1,1,:), ... + img(1,1,1,1) ... + }); + w.end_images(); + + w.write_frames({... + img(:,:,1,1), ... + img(:,:,2,1) ... + }); + w.end_frames(); + + w.close(); + end + function testMaps(testCase, format) d = dictionary(); d("a") = int32(1); diff --git a/models/test/unittests.yml b/models/test/unittests.yml index 511ffadc..0ecf5826 100644 --- a/models/test/unittests.yml +++ b/models/test/unittests.yml @@ -297,6 +297,13 @@ DynamicNDArrays: !protocol recordWithVlensArray: RecordWithVlens[] recordWithDynamicNDArrays: RecordWithDynamicNDArrays +MultiDArrays: !protocol + sequence: + images: !stream + items: float[ch, z, y, x] + frames: !stream + items: float[ch:1, z:1, y:64, x:32] + Maps: !protocol sequence: stringToInt: string->int diff --git a/python/test_model/__init__.py b/python/test_model/__init__.py index 6546c76e..9b49f57e 100644 --- a/python/test_model/__init__.py +++ b/python/test_model/__init__.py @@ -145,6 +145,8 @@ def _parse_version(version: str) -> _Tuple[int, ...]: FlagsWriterBase, MapsReaderBase, MapsWriterBase, + MultiDArraysReaderBase, + MultiDArraysWriterBase, NDArraysReaderBase, NDArraysSingleDimensionReaderBase, NDArraysSingleDimensionWriterBase, @@ -211,6 +213,8 @@ def _parse_version(version: str) -> _Tuple[int, ...]: BinaryFlagsWriter, BinaryMapsReader, BinaryMapsWriter, + BinaryMultiDArraysReader, + BinaryMultiDArraysWriter, BinaryNDArraysReader, BinaryNDArraysSingleDimensionReader, BinaryNDArraysSingleDimensionWriter, @@ -277,6 +281,8 @@ def _parse_version(version: str) -> _Tuple[int, ...]: NDJsonFlagsWriter, NDJsonMapsReader, NDJsonMapsWriter, + NDJsonMultiDArraysReader, + NDJsonMultiDArraysWriter, NDJsonNDArraysReader, NDJsonNDArraysSingleDimensionReader, NDJsonNDArraysSingleDimensionWriter, diff --git a/python/test_model/binary.py b/python/test_model/binary.py index 4097c6f5..3cf168c6 100644 --- a/python/test_model/binary.py +++ b/python/test_model/binary.py @@ -701,6 +701,35 @@ def _read_record_with_vlens_array(self) -> npt.NDArray[np.void]: def _read_record_with_dynamic_nd_arrays(self) -> RecordWithDynamicNDArrays: return RecordWithDynamicNDArraysSerializer().read(self._stream) +class BinaryMultiDArraysWriter(_binary.BinaryProtocolWriter, MultiDArraysWriterBase): + """Binary writer for the MultiDArrays protocol.""" + + + def __init__(self, stream: typing.Union[typing.BinaryIO, str]) -> None: + MultiDArraysWriterBase.__init__(self) + _binary.BinaryProtocolWriter.__init__(self, stream, MultiDArraysWriterBase.schema) + + def _write_images(self, value: collections.abc.Iterable[npt.NDArray[np.float32]]) -> None: + _binary.StreamSerializer(_binary.NDArraySerializer(_binary.float32_serializer, 4)).write(self._stream, value) + + def _write_frames(self, value: collections.abc.Iterable[npt.NDArray[np.float32]]) -> None: + _binary.StreamSerializer(_binary.FixedNDArraySerializer(_binary.float32_serializer, (1, 1, 64, 32,))).write(self._stream, value) + + +class BinaryMultiDArraysReader(_binary.BinaryProtocolReader, MultiDArraysReaderBase): + """Binary writer for the MultiDArrays protocol.""" + + + def __init__(self, stream: typing.Union[io.BufferedReader, io.BytesIO, typing.BinaryIO, str]) -> None: + MultiDArraysReaderBase.__init__(self) + _binary.BinaryProtocolReader.__init__(self, stream, MultiDArraysReaderBase.schema) + + def _read_images(self) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + return _binary.StreamSerializer(_binary.NDArraySerializer(_binary.float32_serializer, 4)).read(self._stream) + + def _read_frames(self) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + return _binary.StreamSerializer(_binary.FixedNDArraySerializer(_binary.float32_serializer, (1, 1, 64, 32,))).read(self._stream) + class BinaryMapsWriter(_binary.BinaryProtocolWriter, MapsWriterBase): """Binary writer for the Maps protocol.""" diff --git a/python/test_model/ndjson.py b/python/test_model/ndjson.py index 582bdebd..1025db3a 100644 --- a/python/test_model/ndjson.py +++ b/python/test_model/ndjson.py @@ -3340,6 +3340,45 @@ def _read_record_with_dynamic_nd_arrays(self) -> RecordWithDynamicNDArrays: converter = RecordWithDynamicNDArraysConverter() return converter.from_json(json_object) +class NDJsonMultiDArraysWriter(_ndjson.NDJsonProtocolWriter, MultiDArraysWriterBase): + """NDJson writer for the MultiDArrays protocol.""" + + + def __init__(self, stream: typing.Union[typing.TextIO, str]) -> None: + MultiDArraysWriterBase.__init__(self) + _ndjson.NDJsonProtocolWriter.__init__(self, stream, MultiDArraysWriterBase.schema) + + def _write_images(self, value: collections.abc.Iterable[npt.NDArray[np.float32]]) -> None: + converter = _ndjson.NDArrayConverter(_ndjson.float32_converter, 4) + for item in value: + json_item = converter.to_json(item) + self._write_json_line({"images": json_item}) + + def _write_frames(self, value: collections.abc.Iterable[npt.NDArray[np.float32]]) -> None: + converter = _ndjson.FixedNDArrayConverter(_ndjson.float32_converter, (1, 1, 64, 32,)) + for item in value: + json_item = converter.to_json(item) + self._write_json_line({"frames": json_item}) + + +class NDJsonMultiDArraysReader(_ndjson.NDJsonProtocolReader, MultiDArraysReaderBase): + """NDJson writer for the MultiDArrays protocol.""" + + + def __init__(self, stream: typing.Union[io.BufferedReader, typing.TextIO, str]) -> None: + MultiDArraysReaderBase.__init__(self) + _ndjson.NDJsonProtocolReader.__init__(self, stream, MultiDArraysReaderBase.schema) + + def _read_images(self) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + converter = _ndjson.NDArrayConverter(_ndjson.float32_converter, 4) + while (json_object := self._read_json_line("images", False)) is not _ndjson.MISSING_SENTINEL: + yield converter.from_json(json_object) + + def _read_frames(self) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + converter = _ndjson.FixedNDArrayConverter(_ndjson.float32_converter, (1, 1, 64, 32,)) + while (json_object := self._read_json_line("frames", False)) is not _ndjson.MISSING_SENTINEL: + yield converter.from_json(json_object) + class NDJsonMapsWriter(_ndjson.NDJsonProtocolWriter, MapsWriterBase): """NDJson writer for the Maps protocol.""" diff --git a/python/test_model/protocols.py b/python/test_model/protocols.py index 7c4e622c..9276f020 100644 --- a/python/test_model/protocols.py +++ b/python/test_model/protocols.py @@ -3769,6 +3769,173 @@ def _state_to_method_name(self, state: int) -> str: return 'read_record_with_dynamic_nd_arrays' return "" +class MultiDArraysWriterBase(abc.ABC): + """Abstract writer for the MultiDArrays protocol.""" + + + def __init__(self) -> None: + self._state = 0 + + schema = r"""{"protocol":{"name":"MultiDArrays","sequence":[{"name":"images","type":{"stream":{"items":{"array":{"items":"float32","dimensions":[{"name":"ch"},{"name":"z"},{"name":"y"},{"name":"x"}]}}}}},{"name":"frames","type":{"stream":{"items":{"array":{"items":"float32","dimensions":[{"name":"ch","length":1},{"name":"z","length":1},{"name":"y","length":64},{"name":"x","length":32}]}}}}}]},"types":null}""" + + def close(self) -> None: + if self._state == 3: + try: + self._end_stream() + return + finally: + self._close() + self._close() + if self._state != 4: + expected_method = self._state_to_method_name((self._state + 1) & ~1) + raise ProtocolError(f"Protocol writer closed before all steps were called. Expected to call to '{expected_method}'.") + + def __enter__(self): + return self + + def __exit__(self, exc_type: typing.Optional[type[BaseException]], exc: typing.Optional[BaseException], traceback: object) -> None: + try: + self.close() + except Exception as e: + if exc is None: + raise e + + def write_images(self, value: collections.abc.Iterable[npt.NDArray[np.float32]]) -> None: + """Ordinal 0""" + + if self._state & ~1 != 0: + self._raise_unexpected_state(0) + + self._write_images(value) + self._state = 1 + + def write_frames(self, value: collections.abc.Iterable[npt.NDArray[np.float32]]) -> None: + """Ordinal 1""" + + if self._state == 1: + self._end_stream() + self._state = 2 + elif self._state & ~1 != 2: + self._raise_unexpected_state(2) + + self._write_frames(value) + self._state = 3 + + @abc.abstractmethod + def _write_images(self, value: collections.abc.Iterable[npt.NDArray[np.float32]]) -> None: + raise NotImplementedError() + + @abc.abstractmethod + def _write_frames(self, value: collections.abc.Iterable[npt.NDArray[np.float32]]) -> None: + raise NotImplementedError() + + @abc.abstractmethod + def _close(self) -> None: + pass + + @abc.abstractmethod + def _end_stream(self) -> None: + pass + + def _raise_unexpected_state(self, actual: int) -> None: + expected_method = self._state_to_method_name(self._state) + actual_method = self._state_to_method_name(actual) + raise ProtocolError(f"Expected to call to '{expected_method}' but received call to '{actual_method}'.") + + def _state_to_method_name(self, state: int) -> str: + if state == 0: + return 'write_images' + if state == 2: + return 'write_frames' + return "" + +class MultiDArraysReaderBase(abc.ABC): + """Abstract reader for the MultiDArrays protocol.""" + + + def __init__(self) -> None: + self._state = 0 + + def close(self) -> None: + self._close() + if self._state != 4: + if self._state % 2 == 1: + previous_method = self._state_to_method_name(self._state - 1) + raise ProtocolError(f"Protocol reader closed before all data was consumed. The iterable returned by '{previous_method}' was not fully consumed.") + else: + expected_method = self._state_to_method_name(self._state) + raise ProtocolError(f"Protocol reader closed before all data was consumed. Expected call to '{expected_method}'.") + + + schema = MultiDArraysWriterBase.schema + + def __enter__(self): + return self + + def __exit__(self, exc_type: typing.Optional[type[BaseException]], exc: typing.Optional[BaseException], traceback: object) -> None: + try: + self.close() + except Exception as e: + if exc is None: + raise e + + @abc.abstractmethod + def _close(self) -> None: + raise NotImplementedError() + + def read_images(self) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + """Ordinal 0""" + + if self._state != 0: + self._raise_unexpected_state(0) + + value = self._read_images() + self._state = 1 + return self._wrap_iterable(value, 2) + + def read_frames(self) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + """Ordinal 1""" + + if self._state != 2: + self._raise_unexpected_state(2) + + value = self._read_frames() + self._state = 3 + return self._wrap_iterable(value, 4) + + def copy_to(self, writer: MultiDArraysWriterBase) -> None: + writer.write_images(self.read_images()) + writer.write_frames(self.read_frames()) + + @abc.abstractmethod + def _read_images(self) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + raise NotImplementedError() + + @abc.abstractmethod + def _read_frames(self) -> collections.abc.Iterable[npt.NDArray[np.float32]]: + raise NotImplementedError() + + T = typing.TypeVar('T') + def _wrap_iterable(self, iterable: collections.abc.Iterable[T], final_state: int) -> collections.abc.Iterable[T]: + yield from iterable + self._state = final_state + + def _raise_unexpected_state(self, actual: int) -> None: + actual_method = self._state_to_method_name(actual) + if self._state % 2 == 1: + previous_method = self._state_to_method_name(self._state - 1) + raise ProtocolError(f"Received call to '{actual_method}' but the iterable returned by '{previous_method}' was not fully consumed.") + else: + expected_method = self._state_to_method_name(self._state) + raise ProtocolError(f"Expected to call to '{expected_method}' but received call to '{actual_method}'.") + + def _state_to_method_name(self, state: int) -> str: + if state == 0: + return 'read_images' + if state == 2: + return 'read_frames' + return "" + class MapsWriterBase(abc.ABC): """Abstract writer for the Maps protocol.""" diff --git a/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m index b43faa60..58871f4f 100644 --- a/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/FixedNDArraySerializer.m @@ -41,11 +41,7 @@ function write(self, outstream, values) end function value = read(self, instream) - if isscalar(self.shape_) - value = self.read_data_(instream, [1 self.shape_]); - else - value = self.read_data_(instream, self.shape_); - end + value = self.read_data_(instream, self.shape_); end function s = get_shape(self) diff --git a/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m b/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m index ed853fcc..cde64343 100644 --- a/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m +++ b/tooling/internal/matlab/static_files/+binary/NDArraySerializer.m @@ -14,18 +14,18 @@ end function write(self, outstream, values) + sz = size(values); if ndims(values) < self.ndims_ - throw(yardl.ValueError("Expected %d dimensions, got %d", self.ndims_, ndims(values))); + sz = [sz ones(1, self.ndims_-ndims(values))]; end - sz = size(values); flipped_shape = flip(sz); - for dim = 1: self.ndims_ + for dim = 1:self.ndims_ len = flipped_shape(dim); outstream.write_unsigned_varint(len); end - if ndims(values) == self.ndims_ + if length(sz) == self.ndims_ % This is an NDArray of scalars self.write_data_(outstream, values(:)); return diff --git a/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m b/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m index 9653980d..12cf7750 100644 --- a/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m +++ b/tooling/internal/matlab/static_files/+binary/NDArraySerializerBase.m @@ -79,7 +79,15 @@ function write_data_(self, outstream, values) end end - res = squeeze(reshape(res, [item_shape shape])); + % Tricky reshaping to remove unnecessary singleton dimensions in + % subarrays, arrays of fixed vectors, etc. + item_shape = item_shape(item_shape > 1); + if isempty(item_shape) && isscalar(shape) + item_shape = 1; + end + newshape = [item_shape shape]; + res = reshape(res, newshape); + if iscolumn(res) res = transpose(res); end From 909bca7090b185a205a0bf4da3185fa4a4183027 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Tue, 7 May 2024 02:43:29 +0000 Subject: [PATCH 25/32] Add keyword-args to MATLAB Record constructors --- ...enericRecordWithComputedFieldsSerializer.m | 6 +- .../+binary/RecordWithUnionsSerializer.m | 6 +- .../GenericRecordWithComputedFields.m | 10 +- .../generated/+basic_types/RecordWithUnions.m | 17 +-- .../+binary/GenericRecordSerializer.m | 6 +- ...RecordContainingGenericRecordsSerializer.m | 6 +- ...ContainingNestedGenericRecordsSerializer.m | 6 +- .../RecordNotUsedInProtocolSerializer.m | 6 +- .../RecordWithAliasedGenericsSerializer.m | 6 +- ...ithAliasedOptionalGenericFieldSerializer.m | 6 +- ...iasedOptionalGenericUnionFieldSerializer.m | 6 +- .../+binary/RecordWithArraysSerializer.m | 6 +- .../RecordWithArraysSimpleSyntaxSerializer.m | 6 +- .../RecordWithComputedFieldsSerializer.m | 6 +- .../RecordWithDynamicNDArraysSerializer.m | 6 +- .../+binary/RecordWithEnumsSerializer.m | 6 +- .../+binary/RecordWithFixedArraysSerializer.m | 6 +- .../RecordWithFixedCollectionsSerializer.m | 6 +- .../RecordWithFixedVectorsSerializer.m | 6 +- .../RecordWithGenericArraysSerializer.m | 6 +- .../RecordWithGenericFixedVectorsSerializer.m | 6 +- .../+binary/RecordWithGenericMapsSerializer.m | 6 +- ...cordWithGenericVectorOfRecordsSerializer.m | 6 +- .../RecordWithGenericVectorsSerializer.m | 6 +- .../RecordWithKeywordFieldsSerializer.m | 6 +- .../+binary/RecordWithNDArraysSerializer.m | 6 +- ...ordWithNDArraysSingleDimensionSerializer.m | 6 +- .../RecordWithNamedFixedArraysSerializer.m | 6 +- .../RecordWithOptionalFieldsSerializer.m | 6 +- ...RecordWithOptionalGenericFieldSerializer.m | 6 +- ...dWithOptionalGenericUnionFieldSerializer.m | 6 +- .../RecordWithOptionalVectorSerializer.m | 6 +- .../RecordWithPrimitiveAliasesSerializer.m | 6 +- .../+binary/RecordWithPrimitivesSerializer.m | 6 +- .../+binary/RecordWithStringsSerializer.m | 6 +- .../RecordWithUnionsOfContainersSerializer.m | 6 +- .../RecordWithVectorOfTimesSerializer.m | 6 +- .../+binary/RecordWithVectorsSerializer.m | 6 +- .../RecordWithVlenCollectionsSerializer.m | 6 +- .../+binary/RecordWithVlensSerializer.m | 6 +- .../+binary/SimpleAcquisitionSerializer.m | 6 +- .../SimpleEncodingCountersSerializer.m | 6 +- .../+binary/SimpleRecordSerializer.m | 6 +- .../+binary/SmallBenchmarkRecordSerializer.m | 6 +- .../+binary/TupleWithRecordsSerializer.m | 6 +- matlab/generated/+test_model/GenericRecord.m | 28 +++- .../RecordContainingGenericRecords.m | 49 ++++-- .../RecordContainingNestedGenericRecords.m | 25 ++- .../+test_model/RecordNotUsedInProtocol.m | 13 +- .../+test_model/RecordWithAliasedGenerics.m | 13 +- .../RecordWithAliasedOptionalGenericField.m | 9 +- ...cordWithAliasedOptionalGenericUnionField.m | 9 +- .../generated/+test_model/RecordWithArrays.m | 41 +++-- .../RecordWithArraysSimpleSyntax.m | 41 +++-- .../+test_model/RecordWithComputedFields.m | 117 +++++++-------- .../+test_model/RecordWithDynamicNDArrays.m | 17 +-- .../generated/+test_model/RecordWithEnums.m | 17 +-- .../+test_model/RecordWithFixedArrays.m | 17 +-- .../+test_model/RecordWithFixedCollections.m | 13 +- .../+test_model/RecordWithFixedVectors.m | 17 +-- .../+test_model/RecordWithGenericArrays.m | 40 ++++- .../RecordWithGenericFixedVectors.m | 16 +- .../+test_model/RecordWithGenericMaps.m | 13 +- .../RecordWithGenericVectorOfRecords.m | 10 +- .../+test_model/RecordWithGenericVectors.m | 16 +- .../+test_model/RecordWithKeywordFields.m | 16 +- .../+test_model/RecordWithNDArrays.m | 17 +-- .../RecordWithNDArraysSingleDimension.m | 17 +-- .../+test_model/RecordWithNamedFixedArrays.m | 17 +-- .../+test_model/RecordWithOptionalFields.m | 17 +-- .../RecordWithOptionalGenericField.m | 9 +- .../RecordWithOptionalGenericUnionField.m | 9 +- .../+test_model/RecordWithOptionalVector.m | 9 +- .../+test_model/RecordWithPrimitiveAliases.m | 41 +++-- .../+test_model/RecordWithPrimitives.m | 73 +++++---- .../generated/+test_model/RecordWithStrings.m | 13 +- .../RecordWithUnionsOfContainers.m | 17 +-- .../+test_model/RecordWithVectorOfTimes.m | 9 +- .../generated/+test_model/RecordWithVectors.m | 17 +-- .../+test_model/RecordWithVlenCollections.m | 13 +- .../generated/+test_model/RecordWithVlens.m | 17 +-- .../generated/+test_model/SimpleAcquisition.m | 21 ++- .../+test_model/SimpleEncodingCounters.m | 21 ++- matlab/generated/+test_model/SimpleRecord.m | 17 +-- .../+test_model/SmallBenchmarkRecord.m | 17 +-- .../generated/+test_model/TupleWithRecords.m | 13 +- .../+tuples/+binary/TupleSerializer.m | 6 +- matlab/generated/+tuples/Tuple.m | 16 +- matlab/test/ComputedFieldsTest.m | 8 +- matlab/test/EqualityTest.m | 48 +++--- matlab/test/GeneratedTypesTest.m | 11 +- matlab/test/RoundTripTest.m | 142 ++++++++++-------- matlab/test/benchmark.m | 5 +- tooling/internal/matlab/binary/binary.go | 10 +- tooling/internal/matlab/types/types.go | 66 ++++---- 95 files changed, 823 insertions(+), 695 deletions(-) diff --git a/matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m b/matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m index 680eeee0..779a5551 100644 --- a/matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m +++ b/matlab/generated/+basic_types/+binary/GenericRecordWithComputedFieldsSerializer.m @@ -13,12 +13,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) basic_types.GenericRecordWithComputedFields end - self.write_(outstream, value.f1) + self.write_(outstream, value.f1); end function value = read(self, instream) - field_values = self.read_(instream); - value = basic_types.GenericRecordWithComputedFields(field_values{:}); + fields = self.read_(instream); + value = basic_types.GenericRecordWithComputedFields(f1=fields{1}); end end end diff --git a/matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m b/matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m index e5088ca7..9ca1bfa1 100644 --- a/matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m +++ b/matlab/generated/+basic_types/+binary/RecordWithUnionsSerializer.m @@ -15,12 +15,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) basic_types.RecordWithUnions end - self.write_(outstream, value.null_or_int_or_string, value.date_or_datetime, value.null_or_fruits_or_days_of_week) + self.write_(outstream, value.null_or_int_or_string, value.date_or_datetime, value.null_or_fruits_or_days_of_week); end function value = read(self, instream) - field_values = self.read_(instream); - value = basic_types.RecordWithUnions(field_values{:}); + fields = self.read_(instream); + value = basic_types.RecordWithUnions(null_or_int_or_string=fields{1}, date_or_datetime=fields{2}, null_or_fruits_or_days_of_week=fields{3}); end end end diff --git a/matlab/generated/+basic_types/GenericRecordWithComputedFields.m b/matlab/generated/+basic_types/GenericRecordWithComputedFields.m index c5bc5f2e..c7781274 100644 --- a/matlab/generated/+basic_types/GenericRecordWithComputedFields.m +++ b/matlab/generated/+basic_types/GenericRecordWithComputedFields.m @@ -6,8 +6,14 @@ end methods - function self = GenericRecordWithComputedFields(f1) - self.f1 = f1; + function self = GenericRecordWithComputedFields(kwargs) + arguments + kwargs.f1; + end + if ~isfield(kwargs, "f1") + throw(yardl.TypeError("Missing required keyword argument 'f1'")) + end + self.f1 = kwargs.f1; end function res = type_index(self) diff --git a/matlab/generated/+basic_types/RecordWithUnions.m b/matlab/generated/+basic_types/RecordWithUnions.m index 0b3510d7..da4d2813 100644 --- a/matlab/generated/+basic_types/RecordWithUnions.m +++ b/matlab/generated/+basic_types/RecordWithUnions.m @@ -8,16 +8,15 @@ end methods - function self = RecordWithUnions(null_or_int_or_string, date_or_datetime, null_or_fruits_or_days_of_week) - if nargin > 0 - self.null_or_int_or_string = null_or_int_or_string; - self.date_or_datetime = date_or_datetime; - self.null_or_fruits_or_days_of_week = null_or_fruits_or_days_of_week; - else - self.null_or_int_or_string = yardl.None; - self.date_or_datetime = basic_types.TimeOrDatetime.Time(yardl.Time()); - self.null_or_fruits_or_days_of_week = yardl.None; + function self = RecordWithUnions(kwargs) + arguments + kwargs.null_or_int_or_string = yardl.None; + kwargs.date_or_datetime = basic_types.TimeOrDatetime.Time(yardl.Time()); + kwargs.null_or_fruits_or_days_of_week = yardl.None; end + self.null_or_int_or_string = kwargs.null_or_int_or_string; + self.date_or_datetime = kwargs.date_or_datetime; + self.null_or_fruits_or_days_of_week = kwargs.null_or_fruits_or_days_of_week; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/+binary/GenericRecordSerializer.m b/matlab/generated/+test_model/+binary/GenericRecordSerializer.m index c24491bf..b32ebc52 100644 --- a/matlab/generated/+test_model/+binary/GenericRecordSerializer.m +++ b/matlab/generated/+test_model/+binary/GenericRecordSerializer.m @@ -16,12 +16,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.GenericRecord end - self.write_(outstream, value.scalar_1, value.scalar_2, value.vector_1, value.image_2) + self.write_(outstream, value.scalar_1, value.scalar_2, value.vector_1, value.image_2); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.GenericRecord(field_values{:}); + fields = self.read_(instream); + value = test_model.GenericRecord(scalar_1=fields{1}, scalar_2=fields{2}, vector_1=fields{3}, image_2=fields{4}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m b/matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m index 60ec2301..7410338e 100644 --- a/matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordContainingGenericRecordsSerializer.m @@ -22,12 +22,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordContainingGenericRecords end - self.write_(outstream, value.g1, value.g1a, value.g2, value.g2a, value.g3, value.g3a, value.g4, value.g5, value.g6, value.g7) + self.write_(outstream, value.g1, value.g1a, value.g2, value.g2a, value.g3, value.g3a, value.g4, value.g5, value.g6, value.g7); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordContainingGenericRecords(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordContainingGenericRecords(g1=fields{1}, g1a=fields{2}, g2=fields{3}, g2a=fields{4}, g3=fields{5}, g3a=fields{6}, g4=fields{7}, g5=fields{8}, g6=fields{9}, g7=fields{10}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m b/matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m index 3bb78a34..802ead64 100644 --- a/matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordContainingNestedGenericRecordsSerializer.m @@ -17,12 +17,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordContainingNestedGenericRecords end - self.write_(outstream, value.f1, value.f1a, value.f2, value.f2a, value.nested) + self.write_(outstream, value.f1, value.f1a, value.f2, value.f2a, value.nested); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordContainingNestedGenericRecords(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordContainingNestedGenericRecords(f1=fields{1}, f1a=fields{2}, f2=fields{3}, f2a=fields{4}, nested=fields{5}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m b/matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m index 5b3f4b4b..90725dfb 100644 --- a/matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordNotUsedInProtocolSerializer.m @@ -14,12 +14,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordNotUsedInProtocol end - self.write_(outstream, value.u1, value.u2) + self.write_(outstream, value.u1, value.u2); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordNotUsedInProtocol(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordNotUsedInProtocol(u1=fields{1}, u2=fields{2}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m index 7a3ee385..ad2e284c 100644 --- a/matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithAliasedGenericsSerializer.m @@ -14,12 +14,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithAliasedGenerics end - self.write_(outstream, value.my_strings, value.aliased_strings) + self.write_(outstream, value.my_strings, value.aliased_strings); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithAliasedGenerics(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithAliasedGenerics(my_strings=fields{1}, aliased_strings=fields{2}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m index 7fe3f9f0..89cf2b76 100644 --- a/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericFieldSerializer.m @@ -13,12 +13,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithAliasedOptionalGenericField end - self.write_(outstream, value.v) + self.write_(outstream, value.v); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithAliasedOptionalGenericField(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithAliasedOptionalGenericField(v=fields{1}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m index 91febc81..612151e3 100644 --- a/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithAliasedOptionalGenericUnionFieldSerializer.m @@ -13,12 +13,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithAliasedOptionalGenericUnionField end - self.write_(outstream, value.v) + self.write_(outstream, value.v); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithAliasedOptionalGenericUnionField(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithAliasedOptionalGenericUnionField(v=fields{1}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m index 45aa8f10..e67bcc5f 100644 --- a/matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithArraysSerializer.m @@ -21,12 +21,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithArrays end - self.write_(outstream, value.default_array, value.default_array_with_empty_dimension, value.rank_1_array, value.rank_2_array, value.rank_2_array_with_named_dimensions, value.rank_2_fixed_array, value.rank_2_fixed_array_with_named_dimensions, value.dynamic_array, value.array_of_vectors) + self.write_(outstream, value.default_array, value.default_array_with_empty_dimension, value.rank_1_array, value.rank_2_array, value.rank_2_array_with_named_dimensions, value.rank_2_fixed_array, value.rank_2_fixed_array_with_named_dimensions, value.dynamic_array, value.array_of_vectors); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithArrays(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithArrays(default_array=fields{1}, default_array_with_empty_dimension=fields{2}, rank_1_array=fields{3}, rank_2_array=fields{4}, rank_2_array_with_named_dimensions=fields{5}, rank_2_fixed_array=fields{6}, rank_2_fixed_array_with_named_dimensions=fields{7}, dynamic_array=fields{8}, array_of_vectors=fields{9}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m b/matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m index 2a226ad3..153c9fdc 100644 --- a/matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithArraysSimpleSyntaxSerializer.m @@ -21,12 +21,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithArraysSimpleSyntax end - self.write_(outstream, value.default_array, value.default_array_with_empty_dimension, value.rank_1_array, value.rank_2_array, value.rank_2_array_with_named_dimensions, value.rank_2_fixed_array, value.rank_2_fixed_array_with_named_dimensions, value.dynamic_array, value.array_of_vectors) + self.write_(outstream, value.default_array, value.default_array_with_empty_dimension, value.rank_1_array, value.rank_2_array, value.rank_2_array_with_named_dimensions, value.rank_2_fixed_array, value.rank_2_fixed_array_with_named_dimensions, value.dynamic_array, value.array_of_vectors); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithArraysSimpleSyntax(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithArraysSimpleSyntax(default_array=fields{1}, default_array_with_empty_dimension=fields{2}, rank_1_array=fields{3}, rank_2_array=fields{4}, rank_2_array_with_named_dimensions=fields{5}, rank_2_fixed_array=fields{6}, rank_2_fixed_array_with_named_dimensions=fields{7}, dynamic_array=fields{8}, array_of_vectors=fields{9}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m index 91b64963..7c9f1ee5 100644 --- a/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithComputedFieldsSerializer.m @@ -40,12 +40,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithComputedFields end - self.write_(outstream, value.array_field, value.array_field_map_dimensions, value.dynamic_array_field, value.fixed_array_field, value.int_field, value.int8_field, value.uint8_field, value.int16_field, value.uint16_field, value.uint32_field, value.int64_field, value.uint64_field, value.size_field, value.float32_field, value.float64_field, value.complexfloat32_field, value.complexfloat64_field, value.string_field, value.tuple_field, value.vector_field, value.vector_of_vectors_field, value.fixed_vector_field, value.fixed_vector_of_vectors_field, value.optional_named_array, value.int_float_union, value.nullable_int_float_union, value.union_with_nested_generic_union, value.map_field) + self.write_(outstream, value.array_field, value.array_field_map_dimensions, value.dynamic_array_field, value.fixed_array_field, value.int_field, value.int8_field, value.uint8_field, value.int16_field, value.uint16_field, value.uint32_field, value.int64_field, value.uint64_field, value.size_field, value.float32_field, value.float64_field, value.complexfloat32_field, value.complexfloat64_field, value.string_field, value.tuple_field, value.vector_field, value.vector_of_vectors_field, value.fixed_vector_field, value.fixed_vector_of_vectors_field, value.optional_named_array, value.int_float_union, value.nullable_int_float_union, value.union_with_nested_generic_union, value.map_field); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithComputedFields(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithComputedFields(array_field=fields{1}, array_field_map_dimensions=fields{2}, dynamic_array_field=fields{3}, fixed_array_field=fields{4}, int_field=fields{5}, int8_field=fields{6}, uint8_field=fields{7}, int16_field=fields{8}, uint16_field=fields{9}, uint32_field=fields{10}, int64_field=fields{11}, uint64_field=fields{12}, size_field=fields{13}, float32_field=fields{14}, float64_field=fields{15}, complexfloat32_field=fields{16}, complexfloat64_field=fields{17}, string_field=fields{18}, tuple_field=fields{19}, vector_field=fields{20}, vector_of_vectors_field=fields{21}, fixed_vector_field=fields{22}, fixed_vector_of_vectors_field=fields{23}, optional_named_array=fields{24}, int_float_union=fields{25}, nullable_int_float_union=fields{26}, union_with_nested_generic_union=fields{27}, map_field=fields{28}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m index 7272e4d3..3e61b833 100644 --- a/matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithDynamicNDArraysSerializer.m @@ -15,12 +15,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithDynamicNDArrays end - self.write_(outstream, value.ints, value.simple_record_array, value.record_with_vlens_array) + self.write_(outstream, value.ints, value.simple_record_array, value.record_with_vlens_array); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithDynamicNDArrays(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithDynamicNDArrays(ints=fields{1}, simple_record_array=fields{2}, record_with_vlens_array=fields{3}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m index 45f53afe..89696610 100644 --- a/matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithEnumsSerializer.m @@ -15,12 +15,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithEnums end - self.write_(outstream, value.enum, value.flags, value.flags_2) + self.write_(outstream, value.enum, value.flags, value.flags_2); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithEnums(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithEnums(enum=fields{1}, flags=fields{2}, flags_2=fields{3}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m index 851c1556..649c484d 100644 --- a/matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithFixedArraysSerializer.m @@ -15,12 +15,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithFixedArrays end - self.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) + self.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithFixedArrays(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithFixedArrays(ints=fields{1}, fixed_simple_record_array=fields{2}, fixed_record_with_vlens_array=fields{3}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m index 2f426c83..e155bbb4 100644 --- a/matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithFixedCollectionsSerializer.m @@ -14,12 +14,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithFixedCollections end - self.write_(outstream, value.fixed_vector, value.fixed_array) + self.write_(outstream, value.fixed_vector, value.fixed_array); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithFixedCollections(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithFixedCollections(fixed_vector=fields{1}, fixed_array=fields{2}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m index e5c9634f..7a296ac5 100644 --- a/matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithFixedVectorsSerializer.m @@ -15,12 +15,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithFixedVectors end - self.write_(outstream, value.fixed_int_vector, value.fixed_simple_record_vector, value.fixed_record_with_vlens_vector) + self.write_(outstream, value.fixed_int_vector, value.fixed_simple_record_vector, value.fixed_record_with_vlens_vector); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithFixedVectors(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithFixedVectors(fixed_int_vector=fields{1}, fixed_simple_record_vector=fields{2}, fixed_record_with_vlens_vector=fields{3}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m index c4c0546c..c82a2717 100644 --- a/matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithGenericArraysSerializer.m @@ -18,12 +18,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithGenericArrays end - self.write_(outstream, value.nd, value.fixed_nd, value.dynamic_nd, value.aliased_nd, value.aliased_fixed_nd, value.aliased_dynamic_nd) + self.write_(outstream, value.nd, value.fixed_nd, value.dynamic_nd, value.aliased_nd, value.aliased_fixed_nd, value.aliased_dynamic_nd); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithGenericArrays(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithGenericArrays(nd=fields{1}, fixed_nd=fields{2}, dynamic_nd=fields{3}, aliased_nd=fields{4}, aliased_fixed_nd=fields{5}, aliased_dynamic_nd=fields{6}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m index 841eb30a..0fc88fd0 100644 --- a/matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithGenericFixedVectorsSerializer.m @@ -14,12 +14,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithGenericFixedVectors end - self.write_(outstream, value.fv, value.afv) + self.write_(outstream, value.fv, value.afv); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithGenericFixedVectors(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithGenericFixedVectors(fv=fields{1}, afv=fields{2}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m index 015eda54..14082704 100644 --- a/matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithGenericMapsSerializer.m @@ -14,12 +14,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithGenericMaps end - self.write_(outstream, value.m, value.am) + self.write_(outstream, value.m, value.am); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithGenericMaps(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithGenericMaps(m=fields{1}, am=fields{2}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m index 7c3d1250..fbc1f344 100644 --- a/matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithGenericVectorOfRecordsSerializer.m @@ -13,12 +13,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithGenericVectorOfRecords end - self.write_(outstream, value.v) + self.write_(outstream, value.v); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithGenericVectorOfRecords(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithGenericVectorOfRecords(v=fields{1}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m index c5b54317..27713d9f 100644 --- a/matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithGenericVectorsSerializer.m @@ -14,12 +14,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithGenericVectors end - self.write_(outstream, value.v, value.av) + self.write_(outstream, value.v, value.av); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithGenericVectors(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithGenericVectors(v=fields{1}, av=fields{2}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m index a8dbaede..fbd2fc2b 100644 --- a/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithKeywordFieldsSerializer.m @@ -15,12 +15,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithKeywordFields end - self.write_(outstream, value.int, value.sizeof, value.if_) + self.write_(outstream, value.int, value.sizeof, value.if_); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithKeywordFields(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithKeywordFields(int=fields{1}, sizeof=fields{2}, if_=fields{3}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m index 522f03cc..ce768aad 100644 --- a/matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithNDArraysSerializer.m @@ -15,12 +15,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithNDArrays end - self.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) + self.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithNDArrays(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithNDArrays(ints=fields{1}, fixed_simple_record_array=fields{2}, fixed_record_with_vlens_array=fields{3}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m b/matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m index 8ae7e35e..54e900af 100644 --- a/matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithNDArraysSingleDimensionSerializer.m @@ -15,12 +15,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithNDArraysSingleDimension end - self.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) + self.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithNDArraysSingleDimension(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithNDArraysSingleDimension(ints=fields{1}, fixed_simple_record_array=fields{2}, fixed_record_with_vlens_array=fields{3}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m b/matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m index d818c778..25ec629b 100644 --- a/matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithNamedFixedArraysSerializer.m @@ -15,12 +15,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithNamedFixedArrays end - self.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array) + self.write_(outstream, value.ints, value.fixed_simple_record_array, value.fixed_record_with_vlens_array); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithNamedFixedArrays(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithNamedFixedArrays(ints=fields{1}, fixed_simple_record_array=fields{2}, fixed_record_with_vlens_array=fields{3}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m index aea1d258..20efe112 100644 --- a/matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalFieldsSerializer.m @@ -15,12 +15,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithOptionalFields end - self.write_(outstream, value.optional_int, value.optional_int_alternate_syntax, value.optional_time) + self.write_(outstream, value.optional_int, value.optional_int_alternate_syntax, value.optional_time); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithOptionalFields(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithOptionalFields(optional_int=fields{1}, optional_int_alternate_syntax=fields{2}, optional_time=fields{3}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m index 092b6039..d2290501 100644 --- a/matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericFieldSerializer.m @@ -13,12 +13,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithOptionalGenericField end - self.write_(outstream, value.v) + self.write_(outstream, value.v); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithOptionalGenericField(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithOptionalGenericField(v=fields{1}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m index 84fd5485..96b48901 100644 --- a/matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalGenericUnionFieldSerializer.m @@ -13,12 +13,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithOptionalGenericUnionField end - self.write_(outstream, value.v) + self.write_(outstream, value.v); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithOptionalGenericUnionField(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithOptionalGenericUnionField(v=fields{1}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m b/matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m index e058ccb1..a56df049 100644 --- a/matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithOptionalVectorSerializer.m @@ -13,12 +13,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithOptionalVector end - self.write_(outstream, value.optional_vector) + self.write_(outstream, value.optional_vector); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithOptionalVector(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithOptionalVector(optional_vector=fields{1}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m b/matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m index bc473f80..1c45774f 100644 --- a/matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithPrimitiveAliasesSerializer.m @@ -21,12 +21,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithPrimitiveAliases end - self.write_(outstream, value.byte_field, value.int_field, value.uint_field, value.long_field, value.ulong_field, value.float_field, value.double_field, value.complexfloat_field, value.complexdouble_field) + self.write_(outstream, value.byte_field, value.int_field, value.uint_field, value.long_field, value.ulong_field, value.float_field, value.double_field, value.complexfloat_field, value.complexdouble_field); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithPrimitiveAliases(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithPrimitiveAliases(byte_field=fields{1}, int_field=fields{2}, uint_field=fields{3}, long_field=fields{4}, ulong_field=fields{5}, float_field=fields{6}, double_field=fields{7}, complexfloat_field=fields{8}, complexdouble_field=fields{9}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m b/matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m index 733d9cd3..4ca70450 100644 --- a/matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithPrimitivesSerializer.m @@ -29,12 +29,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithPrimitives end - self.write_(outstream, value.bool_field, value.int8_field, value.uint8_field, value.int16_field, value.uint16_field, value.int32_field, value.uint32_field, value.int64_field, value.uint64_field, value.size_field, value.float32_field, value.float64_field, value.complexfloat32_field, value.complexfloat64_field, value.date_field, value.time_field, value.datetime_field) + self.write_(outstream, value.bool_field, value.int8_field, value.uint8_field, value.int16_field, value.uint16_field, value.int32_field, value.uint32_field, value.int64_field, value.uint64_field, value.size_field, value.float32_field, value.float64_field, value.complexfloat32_field, value.complexfloat64_field, value.date_field, value.time_field, value.datetime_field); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithPrimitives(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithPrimitives(bool_field=fields{1}, int8_field=fields{2}, uint8_field=fields{3}, int16_field=fields{4}, uint16_field=fields{5}, int32_field=fields{6}, uint32_field=fields{7}, int64_field=fields{8}, uint64_field=fields{9}, size_field=fields{10}, float32_field=fields{11}, float64_field=fields{12}, complexfloat32_field=fields{13}, complexfloat64_field=fields{14}, date_field=fields{15}, time_field=fields{16}, datetime_field=fields{17}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m index 158f3f72..0342bf59 100644 --- a/matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithStringsSerializer.m @@ -14,12 +14,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithStrings end - self.write_(outstream, value.a, value.b) + self.write_(outstream, value.a, value.b); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithStrings(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithStrings(a=fields{1}, b=fields{2}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m b/matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m index 1817f6a9..affbce1e 100644 --- a/matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithUnionsOfContainersSerializer.m @@ -15,12 +15,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithUnionsOfContainers end - self.write_(outstream, value.map_or_scalar, value.vector_or_scalar, value.array_or_scalar) + self.write_(outstream, value.map_or_scalar, value.vector_or_scalar, value.array_or_scalar); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithUnionsOfContainers(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithUnionsOfContainers(map_or_scalar=fields{1}, vector_or_scalar=fields{2}, array_or_scalar=fields{3}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m index d72da3a2..1cb42129 100644 --- a/matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithVectorOfTimesSerializer.m @@ -13,12 +13,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithVectorOfTimes end - self.write_(outstream, value.times) + self.write_(outstream, value.times); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithVectorOfTimes(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithVectorOfTimes(times=fields{1}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m index 37b28575..1b5b7fe5 100644 --- a/matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithVectorsSerializer.m @@ -15,12 +15,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithVectors end - self.write_(outstream, value.default_vector, value.default_vector_fixed_length, value.vector_of_vectors) + self.write_(outstream, value.default_vector, value.default_vector_fixed_length, value.vector_of_vectors); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithVectors(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithVectors(default_vector=fields{1}, default_vector_fixed_length=fields{2}, vector_of_vectors=fields{3}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m index 5a5304c3..3c177289 100644 --- a/matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithVlenCollectionsSerializer.m @@ -14,12 +14,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithVlenCollections end - self.write_(outstream, value.vector, value.array) + self.write_(outstream, value.vector, value.array); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithVlenCollections(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithVlenCollections(vector=fields{1}, array=fields{2}); end end end diff --git a/matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m b/matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m index 17ec8a7e..a068254e 100644 --- a/matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m +++ b/matlab/generated/+test_model/+binary/RecordWithVlensSerializer.m @@ -15,12 +15,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.RecordWithVlens end - self.write_(outstream, value.a, value.b, value.c) + self.write_(outstream, value.a, value.b, value.c); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.RecordWithVlens(field_values{:}); + fields = self.read_(instream); + value = test_model.RecordWithVlens(a=fields{1}, b=fields{2}, c=fields{3}); end end end diff --git a/matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m b/matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m index 03e7db4d..284a092c 100644 --- a/matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m +++ b/matlab/generated/+test_model/+binary/SimpleAcquisitionSerializer.m @@ -16,12 +16,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.SimpleAcquisition end - self.write_(outstream, value.flags, value.idx, value.data, value.trajectory) + self.write_(outstream, value.flags, value.idx, value.data, value.trajectory); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.SimpleAcquisition(field_values{:}); + fields = self.read_(instream); + value = test_model.SimpleAcquisition(flags=fields{1}, idx=fields{2}, data=fields{3}, trajectory=fields{4}); end end end diff --git a/matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m b/matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m index 7d7dab74..e8ad021e 100644 --- a/matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m +++ b/matlab/generated/+test_model/+binary/SimpleEncodingCountersSerializer.m @@ -16,12 +16,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.SimpleEncodingCounters end - self.write_(outstream, value.e1, value.e2, value.slice, value.repetition) + self.write_(outstream, value.e1, value.e2, value.slice, value.repetition); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.SimpleEncodingCounters(field_values{:}); + fields = self.read_(instream); + value = test_model.SimpleEncodingCounters(e1=fields{1}, e2=fields{2}, slice=fields{3}, repetition=fields{4}); end end end diff --git a/matlab/generated/+test_model/+binary/SimpleRecordSerializer.m b/matlab/generated/+test_model/+binary/SimpleRecordSerializer.m index f48ca5f0..04ef3054 100644 --- a/matlab/generated/+test_model/+binary/SimpleRecordSerializer.m +++ b/matlab/generated/+test_model/+binary/SimpleRecordSerializer.m @@ -15,12 +15,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.SimpleRecord end - self.write_(outstream, value.x, value.y, value.z) + self.write_(outstream, value.x, value.y, value.z); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.SimpleRecord(field_values{:}); + fields = self.read_(instream); + value = test_model.SimpleRecord(x=fields{1}, y=fields{2}, z=fields{3}); end end end diff --git a/matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m b/matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m index 9c89994c..764ed7d1 100644 --- a/matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m +++ b/matlab/generated/+test_model/+binary/SmallBenchmarkRecordSerializer.m @@ -15,12 +15,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.SmallBenchmarkRecord end - self.write_(outstream, value.a, value.b, value.c) + self.write_(outstream, value.a, value.b, value.c); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.SmallBenchmarkRecord(field_values{:}); + fields = self.read_(instream); + value = test_model.SmallBenchmarkRecord(a=fields{1}, b=fields{2}, c=fields{3}); end end end diff --git a/matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m b/matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m index 3f7d2c20..ee6c1e79 100644 --- a/matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m +++ b/matlab/generated/+test_model/+binary/TupleWithRecordsSerializer.m @@ -14,12 +14,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) test_model.TupleWithRecords end - self.write_(outstream, value.a, value.b) + self.write_(outstream, value.a, value.b); end function value = read(self, instream) - field_values = self.read_(instream); - value = test_model.TupleWithRecords(field_values{:}); + fields = self.read_(instream); + value = test_model.TupleWithRecords(a=fields{1}, b=fields{2}); end end end diff --git a/matlab/generated/+test_model/GenericRecord.m b/matlab/generated/+test_model/GenericRecord.m index 412e084d..7286f700 100644 --- a/matlab/generated/+test_model/GenericRecord.m +++ b/matlab/generated/+test_model/GenericRecord.m @@ -9,11 +9,29 @@ end methods - function self = GenericRecord(scalar_1, scalar_2, vector_1, image_2) - self.scalar_1 = scalar_1; - self.scalar_2 = scalar_2; - self.vector_1 = vector_1; - self.image_2 = image_2; + function self = GenericRecord(kwargs) + arguments + kwargs.scalar_1; + kwargs.scalar_2; + kwargs.vector_1; + kwargs.image_2; + end + if ~isfield(kwargs, "scalar_1") + throw(yardl.TypeError("Missing required keyword argument 'scalar_1'")) + end + self.scalar_1 = kwargs.scalar_1; + if ~isfield(kwargs, "scalar_2") + throw(yardl.TypeError("Missing required keyword argument 'scalar_2'")) + end + self.scalar_2 = kwargs.scalar_2; + if ~isfield(kwargs, "vector_1") + throw(yardl.TypeError("Missing required keyword argument 'vector_1'")) + end + self.vector_1 = kwargs.vector_1; + if ~isfield(kwargs, "image_2") + throw(yardl.TypeError("Missing required keyword argument 'image_2'")) + end + self.image_2 = kwargs.image_2; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordContainingGenericRecords.m b/matlab/generated/+test_model/RecordContainingGenericRecords.m index 07f3eb3a..9633ba75 100644 --- a/matlab/generated/+test_model/RecordContainingGenericRecords.m +++ b/matlab/generated/+test_model/RecordContainingGenericRecords.m @@ -15,17 +15,44 @@ end methods - function self = RecordContainingGenericRecords(g1, g1a, g2, g2a, g3, g3a, g4, g5, g6, g7) - self.g1 = g1; - self.g1a = g1a; - self.g2 = g2; - self.g2a = g2a; - self.g3 = g3; - self.g3a = g3a; - self.g4 = g4; - self.g5 = g5; - self.g6 = g6; - self.g7 = g7; + function self = RecordContainingGenericRecords(kwargs) + arguments + kwargs.g1 = test_model.RecordWithOptionalGenericField(); + kwargs.g1a = test_model.RecordWithAliasedOptionalGenericField(); + kwargs.g2 = test_model.RecordWithOptionalGenericUnionField(); + kwargs.g2a = test_model.RecordWithAliasedOptionalGenericUnionField(); + kwargs.g3; + kwargs.g3a; + kwargs.g4; + kwargs.g5; + kwargs.g6; + kwargs.g7 = test_model.RecordWithGenericMaps(); + end + self.g1 = kwargs.g1; + self.g1a = kwargs.g1a; + self.g2 = kwargs.g2; + self.g2a = kwargs.g2a; + if ~isfield(kwargs, "g3") + throw(yardl.TypeError("Missing required keyword argument 'g3'")) + end + self.g3 = kwargs.g3; + if ~isfield(kwargs, "g3a") + throw(yardl.TypeError("Missing required keyword argument 'g3a'")) + end + self.g3a = kwargs.g3a; + if ~isfield(kwargs, "g4") + throw(yardl.TypeError("Missing required keyword argument 'g4'")) + end + self.g4 = kwargs.g4; + if ~isfield(kwargs, "g5") + throw(yardl.TypeError("Missing required keyword argument 'g5'")) + end + self.g5 = kwargs.g5; + if ~isfield(kwargs, "g6") + throw(yardl.TypeError("Missing required keyword argument 'g6'")) + end + self.g6 = kwargs.g6; + self.g7 = kwargs.g7; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m b/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m index fa56c634..68f63f12 100644 --- a/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m +++ b/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m @@ -10,20 +10,19 @@ end methods - function self = RecordContainingNestedGenericRecords(f1, f1a, f2, f2a, nested) - if nargin > 0 - self.f1 = f1; - self.f1a = f1a; - self.f2 = f2; - self.f2a = f2a; - self.nested = nested; - else - self.f1 = test_model.RecordWithOptionalGenericField(yardl.None); - self.f1a = test_model.RecordWithAliasedOptionalGenericField(yardl.None); - self.f2 = test_model.RecordWithOptionalGenericUnionField(yardl.None); - self.f2a = test_model.RecordWithAliasedOptionalGenericUnionField(yardl.None); - self.nested = test_model.RecordContainingGenericRecords(test_model.RecordWithOptionalGenericField(yardl.None), test_model.RecordWithAliasedOptionalGenericField(yardl.None), test_model.RecordWithOptionalGenericUnionField(yardl.None), test_model.RecordWithAliasedOptionalGenericUnionField(yardl.None), tuples.Tuple("", int32(0)), tuples.Tuple("", int32(0)), test_model.RecordWithGenericVectors(int32.empty(), int32.empty()), test_model.RecordWithGenericFixedVectors(repelem(int32(0), 3), repelem(int32(0), 3)), test_model.RecordWithGenericArrays(int32.empty(0, 0), repelem(int32(0), 8, 16), int32.empty(), int32.empty(0, 0), repelem(int32(0), 8, 16), int32.empty()), test_model.RecordWithGenericMaps(dictionary, dictionary)); + function self = RecordContainingNestedGenericRecords(kwargs) + arguments + kwargs.f1 = test_model.RecordWithOptionalGenericField(); + kwargs.f1a = test_model.RecordWithAliasedOptionalGenericField(); + kwargs.f2 = test_model.RecordWithOptionalGenericUnionField(); + kwargs.f2a = test_model.RecordWithAliasedOptionalGenericUnionField(); + kwargs.nested = test_model.RecordContainingGenericRecords(g3=tuples.Tuple(v1="", v2=int32(0)), g3a=tuples.Tuple(v1="", v2=int32(0)), g4=test_model.RecordWithGenericVectors(v=int32.empty(), av=int32.empty()), g5=test_model.RecordWithGenericFixedVectors(fv=repelem(int32(0), 3), afv=repelem(int32(0), 3)), g6=test_model.RecordWithGenericArrays(nd=int32.empty(0, 0), fixed_nd=repelem(int32(0), 8, 16), dynamic_nd=int32.empty(), aliased_nd=int32.empty(0, 0), aliased_fixed_nd=repelem(int32(0), 8, 16), aliased_dynamic_nd=int32.empty())); end + self.f1 = kwargs.f1; + self.f1a = kwargs.f1a; + self.f2 = kwargs.f2; + self.f2a = kwargs.f2a; + self.nested = kwargs.nested; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordNotUsedInProtocol.m b/matlab/generated/+test_model/RecordNotUsedInProtocol.m index c5ecfe52..90bc5e1e 100644 --- a/matlab/generated/+test_model/RecordNotUsedInProtocol.m +++ b/matlab/generated/+test_model/RecordNotUsedInProtocol.m @@ -7,14 +7,13 @@ end methods - function self = RecordNotUsedInProtocol(u1, u2) - if nargin > 0 - self.u1 = u1; - self.u2 = u2; - else - self.u1 = test_model.GenericUnion3.T(int32(0)); - self.u2 = test_model.GenericUnion3Alternate.U(int32(0)); + function self = RecordNotUsedInProtocol(kwargs) + arguments + kwargs.u1 = test_model.GenericUnion3.T(int32(0)); + kwargs.u2 = test_model.GenericUnion3Alternate.U(int32(0)); end + self.u1 = kwargs.u1; + self.u2 = kwargs.u2; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithAliasedGenerics.m b/matlab/generated/+test_model/RecordWithAliasedGenerics.m index c612c232..68c0e8cc 100644 --- a/matlab/generated/+test_model/RecordWithAliasedGenerics.m +++ b/matlab/generated/+test_model/RecordWithAliasedGenerics.m @@ -7,14 +7,13 @@ end methods - function self = RecordWithAliasedGenerics(my_strings, aliased_strings) - if nargin > 0 - self.my_strings = my_strings; - self.aliased_strings = aliased_strings; - else - self.my_strings = tuples.Tuple("", ""); - self.aliased_strings = tuples.Tuple("", ""); + function self = RecordWithAliasedGenerics(kwargs) + arguments + kwargs.my_strings = tuples.Tuple(v1="", v2=""); + kwargs.aliased_strings = tuples.Tuple(v1="", v2=""); end + self.my_strings = kwargs.my_strings; + self.aliased_strings = kwargs.aliased_strings; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m index 2c698a36..da3619e2 100644 --- a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m +++ b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericField.m @@ -6,12 +6,11 @@ end methods - function self = RecordWithAliasedOptionalGenericField(v) - if nargin > 0 - self.v = v; - else - self.v = yardl.None; + function self = RecordWithAliasedOptionalGenericField(kwargs) + arguments + kwargs.v = yardl.None; end + self.v = kwargs.v; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m index 2890b48b..d4ff5cbe 100644 --- a/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m +++ b/matlab/generated/+test_model/RecordWithAliasedOptionalGenericUnionField.m @@ -6,12 +6,11 @@ end methods - function self = RecordWithAliasedOptionalGenericUnionField(v) - if nargin > 0 - self.v = v; - else - self.v = yardl.None; + function self = RecordWithAliasedOptionalGenericUnionField(kwargs) + arguments + kwargs.v = yardl.None; end + self.v = kwargs.v; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithArrays.m b/matlab/generated/+test_model/RecordWithArrays.m index eb28a8f4..1302988f 100644 --- a/matlab/generated/+test_model/RecordWithArrays.m +++ b/matlab/generated/+test_model/RecordWithArrays.m @@ -14,28 +14,27 @@ end methods - function self = RecordWithArrays(default_array, default_array_with_empty_dimension, rank_1_array, rank_2_array, rank_2_array_with_named_dimensions, rank_2_fixed_array, rank_2_fixed_array_with_named_dimensions, dynamic_array, array_of_vectors) - if nargin > 0 - self.default_array = default_array; - self.default_array_with_empty_dimension = default_array_with_empty_dimension; - self.rank_1_array = rank_1_array; - self.rank_2_array = rank_2_array; - self.rank_2_array_with_named_dimensions = rank_2_array_with_named_dimensions; - self.rank_2_fixed_array = rank_2_fixed_array; - self.rank_2_fixed_array_with_named_dimensions = rank_2_fixed_array_with_named_dimensions; - self.dynamic_array = dynamic_array; - self.array_of_vectors = array_of_vectors; - else - self.default_array = int32.empty(); - self.default_array_with_empty_dimension = int32.empty(); - self.rank_1_array = int32.empty(0); - self.rank_2_array = int32.empty(0, 0); - self.rank_2_array_with_named_dimensions = int32.empty(0, 0); - self.rank_2_fixed_array = repelem(int32(0), 4, 3); - self.rank_2_fixed_array_with_named_dimensions = repelem(int32(0), 4, 3); - self.dynamic_array = int32.empty(); - self.array_of_vectors = repelem(repelem(int32(0), 4), 5, 1); + function self = RecordWithArrays(kwargs) + arguments + kwargs.default_array = int32.empty(); + kwargs.default_array_with_empty_dimension = int32.empty(); + kwargs.rank_1_array = int32.empty(0); + kwargs.rank_2_array = int32.empty(0, 0); + kwargs.rank_2_array_with_named_dimensions = int32.empty(0, 0); + kwargs.rank_2_fixed_array = repelem(int32(0), 4, 3); + kwargs.rank_2_fixed_array_with_named_dimensions = repelem(int32(0), 4, 3); + kwargs.dynamic_array = int32.empty(); + kwargs.array_of_vectors = repelem(repelem(int32(0), 4), 5, 1); end + self.default_array = kwargs.default_array; + self.default_array_with_empty_dimension = kwargs.default_array_with_empty_dimension; + self.rank_1_array = kwargs.rank_1_array; + self.rank_2_array = kwargs.rank_2_array; + self.rank_2_array_with_named_dimensions = kwargs.rank_2_array_with_named_dimensions; + self.rank_2_fixed_array = kwargs.rank_2_fixed_array; + self.rank_2_fixed_array_with_named_dimensions = kwargs.rank_2_fixed_array_with_named_dimensions; + self.dynamic_array = kwargs.dynamic_array; + self.array_of_vectors = kwargs.array_of_vectors; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m b/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m index f25fd99d..8a3a6d2d 100644 --- a/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m +++ b/matlab/generated/+test_model/RecordWithArraysSimpleSyntax.m @@ -14,28 +14,27 @@ end methods - function self = RecordWithArraysSimpleSyntax(default_array, default_array_with_empty_dimension, rank_1_array, rank_2_array, rank_2_array_with_named_dimensions, rank_2_fixed_array, rank_2_fixed_array_with_named_dimensions, dynamic_array, array_of_vectors) - if nargin > 0 - self.default_array = default_array; - self.default_array_with_empty_dimension = default_array_with_empty_dimension; - self.rank_1_array = rank_1_array; - self.rank_2_array = rank_2_array; - self.rank_2_array_with_named_dimensions = rank_2_array_with_named_dimensions; - self.rank_2_fixed_array = rank_2_fixed_array; - self.rank_2_fixed_array_with_named_dimensions = rank_2_fixed_array_with_named_dimensions; - self.dynamic_array = dynamic_array; - self.array_of_vectors = array_of_vectors; - else - self.default_array = int32.empty(); - self.default_array_with_empty_dimension = int32.empty(); - self.rank_1_array = int32.empty(0); - self.rank_2_array = int32.empty(0, 0); - self.rank_2_array_with_named_dimensions = int32.empty(0, 0); - self.rank_2_fixed_array = repelem(int32(0), 4, 3); - self.rank_2_fixed_array_with_named_dimensions = repelem(int32(0), 4, 3); - self.dynamic_array = int32.empty(); - self.array_of_vectors = repelem(repelem(int32(0), 4), 5, 1); + function self = RecordWithArraysSimpleSyntax(kwargs) + arguments + kwargs.default_array = int32.empty(); + kwargs.default_array_with_empty_dimension = int32.empty(); + kwargs.rank_1_array = int32.empty(0); + kwargs.rank_2_array = int32.empty(0, 0); + kwargs.rank_2_array_with_named_dimensions = int32.empty(0, 0); + kwargs.rank_2_fixed_array = repelem(int32(0), 4, 3); + kwargs.rank_2_fixed_array_with_named_dimensions = repelem(int32(0), 4, 3); + kwargs.dynamic_array = int32.empty(); + kwargs.array_of_vectors = repelem(repelem(int32(0), 4), 5, 1); end + self.default_array = kwargs.default_array; + self.default_array_with_empty_dimension = kwargs.default_array_with_empty_dimension; + self.rank_1_array = kwargs.rank_1_array; + self.rank_2_array = kwargs.rank_2_array; + self.rank_2_array_with_named_dimensions = kwargs.rank_2_array_with_named_dimensions; + self.rank_2_fixed_array = kwargs.rank_2_fixed_array; + self.rank_2_fixed_array_with_named_dimensions = kwargs.rank_2_fixed_array_with_named_dimensions; + self.dynamic_array = kwargs.dynamic_array; + self.array_of_vectors = kwargs.array_of_vectors; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithComputedFields.m b/matlab/generated/+test_model/RecordWithComputedFields.m index 15037ad5..9cb98b2c 100644 --- a/matlab/generated/+test_model/RecordWithComputedFields.m +++ b/matlab/generated/+test_model/RecordWithComputedFields.m @@ -33,66 +33,65 @@ end methods - function self = RecordWithComputedFields(array_field, array_field_map_dimensions, dynamic_array_field, fixed_array_field, int_field, int8_field, uint8_field, int16_field, uint16_field, uint32_field, int64_field, uint64_field, size_field, float32_field, float64_field, complexfloat32_field, complexfloat64_field, string_field, tuple_field, vector_field, vector_of_vectors_field, fixed_vector_field, fixed_vector_of_vectors_field, optional_named_array, int_float_union, nullable_int_float_union, union_with_nested_generic_union, map_field) - if nargin > 0 - self.array_field = array_field; - self.array_field_map_dimensions = array_field_map_dimensions; - self.dynamic_array_field = dynamic_array_field; - self.fixed_array_field = fixed_array_field; - self.int_field = int_field; - self.int8_field = int8_field; - self.uint8_field = uint8_field; - self.int16_field = int16_field; - self.uint16_field = uint16_field; - self.uint32_field = uint32_field; - self.int64_field = int64_field; - self.uint64_field = uint64_field; - self.size_field = size_field; - self.float32_field = float32_field; - self.float64_field = float64_field; - self.complexfloat32_field = complexfloat32_field; - self.complexfloat64_field = complexfloat64_field; - self.string_field = string_field; - self.tuple_field = tuple_field; - self.vector_field = vector_field; - self.vector_of_vectors_field = vector_of_vectors_field; - self.fixed_vector_field = fixed_vector_field; - self.fixed_vector_of_vectors_field = fixed_vector_of_vectors_field; - self.optional_named_array = optional_named_array; - self.int_float_union = int_float_union; - self.nullable_int_float_union = nullable_int_float_union; - self.union_with_nested_generic_union = union_with_nested_generic_union; - self.map_field = map_field; - else - self.array_field = int32.empty(0, 0); - self.array_field_map_dimensions = int32.empty(0, 0); - self.dynamic_array_field = int32.empty(); - self.fixed_array_field = repelem(int32(0), 4, 3); - self.int_field = int32(0); - self.int8_field = int8(0); - self.uint8_field = uint8(0); - self.int16_field = int16(0); - self.uint16_field = uint16(0); - self.uint32_field = uint32(0); - self.int64_field = int64(0); - self.uint64_field = uint64(0); - self.size_field = uint64(0); - self.float32_field = single(0); - self.float64_field = double(0); - self.complexfloat32_field = complex(single(0)); - self.complexfloat64_field = complex(0); - self.string_field = ""; - self.tuple_field = tuples.Tuple(int32(0), int32(0)); - self.vector_field = int32.empty(); - self.vector_of_vectors_field = int32.empty(); - self.fixed_vector_field = repelem(int32(0), 3); - self.fixed_vector_of_vectors_field = repelem({repelem(int32(0), 3)}, 2); - self.optional_named_array = yardl.None; - self.int_float_union = test_model.Int32OrFloat32.Int32(int32(0)); - self.nullable_int_float_union = yardl.None; - self.union_with_nested_generic_union = test_model.IntOrGenericRecordWithComputedFields.Int(int32(0)); - self.map_field = dictionary; + function self = RecordWithComputedFields(kwargs) + arguments + kwargs.array_field = int32.empty(0, 0); + kwargs.array_field_map_dimensions = int32.empty(0, 0); + kwargs.dynamic_array_field = int32.empty(); + kwargs.fixed_array_field = repelem(int32(0), 4, 3); + kwargs.int_field = int32(0); + kwargs.int8_field = int8(0); + kwargs.uint8_field = uint8(0); + kwargs.int16_field = int16(0); + kwargs.uint16_field = uint16(0); + kwargs.uint32_field = uint32(0); + kwargs.int64_field = int64(0); + kwargs.uint64_field = uint64(0); + kwargs.size_field = uint64(0); + kwargs.float32_field = single(0); + kwargs.float64_field = double(0); + kwargs.complexfloat32_field = complex(single(0)); + kwargs.complexfloat64_field = complex(0); + kwargs.string_field = ""; + kwargs.tuple_field = tuples.Tuple(v1=int32(0), v2=int32(0)); + kwargs.vector_field = int32.empty(); + kwargs.vector_of_vectors_field = int32.empty(); + kwargs.fixed_vector_field = repelem(int32(0), 3); + kwargs.fixed_vector_of_vectors_field = repelem({repelem(int32(0), 3)}, 2); + kwargs.optional_named_array = yardl.None; + kwargs.int_float_union = test_model.Int32OrFloat32.Int32(int32(0)); + kwargs.nullable_int_float_union = yardl.None; + kwargs.union_with_nested_generic_union = test_model.IntOrGenericRecordWithComputedFields.Int(int32(0)); + kwargs.map_field = dictionary; end + self.array_field = kwargs.array_field; + self.array_field_map_dimensions = kwargs.array_field_map_dimensions; + self.dynamic_array_field = kwargs.dynamic_array_field; + self.fixed_array_field = kwargs.fixed_array_field; + self.int_field = kwargs.int_field; + self.int8_field = kwargs.int8_field; + self.uint8_field = kwargs.uint8_field; + self.int16_field = kwargs.int16_field; + self.uint16_field = kwargs.uint16_field; + self.uint32_field = kwargs.uint32_field; + self.int64_field = kwargs.int64_field; + self.uint64_field = kwargs.uint64_field; + self.size_field = kwargs.size_field; + self.float32_field = kwargs.float32_field; + self.float64_field = kwargs.float64_field; + self.complexfloat32_field = kwargs.complexfloat32_field; + self.complexfloat64_field = kwargs.complexfloat64_field; + self.string_field = kwargs.string_field; + self.tuple_field = kwargs.tuple_field; + self.vector_field = kwargs.vector_field; + self.vector_of_vectors_field = kwargs.vector_of_vectors_field; + self.fixed_vector_field = kwargs.fixed_vector_field; + self.fixed_vector_of_vectors_field = kwargs.fixed_vector_of_vectors_field; + self.optional_named_array = kwargs.optional_named_array; + self.int_float_union = kwargs.int_float_union; + self.nullable_int_float_union = kwargs.nullable_int_float_union; + self.union_with_nested_generic_union = kwargs.union_with_nested_generic_union; + self.map_field = kwargs.map_field; end function res = int_literal(self) diff --git a/matlab/generated/+test_model/RecordWithDynamicNDArrays.m b/matlab/generated/+test_model/RecordWithDynamicNDArrays.m index 0091d4b4..118cb61f 100644 --- a/matlab/generated/+test_model/RecordWithDynamicNDArrays.m +++ b/matlab/generated/+test_model/RecordWithDynamicNDArrays.m @@ -8,16 +8,15 @@ end methods - function self = RecordWithDynamicNDArrays(ints, simple_record_array, record_with_vlens_array) - if nargin > 0 - self.ints = ints; - self.simple_record_array = simple_record_array; - self.record_with_vlens_array = record_with_vlens_array; - else - self.ints = int32.empty(); - self.simple_record_array = test_model.SimpleRecord.empty(); - self.record_with_vlens_array = test_model.RecordWithVlens.empty(); + function self = RecordWithDynamicNDArrays(kwargs) + arguments + kwargs.ints = int32.empty(); + kwargs.simple_record_array = test_model.SimpleRecord.empty(); + kwargs.record_with_vlens_array = test_model.RecordWithVlens.empty(); end + self.ints = kwargs.ints; + self.simple_record_array = kwargs.simple_record_array; + self.record_with_vlens_array = kwargs.record_with_vlens_array; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithEnums.m b/matlab/generated/+test_model/RecordWithEnums.m index c30b24e0..b3b6a0a4 100644 --- a/matlab/generated/+test_model/RecordWithEnums.m +++ b/matlab/generated/+test_model/RecordWithEnums.m @@ -8,16 +8,15 @@ end methods - function self = RecordWithEnums(enum, flags, flags_2) - if nargin > 0 - self.enum = enum; - self.flags = flags; - self.flags_2 = flags_2; - else - self.enum = basic_types.Fruits.APPLE; - self.flags = basic_types.DaysOfWeek(0); - self.flags_2 = basic_types.TextFormat.REGULAR; + function self = RecordWithEnums(kwargs) + arguments + kwargs.enum = basic_types.Fruits.APPLE; + kwargs.flags = basic_types.DaysOfWeek(0); + kwargs.flags_2 = basic_types.TextFormat.REGULAR; end + self.enum = kwargs.enum; + self.flags = kwargs.flags; + self.flags_2 = kwargs.flags_2; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithFixedArrays.m b/matlab/generated/+test_model/RecordWithFixedArrays.m index 1e7009df..c60cd0d1 100644 --- a/matlab/generated/+test_model/RecordWithFixedArrays.m +++ b/matlab/generated/+test_model/RecordWithFixedArrays.m @@ -8,16 +8,15 @@ end methods - function self = RecordWithFixedArrays(ints, fixed_simple_record_array, fixed_record_with_vlens_array) - if nargin > 0 - self.ints = ints; - self.fixed_simple_record_array = fixed_simple_record_array; - self.fixed_record_with_vlens_array = fixed_record_with_vlens_array; - else - self.ints = repelem(int32(0), 3, 2); - self.fixed_simple_record_array = repelem(test_model.SimpleRecord(), 2, 3); - self.fixed_record_with_vlens_array = repelem(test_model.RecordWithVlens(), 2, 2); + function self = RecordWithFixedArrays(kwargs) + arguments + kwargs.ints = repelem(int32(0), 3, 2); + kwargs.fixed_simple_record_array = repelem(test_model.SimpleRecord(), 2, 3); + kwargs.fixed_record_with_vlens_array = repelem(test_model.RecordWithVlens(), 2, 2); end + self.ints = kwargs.ints; + self.fixed_simple_record_array = kwargs.fixed_simple_record_array; + self.fixed_record_with_vlens_array = kwargs.fixed_record_with_vlens_array; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithFixedCollections.m b/matlab/generated/+test_model/RecordWithFixedCollections.m index 9ef0c4ce..8f761daa 100644 --- a/matlab/generated/+test_model/RecordWithFixedCollections.m +++ b/matlab/generated/+test_model/RecordWithFixedCollections.m @@ -7,14 +7,13 @@ end methods - function self = RecordWithFixedCollections(fixed_vector, fixed_array) - if nargin > 0 - self.fixed_vector = fixed_vector; - self.fixed_array = fixed_array; - else - self.fixed_vector = repelem(int32(0), 3); - self.fixed_array = repelem(int32(0), 3, 2); + function self = RecordWithFixedCollections(kwargs) + arguments + kwargs.fixed_vector = repelem(int32(0), 3); + kwargs.fixed_array = repelem(int32(0), 3, 2); end + self.fixed_vector = kwargs.fixed_vector; + self.fixed_array = kwargs.fixed_array; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithFixedVectors.m b/matlab/generated/+test_model/RecordWithFixedVectors.m index 43b302fd..0cab98fd 100644 --- a/matlab/generated/+test_model/RecordWithFixedVectors.m +++ b/matlab/generated/+test_model/RecordWithFixedVectors.m @@ -8,16 +8,15 @@ end methods - function self = RecordWithFixedVectors(fixed_int_vector, fixed_simple_record_vector, fixed_record_with_vlens_vector) - if nargin > 0 - self.fixed_int_vector = fixed_int_vector; - self.fixed_simple_record_vector = fixed_simple_record_vector; - self.fixed_record_with_vlens_vector = fixed_record_with_vlens_vector; - else - self.fixed_int_vector = repelem(int32(0), 5); - self.fixed_simple_record_vector = repelem(test_model.SimpleRecord(), 3); - self.fixed_record_with_vlens_vector = repelem(test_model.RecordWithVlens(), 2); + function self = RecordWithFixedVectors(kwargs) + arguments + kwargs.fixed_int_vector = repelem(int32(0), 5); + kwargs.fixed_simple_record_vector = repelem(test_model.SimpleRecord(), 3); + kwargs.fixed_record_with_vlens_vector = repelem(test_model.RecordWithVlens(), 2); end + self.fixed_int_vector = kwargs.fixed_int_vector; + self.fixed_simple_record_vector = kwargs.fixed_simple_record_vector; + self.fixed_record_with_vlens_vector = kwargs.fixed_record_with_vlens_vector; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithGenericArrays.m b/matlab/generated/+test_model/RecordWithGenericArrays.m index 1df3d1de..b66e3d75 100644 --- a/matlab/generated/+test_model/RecordWithGenericArrays.m +++ b/matlab/generated/+test_model/RecordWithGenericArrays.m @@ -11,13 +11,39 @@ end methods - function self = RecordWithGenericArrays(nd, fixed_nd, dynamic_nd, aliased_nd, aliased_fixed_nd, aliased_dynamic_nd) - self.nd = nd; - self.fixed_nd = fixed_nd; - self.dynamic_nd = dynamic_nd; - self.aliased_nd = aliased_nd; - self.aliased_fixed_nd = aliased_fixed_nd; - self.aliased_dynamic_nd = aliased_dynamic_nd; + function self = RecordWithGenericArrays(kwargs) + arguments + kwargs.nd; + kwargs.fixed_nd; + kwargs.dynamic_nd; + kwargs.aliased_nd; + kwargs.aliased_fixed_nd; + kwargs.aliased_dynamic_nd; + end + if ~isfield(kwargs, "nd") + throw(yardl.TypeError("Missing required keyword argument 'nd'")) + end + self.nd = kwargs.nd; + if ~isfield(kwargs, "fixed_nd") + throw(yardl.TypeError("Missing required keyword argument 'fixed_nd'")) + end + self.fixed_nd = kwargs.fixed_nd; + if ~isfield(kwargs, "dynamic_nd") + throw(yardl.TypeError("Missing required keyword argument 'dynamic_nd'")) + end + self.dynamic_nd = kwargs.dynamic_nd; + if ~isfield(kwargs, "aliased_nd") + throw(yardl.TypeError("Missing required keyword argument 'aliased_nd'")) + end + self.aliased_nd = kwargs.aliased_nd; + if ~isfield(kwargs, "aliased_fixed_nd") + throw(yardl.TypeError("Missing required keyword argument 'aliased_fixed_nd'")) + end + self.aliased_fixed_nd = kwargs.aliased_fixed_nd; + if ~isfield(kwargs, "aliased_dynamic_nd") + throw(yardl.TypeError("Missing required keyword argument 'aliased_dynamic_nd'")) + end + self.aliased_dynamic_nd = kwargs.aliased_dynamic_nd; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithGenericFixedVectors.m b/matlab/generated/+test_model/RecordWithGenericFixedVectors.m index 869726bf..f3298457 100644 --- a/matlab/generated/+test_model/RecordWithGenericFixedVectors.m +++ b/matlab/generated/+test_model/RecordWithGenericFixedVectors.m @@ -7,9 +7,19 @@ end methods - function self = RecordWithGenericFixedVectors(fv, afv) - self.fv = fv; - self.afv = afv; + function self = RecordWithGenericFixedVectors(kwargs) + arguments + kwargs.fv; + kwargs.afv; + end + if ~isfield(kwargs, "fv") + throw(yardl.TypeError("Missing required keyword argument 'fv'")) + end + self.fv = kwargs.fv; + if ~isfield(kwargs, "afv") + throw(yardl.TypeError("Missing required keyword argument 'afv'")) + end + self.afv = kwargs.afv; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithGenericMaps.m b/matlab/generated/+test_model/RecordWithGenericMaps.m index 95a54fb4..75598bd9 100644 --- a/matlab/generated/+test_model/RecordWithGenericMaps.m +++ b/matlab/generated/+test_model/RecordWithGenericMaps.m @@ -7,14 +7,13 @@ end methods - function self = RecordWithGenericMaps(m, am) - if nargin > 0 - self.m = m; - self.am = am; - else - self.m = dictionary; - self.am = dictionary; + function self = RecordWithGenericMaps(kwargs) + arguments + kwargs.m = dictionary; + kwargs.am = dictionary; end + self.m = kwargs.m; + self.am = kwargs.am; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m b/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m index 65219711..52be4792 100644 --- a/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m +++ b/matlab/generated/+test_model/RecordWithGenericVectorOfRecords.m @@ -6,8 +6,14 @@ end methods - function self = RecordWithGenericVectorOfRecords(v) - self.v = v; + function self = RecordWithGenericVectorOfRecords(kwargs) + arguments + kwargs.v; + end + if ~isfield(kwargs, "v") + throw(yardl.TypeError("Missing required keyword argument 'v'")) + end + self.v = kwargs.v; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithGenericVectors.m b/matlab/generated/+test_model/RecordWithGenericVectors.m index ed7ebcb0..5eb735c5 100644 --- a/matlab/generated/+test_model/RecordWithGenericVectors.m +++ b/matlab/generated/+test_model/RecordWithGenericVectors.m @@ -7,9 +7,19 @@ end methods - function self = RecordWithGenericVectors(v, av) - self.v = v; - self.av = av; + function self = RecordWithGenericVectors(kwargs) + arguments + kwargs.v; + kwargs.av; + end + if ~isfield(kwargs, "v") + throw(yardl.TypeError("Missing required keyword argument 'v'")) + end + self.v = kwargs.v; + if ~isfield(kwargs, "av") + throw(yardl.TypeError("Missing required keyword argument 'av'")) + end + self.av = kwargs.av; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithKeywordFields.m b/matlab/generated/+test_model/RecordWithKeywordFields.m index 5d318541..02a6ca77 100644 --- a/matlab/generated/+test_model/RecordWithKeywordFields.m +++ b/matlab/generated/+test_model/RecordWithKeywordFields.m @@ -8,10 +8,18 @@ end methods - function self = RecordWithKeywordFields(int, sizeof, if_) - self.int = int; - self.sizeof = sizeof; - self.if_ = if_; + function self = RecordWithKeywordFields(kwargs) + arguments + kwargs.int = ""; + kwargs.sizeof = int32.empty(0, 0); + kwargs.if_; + end + self.int = kwargs.int; + self.sizeof = kwargs.sizeof; + if ~isfield(kwargs, "if_") + throw(yardl.TypeError("Missing required keyword argument 'if_'")) + end + self.if_ = kwargs.if_; end function res = float(self) diff --git a/matlab/generated/+test_model/RecordWithNDArrays.m b/matlab/generated/+test_model/RecordWithNDArrays.m index b2c3e366..209161f9 100644 --- a/matlab/generated/+test_model/RecordWithNDArrays.m +++ b/matlab/generated/+test_model/RecordWithNDArrays.m @@ -8,16 +8,15 @@ end methods - function self = RecordWithNDArrays(ints, fixed_simple_record_array, fixed_record_with_vlens_array) - if nargin > 0 - self.ints = ints; - self.fixed_simple_record_array = fixed_simple_record_array; - self.fixed_record_with_vlens_array = fixed_record_with_vlens_array; - else - self.ints = int32.empty(0, 0); - self.fixed_simple_record_array = test_model.SimpleRecord.empty(0, 0); - self.fixed_record_with_vlens_array = test_model.RecordWithVlens.empty(0, 0); + function self = RecordWithNDArrays(kwargs) + arguments + kwargs.ints = int32.empty(0, 0); + kwargs.fixed_simple_record_array = test_model.SimpleRecord.empty(0, 0); + kwargs.fixed_record_with_vlens_array = test_model.RecordWithVlens.empty(0, 0); end + self.ints = kwargs.ints; + self.fixed_simple_record_array = kwargs.fixed_simple_record_array; + self.fixed_record_with_vlens_array = kwargs.fixed_record_with_vlens_array; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m b/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m index 6cbaed86..bb378d98 100644 --- a/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m +++ b/matlab/generated/+test_model/RecordWithNDArraysSingleDimension.m @@ -8,16 +8,15 @@ end methods - function self = RecordWithNDArraysSingleDimension(ints, fixed_simple_record_array, fixed_record_with_vlens_array) - if nargin > 0 - self.ints = ints; - self.fixed_simple_record_array = fixed_simple_record_array; - self.fixed_record_with_vlens_array = fixed_record_with_vlens_array; - else - self.ints = int32.empty(0); - self.fixed_simple_record_array = test_model.SimpleRecord.empty(0); - self.fixed_record_with_vlens_array = test_model.RecordWithVlens.empty(0); + function self = RecordWithNDArraysSingleDimension(kwargs) + arguments + kwargs.ints = int32.empty(0); + kwargs.fixed_simple_record_array = test_model.SimpleRecord.empty(0); + kwargs.fixed_record_with_vlens_array = test_model.RecordWithVlens.empty(0); end + self.ints = kwargs.ints; + self.fixed_simple_record_array = kwargs.fixed_simple_record_array; + self.fixed_record_with_vlens_array = kwargs.fixed_record_with_vlens_array; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithNamedFixedArrays.m b/matlab/generated/+test_model/RecordWithNamedFixedArrays.m index 00a81e27..33e13d11 100644 --- a/matlab/generated/+test_model/RecordWithNamedFixedArrays.m +++ b/matlab/generated/+test_model/RecordWithNamedFixedArrays.m @@ -8,16 +8,15 @@ end methods - function self = RecordWithNamedFixedArrays(ints, fixed_simple_record_array, fixed_record_with_vlens_array) - if nargin > 0 - self.ints = ints; - self.fixed_simple_record_array = fixed_simple_record_array; - self.fixed_record_with_vlens_array = fixed_record_with_vlens_array; - else - self.ints = repelem(int32(0), 3, 2); - self.fixed_simple_record_array = repelem(test_model.SimpleRecord(), 2, 3); - self.fixed_record_with_vlens_array = repelem(test_model.RecordWithVlens(), 2, 2); + function self = RecordWithNamedFixedArrays(kwargs) + arguments + kwargs.ints = repelem(int32(0), 3, 2); + kwargs.fixed_simple_record_array = repelem(test_model.SimpleRecord(), 2, 3); + kwargs.fixed_record_with_vlens_array = repelem(test_model.RecordWithVlens(), 2, 2); end + self.ints = kwargs.ints; + self.fixed_simple_record_array = kwargs.fixed_simple_record_array; + self.fixed_record_with_vlens_array = kwargs.fixed_record_with_vlens_array; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithOptionalFields.m b/matlab/generated/+test_model/RecordWithOptionalFields.m index 70b89199..55d15c6f 100644 --- a/matlab/generated/+test_model/RecordWithOptionalFields.m +++ b/matlab/generated/+test_model/RecordWithOptionalFields.m @@ -8,16 +8,15 @@ end methods - function self = RecordWithOptionalFields(optional_int, optional_int_alternate_syntax, optional_time) - if nargin > 0 - self.optional_int = optional_int; - self.optional_int_alternate_syntax = optional_int_alternate_syntax; - self.optional_time = optional_time; - else - self.optional_int = yardl.None; - self.optional_int_alternate_syntax = yardl.None; - self.optional_time = yardl.None; + function self = RecordWithOptionalFields(kwargs) + arguments + kwargs.optional_int = yardl.None; + kwargs.optional_int_alternate_syntax = yardl.None; + kwargs.optional_time = yardl.None; end + self.optional_int = kwargs.optional_int; + self.optional_int_alternate_syntax = kwargs.optional_int_alternate_syntax; + self.optional_time = kwargs.optional_time; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithOptionalGenericField.m b/matlab/generated/+test_model/RecordWithOptionalGenericField.m index b12bc6da..89088836 100644 --- a/matlab/generated/+test_model/RecordWithOptionalGenericField.m +++ b/matlab/generated/+test_model/RecordWithOptionalGenericField.m @@ -6,12 +6,11 @@ end methods - function self = RecordWithOptionalGenericField(v) - if nargin > 0 - self.v = v; - else - self.v = yardl.None; + function self = RecordWithOptionalGenericField(kwargs) + arguments + kwargs.v = yardl.None; end + self.v = kwargs.v; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m b/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m index 4b579e8b..6c57abfd 100644 --- a/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m +++ b/matlab/generated/+test_model/RecordWithOptionalGenericUnionField.m @@ -6,12 +6,11 @@ end methods - function self = RecordWithOptionalGenericUnionField(v) - if nargin > 0 - self.v = v; - else - self.v = yardl.None; + function self = RecordWithOptionalGenericUnionField(kwargs) + arguments + kwargs.v = yardl.None; end + self.v = kwargs.v; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithOptionalVector.m b/matlab/generated/+test_model/RecordWithOptionalVector.m index 62280015..37b85fec 100644 --- a/matlab/generated/+test_model/RecordWithOptionalVector.m +++ b/matlab/generated/+test_model/RecordWithOptionalVector.m @@ -6,12 +6,11 @@ end methods - function self = RecordWithOptionalVector(optional_vector) - if nargin > 0 - self.optional_vector = optional_vector; - else - self.optional_vector = yardl.None; + function self = RecordWithOptionalVector(kwargs) + arguments + kwargs.optional_vector = yardl.None; end + self.optional_vector = kwargs.optional_vector; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithPrimitiveAliases.m b/matlab/generated/+test_model/RecordWithPrimitiveAliases.m index 88ff1226..63411fde 100644 --- a/matlab/generated/+test_model/RecordWithPrimitiveAliases.m +++ b/matlab/generated/+test_model/RecordWithPrimitiveAliases.m @@ -14,28 +14,27 @@ end methods - function self = RecordWithPrimitiveAliases(byte_field, int_field, uint_field, long_field, ulong_field, float_field, double_field, complexfloat_field, complexdouble_field) - if nargin > 0 - self.byte_field = byte_field; - self.int_field = int_field; - self.uint_field = uint_field; - self.long_field = long_field; - self.ulong_field = ulong_field; - self.float_field = float_field; - self.double_field = double_field; - self.complexfloat_field = complexfloat_field; - self.complexdouble_field = complexdouble_field; - else - self.byte_field = uint8(0); - self.int_field = int32(0); - self.uint_field = uint32(0); - self.long_field = int64(0); - self.ulong_field = uint64(0); - self.float_field = single(0); - self.double_field = double(0); - self.complexfloat_field = complex(single(0)); - self.complexdouble_field = complex(0); + function self = RecordWithPrimitiveAliases(kwargs) + arguments + kwargs.byte_field = uint8(0); + kwargs.int_field = int32(0); + kwargs.uint_field = uint32(0); + kwargs.long_field = int64(0); + kwargs.ulong_field = uint64(0); + kwargs.float_field = single(0); + kwargs.double_field = double(0); + kwargs.complexfloat_field = complex(single(0)); + kwargs.complexdouble_field = complex(0); end + self.byte_field = kwargs.byte_field; + self.int_field = kwargs.int_field; + self.uint_field = kwargs.uint_field; + self.long_field = kwargs.long_field; + self.ulong_field = kwargs.ulong_field; + self.float_field = kwargs.float_field; + self.double_field = kwargs.double_field; + self.complexfloat_field = kwargs.complexfloat_field; + self.complexdouble_field = kwargs.complexdouble_field; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithPrimitives.m b/matlab/generated/+test_model/RecordWithPrimitives.m index 7023e8fe..5041cacb 100644 --- a/matlab/generated/+test_model/RecordWithPrimitives.m +++ b/matlab/generated/+test_model/RecordWithPrimitives.m @@ -22,44 +22,43 @@ end methods - function self = RecordWithPrimitives(bool_field, int8_field, uint8_field, int16_field, uint16_field, int32_field, uint32_field, int64_field, uint64_field, size_field, float32_field, float64_field, complexfloat32_field, complexfloat64_field, date_field, time_field, datetime_field) - if nargin > 0 - self.bool_field = bool_field; - self.int8_field = int8_field; - self.uint8_field = uint8_field; - self.int16_field = int16_field; - self.uint16_field = uint16_field; - self.int32_field = int32_field; - self.uint32_field = uint32_field; - self.int64_field = int64_field; - self.uint64_field = uint64_field; - self.size_field = size_field; - self.float32_field = float32_field; - self.float64_field = float64_field; - self.complexfloat32_field = complexfloat32_field; - self.complexfloat64_field = complexfloat64_field; - self.date_field = date_field; - self.time_field = time_field; - self.datetime_field = datetime_field; - else - self.bool_field = false; - self.int8_field = int8(0); - self.uint8_field = uint8(0); - self.int16_field = int16(0); - self.uint16_field = uint16(0); - self.int32_field = int32(0); - self.uint32_field = uint32(0); - self.int64_field = int64(0); - self.uint64_field = uint64(0); - self.size_field = uint64(0); - self.float32_field = single(0); - self.float64_field = double(0); - self.complexfloat32_field = complex(single(0)); - self.complexfloat64_field = complex(0); - self.date_field = yardl.Date(); - self.time_field = yardl.Time(); - self.datetime_field = yardl.DateTime(); + function self = RecordWithPrimitives(kwargs) + arguments + kwargs.bool_field = false; + kwargs.int8_field = int8(0); + kwargs.uint8_field = uint8(0); + kwargs.int16_field = int16(0); + kwargs.uint16_field = uint16(0); + kwargs.int32_field = int32(0); + kwargs.uint32_field = uint32(0); + kwargs.int64_field = int64(0); + kwargs.uint64_field = uint64(0); + kwargs.size_field = uint64(0); + kwargs.float32_field = single(0); + kwargs.float64_field = double(0); + kwargs.complexfloat32_field = complex(single(0)); + kwargs.complexfloat64_field = complex(0); + kwargs.date_field = yardl.Date(); + kwargs.time_field = yardl.Time(); + kwargs.datetime_field = yardl.DateTime(); end + self.bool_field = kwargs.bool_field; + self.int8_field = kwargs.int8_field; + self.uint8_field = kwargs.uint8_field; + self.int16_field = kwargs.int16_field; + self.uint16_field = kwargs.uint16_field; + self.int32_field = kwargs.int32_field; + self.uint32_field = kwargs.uint32_field; + self.int64_field = kwargs.int64_field; + self.uint64_field = kwargs.uint64_field; + self.size_field = kwargs.size_field; + self.float32_field = kwargs.float32_field; + self.float64_field = kwargs.float64_field; + self.complexfloat32_field = kwargs.complexfloat32_field; + self.complexfloat64_field = kwargs.complexfloat64_field; + self.date_field = kwargs.date_field; + self.time_field = kwargs.time_field; + self.datetime_field = kwargs.datetime_field; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithStrings.m b/matlab/generated/+test_model/RecordWithStrings.m index 15f4fc54..481c71e0 100644 --- a/matlab/generated/+test_model/RecordWithStrings.m +++ b/matlab/generated/+test_model/RecordWithStrings.m @@ -7,14 +7,13 @@ end methods - function self = RecordWithStrings(a, b) - if nargin > 0 - self.a = a; - self.b = b; - else - self.a = ""; - self.b = ""; + function self = RecordWithStrings(kwargs) + arguments + kwargs.a = ""; + kwargs.b = ""; end + self.a = kwargs.a; + self.b = kwargs.b; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithUnionsOfContainers.m b/matlab/generated/+test_model/RecordWithUnionsOfContainers.m index 8f6ea691..127a5f6b 100644 --- a/matlab/generated/+test_model/RecordWithUnionsOfContainers.m +++ b/matlab/generated/+test_model/RecordWithUnionsOfContainers.m @@ -8,16 +8,15 @@ end methods - function self = RecordWithUnionsOfContainers(map_or_scalar, vector_or_scalar, array_or_scalar) - if nargin > 0 - self.map_or_scalar = map_or_scalar; - self.vector_or_scalar = vector_or_scalar; - self.array_or_scalar = array_or_scalar; - else - self.map_or_scalar = test_model.MapOrScalar.Map(dictionary); - self.vector_or_scalar = test_model.VectorOrScalar.Vector(int32.empty()); - self.array_or_scalar = test_model.ArrayOrScalar.Array(int32.empty()); + function self = RecordWithUnionsOfContainers(kwargs) + arguments + kwargs.map_or_scalar = test_model.MapOrScalar.Map(dictionary); + kwargs.vector_or_scalar = test_model.VectorOrScalar.Vector(int32.empty()); + kwargs.array_or_scalar = test_model.ArrayOrScalar.Array(int32.empty()); end + self.map_or_scalar = kwargs.map_or_scalar; + self.vector_or_scalar = kwargs.vector_or_scalar; + self.array_or_scalar = kwargs.array_or_scalar; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithVectorOfTimes.m b/matlab/generated/+test_model/RecordWithVectorOfTimes.m index 5126af1a..6c5845e2 100644 --- a/matlab/generated/+test_model/RecordWithVectorOfTimes.m +++ b/matlab/generated/+test_model/RecordWithVectorOfTimes.m @@ -6,12 +6,11 @@ end methods - function self = RecordWithVectorOfTimes(times) - if nargin > 0 - self.times = times; - else - self.times = yardl.Time.empty(); + function self = RecordWithVectorOfTimes(kwargs) + arguments + kwargs.times = yardl.Time.empty(); end + self.times = kwargs.times; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithVectors.m b/matlab/generated/+test_model/RecordWithVectors.m index fa667a04..e2a10ad5 100644 --- a/matlab/generated/+test_model/RecordWithVectors.m +++ b/matlab/generated/+test_model/RecordWithVectors.m @@ -8,16 +8,15 @@ end methods - function self = RecordWithVectors(default_vector, default_vector_fixed_length, vector_of_vectors) - if nargin > 0 - self.default_vector = default_vector; - self.default_vector_fixed_length = default_vector_fixed_length; - self.vector_of_vectors = vector_of_vectors; - else - self.default_vector = int32.empty(); - self.default_vector_fixed_length = repelem(int32(0), 3); - self.vector_of_vectors = int32.empty(); + function self = RecordWithVectors(kwargs) + arguments + kwargs.default_vector = int32.empty(); + kwargs.default_vector_fixed_length = repelem(int32(0), 3); + kwargs.vector_of_vectors = int32.empty(); end + self.default_vector = kwargs.default_vector; + self.default_vector_fixed_length = kwargs.default_vector_fixed_length; + self.vector_of_vectors = kwargs.vector_of_vectors; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithVlenCollections.m b/matlab/generated/+test_model/RecordWithVlenCollections.m index 4cfb7b0c..c7d65562 100644 --- a/matlab/generated/+test_model/RecordWithVlenCollections.m +++ b/matlab/generated/+test_model/RecordWithVlenCollections.m @@ -7,14 +7,13 @@ end methods - function self = RecordWithVlenCollections(vector, array) - if nargin > 0 - self.vector = vector; - self.array = array; - else - self.vector = int32.empty(); - self.array = int32.empty(0, 0); + function self = RecordWithVlenCollections(kwargs) + arguments + kwargs.vector = int32.empty(); + kwargs.array = int32.empty(0, 0); end + self.vector = kwargs.vector; + self.array = kwargs.array; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/RecordWithVlens.m b/matlab/generated/+test_model/RecordWithVlens.m index 698b7e10..b7209a0e 100644 --- a/matlab/generated/+test_model/RecordWithVlens.m +++ b/matlab/generated/+test_model/RecordWithVlens.m @@ -8,16 +8,15 @@ end methods - function self = RecordWithVlens(a, b, c) - if nargin > 0 - self.a = a; - self.b = b; - self.c = c; - else - self.a = test_model.SimpleRecord.empty(); - self.b = int32(0); - self.c = int32(0); + function self = RecordWithVlens(kwargs) + arguments + kwargs.a = test_model.SimpleRecord.empty(); + kwargs.b = int32(0); + kwargs.c = int32(0); end + self.a = kwargs.a; + self.b = kwargs.b; + self.c = kwargs.c; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/SimpleAcquisition.m b/matlab/generated/+test_model/SimpleAcquisition.m index fed07d27..681ab44f 100644 --- a/matlab/generated/+test_model/SimpleAcquisition.m +++ b/matlab/generated/+test_model/SimpleAcquisition.m @@ -9,18 +9,17 @@ end methods - function self = SimpleAcquisition(flags, idx, data, trajectory) - if nargin > 0 - self.flags = flags; - self.idx = idx; - self.data = data; - self.trajectory = trajectory; - else - self.flags = uint64(0); - self.idx = test_model.SimpleEncodingCounters(); - self.data = single.empty(0, 0); - self.trajectory = single.empty(0, 0); + function self = SimpleAcquisition(kwargs) + arguments + kwargs.flags = uint64(0); + kwargs.idx = test_model.SimpleEncodingCounters(); + kwargs.data = single.empty(0, 0); + kwargs.trajectory = single.empty(0, 0); end + self.flags = kwargs.flags; + self.idx = kwargs.idx; + self.data = kwargs.data; + self.trajectory = kwargs.trajectory; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/SimpleEncodingCounters.m b/matlab/generated/+test_model/SimpleEncodingCounters.m index ab7e4780..848ef301 100644 --- a/matlab/generated/+test_model/SimpleEncodingCounters.m +++ b/matlab/generated/+test_model/SimpleEncodingCounters.m @@ -9,18 +9,17 @@ end methods - function self = SimpleEncodingCounters(e1, e2, slice, repetition) - if nargin > 0 - self.e1 = e1; - self.e2 = e2; - self.slice = slice; - self.repetition = repetition; - else - self.e1 = yardl.None; - self.e2 = yardl.None; - self.slice = yardl.None; - self.repetition = yardl.None; + function self = SimpleEncodingCounters(kwargs) + arguments + kwargs.e1 = yardl.None; + kwargs.e2 = yardl.None; + kwargs.slice = yardl.None; + kwargs.repetition = yardl.None; end + self.e1 = kwargs.e1; + self.e2 = kwargs.e2; + self.slice = kwargs.slice; + self.repetition = kwargs.repetition; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/SimpleRecord.m b/matlab/generated/+test_model/SimpleRecord.m index 51ecb8fc..df234d1b 100644 --- a/matlab/generated/+test_model/SimpleRecord.m +++ b/matlab/generated/+test_model/SimpleRecord.m @@ -8,16 +8,15 @@ end methods - function self = SimpleRecord(x, y, z) - if nargin > 0 - self.x = x; - self.y = y; - self.z = z; - else - self.x = int32(0); - self.y = int32(0); - self.z = int32(0); + function self = SimpleRecord(kwargs) + arguments + kwargs.x = int32(0); + kwargs.y = int32(0); + kwargs.z = int32(0); end + self.x = kwargs.x; + self.y = kwargs.y; + self.z = kwargs.z; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/SmallBenchmarkRecord.m b/matlab/generated/+test_model/SmallBenchmarkRecord.m index 55c1e5a4..39ff0084 100644 --- a/matlab/generated/+test_model/SmallBenchmarkRecord.m +++ b/matlab/generated/+test_model/SmallBenchmarkRecord.m @@ -8,16 +8,15 @@ end methods - function self = SmallBenchmarkRecord(a, b, c) - if nargin > 0 - self.a = a; - self.b = b; - self.c = c; - else - self.a = double(0); - self.b = single(0); - self.c = single(0); + function self = SmallBenchmarkRecord(kwargs) + arguments + kwargs.a = double(0); + kwargs.b = single(0); + kwargs.c = single(0); end + self.a = kwargs.a; + self.b = kwargs.b; + self.c = kwargs.c; end function res = eq(self, other) diff --git a/matlab/generated/+test_model/TupleWithRecords.m b/matlab/generated/+test_model/TupleWithRecords.m index 96edbdf8..7c30a968 100644 --- a/matlab/generated/+test_model/TupleWithRecords.m +++ b/matlab/generated/+test_model/TupleWithRecords.m @@ -7,14 +7,13 @@ end methods - function self = TupleWithRecords(a, b) - if nargin > 0 - self.a = a; - self.b = b; - else - self.a = test_model.SimpleRecord(); - self.b = test_model.SimpleRecord(); + function self = TupleWithRecords(kwargs) + arguments + kwargs.a = test_model.SimpleRecord(); + kwargs.b = test_model.SimpleRecord(); end + self.a = kwargs.a; + self.b = kwargs.b; end function res = eq(self, other) diff --git a/matlab/generated/+tuples/+binary/TupleSerializer.m b/matlab/generated/+tuples/+binary/TupleSerializer.m index 52e59af2..6229b7b0 100644 --- a/matlab/generated/+tuples/+binary/TupleSerializer.m +++ b/matlab/generated/+tuples/+binary/TupleSerializer.m @@ -14,12 +14,12 @@ function write(self, outstream, value) outstream (1,1) yardl.binary.CodedOutputStream value (1,1) tuples.Tuple end - self.write_(outstream, value.v1, value.v2) + self.write_(outstream, value.v1, value.v2); end function value = read(self, instream) - field_values = self.read_(instream); - value = tuples.Tuple(field_values{:}); + fields = self.read_(instream); + value = tuples.Tuple(v1=fields{1}, v2=fields{2}); end end end diff --git a/matlab/generated/+tuples/Tuple.m b/matlab/generated/+tuples/Tuple.m index 965e3463..6e0f491b 100644 --- a/matlab/generated/+tuples/Tuple.m +++ b/matlab/generated/+tuples/Tuple.m @@ -7,9 +7,19 @@ end methods - function self = Tuple(v1, v2) - self.v1 = v1; - self.v2 = v2; + function self = Tuple(kwargs) + arguments + kwargs.v1; + kwargs.v2; + end + if ~isfield(kwargs, "v1") + throw(yardl.TypeError("Missing required keyword argument 'v1'")) + end + self.v1 = kwargs.v1; + if ~isfield(kwargs, "v2") + throw(yardl.TypeError("Missing required keyword argument 'v2'")) + end + self.v2 = kwargs.v2; end function res = eq(self, other) diff --git a/matlab/test/ComputedFieldsTest.m b/matlab/test/ComputedFieldsTest.m index d302606a..25a8b00c 100644 --- a/matlab/test/ComputedFieldsTest.m +++ b/matlab/test/ComputedFieldsTest.m @@ -14,7 +14,7 @@ function testFieldAccess(testCase) r.string_field = "hello"; testCase.verifyEqual(r.access_string_field(), "hello"); - r.tuple_field = test_model.MyTuple(1, 2); + r.tuple_field = test_model.MyTuple(v1=1, v2=2); testCase.verifyEqual(r.access_tuple_field(), r.tuple_field); testCase.verifyEqual(r.access_nested_tuple_field(), r.tuple_field.v2); @@ -147,13 +147,13 @@ function testSwitch(testCase) testCase.verifyEqual(r.nested_switch(), -1); testCase.verifyEqual(r.use_nested_computed_field(), -1); - g0 = basic_types.GenericRecordWithComputedFields(basic_types.T0OrT1.T0("hi")); + g0 = basic_types.GenericRecordWithComputedFields(f1=basic_types.T0OrT1.T0("hi")); r.union_with_nested_generic_union = ... test_model.IntOrGenericRecordWithComputedFields.GenericRecordWithComputedFields(g0); testCase.verifyEqual(r.nested_switch(), int32(10)); testCase.verifyEqual(r.use_nested_computed_field(), int32(0)); - g1 = basic_types.GenericRecordWithComputedFields(basic_types.T0OrT1.T1(single(42.9))); + g1 = basic_types.GenericRecordWithComputedFields(f1=basic_types.T0OrT1.T1(single(42.9))); r.union_with_nested_generic_union = ... test_model.IntOrGenericRecordWithComputedFields.GenericRecordWithComputedFields(g1); testCase.verifyEqual(r.nested_switch(), int32(20)); @@ -163,7 +163,7 @@ function testSwitch(testCase) testCase.verifyEqual(r.switch_over_single_value(), int32(10)); - gr = basic_types.GenericRecordWithComputedFields(basic_types.T0OrT1.T0(int32(42))); + gr = basic_types.GenericRecordWithComputedFields(f1=basic_types.T0OrT1.T0(int32(42))); testCase.verifyEqual(gr.type_index(), 0); gr.f1 = basic_types.T0OrT1.T1(single(42.9)); testCase.verifyEqual(gr.type_index(), 1); diff --git a/matlab/test/EqualityTest.m b/matlab/test/EqualityTest.m index 9603e4c4..b82eeae7 100644 --- a/matlab/test/EqualityTest.m +++ b/matlab/test/EqualityTest.m @@ -5,11 +5,11 @@ methods (Test) function testSimpleEquality(testCase) - a = test_model.SimpleRecord(1, 2, 3); - b = test_model.SimpleRecord(1, 2, 3); + a = test_model.SimpleRecord(x=1, y=2, z=3); + b = test_model.SimpleRecord(x=1, y=2, z=3); testCase.verifyEqual(a, b); - c = test_model.SimpleRecord(1, 2, 4); + c = test_model.SimpleRecord(x=1, y=2, z=4); testCase.verifyNotEqual(a, c); testCase.verifyEqual([a, b], [b, a]); @@ -47,11 +47,17 @@ function testEnumEquality(testCase) end function testRecordWithEnumEquality(testCase) - a = test_model.RecordWithEnums(test_model.Fruits.APPLE, bitor(test_model.DaysOfWeek.SATURDAY, test_model.DaysOfWeek.SUNDAY), 0); - b = test_model.RecordWithEnums(test_model.Fruits.APPLE, bitor(test_model.DaysOfWeek.SATURDAY, test_model.DaysOfWeek.SUNDAY), 0); + a = test_model.RecordWithEnums(enum=test_model.Fruits.APPLE, ... + flags=bitor(test_model.DaysOfWeek.SATURDAY, test_model.DaysOfWeek.SUNDAY), ... + flags_2=0); + b = test_model.RecordWithEnums(enum=test_model.Fruits.APPLE, ... + flags=bitor(test_model.DaysOfWeek.SATURDAY, test_model.DaysOfWeek.SUNDAY), ... + flags_2=0); testCase.verifyEqual(a, b); - c = test_model.RecordWithEnums(test_model.Fruits.APPLE, test_model.DaysOfWeek.SATURDAY, 0); + c = test_model.RecordWithEnums(enum=test_model.Fruits.APPLE, ... + flags=test_model.DaysOfWeek.SATURDAY, ... + flags_2=0); testCase.verifyNotEqual(a, c); testCase.verifyEqual([a, b, c], [b, a, c]); @@ -116,15 +122,15 @@ function testStringEquality(testCase) function testRecordWithPrimitiveVectorsEquality(testCase) a = test_model.RecordWithVectors( ... - [1, 2], ... - [1, 2, 3], ... - [[1, 2], [3, 4]] ... + default_vector=[1, 2], ... + default_vector_fixed_length=[1, 2, 3], ... + vector_of_vectors=[[1, 2], [3, 4]] ... ); b = test_model.RecordWithVectors( ... - [1, 2], ... - [1, 2, 3], ... - [[1, 2], [3, 4]] ... + default_vector=[1, 2], ... + default_vector_fixed_length=[1, 2, 3], ... + vector_of_vectors=[[1, 2], [3, 4]] ... ); testCase.verifyEqual(a, b); @@ -154,15 +160,15 @@ function testOptionalIntEquality(testCase) function testTimeVectorEquality(testCase) a = test_model.RecordWithVectorOfTimes(... - [yardl.Time.from_components(1, 1, 1, 1), yardl.Time.from_components(1, 1, 1, 1)] ... + times=[yardl.Time.from_components(1, 1, 1, 1), yardl.Time.from_components(1, 1, 1, 1)] ... ); b = test_model.RecordWithVectorOfTimes(... - [yardl.Time.from_components(1, 1, 1, 1), yardl.Time.from_components(1, 1, 1, 1)] ... + times=[yardl.Time.from_components(1, 1, 1, 1), yardl.Time.from_components(1, 1, 1, 1)] ... ); testCase.verifyEqual(a, b); c = test_model.RecordWithVectorOfTimes(... - [yardl.Time.from_components(1, 1, 1, 1), yardl.Time.from_components(1, 1, 1, 2)] ... + times=[yardl.Time.from_components(1, 1, 1, 1), yardl.Time.from_components(1, 1, 1, 2)] ... ); testCase.verifyNotEqual(a, c); @@ -219,15 +225,17 @@ function testTimeUnionEquality(testCase) end function testGenericEquality(testCase) - a = test_model.GenericRecord(1, 2.0, [1, 2, 3], single([[1.1, 2.2], [3.3, 4.4]])); - b = test_model.GenericRecord(1, 2.0, [1, 2, 3], single([[1.1, 2.2], [3.3, 4.4]])); + a = test_model.GenericRecord(scalar_1=1, scalar_2=2.0, vector_1=[1, 2, 3], ... + image_2=single([[1.1, 2.2], [3.3, 4.4]])); + b = test_model.GenericRecord(scalar_1=1, scalar_2=2.0, vector_1=[1, 2, 3], ... + image_2=single([[1.1, 2.2], [3.3, 4.4]])); testCase.verifyEqual(a, b); - c = test_model.MyTuple(42.0, "hello, world"); - d = tuples.Tuple(42.0, "hello, world"); + c = test_model.MyTuple(v1=42.0, v2="hello, world"); + d = tuples.Tuple(v1=42.0, v2="hello, world"); testCase.verifyTrue(c == d) - e = test_model.AliasedTuple(42.0, "hello, world"); + e = test_model.AliasedTuple(v1=42.0, v2="hello, world"); testCase.verifyTrue(c == e); testCase.verifyEqual({a, b, c, d, e}, {b, a, d, c, e}); diff --git a/matlab/test/GeneratedTypesTest.m b/matlab/test/GeneratedTypesTest.m index 16c0a2a2..aba95605 100644 --- a/matlab/test/GeneratedTypesTest.m +++ b/matlab/test/GeneratedTypesTest.m @@ -82,16 +82,19 @@ function testDefaultRecordGenericEmpty(testCase) g2a = test_model.RecordWithAliasedOptionalGenericUnionField(); testCase.verifyEqual(g2a.v, g2.v) - testCase.verifyError(@() test_model.MyTuple(), 'MATLAB:minrhs'); + % testCase.verifyError(@() test_model.MyTuple(), 'MATLAB:minrhs'); + testCase.verifyError(@() test_model.MyTuple(), 'yardl:TypeError'); + t = test_model.MyTuple(v1="a", v2=42); + rm = test_model.RecordWithGenericMaps(); testCase.verifyEqual(rm.m, dictionary); testCase.verifyEqual(rm.am, rm.m); end function testDefaultRecordWithGenericRequiredArguments(testCase) - testCase.verifyError(@() test_model.RecordWithGenericArrays(), 'MATLAB:minrhs'); - testCase.verifyError(@() test_model.RecordWithGenericVectors(), 'MATLAB:minrhs'); - testCase.verifyError(@() test_model.RecordWithGenericFixedVectors(), 'MATLAB:minrhs'); + testCase.verifyError(@() test_model.RecordWithGenericArrays(), 'yardl:TypeError'); + testCase.verifyError(@() test_model.RecordWithGenericVectors(), 'yardl:TypeError'); + testCase.verifyError(@() test_model.RecordWithGenericFixedVectors(), 'yardl:TypeError'); end function testDefaultRecordContainingNestedGenericRecords(testCase) diff --git a/matlab/test/RoundTripTest.m b/matlab/test/RoundTripTest.m index c0558e32..948fa57f 100644 --- a/matlab/test/RoundTripTest.m +++ b/matlab/test/RoundTripTest.m @@ -45,19 +45,23 @@ function testScalarOptionals(testCase, format) w = create_validating_writer(testCase, format, 'ScalarOptionals'); w.write_optional_int(int32(55)); - w.write_optional_record(test_model.SimpleRecord(8, 9, 10)); + w.write_optional_record(test_model.SimpleRecord(x=8, y=9, z=10)); w.write_record_with_optional_fields(... - test_model.RecordWithOptionalFields(int32(44), int32(44), yardl.Time.from_components(12, 34, 56, 0))); + test_model.RecordWithOptionalFields(optional_int=int32(44), ... + optional_int_alternate_syntax=int32(44), ... + optional_time=yardl.Time.from_components(12, 34, 56, 0))); w.write_optional_record_with_optional_fields(... - test_model.RecordWithOptionalFields(int32(12), int32(12), yardl.Time.from_components(11, 32, 26, 0))); + test_model.RecordWithOptionalFields(optional_int=int32(12), ... + optional_int_alternate_syntax=int32(12), ... + optional_time=yardl.Time.from_components(11, 32, 26, 0))); w.close(); end function testNestedRecords(testCase, format) w = create_validating_writer(testCase, format, 'NestedRecords'); t = test_model.TupleWithRecords(... - test_model.SimpleRecord(1, 2, 3), ... - test_model.SimpleRecord(4, 5, 6)); + a=test_model.SimpleRecord(x=1, y=2, z=3), ... + b=test_model.SimpleRecord(x=4, y=5, z=6)); w.write_tuple_with_records(t); w.close(); end @@ -67,9 +71,9 @@ function testVariableLengthVectors(testCase, format) w.write_int_vector(int32([1, 2, 3])); w.write_complex_vector(single([1+2j, 3+4j])); rec = test_model.RecordWithVlens(... - [test_model.SimpleRecord(1, 2, 3), test_model.SimpleRecord(4, 5, 6)], ... - 4, ... - 2 ... + a=[test_model.SimpleRecord(x=1, y=2, z=3), test_model.SimpleRecord(x=4, y=5, z=6)], ... + b=4, ... + c=2 ... ); w.write_record_with_vlens(rec); w.write_vlen_of_record_with_vlens([rec, rec]); @@ -79,7 +83,7 @@ function testVariableLengthVectors(testCase, format) function testStrings(testCase, format) w = create_validating_writer(testCase, format, 'Strings'); w.write_single_string("hello"); - w.write_rec_with_string(test_model.RecordWithStrings("Montréal", "臺北市")); + w.write_rec_with_string(test_model.RecordWithStrings(a="Montréal", b="臺北市")); w.close(); end @@ -89,17 +93,22 @@ function testOptionalVectors(testCase, format) w.close(); w = create_validating_writer(testCase, format, 'OptionalVectors'); - w.write_record_with_optional_vector(test_model.RecordWithOptionalVector(int32([1, 2, 3]))); + w.write_record_with_optional_vector(test_model.RecordWithOptionalVector(optional_vector=int32([1, 2, 3]))); w.close(); end function testFixedVectors(testCase, format) ints = int32([1, 2, 3, 4, 5]); SR = @test_model.SimpleRecord; - simple_recs = [SR(1, 2, 3), SR(4, 5, 6), SR(7, 8, 9)]; + simple_recs = [SR(x=1, y=2, z=3), SR(x=4, y=5, z=6), SR(x=7, y=8, z=9)]; RV = @test_model.RecordWithVlens; - vlens_recs = [RV([SR(1, 2, 3), SR(4, 5, 6)], 4, 2), RV([SR(7, 8, 9), SR(10, 11, 12)], 5, 3)]; - rec_with_fixed = test_model.RecordWithFixedVectors(ints, simple_recs, vlens_recs); + vlens_recs = [... + RV(a=[SR(x=1, y=2, z=3), SR(x=4, y=5, z=6)], b=4, c=2), ... + RV(a=[SR(x=7, y=8, z=9), SR(x=10, y=11, z=12)], b=5, c=3)]; + rec_with_fixed = test_model.RecordWithFixedVectors(... + fixed_int_vector=ints, ... + fixed_simple_record_vector=simple_recs, ... + fixed_record_with_vlens_vector=vlens_recs); w = create_validating_writer(testCase, format, 'FixedVectors'); w.write_fixed_int_vector(ints); @@ -115,24 +124,27 @@ function testFixedArrays(testCase, format) SR = @test_model.SimpleRecord; simple_recs = [... - [SR(1, 2, 3), SR(4, 5, 6)]; ... - [SR(11, 12, 13), SR(14, 15, 16)]; ... - [SR(21, 22, 23), SR(24, 25, 26)] ... + [SR(x=1, y=2, z=3), SR(x=4, y=5, z=6)]; ... + [SR(x=11, y=12, z=13), SR(x=14, y=15, z=16)]; ... + [SR(x=21, y=22, z=23), SR(x=24, y=25, z=26)] ... ]; simple_recs = transpose(simple_recs); RV = @test_model.RecordWithVlens; vlens_recs = [... [... - RV([SR(1, 2, 3), SR(7, 8, 9)], 13, 14), ... - RV([SR(7, 8, 9), SR(10, 11, 12)], 5, 3)]; ... + RV(a=[SR(x=1, y=2, z=3), SR(x=7, y=8, z=9)], b=13, c=14), ... + RV(a=[SR(x=7, y=8, z=9), SR(x=10, y=11, z=12)], b=5, c=3)]; ... [... - RV([SR(31, 32, 33), SR(34, 35, 36), SR(37, 38, 39)], 213, 214), ... - RV([SR(41, 42, 43)], 313, 314)] ... + RV(a=[SR(x=31, y=32, z=33), SR(x=34, y=35, z=36), SR(x=37, y=38, z=39)], b=213, c=214), ... + RV(a=[SR(x=41, y=42, z=43)], b=313, c=314)] ... ]; vlens_recs = transpose(vlens_recs); - rec_with_fixed = test_model.RecordWithFixedArrays(ints, simple_recs, vlens_recs); + rec_with_fixed = test_model.RecordWithFixedArrays(... + ints=ints, ... + fixed_simple_record_array=simple_recs, ... + fixed_record_with_vlens_array=vlens_recs); w = create_validating_writer(testCase, format, 'FixedArrays'); w.write_ints(ints); @@ -186,14 +198,14 @@ function testSubarrays(testCase, format) function testSubarraysInRecords(testCase, format) RF = @test_model.RecordWithFixedCollections; records_with_fixed = [... - RF(int32([1, 2, 3]), int32([[11; 12; 13], [14; 15; 16]])), ... - RF(int32([101, 102, 103]), int32([[1011; 1012; 1013], [1014; 1015; 1016]])), ... + RF(fixed_vector=int32([1, 2, 3]), fixed_array=int32([[11; 12; 13], [14; 15; 16]])), ... + RF(fixed_vector=int32([101, 102, 103]), fixed_array=int32([[1011; 1012; 1013], [1014; 1015; 1016]])), ... ]; RV = @test_model.RecordWithVlenCollections; records_with_vlens = [... - RV(int32([1, 2, 3]), int32([[11, 12, 13]; [14, 15, 16]])), ...]) - RV(int32([101, 102, 103]), int32([[1011, 1012, 1013]; [1014, 1015, 1016]])), ... + RV(vector=int32([1, 2, 3]), array=int32([[11, 12, 13]; [14, 15, 16]])), ...]) + RV(vector=int32([101, 102, 103]), array=int32([[1011, 1012, 1013]; [1014, 1015, 1016]])), ... ]; w = create_validating_writer(testCase, format, 'SubarraysInRecords'); @@ -207,24 +219,27 @@ function testNDArrays(testCase, format) SR = @test_model.SimpleRecord; simple_recs = [... - [SR(1, 2, 3), SR(4, 5, 6)]; ... - [SR(11, 12, 13), SR(14, 15, 16)]; ... - [SR(21, 22, 23), SR(24, 25, 26)] ... + [SR(x=1, y=2, z=3), SR(x=4, y=5, z=6)]; ... + [SR(x=11, y=12, z=13), SR(x=14, y=15, z=16)]; ... + [SR(x=21, y=22, z=23), SR(x=24, y=25, z=26)] ... ]; simple_recs = transpose(simple_recs); RV = @test_model.RecordWithVlens; vlens_recs = [... [... - RV([SR(1, 2, 3), SR(7, 8, 9)], 13, 14), ... - RV([SR(7, 8, 9), SR(10, 11, 12)], 5, 3)]; ... + RV(a=[SR(x=1, y=2, z=3), SR(x=7, y=8, z=9)], b=13, c=14), ... + RV(a=[SR(x=7, y=8, z=9), SR(x=10, y=11, z=12)], b=5, c=3)]; ... [... - RV([SR(31, 32, 33), SR(34, 35, 36), SR(37, 38, 39)], 213, 214), ... - RV([SR(41, 42, 43)], 313, 314)] ... + RV(a=[SR(x=31, y=32, z=33), SR(x=34, y=35, z=36), SR(x=37, y=38, z=39)], b=213, c=214), ... + RV(a=[SR(x=41, y=42, z=43)], b=313, c=314)] ... ]; vlens_recs = transpose(vlens_recs); - rec_with_nds = test_model.RecordWithNDArrays(ints, simple_recs, vlens_recs); + rec_with_nds = test_model.RecordWithNDArrays(... + ints=ints, ... + fixed_simple_record_array=simple_recs, ... + fixed_record_with_vlens_array=vlens_recs); w = create_validating_writer(testCase, format, 'NDArrays'); w.write_ints(ints); @@ -239,15 +254,18 @@ function testDynamicNDArrays(testCase, format) ints = transpose(int32([[1, 2, 3]; [4, 5, 6]; [7, 8, 9]; [10, 11, 12]])); SR = @test_model.SimpleRecord; simple_recs = transpose([... - [SR(1, 2, 3), SR(4, 5, 6), SR(7, 8, 9)]; ... - [SR(11, 12, 13), SR(14, 15, 16), SR(17, 18, 19)]; ... + [SR(x=1, y=2, z=3), SR(x=4, y=5, z=6), SR(x=7, y=8, z=9)]; ... + [SR(x=11, y=12, z=13), SR(x=14, y=15, z=16), SR(x=17, y=18, z=19)]; ... ]); RV = @test_model.RecordWithVlens; vlens_recs = transpose([... - [RV([SR(1, 2, 3)], -33, 44)]; ... - [RV([SR(8, 2, 9), SR(28, 3, 34)], 233, 347)] ... + [RV(a=[SR(x=1, y=2, z=3)], b=-33, c=44)]; ... + [RV(a=[SR(x=8, y=2, z=9), SR(x=28, y=3, z=34)], b=233, c=347)] ... ]); - rec_with_dynamic_nds = test_model.RecordWithDynamicNDArrays(ints, simple_recs, vlens_recs); + rec_with_dynamic_nds = test_model.RecordWithDynamicNDArrays(... + ints=ints, ... + simple_record_array=simple_recs, ... + record_with_vlens_array=vlens_recs); w = create_validating_writer(testCase, format, 'DynamicNDArrays'); w.write_ints(ints); @@ -315,13 +333,13 @@ function testUnions(testCase, format) w.close(); w = create_validating_writer(testCase, format, 'Unions'); - w.write_int_or_simple_record(test_model.Int32OrSimpleRecord.SimpleRecord(test_model.SimpleRecord(1, 2, 3))); - w.write_int_or_record_with_vlens(test_model.Int32OrRecordWithVlens.RecordWithVlens(test_model.RecordWithVlens([test_model.SimpleRecord(1, 2, 3)], 12, 13))); + w.write_int_or_simple_record(test_model.Int32OrSimpleRecord.SimpleRecord(test_model.SimpleRecord(x=1, y=2, z=3))); + w.write_int_or_record_with_vlens(test_model.Int32OrRecordWithVlens.RecordWithVlens(test_model.RecordWithVlens(a=[test_model.SimpleRecord(x=1, y=2, z=3)], b=12, c=13))); w.write_monosotate_or_int_or_simple_record(test_model.Int32OrSimpleRecord.Int32(6)); w.write_record_with_unions(basic_types.RecordWithUnions(... - basic_types.Int32OrString.Int32(7), ... - basic_types.TimeOrDatetime.Datetime(yardl.DateTime.from_components(2025, 3, 4, 12, 34, 56, 0)), ... - basic_types.GenericNullableUnion2.T1(basic_types.Fruits.APPLE) ... + null_or_int_or_string= basic_types.Int32OrString.Int32(7), ... + date_or_datetime= basic_types.TimeOrDatetime.Datetime(yardl.DateTime.from_components(2025, 3, 4, 12, 34, 56, 0)), ... + null_or_fruits_or_days_of_week= basic_types.GenericNullableUnion2.T1(basic_types.Fruits.APPLE) ... )); w.close(); end @@ -369,8 +387,8 @@ function testSimpleStreams(testCase, format) w.end_optional_int_data(); w.write_record_with_optional_vector_data([... test_model.RecordWithOptionalVector(), ... - test_model.RecordWithOptionalVector(int32([1, 2, 3])), ... - test_model.RecordWithOptionalVector(int32(1:10)) ... + test_model.RecordWithOptionalVector(optional_vector=int32([1, 2, 3])), ... + test_model.RecordWithOptionalVector(optional_vector=int32(1:10)) ... ]); w.end_record_with_optional_vector_data(); w.write_fixed_vector(... @@ -418,14 +436,14 @@ function testStreamsOfUnions(testCase, format) w = create_validating_writer(testCase, format, 'StreamsOfUnions'); w.write_int_or_simple_record([... test_model.Int32OrSimpleRecord.Int32(1), ... - test_model.Int32OrSimpleRecord.SimpleRecord(test_model.SimpleRecord(1, 2, 3)), ... + test_model.Int32OrSimpleRecord.SimpleRecord(test_model.SimpleRecord(x=1, y=2, z=3)), ... test_model.Int32OrSimpleRecord.Int32(2) ... ]); w.end_int_or_simple_record(); w.write_nullable_int_or_simple_record([... yardl.None, ... test_model.Int32OrSimpleRecord.Int32(1), ... - test_model.Int32OrSimpleRecord.SimpleRecord(test_model.SimpleRecord(1, 2, 3)), ... + test_model.Int32OrSimpleRecord.SimpleRecord(test_model.SimpleRecord(x=1, y=2, z=3)), ... yardl.None, ... test_model.Int32OrSimpleRecord.Int32(2), ... yardl.None ... @@ -438,14 +456,14 @@ function testStreamsOfAliasedUnions(testCase, format) w = create_validating_writer(testCase, format, 'StreamsOfAliasedUnions'); w.write_int_or_simple_record([... test_model.AliasedIntOrSimpleRecord.Int32(1), ... - test_model.AliasedIntOrSimpleRecord.SimpleRecord(test_model.SimpleRecord(1, 2, 3)), ... + test_model.AliasedIntOrSimpleRecord.SimpleRecord(test_model.SimpleRecord(x=1, y=2, z=3)), ... test_model.AliasedIntOrSimpleRecord.Int32(2) ... ]); w.end_int_or_simple_record(); w.write_nullable_int_or_simple_record([... yardl.None, ... test_model.AliasedNullableIntSimpleRecord.Int32(1), ... - test_model.AliasedNullableIntSimpleRecord.SimpleRecord(test_model.SimpleRecord(1, 2, 3)), ... + test_model.AliasedNullableIntSimpleRecord.SimpleRecord(test_model.SimpleRecord(x=1, y=2, z=3)), ... yardl.None, ... test_model.AliasedNullableIntSimpleRecord.Int32(2), ... yardl.None ... @@ -460,11 +478,11 @@ function testSimpleGenerics(testCase, format) w.write_int_image(transpose(int32([[1, 2]; [3, 4]]))); w.write_int_image_alternate_syntax(transpose(int32([[1, 2]; [3, 4]]))); w.write_string_image(transpose([["a", "b"]; ["c", "d"]])); - w.write_int_float_tuple(test_model.MyTuple(int32(1), single(2))); - w.write_float_float_tuple(test_model.MyTuple(single(1), single(2))); - t = test_model.MyTuple(int32(1), single(2)); + w.write_int_float_tuple(test_model.MyTuple(v1=int32(1), v2=single(2))); + w.write_float_float_tuple(test_model.MyTuple(v1=single(1), v2=single(2))); + t = test_model.MyTuple(v1=int32(1), v2=single(2)); w.write_int_float_tuple_alternate_syntax(t); - w.write_int_string_tuple(test_model.MyTuple(int32(1), "2")); + w.write_int_string_tuple(test_model.MyTuple(v1=int32(1), v2="2")); w.write_stream_of_type_variants([... test_model.ImageFloatOrImageDouble.ImageFloat(transpose(single([[1, 2]; [3, 4]]))), ... test_model.ImageFloatOrImageDouble.ImageDouble(transpose([[1, 2]; [3, 4]])) ... @@ -489,15 +507,15 @@ function testAdvancedGenerics(testCase, format) w.write_float_image_image(img_img_array); w.write_generic_record_1(test_model.GenericRecord(... - int32(1), ... - "hello", ... - int32([1, 2, 3]), ... - [["abc", "def"]; ["a", "b"]] ... + scalar_1=int32(1), ... + scalar_2="hello", ... + vector_1=int32([1, 2, 3]), ... + image_2=[["abc", "def"]; ["a", "b"]] ... )); - w.write_tuple_of_optionals(test_model.MyTuple(yardl.None, "hello")); - w.write_tuple_of_optionals_alternate_syntax(test_model.MyTuple(int32(34), yardl.None)); - w.write_tuple_of_vectors(test_model.MyTuple(int32([1, 2, 3]), single([4, 5, 6]))); + w.write_tuple_of_optionals(test_model.MyTuple(v1=yardl.None, v2="hello")); + w.write_tuple_of_optionals_alternate_syntax(test_model.MyTuple(v1=int32(34), v2=yardl.None)); + w.write_tuple_of_vectors(test_model.MyTuple(v1=int32([1, 2, 3]), v2=single([4, 5, 6]))); w.close(); end @@ -505,8 +523,8 @@ function testAliases(testCase, format) w = create_validating_writer(testCase, format, 'Aliases'); w.write_aliased_string("hello"); w.write_aliased_enum(test_model.Fruits.APPLE); - w.write_aliased_open_generic(test_model.AliasedOpenGeneric("hello", test_model.Fruits.BANANA)); - w.write_aliased_closed_generic(test_model.AliasedClosedGeneric("hello", test_model.Fruits.PEAR)); + w.write_aliased_open_generic(test_model.AliasedOpenGeneric(v1="hello", v2=test_model.Fruits.BANANA)); + w.write_aliased_closed_generic(test_model.AliasedClosedGeneric(v1="hello", v2=test_model.Fruits.PEAR)); w.write_aliased_optional(int32(23)); w.write_aliased_generic_optional(single(44)); w.write_aliased_generic_union_2(test_model.AliasedGenericUnion2.T1("hello")); diff --git a/matlab/test/benchmark.m b/matlab/test/benchmark.m index 5214017e..9d802273 100644 --- a/matlab/test/benchmark.m +++ b/matlab/test/benchmark.m @@ -212,7 +212,10 @@ function read() function res = benchmark_small_record(format) scale = 1; - record = test_model.SmallBenchmarkRecord(double(73278383.23123213), single(78323.2820379), single(-2938923.29882)); + record = test_model.SmallBenchmarkRecord(); + record.a = double(73278383.23123213); + record.b = single(78323.2820379); + record.c = single(-2938923.29882); repetitions = scale_repetitions(50000, scale); total_bytes = 16 * repetitions; diff --git a/tooling/internal/matlab/binary/binary.go b/tooling/internal/matlab/binary/binary.go index c7ed3544..035431f3 100644 --- a/tooling/internal/matlab/binary/binary.go +++ b/tooling/internal/matlab/binary/binary.go @@ -193,14 +193,18 @@ func writeRecordSerializer(fw *common.MatlabFileWriter, rec *dsl.RecordDefinitio for i, field := range rec.Fields { fieldAccesses[i] = fmt.Sprintf("value.%s", common.FieldIdentifierName(field.Name)) } - fmt.Fprintf(w, "self.write_(outstream, %s)\n", strings.Join(fieldAccesses, ", ")) + fmt.Fprintf(w, "self.write_(outstream, %s);\n", strings.Join(fieldAccesses, ", ")) }) w.WriteStringln("") fmt.Fprintf(w, "function value = read(self, instream)\n") common.WriteBlockBody(w, func() { - w.WriteStringln("field_values = self.read_(instream);") - fmt.Fprintf(w, "value = %s(field_values{:});\n", typeSyntax) + w.WriteStringln("fields = self.read_(instream);") + fieldWrites := make([]string, len(rec.Fields)) + for i, field := range rec.Fields { + fieldWrites[i] = fmt.Sprintf("%s=fields{%d}", common.FieldIdentifierName(field.Name), i+1) + } + fmt.Fprintf(w, "value = %s(%s);\n", typeSyntax, strings.Join(fieldWrites, ", ")) }) }) }) diff --git a/tooling/internal/matlab/types/types.go b/tooling/internal/matlab/types/types.go index 7507c8a6..64a6c237 100644 --- a/tooling/internal/matlab/types/types.go +++ b/tooling/internal/matlab/types/types.go @@ -274,18 +274,17 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. w.WriteStringln("properties") var fieldNames []string - requireConstructorArgs := false + requiresArgsToConstruct := false common.WriteBlockBody(w, func() { for _, field := range rec.Fields { common.WriteComment(w, field.Comment) fieldName := common.FieldIdentifierName(field.Name) fieldNames = append(fieldNames, fieldName) w.WriteStringln(fieldName) - _, defaultExpressionKind := typeDefault(field.Type, rec.Namespace, "", st) switch defaultExpressionKind { case defaultValueKindNone: - requireConstructorArgs = true + requiresArgsToConstruct = true } } }) @@ -294,33 +293,32 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. w.WriteStringln("methods") common.WriteBlockBody(w, func() { - // Record Constructor - fmt.Fprintf(w, "function self = %s(%s)\n", recordName, strings.Join(fieldNames, ", ")) + fmt.Fprintf(w, "function self = %s(kwargs)\n", recordName) common.WriteBlockBody(w, func() { - if requireConstructorArgs { + w.WriteStringln("arguments") + common.WriteBlockBody(w, func() { for _, field := range rec.Fields { - fmt.Fprintf(w, "self.%s = %s;\n", common.FieldIdentifierName(field.Name), common.FieldIdentifierName(field.Name)) - } - } else { - w.WriteStringln("if nargin > 0") - w.Indented(func() { - for _, field := range rec.Fields { - fmt.Fprintf(w, "self.%s = %s;\n", common.FieldIdentifierName(field.Name), common.FieldIdentifierName(field.Name)) - } - }) - w.WriteStringln("else") - common.WriteBlockBody(w, func() { - for _, field := range rec.Fields { - fieldName := common.FieldIdentifierName(field.Name) - defaultExpression, defaultExpressionKind := typeDefault(field.Type, rec.Namespace, "", st) - switch defaultExpressionKind { - case defaultValueKindNone: - w.WriteStringln(fieldName) - case defaultValueKindImmutable, defaultValueKindMutable: - fmt.Fprintf(w, "self.%s = %s;\n", fieldName, defaultExpression) - } + fieldName := common.FieldIdentifierName(field.Name) + defaultExpression, defaultExpressionKind := typeDefault(field.Type, rec.Namespace, "", st) + switch defaultExpressionKind { + case defaultValueKindNone: + fmt.Fprintf(w, "kwargs.%s;\n", fieldName) + case defaultValueKindImmutable, defaultValueKindMutable: + fmt.Fprintf(w, "kwargs.%s = %s;\n", fieldName, defaultExpression) } - }) + } + }) + for _, field := range rec.Fields { + fieldName := common.FieldIdentifierName(field.Name) + _, defaultExpressionKind := typeDefault(field.Type, rec.Namespace, "", st) + switch defaultExpressionKind { + case defaultValueKindNone: + fmt.Fprintf(w, "if ~isfield(kwargs, \"%s\")\n", fieldName) + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "throw(yardl.TypeError(\"Missing required keyword argument '%s'\"))\n", fieldName) + }) + } + fmt.Fprintf(w, "self.%s = kwargs.%s;\n", fieldName, fieldName) } }) w.WriteStringln("") @@ -364,7 +362,7 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. }) w.WriteStringln("") - if !requireConstructorArgs { + if !requiresArgsToConstruct { w.WriteStringln("methods (Static)") common.WriteBlockBody(w, func() { writeZerosStaticMethod(w, common.TypeSyntax(rec, rec.Namespace), []string{}) @@ -1075,13 +1073,21 @@ func typeDefinitionDefault(t dsl.TypeDefinition, contextNamespace string, st dsl return fmt.Sprintf("%s()", common.TypeSyntax(t, contextNamespace)), defaultValueKindMutable } + // t is a *closed* generic record type + // genericDef is its original generic type definition + genericDef := st[t.GetQualifiedName()].(*dsl.RecordDefinition) args := make([]string, 0) - for _, f := range t.Fields { + for i, f := range t.Fields { fieldDefaultExpr, fieldDefaultKind := typeDefault(f.Type, contextNamespace, "", st) if fieldDefaultKind == defaultValueKindNone { return "", defaultValueKindNone } - args = append(args, fieldDefaultExpr) + + // Only write a constructor argument if it is needed, e.g. the record definition's field is generic and doesn't have a default value + _, genDefaultKind := typeDefault(genericDef.Fields[i].Type, contextNamespace, "", st) + if genDefaultKind == defaultValueKindNone { + args = append(args, fmt.Sprintf("%s=%s", common.FieldIdentifierName(f.Name), fieldDefaultExpr)) + } } return fmt.Sprintf("%s(%s)", common.TypeSyntax(t, contextNamespace), strings.Join(args, ", ")), defaultValueKindMutable From 328219d9c30a161463d122821fead57f55866110 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Tue, 7 May 2024 02:55:19 +0000 Subject: [PATCH 26/32] Update docs with MATLAB Record kwargs --- docs/matlab/language.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/matlab/language.md b/docs/matlab/language.md index 90183028..6fd62d63 100644 --- a/docs/matlab/language.md +++ b/docs/matlab/language.md @@ -371,10 +371,16 @@ Example usage: ```matlab permissions = bitor(sandbox.Permissions.READ, sandbox.Permissions.EXECUTE); +% Or +permissions = sandbox.Permissions.READ.with_flag(sandbox.Permissions.EXECUTE); % ... if bitand(sandbox.Permissions.READ, permissions) % ... end +% Or +if permissions.has_flags(sandbox.Permissions.READ) + % ... +end ``` ## Maps @@ -657,7 +663,7 @@ Computed fields become parameterless methods on the generated Python class. Here is an example of invoking the field from the preceding Yardl definition: ```matlab ->> rec = sandbox.MyRec(sandbox.Int32OrNamedArray.Int32(4)); +>> rec = sandbox.MyRec(my_union=sandbox.Int32OrNamedArray.Int32(4)); >> rec.my_union_size() ans = @@ -665,14 +671,14 @@ ans = 1 >> arr = sandbox.NamedArray(int32(ones(7))); ->> rec = sandbox.MyRec(sandbox.Int32OrNamedArray.NamedArray(arr)); +>> rec = sandbox.MyRec(my_union=sandbox.Int32OrNamedArray.NamedArray(arr)); >> rec.my_union_size() ans = 49 ->> rec = sandbox.MyRec(yardl.None); +>> rec = sandbox.MyRec(my_union=yardl.None); >> rec.my_union_size() ans = @@ -711,7 +717,7 @@ w = sandbox.binary.MyProtocolWriter("sandbox.bin"); w.write_point(p); w.close(); -p = sandbox.Point("a", "b"); +p = sandbox.Point(x="a", y="b"); w = sandbox.binary.MyProtocolWriter("sandbox.bin"); w.write_point(p); % Error: ...Value must be of type int32 or be convertible to int32. // [!code error] w.close(); @@ -729,8 +735,8 @@ MyTuple: BasicTypes.Tuple Imported types are likewise namespaced in Matlab packages: ```matlab -t1 = basic_types.Tuple("John Smith", 42); -t2 = sandbox.MyTuple("John Smith", 42); +t1 = basic_types.Tuple(v1="John Smith", v2=42); +t2 = sandbox.MyTuple(v1="John Smith", v2=42); assert(t1 == t2); ``` From 6aec5a310a9ddf1c0152ccb45e876e65b142cdb4 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Mon, 13 May 2024 13:17:59 +0000 Subject: [PATCH 27/32] Fix RuntimeErrors in MATLAB binary streams --- matlab/test/CodedStreamTest.m | 17 +++++++++++++++++ .../static_files/+binary/CodedInputStream.m | 2 +- .../static_files/+binary/CodedOutputStream.m | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/matlab/test/CodedStreamTest.m b/matlab/test/CodedStreamTest.m index a13b9bca..f36c830e 100644 --- a/matlab/test/CodedStreamTest.m +++ b/matlab/test/CodedStreamTest.m @@ -5,6 +5,23 @@ methods (Test) + function testConstructors(testCase) + filename = "/mnt/does_not_exist/foo/bar"; + testCase.verifyError(@() yardl.binary.CodedInputStream(filename), 'yardl:RuntimeError'); + testCase.verifyError(@() yardl.binary.CodedOutputStream(filename), 'yardl:RuntimeError'); + + filename = tempname; + [fid, errmsg] = fopen(filename, 'w'); + w = yardl.binary.CodedOutputStream(fid); + w.close(); + + [fid, errmsg] = fopen(filename, 'r'); + r = yardl.binary.CodedInputStream(fid); + r.close(); + + delete(filename); + end + function testVarShort(testCase) entries = int16([0, 1, 5, 33, 0x7E, 0x7F, 0x80, 0x81, 255, 256, 257, 838, 0x3FFF, 0x4000, 0x4001, 0x7FFF]); diff --git a/tooling/internal/matlab/static_files/+binary/CodedInputStream.m b/tooling/internal/matlab/static_files/+binary/CodedInputStream.m index 8479dd0e..34e03ca6 100755 --- a/tooling/internal/matlab/static_files/+binary/CodedInputStream.m +++ b/tooling/internal/matlab/static_files/+binary/CodedInputStream.m @@ -13,7 +13,7 @@ if isa(infile, "string") || isa(infile, "char") [fileId, errMsg] = fopen(infile, "r"); if fileId < 0 - throw(yardl.RuntimError(errMsg)); + throw(yardl.RuntimeError(errMsg)); end self.fid_ = fileId; self.owns_stream_ = true; diff --git a/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m b/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m index 235e0dcc..c2aedf38 100755 --- a/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m +++ b/tooling/internal/matlab/static_files/+binary/CodedOutputStream.m @@ -13,7 +13,7 @@ if isa(outfile, "string") || isa(outfile, "char") [fileId, errMsg] = fopen(outfile, "W"); if fileId < 0 - throw(yardl.RuntimError(errMsg)); + throw(yardl.RuntimeError(errMsg)); end self.fid_ = fileId; self.owns_stream_ = true; From 86770e35e474b2c6862d11eb96f234b93fb5fe56 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Mon, 13 May 2024 14:16:32 +0000 Subject: [PATCH 28/32] Add MATLAB to sandbox model and update MATLAB docs --- docs/cpp/packages.md | 4 +- docs/index.md | 4 +- docs/matlab/language.md | 62 ++++++++------- docs/matlab/quickstart.md | 12 +-- docs/parts/intro-core.md | 2 +- justfile | 13 +++- .../+sandbox/+binary/HelloWorldReader.m | 26 +++++++ .../+sandbox/+binary/HelloWorldWriter.m | 22 ++++++ .../generated/+sandbox/HelloWorldReaderBase.m | 78 +++++++++++++++++++ .../generated/+sandbox/HelloWorldWriterBase.m | 69 ++++++++++++++++ matlab/run_sandbox.m | 25 ++++++ models/sandbox/_package.yml | 3 + .../internal/python/static_files/_binary.py | 2 +- 13 files changed, 282 insertions(+), 40 deletions(-) create mode 100644 matlab/generated/+sandbox/+binary/HelloWorldReader.m create mode 100644 matlab/generated/+sandbox/+binary/HelloWorldWriter.m create mode 100644 matlab/generated/+sandbox/HelloWorldReaderBase.m create mode 100644 matlab/generated/+sandbox/HelloWorldWriterBase.m create mode 100644 matlab/run_sandbox.m diff --git a/docs/cpp/packages.md b/docs/cpp/packages.md index 0bc07733..0690bf0c 100644 --- a/docs/cpp/packages.md +++ b/docs/cpp/packages.md @@ -46,9 +46,9 @@ python: # The directory where the generated Python package will be written outputDir: ../path/relative/to/this/file -# Settings for Matlab code generation (optional) +# Settings for MATLAB code generation (optional) matlab: - # The directory where the generated Matlab packages will be written + # The directory where the generated MATLAB packages will be written outputDir: ../path/relative/to/this/file ``` diff --git a/docs/index.md b/docs/index.md index 9ad87d7b..4eb348e4 100644 --- a/docs/index.md +++ b/docs/index.md @@ -16,7 +16,7 @@ hero: text: Get Started With C++ link: /cpp/installation - theme: brand - text: Get Started With Matlab + text: Get Started With MATLAB link: /matlab/quickstart - theme: alt text: View on GitHub @@ -24,7 +24,7 @@ hero: features: - title: Multiple Languages - details: Define your model in a simple YAML syntax and generate clean Python, C++, and Matlab. + details: Define your model in a simple YAML syntax and generate clean Python, C++, and MATLAB. - title: Multiple Formats details: Supports writing to a compact binary format, NDJSON, or HDF5. - title: Stream-Oriented diff --git a/docs/matlab/language.md b/docs/matlab/language.md index 6fd62d63..df617d77 100644 --- a/docs/matlab/language.md +++ b/docs/matlab/language.md @@ -2,7 +2,7 @@ :::info Note -The Matlab implementation supports the binary format, but does not +The MATLAB implementation supports the binary format, but does not currently support HDF5 or NDJSON. ::: @@ -97,7 +97,7 @@ connection. ## Records Records have fields and, optionally, [computed fields](#computed-fields). In -generated Matlab code, they map to class definitions. +generated MATLAB code, they map to class definitions. Fields have a name and can be of any primitive or compound type. For example: @@ -126,15 +126,25 @@ RecordB: !record Note that Yardl does not support type inheritance. -The generated class constructors take arguments for each field and +The generated class constructors accept *named* arguments for each field and in most cases they are optional. They are only required when the field type is [generic](#generics). +Example: + +```matlab +r1 = MyRecord(); +r1.myIntField = uint32(42); +r1.myStringField = "hello, world"; + +r2 = MyRecord(myIntField=uint32(42), myStringField="hello, world"); +``` + ## Primitive Types Yardl has the following primitive types: -| Yardl Type | Comment | Matlab Type | +| Yardl Type | Comment | MATLAB Type | | ---------------- | ----------------------------------------------------------------------- | -------------------| | `bool` | | `logical` | | `int8` | | `int8` | @@ -165,8 +175,8 @@ Yardl has the following primitive types: | `datetime` | A number of nanoseconds since the epoch | `yardl.DateTime` | `yardl.Date`, `yardl.Time`, and `yardl.DateTime` are custom classes because -Yardl uses nanosecond precision and Matlab's `datetime` has only microsecond precision. -Each of them can be easily converted to/from a Matlab `datetime` by calling +Yardl uses nanosecond precision and MATLAB's `datetime` has only microsecond precision. +Each of them can be easily converted to/from a MATLAB `datetime` by calling the corresponding `to_datetime()` or `from_datetime()` method. ## Optional Types @@ -188,7 +198,7 @@ Rec: !record optionalInt: [null, int] # equivalent to the example above ``` -In Matlab, optional values can be instantiated using `yardl.Optional(value)`, and have the value `yardl.None` when not set. +In MATLAB, optional values can be instantiated using `yardl.Optional(value)`, and have the value `yardl.None` when not set. ## Unions @@ -208,12 +218,12 @@ Rec: !record - float ``` -The `null` type in the example above means that no value (`yardl.None` in Matlab) is +The `null` type in the example above means that no value (`yardl.None` in MATLAB) is also a possibility. ### Generated Union Types -For the Matlab codegen, we represent unions as a [tagged +For the MATLAB codegen, we represent unions as a [tagged union](https://en.wikipedia.org/wiki/Tagged_union) and we generate a class for each union in a model. In the example above, the union `[int, float]` would have a class named `Int32OrFloat32`. Each union case then has a corresponding static @@ -307,9 +317,9 @@ Fruits: !enum - pear ``` -Enums are generated as custom Matlab class definitions, *not* using Matlab's `enumeration` support, which doesn't allow integer values that are not explicitly defined in the enum definition. +Enums are generated as custom MATLAB class definitions, *not* using MATLAB's `enumeration` support, which doesn't allow integer values that are not explicitly defined in the enum definition. -In Matlab, use the enum constructor to create new values, or the generated static methods for predefined values: +In MATLAB, use the enum constructor to create new values, or the generated static methods for predefined values: ```matlab fruit1 = sandbox.Fruits.APPLE; @@ -365,7 +375,7 @@ Any value without an integer value will have the next power of two bit set that is greater than the previous value. In the example above, `execute` would have the value 4. -Like Enums, Flags are generated as custom Matlab class definitions. +Like Enums, Flags are generated as custom MATLAB class definitions. Example usage: @@ -404,11 +414,11 @@ MyMap: !map Keys are required to be scalar primitive types. -These map to the Matlab `dictionary` type. +These map to the MATLAB `dictionary` type. :::info Note -Matlab's `dictionary` type was introduced in Matlab r2022b, effectively replacing +MATLAB's `dictionary` type was introduced in MATLAB r2022b, effectively replacing the `containers.Map` type. The `containers.Map` does not provide sufficient support for yardl types (including primitive strings) as keys or values. @@ -442,7 +452,7 @@ MyRec: !record length: 10 ``` -Both flavors of vectors are generated as Matlab arrays. +Both flavors of vectors are generated as MATLAB arrays. The generated protocol readers/writers also support cell arrays as vectors. When working with vectors of vectors, the last dimension represents the outer vector: @@ -459,7 +469,7 @@ vs = { [1, 2, 3], [4, 5], [7] }; ## Arrays -Arrays are multidimensional and map to Matlab arrays. Like vectors, there is a simple +Arrays are multidimensional and map to MATLAB arrays. Like vectors, there is a simple syntax and an expanded syntax for declaring them. Both syntaxes are shown in the examples below. @@ -526,21 +536,21 @@ array with 1 dimension of unknown length, you can either give the dimension a name (`int[x]`) or use parentheses to disambiguate from an empty set of dimensions: `int[()]`. -### Matlab Arrays +### MATLAB Arrays -In Matlab, arrays are always created with dimensions reversed with respect to the model definition. -This means that an array defined as `Image: double[x, y, z]` has the shape `[z, y, x]` in Matlab. +In MATLAB, arrays are always created with dimensions reversed with respect to the model definition. +This means that an array defined as `Image: double[x, y, z]` has the shape `[z, y, x]` in MATLAB. Yardl currently supports serializing multi-dimensional arrays only in C-continguous order, where the last dimension increases most rapidly. -Matlab, however, uses Fortran-order to store and serialize multi-dimensional +MATLAB, however, uses Fortran-order to store and serialize multi-dimensional arrays, where the first dimension increases most rapidly. -By reversing Matlab array dimensions, yardl maintains consistency with Matlab's +By reversing MATLAB array dimensions, yardl maintains consistency with MATLAB's support for multi-dimensional array indexing, and provides optimal serialization performance. As a side effect, if you define a *matrix* in yardl as `matrix: double[row, col]`, -you will need to transpose the array in Matlab. +you will need to transpose the array in MATLAB. Example: @@ -561,7 +571,7 @@ ans = ``` -To create an array with more than two dimensions, use Matlab pages: +To create an array with more than two dimensions, use MATLAB pages: ```yaml ndarray: double[2, 3, 4] @@ -594,7 +604,7 @@ Name: string This simply gives another name to a type, so the `Name` type above is no different from the `string` type. -In Matlab, aliases are generated in one of three forms: +In MATLAB, aliases are generated in one of three forms: 1. Union class definition for union types 2. Function wrapper for optionals/vectors/arrays 3. Subclass definitions for all other types @@ -707,7 +717,7 @@ references `Point` with `int` as its type argument. Records and type aliases can be generic, but enums, flags, and protocols cannot. -In Matlab, generics are treated as open types. +In MATLAB, generics are treated as open types. Type validation occurs when values are written using a ProtocolWriter. ```matlab @@ -732,7 +742,7 @@ through their respective yardl namespace: MyTuple: BasicTypes.Tuple ``` -Imported types are likewise namespaced in Matlab packages: +Imported types are likewise namespaced in MATLAB packages: ```matlab t1 = basic_types.Tuple(v1="John Smith", v2=42); diff --git a/docs/matlab/quickstart.md b/docs/matlab/quickstart.md index 0ea35fc2..2c17595d 100644 --- a/docs/matlab/quickstart.md +++ b/docs/matlab/quickstart.md @@ -6,7 +6,7 @@ ### Dependencies -The generated Matlab code requires Matlab R2022b or newer. +The generated MATLAB code requires MATLAB R2022b or newer. ## Getting our Feet Wet @@ -49,7 +49,7 @@ matlab: ``` It specifies the package's namespace along with code generation settings. The -`matlab.outputDir` property specifies where the generated Matlab package should +`matlab.outputDir` property specifies where the generated MATLAB package should go. If you are not interested in generating Python or C++ code, you can remove the corresponding property from the file: @@ -107,13 +107,13 @@ written to or read from a file or binary stream (e.g. over a network connection). This example protocol says that there will be one `Header` value followed by an unknown number of `Sample`s. `Header` and `Sample` are records. -To generate Matlab code for this model, `cd` into the `model` directory and run: +To generate MATLAB code for this model, `cd` into the `model` directory and run: ```bash yardl generate ``` -This will generate a Matlab package in the `outputDir` directory: +This will generate a MATLAB package in the `outputDir` directory: ```txt $ tree . @@ -138,7 +138,7 @@ The top-level package, e.g. `+playground`, contains the class definitions for (1 The adjacent `+yardl` package contains definitions for primitive types, error handling, and serializers. -To use these packages from outside of the `matlab` directory, use Matlab's `addpath` function, e.g. `addpath("../path/to/parent/directory");`. +To use these packages from outside of the `matlab` directory, use MATLAB's `addpath` function, e.g. `addpath("../path/to/parent/directory");`. Ok, let's write some code! In our `matlab` directory (containing the generated `+playground` package), create `run_playground.m` that looks like this: @@ -165,7 +165,7 @@ end r.close(); ``` -Run this directly in Matlab, e.g. `run_playground`, or on the command-line with `matlab -batch run_playground`. +Run this directly in MATLAB, e.g. `run_playground`, or on the command-line with `matlab -batch run_playground`. You can inspect the binary file our code produced with: diff --git a/docs/parts/intro-core.md b/docs/parts/intro-core.md index 4d27d70d..19b2f044 100644 --- a/docs/parts/intro-core.md +++ b/docs/parts/intro-core.md @@ -33,6 +33,6 @@ expect to introduce breaking changes until the project reaches V1. We currently support C++ and Python codegen. Other planned features include: -- Python and Matlab support for reading data with a different schema version +- Python and MATLAB support for reading data with a different schema version - Constraints - Improvements to the language and editing experience diff --git a/justfile b/justfile index cbd59c77..8930993c 100644 --- a/justfile +++ b/justfile @@ -4,6 +4,7 @@ cpp_version := "17" matlab := "disabled" matlab-test-cmd := if matlab != "disabled" { "run-matlab-command runTests" } else { "echo Skipping Matlab tests..." } +matlab-sandbox-cmd := if matlab != "disabled" { "run-matlab-command run_sandbox" } else { "echo Skipping Matlab sandbox..." } benchmark-cmd := if matlab != "disabled" { "python python/benchmark.py --include-matlab" } else { "python python/benchmark.py" } @@ -47,9 +48,17 @@ benchmark-cmd := if matlab != "disabled" { "python python/benchmark.py --include @run-sandbox-python: generate-sandbox python python/run_sandbox.py -@run-sandbox-python-quiet: build-sandbox +@run-sandbox-python-quiet: generate-sandbox python python/run_sandbox.py > /dev/null +@run-sandbox-matlab: generate-sandbox + cd matlab; \ + {{ matlab-sandbox-cmd }} + +@run-sandbox-matlab-quiet: generate-sandbox + cd matlab; \ + {{ matlab-sandbox-cmd }} > /dev/null + @build-all: generate generate-sandbox generate-remote-import generate-evolution configure cd cpp/build && ninja @@ -110,7 +119,7 @@ type-check: generate generate-sandbox cd python pyright . -@validate: build-all test type-check run-sandbox-quiet run-sandbox-python-quiet benchmark +@validate: build-all test type-check run-sandbox-quiet run-sandbox-python-quiet run-sandbox-matlab-quiet benchmark validate-with-no-changes: validate #!/usr/bin/env bash diff --git a/matlab/generated/+sandbox/+binary/HelloWorldReader.m b/matlab/generated/+sandbox/+binary/HelloWorldReader.m new file mode 100644 index 00000000..cdae14d9 --- /dev/null +++ b/matlab/generated/+sandbox/+binary/HelloWorldReader.m @@ -0,0 +1,26 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + +classdef HelloWorldReader < yardl.binary.BinaryProtocolReader & sandbox.HelloWorldReaderBase + % Binary reader for the HelloWorld protocol + properties (Access=protected) + data_serializer + end + + methods + function self = HelloWorldReader(filename) + self@sandbox.HelloWorldReaderBase(); + self@yardl.binary.BinaryProtocolReader(filename, sandbox.HelloWorldReaderBase.schema); + self.data_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Complexfloat64Serializer, [2])); + end + end + + methods (Access=protected) + function more = has_data_(self) + more = self.data_serializer.hasnext(self.stream_); + end + + function value = read_data_(self) + value = self.data_serializer.read(self.stream_); + end + end +end diff --git a/matlab/generated/+sandbox/+binary/HelloWorldWriter.m b/matlab/generated/+sandbox/+binary/HelloWorldWriter.m new file mode 100644 index 00000000..d613db98 --- /dev/null +++ b/matlab/generated/+sandbox/+binary/HelloWorldWriter.m @@ -0,0 +1,22 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + +classdef HelloWorldWriter < yardl.binary.BinaryProtocolWriter & sandbox.HelloWorldWriterBase + % Binary writer for the HelloWorld protocol + properties (Access=protected) + data_serializer + end + + methods + function self = HelloWorldWriter(filename) + self@sandbox.HelloWorldWriterBase(); + self@yardl.binary.BinaryProtocolWriter(filename, sandbox.HelloWorldWriterBase.schema); + self.data_serializer = yardl.binary.StreamSerializer(yardl.binary.FixedNDArraySerializer(yardl.binary.Complexfloat64Serializer, [2])); + end + end + + methods (Access=protected) + function write_data_(self, value) + self.data_serializer.write(self.stream_, value); + end + end +end diff --git a/matlab/generated/+sandbox/HelloWorldReaderBase.m b/matlab/generated/+sandbox/HelloWorldReaderBase.m new file mode 100644 index 00000000..112df588 --- /dev/null +++ b/matlab/generated/+sandbox/HelloWorldReaderBase.m @@ -0,0 +1,78 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + +classdef HelloWorldReaderBase < handle + properties (Access=protected) + state_ + end + + methods + function self = HelloWorldReaderBase() + self.state_ = 0; + end + + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); + throw(yardl.ProtocolError("Protocol reader closed before all data was consumed. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function more = has_data(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); + end + + more = self.has_data_(); + if ~more + self.state_ = 1; + end + end + + function value = read_data(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); + end + + value = self.read_data_(); + end + + function copy_to(self, writer) + while self.has_data() + item = self.read_data(); + writer.write_data({item}); + end + writer.end_data(); + end + end + + methods (Static) + function res = schema() + res = sandbox.HelloWorldWriterBase.schema; + end + end + + methods (Abstract, Access=protected) + has_data_(self) + read_data_(self) + + close_(self) + end + + methods (Access=private) + function raise_unexpected_state_(self, actual) + actual_method = self.state_to_method_name_(actual); + expected_method = self.state_to_method_name_(self.state_); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'.", expected_method, actual_method)); + end + + function name = state_to_method_name_(self, state) + if state == 0 + name = "read_data"; + else + name = ""; + end + end + end +end diff --git a/matlab/generated/+sandbox/HelloWorldWriterBase.m b/matlab/generated/+sandbox/HelloWorldWriterBase.m new file mode 100644 index 00000000..eba0473b --- /dev/null +++ b/matlab/generated/+sandbox/HelloWorldWriterBase.m @@ -0,0 +1,69 @@ +% This file was generated by the "yardl" tool. DO NOT EDIT. + +% Abstract writer for protocol HelloWorld +classdef (Abstract) HelloWorldWriterBase < handle + properties (Access=protected) + state_ + end + + methods + function self = HelloWorldWriterBase() + self.state_ = 0; + end + + function close(self) + self.close_(); + if self.state_ ~= 1 + expected_method = self.state_to_method_name_(self.state_); + throw(yardl.ProtocolError("Protocol writer closed before all steps were called. Expected call to '%s'.", expected_method)); + end + end + + % Ordinal 0 + function write_data(self, value) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); + end + + self.write_data_(value); + end + + function end_data(self) + if self.state_ ~= 0 + self.raise_unexpected_state_(0); + end + + self.end_stream_(); + self.state_ = 1; + end + end + + methods (Static) + function res = schema() + res = string('{"protocol":{"name":"HelloWorld","sequence":[{"name":"data","type":{"stream":{"items":{"array":{"items":"complexfloat64","dimensions":[{"length":2}]}}}}}]},"types":null}'); + end + end + + methods (Abstract, Access=protected) + write_data_(self, value) + + end_stream_(self) + close_(self) + end + + methods (Access=private) + function raise_unexpected_state_(self, actual) + expected_method = self.state_to_method_name_(self.state_); + actual_method = self.state_to_method_name_(actual); + throw(yardl.ProtocolError("Expected call to '%s' but received call to '%s'", expected_method, actual_method)); + end + + function name = state_to_method_name_(self, state) + if state == 0 + name = "write_data or end_data"; + else + name = ''; + end + end + end +end diff --git a/matlab/run_sandbox.m b/matlab/run_sandbox.m new file mode 100644 index 00000000..f9df271a --- /dev/null +++ b/matlab/run_sandbox.m @@ -0,0 +1,25 @@ +addpath("./generated"); + +filename = "sandbox_mat.bin"; + +data = [ ... + [892.37889483 - 9932.485937837j; 73.383672763878 - 33.3394472537j], ... + [3883.22890980 + 373.4933837j; 56985.39384393 - 33833.3330128474373j], ... + [283.383672763878 - 33.3394472537j; 3883.22890980 + 373.4933837j], ... +]; + +w = sandbox.binary.HelloWorldWriter(filename); +w.write_data(data); +w.end_data(); +w.close(); + +r = sandbox.binary.HelloWorldReader(filename); +while r.has_data() + values = r.read_data(); + for n = 1:length(values) + disp(values(n)); + end +end +r.close(); + +system(sprintf("hexdump -C %s", filename)); diff --git a/models/sandbox/_package.yml b/models/sandbox/_package.yml index e4048ffd..29e8cb5c 100644 --- a/models/sandbox/_package.yml +++ b/models/sandbox/_package.yml @@ -5,3 +5,6 @@ cpp: python: outputDir: ../../python/ + +matlab: + outputDir: ../../matlab/generated diff --git a/tooling/internal/python/static_files/_binary.py b/tooling/internal/python/static_files/_binary.py index bc64d238..8e193074 100644 --- a/tooling/internal/python/static_files/_binary.py +++ b/tooling/internal/python/static_files/_binary.py @@ -408,7 +408,7 @@ def write(self, stream: CodedOutputStream, value: Int16) -> None: f"Value {value} is outside the range of a signed 16-bit integer" ) elif not isinstance(value, cast(type, np.int16)): - raise ValueError(f"Value is not an signed 16-bit integer: {value}") + raise ValueError(f"Value is not a signed 16-bit integer: {value}") stream.write_signed_varint(value) From b930bf3ce2e744721ea91fa726743cf5d07b1b47 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Mon, 13 May 2024 19:55:56 +0000 Subject: [PATCH 29/32] Clean up stale files during MATLAB codegen --- justfile | 2 +- matlab/test/RoundTripTest.m | 5 ++- matlab/test/{runTests.m => run_tests.m} | 0 tooling/internal/matlab/common/common.go | 38 ++++++++++++++-- tooling/internal/matlab/matlab.go | 56 ++++++++++++++---------- 5 files changed, 71 insertions(+), 30 deletions(-) rename matlab/test/{runTests.m => run_tests.m} (100%) diff --git a/justfile b/justfile index 8930993c..f222e2e2 100644 --- a/justfile +++ b/justfile @@ -3,7 +3,7 @@ set shell := ['bash', '-ceuo', 'pipefail'] cpp_version := "17" matlab := "disabled" -matlab-test-cmd := if matlab != "disabled" { "run-matlab-command runTests" } else { "echo Skipping Matlab tests..." } +matlab-test-cmd := if matlab != "disabled" { "run-matlab-command run_tests" } else { "echo Skipping Matlab tests..." } matlab-sandbox-cmd := if matlab != "disabled" { "run-matlab-command run_sandbox" } else { "echo Skipping Matlab sandbox..." } benchmark-cmd := if matlab != "disabled" { "python python/benchmark.py --include-matlab" } else { "python python/benchmark.py" } diff --git a/matlab/test/RoundTripTest.m b/matlab/test/RoundTripTest.m index 948fa57f..feb314e4 100644 --- a/matlab/test/RoundTripTest.m +++ b/matlab/test/RoundTripTest.m @@ -355,7 +355,8 @@ function testEnums(testCase, format) function testFlags(testCase, format) w = create_validating_writer(testCase, format, 'Flags'); - mon_or_wed_or_fri = bitor(bitor(test_model.DaysOfWeek.MONDAY, test_model.DaysOfWeek.WEDNESDAY), test_model.DaysOfWeek.FRIDAY); + import test_model.DaysOfWeek; + mon_or_wed_or_fri = DaysOfWeek(DaysOfWeek.MONDAY, DaysOfWeek.WEDNESDAY, DaysOfWeek.FRIDAY); w.write_days([... test_model.DaysOfWeek.SUNDAY, ... test_model.DaysOfWeek(mon_or_wed_or_fri), ... @@ -367,7 +368,7 @@ function testFlags(testCase, format) w.write_formats([... test_model.TextFormat.BOLD, ... - bitor(test_model.TextFormat.BOLD, test_model.TextFormat.ITALIC), ... + test_model.TextFormat.BOLD.with_flags(test_model.TextFormat.ITALIC), ... test_model.TextFormat.REGULAR, ... test_model.TextFormat(232932) ... ]); diff --git a/matlab/test/runTests.m b/matlab/test/run_tests.m similarity index 100% rename from matlab/test/runTests.m rename to matlab/test/run_tests.m diff --git a/tooling/internal/matlab/common/common.go b/tooling/internal/matlab/common/common.go index 658e2831..e94a514c 100644 --- a/tooling/internal/matlab/common/common.go +++ b/tooling/internal/matlab/common/common.go @@ -6,12 +6,14 @@ package common import ( "bytes" "fmt" + "os" "path" "strings" "github.com/microsoft/yardl/tooling/internal/formatting" "github.com/microsoft/yardl/tooling/internal/iocommon" "github.com/microsoft/yardl/tooling/pkg/dsl" + "github.com/rs/zerolog/log" ) var isReservedName = map[string]bool{ @@ -229,7 +231,8 @@ func WriteGeneratedFileHeader(w *formatting.IndentedWriter) { } type MatlabFileWriter struct { - PackageDir string + PackageDir string + filesWritten []string } func (fw *MatlabFileWriter) WriteFile(name string, writeContents func(w *formatting.IndentedWriter)) error { @@ -239,10 +242,37 @@ func (fw *MatlabFileWriter) WriteFile(name string, writeContents func(w *formatt writeContents(w) - fname := fmt.Sprintf("%s.m", name) - definitionsPath := path.Join(fw.PackageDir, fname) - if err := iocommon.WriteFileIfNeeded(definitionsPath, b.Bytes(), 0644); err != nil { + filepath := path.Join(fw.PackageDir, fmt.Sprintf("%s.m", name)) + if err := iocommon.WriteFileIfNeeded(filepath, b.Bytes(), 0644); err != nil { return err } + fw.filesWritten = append(fw.filesWritten, filepath) + return nil +} + +func (fw *MatlabFileWriter) RemoveStaleFiles() error { + written := make(map[string]bool) + for _, fname := range fw.filesWritten { + written[fname] = true + } + + entries, err := os.ReadDir(fw.PackageDir) + if err != nil { + return err + } + + var stalePaths []string + for _, entry := range entries { + filename := path.Join(fw.PackageDir, entry.Name()) + if !entry.IsDir() && !written[filename] { + stalePaths = append(stalePaths, filename) + } + } + for _, name := range stalePaths { + log.Debug().Msgf("Removing stale file %s", name) + if err := os.Remove(name); err != nil { + return err + } + } return nil } diff --git a/tooling/internal/matlab/matlab.go b/tooling/internal/matlab/matlab.go index d7c7a2dc..63614918 100644 --- a/tooling/internal/matlab/matlab.go +++ b/tooling/internal/matlab/matlab.go @@ -33,42 +33,52 @@ func Generate(env *dsl.Environment, options packaging.MatlabCodegenOptions) erro } for _, ns := range env.Namespaces { + // Write package Types and Protocol definitions packageDir := path.Join(options.OutputDir, common.PackageDir(ns.Name)) - if err := os.MkdirAll(packageDir, 0775); err != nil { - return err - } - - topLevelFileWriter := &common.MatlabFileWriter{PackageDir: packageDir} - if err := types.WriteTypes(topLevelFileWriter, ns, env.SymbolTable); err != nil { - return err - } - - if ns.IsTopLevel { - if err := protocols.WriteProtocols(topLevelFileWriter, ns, env.SymbolTable); err != nil { + if err := updatePackage(packageDir, func(fw *common.MatlabFileWriter) error { + if err := types.WriteTypes(fw, ns, env.SymbolTable); err != nil { return err } - - if options.InternalGenerateMocks { - mocksDir := path.Join(packageDir, common.PackageDir("testing")) - if err := os.MkdirAll(mocksDir, 0775); err != nil { - return err - } - fw := &common.MatlabFileWriter{PackageDir: mocksDir} - if err := mocks.WriteMocks(fw, ns); err != nil { + if ns.IsTopLevel { + if err := protocols.WriteProtocols(fw, ns, env.SymbolTable); err != nil { return err } } + return nil + }); err != nil { + return err } + // Write binary serializers binaryDir := path.Join(packageDir, common.PackageDir("binary")) - if err := os.MkdirAll(binaryDir, 0775); err != nil { + if err := updatePackage(binaryDir, func(fw *common.MatlabFileWriter) error { + return binary.WriteBinary(fw, ns) + }); err != nil { return err } - binaryFileWriter := &common.MatlabFileWriter{PackageDir: binaryDir} - if err := binary.WriteBinary(binaryFileWriter, ns); err != nil { - return err + + // Write mocks and test support classes + if ns.IsTopLevel && options.InternalGenerateMocks { + mocksDir := path.Join(packageDir, common.PackageDir("testing")) + if err := updatePackage(mocksDir, func(fw *common.MatlabFileWriter) error { + return mocks.WriteMocks(fw, ns) + }); err != nil { + return err + } } } return nil } + +// Creates `+package` directory, writes the package implementation, and removes stale files. +func updatePackage(packageDir string, writePackageImpl func(*common.MatlabFileWriter) error) error { + if err := os.MkdirAll(packageDir, 0775); err != nil { + return err + } + fw := &common.MatlabFileWriter{PackageDir: packageDir} + + writePackageImpl(fw) + + return fw.RemoveStaleFiles() +} From 6e96c5dc9cb9829cdab4009e223ddb5d35854ab3 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Mon, 13 May 2024 20:00:15 +0000 Subject: [PATCH 30/32] Improve MATLAB string repr for Unions, etc. --- matlab/generated/+basic_types/AliasedMap.m | 3 +- .../+basic_types/GenericNullableUnion2.m | 7 +++- matlab/generated/+basic_types/GenericUnion2.m | 7 +++- matlab/generated/+basic_types/GenericVector.m | 2 +- matlab/generated/+basic_types/Int32OrString.m | 7 +++- matlab/generated/+basic_types/MyTuple.m | 2 +- matlab/generated/+basic_types/T0OrT1.m | 7 +++- .../generated/+basic_types/TimeOrDatetime.m | 7 +++- matlab/generated/+image/FloatImage.m | 2 +- matlab/generated/+image/Image.m | 2 +- matlab/generated/+image/IntImage.m | 2 +- .../+test_model/AcquisitionOrImage.m | 7 +++- .../+test_model/AliasedClosedGeneric.m | 2 +- .../+test_model/AliasedGenericDynamicArray.m | 2 +- .../+test_model/AliasedGenericFixedArray.m | 2 +- .../+test_model/AliasedGenericFixedVector.m | 2 +- .../+test_model/AliasedGenericOptional.m | 2 +- .../+test_model/AliasedGenericRank2Array.m | 2 +- .../+test_model/AliasedGenericVector.m | 2 +- .../+test_model/AliasedIntOrSimpleRecord.m | 7 +++- matlab/generated/+test_model/AliasedMap.m | 3 +- .../+test_model/AliasedMultiGenericOptional.m | 7 +++- .../AliasedNullableIntSimpleRecord.m | 7 +++- .../+test_model/AliasedOpenGeneric.m | 2 +- .../generated/+test_model/AliasedOptional.m | 2 +- matlab/generated/+test_model/AliasedString.m | 3 +- matlab/generated/+test_model/AliasedTuple.m | 2 +- .../AliasedVectorOfGenericRecords.m | 2 +- matlab/generated/+test_model/ArrayOrScalar.m | 7 +++- .../ArrayWithKeywordDimensionNames.m | 2 +- matlab/generated/+test_model/GenericUnion3.m | 7 +++- .../+test_model/GenericUnion3Alternate.m | 7 +++- .../GenericUnionWithRepeatedTypeParameters.m | 7 +++- matlab/generated/+test_model/Image.m | 2 +- .../+test_model/ImageFloatOrImageDouble.m | 7 +++- matlab/generated/+test_model/Int32OrFloat32.m | 7 +++- .../+test_model/Int32OrRecordWithVlens.m | 7 +++- .../+test_model/Int32OrSimpleRecord.m | 7 +++- matlab/generated/+test_model/IntArray.m | 2 +- matlab/generated/+test_model/IntFixedArray.m | 2 +- .../IntOrGenericRecordWithComputedFields.m | 7 +++- matlab/generated/+test_model/IntRank2Array.m | 2 +- matlab/generated/+test_model/MapOrScalar.m | 7 +++- matlab/generated/+test_model/MyTuple.m | 2 +- .../generated/+test_model/NamedFixedNDArray.m | 2 +- matlab/generated/+test_model/NamedNDArray.m | 2 +- .../+test_model/RecordWithVlensFixedArray.m | 2 +- .../+test_model/SimpleRecordFixedArray.m | 2 +- matlab/generated/+test_model/StringOrInt32.m | 7 +++- matlab/generated/+test_model/UOrV.m | 7 +++- .../+test_model/VectorOfGenericRecords.m | 2 +- matlab/generated/+test_model/VectorOrScalar.m | 7 +++- matlab/test/GeneratedTypesTest.m | 12 ++++++ tooling/internal/matlab/static_files/Date.m | 12 +++--- .../internal/matlab/static_files/DateTime.m | 12 +++--- tooling/internal/matlab/static_files/Time.m | 12 +++--- tooling/internal/matlab/static_files/Union.m | 23 ++++++++--- tooling/internal/matlab/types/types.go | 38 ++++++++++++++++--- 58 files changed, 245 insertions(+), 81 deletions(-) diff --git a/matlab/generated/+basic_types/AliasedMap.m b/matlab/generated/+basic_types/AliasedMap.m index 8c224bb2..c594a04e 100644 --- a/matlab/generated/+basic_types/AliasedMap.m +++ b/matlab/generated/+basic_types/AliasedMap.m @@ -1,4 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef AliasedMap < dictionary +function m = AliasedMap(varargin) + m = dictionary(varargin{:}); end diff --git a/matlab/generated/+basic_types/GenericNullableUnion2.m b/matlab/generated/+basic_types/GenericNullableUnion2.m index 1f2ff2ee..fc5f13b1 100644 --- a/matlab/generated/+basic_types/GenericNullableUnion2.m +++ b/matlab/generated/+basic_types/GenericNullableUnion2.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "basic_types.GenericNullableUnion2") && other.index == self.index && other.value == self.value; + eq = isa(other, "basic_types.GenericNullableUnion2") && other.index == self.index && isequal(self.value, other.value); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["T1", "T2"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+basic_types/GenericUnion2.m b/matlab/generated/+basic_types/GenericUnion2.m index 784a55a5..9481abf8 100644 --- a/matlab/generated/+basic_types/GenericUnion2.m +++ b/matlab/generated/+basic_types/GenericUnion2.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "basic_types.GenericUnion2") && other.index == self.index && other.value == self.value; + eq = isa(other, "basic_types.GenericUnion2") && other.index == self.index && isequal(self.value, other.value); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["T1", "T2"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+basic_types/GenericVector.m b/matlab/generated/+basic_types/GenericVector.m index 7d0789dd..09d85a55 100644 --- a/matlab/generated/+basic_types/GenericVector.m +++ b/matlab/generated/+basic_types/GenericVector.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = GenericVector(array) +function a = GenericVector(array) a = array; end diff --git a/matlab/generated/+basic_types/Int32OrString.m b/matlab/generated/+basic_types/Int32OrString.m index f61f00e0..b4bb4273 100644 --- a/matlab/generated/+basic_types/Int32OrString.m +++ b/matlab/generated/+basic_types/Int32OrString.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "basic_types.Int32OrString") && other.index == self.index && other.value == self.value; + eq = isa(other, "basic_types.Int32OrString") && other.index == self.index && all([self.value] == [other.value]); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["Int32", "String"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+basic_types/MyTuple.m b/matlab/generated/+basic_types/MyTuple.m index a9b3a6a4..2487c8c5 100644 --- a/matlab/generated/+basic_types/MyTuple.m +++ b/matlab/generated/+basic_types/MyTuple.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function c = MyTuple(varargin) +function c = MyTuple(varargin) c = tuples.Tuple(varargin{:}); end diff --git a/matlab/generated/+basic_types/T0OrT1.m b/matlab/generated/+basic_types/T0OrT1.m index d7f998ab..0afe2808 100644 --- a/matlab/generated/+basic_types/T0OrT1.m +++ b/matlab/generated/+basic_types/T0OrT1.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "basic_types.T0OrT1") && other.index == self.index && other.value == self.value; + eq = isa(other, "basic_types.T0OrT1") && other.index == self.index && isequal(self.value, other.value); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["T0", "T1"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+basic_types/TimeOrDatetime.m b/matlab/generated/+basic_types/TimeOrDatetime.m index 67f45ab2..027738f1 100644 --- a/matlab/generated/+basic_types/TimeOrDatetime.m +++ b/matlab/generated/+basic_types/TimeOrDatetime.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "basic_types.TimeOrDatetime") && other.index == self.index && other.value == self.value; + eq = isa(other, "basic_types.TimeOrDatetime") && other.index == self.index && all([self.value] == [other.value]); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["Time", "Datetime"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+image/FloatImage.m b/matlab/generated/+image/FloatImage.m index f73dc355..cf3837f1 100644 --- a/matlab/generated/+image/FloatImage.m +++ b/matlab/generated/+image/FloatImage.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = FloatImage(array) +function a = FloatImage(array) arguments array single end diff --git a/matlab/generated/+image/Image.m b/matlab/generated/+image/Image.m index a31eac1f..0332777d 100644 --- a/matlab/generated/+image/Image.m +++ b/matlab/generated/+image/Image.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = Image(array) +function a = Image(array) a = array; end diff --git a/matlab/generated/+image/IntImage.m b/matlab/generated/+image/IntImage.m index a6cd19c4..a229033a 100644 --- a/matlab/generated/+image/IntImage.m +++ b/matlab/generated/+image/IntImage.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = IntImage(array) +function a = IntImage(array) arguments array int32 end diff --git a/matlab/generated/+test_model/AcquisitionOrImage.m b/matlab/generated/+test_model/AcquisitionOrImage.m index b50c81fc..06cea23b 100644 --- a/matlab/generated/+test_model/AcquisitionOrImage.m +++ b/matlab/generated/+test_model/AcquisitionOrImage.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.AcquisitionOrImage") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.AcquisitionOrImage") && other.index == self.index && isequal(self.value, other.value); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["Acquisition", "Image"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/AliasedClosedGeneric.m b/matlab/generated/+test_model/AliasedClosedGeneric.m index 677faef1..546b8395 100644 --- a/matlab/generated/+test_model/AliasedClosedGeneric.m +++ b/matlab/generated/+test_model/AliasedClosedGeneric.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function c = AliasedClosedGeneric(varargin) +function c = AliasedClosedGeneric(varargin) c = test_model.AliasedTuple(varargin{:}); end diff --git a/matlab/generated/+test_model/AliasedGenericDynamicArray.m b/matlab/generated/+test_model/AliasedGenericDynamicArray.m index 5fb27fa5..6163aeb5 100644 --- a/matlab/generated/+test_model/AliasedGenericDynamicArray.m +++ b/matlab/generated/+test_model/AliasedGenericDynamicArray.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = AliasedGenericDynamicArray(array) +function a = AliasedGenericDynamicArray(array) a = array; end diff --git a/matlab/generated/+test_model/AliasedGenericFixedArray.m b/matlab/generated/+test_model/AliasedGenericFixedArray.m index f2e2aee4..d5eb14ba 100644 --- a/matlab/generated/+test_model/AliasedGenericFixedArray.m +++ b/matlab/generated/+test_model/AliasedGenericFixedArray.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = AliasedGenericFixedArray(array) +function a = AliasedGenericFixedArray(array) a = array; end diff --git a/matlab/generated/+test_model/AliasedGenericFixedVector.m b/matlab/generated/+test_model/AliasedGenericFixedVector.m index f73f1dad..c246fa3e 100644 --- a/matlab/generated/+test_model/AliasedGenericFixedVector.m +++ b/matlab/generated/+test_model/AliasedGenericFixedVector.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = AliasedGenericFixedVector(array) +function a = AliasedGenericFixedVector(array) a = array; end diff --git a/matlab/generated/+test_model/AliasedGenericOptional.m b/matlab/generated/+test_model/AliasedGenericOptional.m index 5b2a36c2..522e4e60 100644 --- a/matlab/generated/+test_model/AliasedGenericOptional.m +++ b/matlab/generated/+test_model/AliasedGenericOptional.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function o = AliasedGenericOptional(value) +function o = AliasedGenericOptional(value) o = yardl.Optional(value); end diff --git a/matlab/generated/+test_model/AliasedGenericRank2Array.m b/matlab/generated/+test_model/AliasedGenericRank2Array.m index 1c43a59e..ba481775 100644 --- a/matlab/generated/+test_model/AliasedGenericRank2Array.m +++ b/matlab/generated/+test_model/AliasedGenericRank2Array.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = AliasedGenericRank2Array(array) +function a = AliasedGenericRank2Array(array) a = array; end diff --git a/matlab/generated/+test_model/AliasedGenericVector.m b/matlab/generated/+test_model/AliasedGenericVector.m index d4a99372..c6931967 100644 --- a/matlab/generated/+test_model/AliasedGenericVector.m +++ b/matlab/generated/+test_model/AliasedGenericVector.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = AliasedGenericVector(array) +function a = AliasedGenericVector(array) a = array; end diff --git a/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m b/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m index aef0b3ff..d2dfb4c2 100644 --- a/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m +++ b/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.AliasedIntOrSimpleRecord") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.AliasedIntOrSimpleRecord") && other.index == self.index && all([self.value] == [other.value]); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["Int32", "SimpleRecord"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/AliasedMap.m b/matlab/generated/+test_model/AliasedMap.m index ab6de561..fd5134dd 100644 --- a/matlab/generated/+test_model/AliasedMap.m +++ b/matlab/generated/+test_model/AliasedMap.m @@ -1,4 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef AliasedMap < basic_types.AliasedMap +function m = AliasedMap(varargin) + m = basic_types.AliasedMap(varargin{:}); end diff --git a/matlab/generated/+test_model/AliasedMultiGenericOptional.m b/matlab/generated/+test_model/AliasedMultiGenericOptional.m index 3def7bd0..2c08d7df 100644 --- a/matlab/generated/+test_model/AliasedMultiGenericOptional.m +++ b/matlab/generated/+test_model/AliasedMultiGenericOptional.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.AliasedMultiGenericOptional") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.AliasedMultiGenericOptional") && other.index == self.index && isequal(self.value, other.value); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["T", "U"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m b/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m index 103e5c36..9e59827b 100644 --- a/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m +++ b/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.AliasedNullableIntSimpleRecord") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.AliasedNullableIntSimpleRecord") && other.index == self.index && all([self.value] == [other.value]); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["Int32", "SimpleRecord"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/AliasedOpenGeneric.m b/matlab/generated/+test_model/AliasedOpenGeneric.m index 926723bb..75685264 100644 --- a/matlab/generated/+test_model/AliasedOpenGeneric.m +++ b/matlab/generated/+test_model/AliasedOpenGeneric.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function c = AliasedOpenGeneric(varargin) +function c = AliasedOpenGeneric(varargin) c = test_model.AliasedTuple(varargin{:}); end diff --git a/matlab/generated/+test_model/AliasedOptional.m b/matlab/generated/+test_model/AliasedOptional.m index 3ec56142..f80a59db 100644 --- a/matlab/generated/+test_model/AliasedOptional.m +++ b/matlab/generated/+test_model/AliasedOptional.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function o = AliasedOptional(value) +function o = AliasedOptional(value) arguments value int32 end diff --git a/matlab/generated/+test_model/AliasedString.m b/matlab/generated/+test_model/AliasedString.m index c544744e..34c1c4ab 100644 --- a/matlab/generated/+test_model/AliasedString.m +++ b/matlab/generated/+test_model/AliasedString.m @@ -1,4 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -classdef AliasedString < string +function s = AliasedString(varargin) + s = string(varargin{:}); end diff --git a/matlab/generated/+test_model/AliasedTuple.m b/matlab/generated/+test_model/AliasedTuple.m index f77c1fde..752b1420 100644 --- a/matlab/generated/+test_model/AliasedTuple.m +++ b/matlab/generated/+test_model/AliasedTuple.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function c = AliasedTuple(varargin) +function c = AliasedTuple(varargin) c = test_model.MyTuple(varargin{:}); end diff --git a/matlab/generated/+test_model/AliasedVectorOfGenericRecords.m b/matlab/generated/+test_model/AliasedVectorOfGenericRecords.m index 607013fa..fed1676b 100644 --- a/matlab/generated/+test_model/AliasedVectorOfGenericRecords.m +++ b/matlab/generated/+test_model/AliasedVectorOfGenericRecords.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = AliasedVectorOfGenericRecords(array) +function a = AliasedVectorOfGenericRecords(array) a = array; end diff --git a/matlab/generated/+test_model/ArrayOrScalar.m b/matlab/generated/+test_model/ArrayOrScalar.m index b67a4457..ed579da7 100644 --- a/matlab/generated/+test_model/ArrayOrScalar.m +++ b/matlab/generated/+test_model/ArrayOrScalar.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.ArrayOrScalar") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.ArrayOrScalar") && other.index == self.index && isequal(self.value, other.value); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["Array", "Scalar"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m b/matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m index e1d85eba..bf2391e8 100644 --- a/matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m +++ b/matlab/generated/+test_model/ArrayWithKeywordDimensionNames.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = ArrayWithKeywordDimensionNames(array) +function a = ArrayWithKeywordDimensionNames(array) arguments array int32 end diff --git a/matlab/generated/+test_model/GenericUnion3.m b/matlab/generated/+test_model/GenericUnion3.m index 8c1490c5..08cae531 100644 --- a/matlab/generated/+test_model/GenericUnion3.m +++ b/matlab/generated/+test_model/GenericUnion3.m @@ -42,11 +42,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.GenericUnion3") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.GenericUnion3") && other.index == self.index && isequal(self.value, other.value); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["T", "U", "V"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/GenericUnion3Alternate.m b/matlab/generated/+test_model/GenericUnion3Alternate.m index bf444e97..3e76b8a5 100644 --- a/matlab/generated/+test_model/GenericUnion3Alternate.m +++ b/matlab/generated/+test_model/GenericUnion3Alternate.m @@ -42,11 +42,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.GenericUnion3Alternate") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.GenericUnion3Alternate") && other.index == self.index && isequal(self.value, other.value); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["U", "V", "W"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m b/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m index acc5200e..9b02413b 100644 --- a/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m +++ b/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m @@ -42,11 +42,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.GenericUnionWithRepeatedTypeParameters") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.GenericUnionWithRepeatedTypeParameters") && other.index == self.index && isequal(self.value, other.value); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["T", "Tv", "Ta"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/Image.m b/matlab/generated/+test_model/Image.m index a31eac1f..0332777d 100644 --- a/matlab/generated/+test_model/Image.m +++ b/matlab/generated/+test_model/Image.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = Image(array) +function a = Image(array) a = array; end diff --git a/matlab/generated/+test_model/ImageFloatOrImageDouble.m b/matlab/generated/+test_model/ImageFloatOrImageDouble.m index 1d2c5543..79c65dfa 100644 --- a/matlab/generated/+test_model/ImageFloatOrImageDouble.m +++ b/matlab/generated/+test_model/ImageFloatOrImageDouble.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.ImageFloatOrImageDouble") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.ImageFloatOrImageDouble") && other.index == self.index && isequal(self.value, other.value); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["ImageFloat", "ImageDouble"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/Int32OrFloat32.m b/matlab/generated/+test_model/Int32OrFloat32.m index 8044a248..a58c0bc3 100644 --- a/matlab/generated/+test_model/Int32OrFloat32.m +++ b/matlab/generated/+test_model/Int32OrFloat32.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.Int32OrFloat32") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.Int32OrFloat32") && other.index == self.index && all([self.value] == [other.value]); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["Int32", "Float32"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/Int32OrRecordWithVlens.m b/matlab/generated/+test_model/Int32OrRecordWithVlens.m index 90c0f9e3..a2dbc8e0 100644 --- a/matlab/generated/+test_model/Int32OrRecordWithVlens.m +++ b/matlab/generated/+test_model/Int32OrRecordWithVlens.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.Int32OrRecordWithVlens") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.Int32OrRecordWithVlens") && other.index == self.index && all([self.value] == [other.value]); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["Int32", "RecordWithVlens"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/Int32OrSimpleRecord.m b/matlab/generated/+test_model/Int32OrSimpleRecord.m index 08527043..a3b51c94 100644 --- a/matlab/generated/+test_model/Int32OrSimpleRecord.m +++ b/matlab/generated/+test_model/Int32OrSimpleRecord.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.Int32OrSimpleRecord") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.Int32OrSimpleRecord") && other.index == self.index && all([self.value] == [other.value]); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["Int32", "SimpleRecord"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/IntArray.m b/matlab/generated/+test_model/IntArray.m index 26fd860b..56fc2e5b 100644 --- a/matlab/generated/+test_model/IntArray.m +++ b/matlab/generated/+test_model/IntArray.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = IntArray(array) +function a = IntArray(array) arguments array int32 end diff --git a/matlab/generated/+test_model/IntFixedArray.m b/matlab/generated/+test_model/IntFixedArray.m index 6ef07b92..c4da18be 100644 --- a/matlab/generated/+test_model/IntFixedArray.m +++ b/matlab/generated/+test_model/IntFixedArray.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = IntFixedArray(array) +function a = IntFixedArray(array) arguments array int32 end diff --git a/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m b/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m index 9cd41947..66578f1d 100644 --- a/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m +++ b/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.IntOrGenericRecordWithComputedFields") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.IntOrGenericRecordWithComputedFields") && other.index == self.index && all([self.value] == [other.value]); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["Int", "GenericRecordWithComputedFields"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/IntRank2Array.m b/matlab/generated/+test_model/IntRank2Array.m index a1296d15..c043e267 100644 --- a/matlab/generated/+test_model/IntRank2Array.m +++ b/matlab/generated/+test_model/IntRank2Array.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = IntRank2Array(array) +function a = IntRank2Array(array) arguments array int32 end diff --git a/matlab/generated/+test_model/MapOrScalar.m b/matlab/generated/+test_model/MapOrScalar.m index fff69de4..872b14db 100644 --- a/matlab/generated/+test_model/MapOrScalar.m +++ b/matlab/generated/+test_model/MapOrScalar.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.MapOrScalar") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.MapOrScalar") && other.index == self.index && all([self.value] == [other.value]); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["Map", "Scalar"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/MyTuple.m b/matlab/generated/+test_model/MyTuple.m index be3580d9..bb03cdf3 100644 --- a/matlab/generated/+test_model/MyTuple.m +++ b/matlab/generated/+test_model/MyTuple.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function c = MyTuple(varargin) +function c = MyTuple(varargin) c = basic_types.MyTuple(varargin{:}); end diff --git a/matlab/generated/+test_model/NamedFixedNDArray.m b/matlab/generated/+test_model/NamedFixedNDArray.m index 417d0678..ea3bd33d 100644 --- a/matlab/generated/+test_model/NamedFixedNDArray.m +++ b/matlab/generated/+test_model/NamedFixedNDArray.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = NamedFixedNDArray(array) +function a = NamedFixedNDArray(array) arguments array int32 end diff --git a/matlab/generated/+test_model/NamedNDArray.m b/matlab/generated/+test_model/NamedNDArray.m index ad3f0b98..95fd517d 100644 --- a/matlab/generated/+test_model/NamedNDArray.m +++ b/matlab/generated/+test_model/NamedNDArray.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = NamedNDArray(array) +function a = NamedNDArray(array) arguments array int32 end diff --git a/matlab/generated/+test_model/RecordWithVlensFixedArray.m b/matlab/generated/+test_model/RecordWithVlensFixedArray.m index 71f9d411..f4015b1d 100644 --- a/matlab/generated/+test_model/RecordWithVlensFixedArray.m +++ b/matlab/generated/+test_model/RecordWithVlensFixedArray.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = RecordWithVlensFixedArray(array) +function a = RecordWithVlensFixedArray(array) arguments array test_model.RecordWithVlens end diff --git a/matlab/generated/+test_model/SimpleRecordFixedArray.m b/matlab/generated/+test_model/SimpleRecordFixedArray.m index b53b7636..c89409e7 100644 --- a/matlab/generated/+test_model/SimpleRecordFixedArray.m +++ b/matlab/generated/+test_model/SimpleRecordFixedArray.m @@ -1,6 +1,6 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = SimpleRecordFixedArray(array) +function a = SimpleRecordFixedArray(array) arguments array test_model.SimpleRecord end diff --git a/matlab/generated/+test_model/StringOrInt32.m b/matlab/generated/+test_model/StringOrInt32.m index 325e86c0..55eb1837 100644 --- a/matlab/generated/+test_model/StringOrInt32.m +++ b/matlab/generated/+test_model/StringOrInt32.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.StringOrInt32") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.StringOrInt32") && other.index == self.index && all([self.value] == [other.value]); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["String", "Int32"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/UOrV.m b/matlab/generated/+test_model/UOrV.m index 5acb477e..e74776d3 100644 --- a/matlab/generated/+test_model/UOrV.m +++ b/matlab/generated/+test_model/UOrV.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.UOrV") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.UOrV") && other.index == self.index && isequal(self.value, other.value); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["U", "V"]; + t = tags_(self.index_); + end end end diff --git a/matlab/generated/+test_model/VectorOfGenericRecords.m b/matlab/generated/+test_model/VectorOfGenericRecords.m index d6e5265d..a8f035c4 100644 --- a/matlab/generated/+test_model/VectorOfGenericRecords.m +++ b/matlab/generated/+test_model/VectorOfGenericRecords.m @@ -1,5 +1,5 @@ % This file was generated by the "yardl" tool. DO NOT EDIT. -function a = VectorOfGenericRecords(array) +function a = VectorOfGenericRecords(array) a = array; end diff --git a/matlab/generated/+test_model/VectorOrScalar.m b/matlab/generated/+test_model/VectorOrScalar.m index 56505a1d..486d5eef 100644 --- a/matlab/generated/+test_model/VectorOrScalar.m +++ b/matlab/generated/+test_model/VectorOrScalar.m @@ -34,11 +34,16 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.VectorOrScalar") && other.index == self.index && other.value == self.value; + eq = isa(other, "test_model.VectorOrScalar") && other.index == self.index && all([self.value] == [other.value]); end function ne = ne(self, other) ne = ~self.eq(other); end + + function t = tag(self) + tags_ = ["Vector", "Scalar"]; + t = tags_(self.index_); + end end end diff --git a/matlab/test/GeneratedTypesTest.m b/matlab/test/GeneratedTypesTest.m index aba95605..47eeb227 100644 --- a/matlab/test/GeneratedTypesTest.m +++ b/matlab/test/GeneratedTypesTest.m @@ -212,5 +212,17 @@ function testFlags(testCase) testCase.verifyTrue(bold_underline2.has_flags(underline)); testCase.verifyTrue(bold_underline2.has_flags(bold_underline)); end + + function testUnionTags(testCase) + isi = basic_types.Int32OrString.Int32(42); + testCase.verifyTrue(isi.isInt32()); + testCase.verifyFalse(isi.isString()); + testCase.verifyEqual(isi.tag(), "Int32"); + + iss = basic_types.Int32OrString.String("hello"); + testCase.verifyTrue(iss.isString()); + testCase.verifyFalse(iss.isInt32()); + testCase.verifyEqual(iss.tag(), "String"); + end end end diff --git a/tooling/internal/matlab/static_files/Date.m b/tooling/internal/matlab/static_files/Date.m index fdf30c6a..ed28ebd9 100644 --- a/tooling/internal/matlab/static_files/Date.m +++ b/tooling/internal/matlab/static_files/Date.m @@ -3,25 +3,25 @@ classdef Date < handle - properties (Access=private) - days_since_epoch_ + properties (SetAccess=private) + days_since_epoch end methods function self = Date(days_since_epoch) if nargin > 0 - self.days_since_epoch_ = days_since_epoch; + self.days_since_epoch = days_since_epoch; else - self.days_since_epoch_ = 0; + self.days_since_epoch = 0; end end function value = value(self) - value = self.days_since_epoch_; + value = self.days_since_epoch; end function dt = to_datetime(self) - dt = datetime(0, 'ConvertFrom', 'epochtime') + days(self.days_since_epoch_); + dt = datetime(0, 'ConvertFrom', 'epochtime') + days(self.days_since_epoch); end function eq = eq(self, other) diff --git a/tooling/internal/matlab/static_files/DateTime.m b/tooling/internal/matlab/static_files/DateTime.m index 4a9c2346..5a5ba903 100644 --- a/tooling/internal/matlab/static_files/DateTime.m +++ b/tooling/internal/matlab/static_files/DateTime.m @@ -4,25 +4,25 @@ classdef DateTime < handle % A basic datetime with nanosecond precision, always in UTC. - properties (Access=private) - nanoseconds_since_epoch_ + properties (SetAccess=private) + nanoseconds_since_epoch end methods function self = DateTime(nanoseconds_since_epoch) if nargin > 0 - self.nanoseconds_since_epoch_ = nanoseconds_since_epoch; + self.nanoseconds_since_epoch = nanoseconds_since_epoch; else - self.nanoseconds_since_epoch_ = 0; + self.nanoseconds_since_epoch = 0; end end function value = value(self) - value = self.nanoseconds_since_epoch_; + value = self.nanoseconds_since_epoch; end function dt = to_datetime(self) - dt = datetime(self.nanoseconds_since_epoch_, 'ConvertFrom', 'epochtime', 'TicksPerSecond', 1e9); + dt = datetime(self.nanoseconds_since_epoch, 'ConvertFrom', 'epochtime', 'TicksPerSecond', 1e9); end function eq = eq(self, other) diff --git a/tooling/internal/matlab/static_files/Time.m b/tooling/internal/matlab/static_files/Time.m index eedcce66..e00dea4d 100644 --- a/tooling/internal/matlab/static_files/Time.m +++ b/tooling/internal/matlab/static_files/Time.m @@ -5,8 +5,8 @@ % A basic time of day with nanosecond precision. It is not timezone-aware and is % meant to represent a wall clock time. - properties (Access=private) - nanoseconds_since_midnight_ + properties (SetAccess=private) + nanoseconds_since_midnight end methods @@ -15,18 +15,18 @@ if nanoseconds_since_midnight < 0 || nanoseconds_since_midnight >= 24*60*60*1e9 throw(yardl.ValuError("Time must be between 00:00:00 and 23:59:59.999999999")); end - self.nanoseconds_since_midnight_ = nanoseconds_since_midnight; + self.nanoseconds_since_midnight = nanoseconds_since_midnight; else - self.nanoseconds_since_midnight_ = 0; + self.nanoseconds_since_midnight = 0; end end function value = value(self) - value = self.nanoseconds_since_midnight_; + value = self.nanoseconds_since_midnight; end function dt = to_datetime(self) - dt = datetime(self.nanoseconds_since_midnight_, 'ConvertFrom', 'epochtime', 'Epoch', datetime('today'), 'TicksPerSecond', 1e9); + dt = datetime(self.nanoseconds_since_midnight, 'ConvertFrom', 'epochtime', 'Epoch', datetime('today'), 'TicksPerSecond', 1e9); end function eq = eq(self, other) diff --git a/tooling/internal/matlab/static_files/Union.m b/tooling/internal/matlab/static_files/Union.m index fa802add..60b2750a 100644 --- a/tooling/internal/matlab/static_files/Union.m +++ b/tooling/internal/matlab/static_files/Union.m @@ -1,24 +1,37 @@ % Copyright (c) Microsoft Corporation. % Licensed under the MIT License. -classdef Union < handle +classdef Union < handle & matlab.mixin.CustomDisplay properties (Access=protected) index_ - value_ + end + + properties (SetAccess=protected) + value end methods function self = Union(index, value) self.index_ = index; - self.value_ = value; + self.value = value; end function i = index(self) i = self.index_; end + end + + methods (Abstract) + t = tag(self) + end - function v = value(self) - v = self.value_; + methods (Access=protected) + function displayScalarObject(obj) + className = matlab.mixin.CustomDisplay.getClassNameForHeader(obj); + header = sprintf('%s.%s\n', className, obj.tag()); + disp(header) + propgroup = getPropertyGroups(obj); + matlab.mixin.CustomDisplay.displayPropertyGroups(obj,propgroup) end end end diff --git a/tooling/internal/matlab/types/types.go b/tooling/internal/matlab/types/types.go index 64a6c237..5a6b1bb0 100644 --- a/tooling/internal/matlab/types/types.go +++ b/tooling/internal/matlab/types/types.go @@ -106,11 +106,14 @@ func writeUnionClass(w *formatting.IndentedWriter, className string, generalized w.WriteStringln("methods") common.WriteBlockBody(w, func() { index := 1 + var tags []string for _, tc := range generalizedType.Cases { if tc.Type == nil { continue } - fmt.Fprintf(w, "function res = is%s(self)\n", formatting.ToPascalCase(tc.Tag)) + tag := formatting.ToPascalCase(tc.Tag) + tags = append(tags, fmt.Sprintf(`"%s"`, tag)) + fmt.Fprintf(w, "function res = is%s(self)\n", tag) common.WriteBlockBody(w, func() { fmt.Fprintf(w, "res = self.index == %d;\n", index) }) @@ -120,13 +123,19 @@ func writeUnionClass(w *formatting.IndentedWriter, className string, generalized w.WriteStringln("function eq = eq(self, other)") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "eq = isa(other, \"%s\") && other.index == self.index && other.value == self.value;\n", qualifiedClassName) + fmt.Fprintf(w, "eq = isa(other, \"%s\") && other.index == self.index && %s;\n", qualifiedClassName, typeEqualityExpression(generalizedType, "self.value", "other.value")) }) w.WriteStringln("") w.WriteStringln("function ne = ne(self, other)") common.WriteBlockBody(w, func() { w.WriteStringln("ne = ~self.eq(other);") }) + w.WriteStringln("") + w.WriteStringln("function t = tag(self)") + common.WriteBlockBody(w, func() { + fmt.Fprintf(w, "tags_ = [%s];\n", strings.Join(tags, ", ")) + w.WriteStringln("t = tags_(self.index_);") + }) }) }) @@ -137,20 +146,30 @@ func writeUnionClass(w *formatting.IndentedWriter, className string, generalized func writeNamedType(fw *common.MatlabFileWriter, td *dsl.NamedType) error { return fw.WriteFile(common.TypeIdentifierName(td.Name), func(w *formatting.IndentedWriter) { ut := dsl.GetUnderlyingType(td.Type) - // If the underlying type is a RecordDefinition or Optional, we will generate a "function" alias + // If the underlying type is a RecordDefinition, PrimitiveString, Optional, + // Vector, Array, or Map - we will generate a "function" alias if st, ok := ut.(*dsl.SimpleType); ok { if _, ok := st.ResolvedDefinition.(*dsl.RecordDefinition); ok { - fmt.Fprintf(w, "function c = %s(varargin) \n", common.TypeIdentifierName(td.Name)) + fmt.Fprintf(w, "function c = %s(varargin)\n", common.TypeIdentifierName(td.Name)) common.WriteBlockBody(w, func() { common.WriteComment(w, td.Comment) fmt.Fprintf(w, "c = %s(varargin{:});\n", common.TypeSyntax(td.Type, td.Namespace)) }) return + } else if pd, ok := st.ResolvedDefinition.(dsl.PrimitiveDefinition); ok { + if pd == dsl.PrimitiveString { + fmt.Fprintf(w, "function s = %s(varargin)\n", common.TypeIdentifierName(td.Name)) + common.WriteBlockBody(w, func() { + common.WriteComment(w, td.Comment) + fmt.Fprintf(w, "s = %s(varargin{:});\n", common.TypeSyntax(td.Type, td.Namespace)) + }) + return + } } } else if gt, ok := ut.(*dsl.GeneralizedType); ok { if gt.Cases.IsOptional() { innerType := gt.Cases[1].Type - fmt.Fprintf(w, "function o = %s(value) \n", common.TypeIdentifierName(td.Name)) + fmt.Fprintf(w, "function o = %s(value)\n", common.TypeIdentifierName(td.Name)) common.WriteBlockBody(w, func() { common.WriteComment(w, td.Comment) if !dsl.TypeContainsGenericTypeParameter(innerType) { @@ -167,7 +186,7 @@ func writeNamedType(fw *common.MatlabFileWriter, td *dsl.NamedType) error { switch gt.Dimensionality.(type) { case *dsl.Vector, *dsl.Array: scalar := gt.ToScalar() - fmt.Fprintf(w, "function a = %s(array) \n", common.TypeIdentifierName(td.Name)) + fmt.Fprintf(w, "function a = %s(array)\n", common.TypeIdentifierName(td.Name)) common.WriteBlockBody(w, func() { common.WriteComment(w, td.Comment) if !dsl.TypeContainsGenericTypeParameter(scalar) { @@ -179,6 +198,13 @@ func writeNamedType(fw *common.MatlabFileWriter, td *dsl.NamedType) error { w.WriteStringln("a = array;") }) return + case *dsl.Map: + fmt.Fprintf(w, "function m = %s(varargin)\n", common.TypeIdentifierName(td.Name)) + common.WriteBlockBody(w, func() { + common.WriteComment(w, td.Comment) + fmt.Fprintf(w, "m = %s(varargin{:});\n", common.TypeSyntax(td.Type, td.Namespace)) + }) + return } } From f1fb00fd06e318e617981bf171a450a4323f9341 Mon Sep 17 00:00:00 2001 From: Joe Naegele Date: Wed, 15 May 2024 14:35:07 +0000 Subject: [PATCH 31/32] Fix MATLAB Record class equality operator --- .../+basic_types/GenericNullableUnion2.m | 2 +- matlab/generated/+basic_types/GenericUnion2.m | 2 +- matlab/generated/+basic_types/Int32OrString.m | 2 +- .../generated/+basic_types/RecordWithUnions.m | 6 +-- matlab/generated/+basic_types/T0OrT1.m | 2 +- .../generated/+basic_types/TimeOrDatetime.m | 2 +- .../+test_model/AcquisitionOrImage.m | 2 +- .../+test_model/AliasedIntOrSimpleRecord.m | 2 +- .../+test_model/AliasedMultiGenericOptional.m | 2 +- .../AliasedNullableIntSimpleRecord.m | 2 +- matlab/generated/+test_model/ArrayOrScalar.m | 2 +- matlab/generated/+test_model/GenericUnion3.m | 2 +- .../+test_model/GenericUnion3Alternate.m | 2 +- .../GenericUnionWithRepeatedTypeParameters.m | 2 +- .../+test_model/ImageFloatOrImageDouble.m | 2 +- matlab/generated/+test_model/Int32OrFloat32.m | 2 +- .../+test_model/Int32OrRecordWithVlens.m | 2 +- .../+test_model/Int32OrSimpleRecord.m | 2 +- .../IntOrGenericRecordWithComputedFields.m | 2 +- matlab/generated/+test_model/MapOrScalar.m | 2 +- .../RecordContainingNestedGenericRecords.m | 4 +- .../+test_model/RecordNotUsedInProtocol.m | 4 +- .../+test_model/RecordWithComputedFields.m | 44 +++++++++---------- .../generated/+test_model/RecordWithEnums.m | 6 +-- .../+test_model/RecordWithFixedCollections.m | 2 +- .../+test_model/RecordWithFixedVectors.m | 6 +-- .../+test_model/RecordWithKeywordFields.m | 4 +- .../+test_model/RecordWithOptionalFields.m | 6 +-- .../+test_model/RecordWithOptionalVector.m | 2 +- .../+test_model/RecordWithPrimitiveAliases.m | 18 ++++---- .../+test_model/RecordWithPrimitives.m | 34 +++++++------- .../generated/+test_model/RecordWithStrings.m | 4 +- .../RecordWithUnionsOfContainers.m | 4 +- .../+test_model/RecordWithVectorOfTimes.m | 2 +- .../generated/+test_model/RecordWithVectors.m | 6 +-- .../+test_model/RecordWithVlenCollections.m | 2 +- .../generated/+test_model/RecordWithVlens.m | 6 +-- .../generated/+test_model/SimpleAcquisition.m | 4 +- .../+test_model/SimpleEncodingCounters.m | 8 ++-- matlab/generated/+test_model/SimpleRecord.m | 6 +-- .../+test_model/SmallBenchmarkRecord.m | 6 +-- matlab/generated/+test_model/StringOrInt32.m | 2 +- .../generated/+test_model/TupleWithRecords.m | 4 +- matlab/generated/+test_model/UOrV.m | 2 +- matlab/generated/+test_model/VectorOrScalar.m | 2 +- matlab/test/EqualityTest.m | 11 +++++ .../internal/matlab/static_files/Optional.m | 26 ++++++----- tooling/internal/matlab/types/types.go | 28 +----------- 48 files changed, 143 insertions(+), 154 deletions(-) diff --git a/matlab/generated/+basic_types/GenericNullableUnion2.m b/matlab/generated/+basic_types/GenericNullableUnion2.m index fc5f13b1..574e124a 100644 --- a/matlab/generated/+basic_types/GenericNullableUnion2.m +++ b/matlab/generated/+basic_types/GenericNullableUnion2.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "basic_types.GenericNullableUnion2") && other.index == self.index && isequal(self.value, other.value); + eq = isa(other, "basic_types.GenericNullableUnion2") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+basic_types/GenericUnion2.m b/matlab/generated/+basic_types/GenericUnion2.m index 9481abf8..610b0703 100644 --- a/matlab/generated/+basic_types/GenericUnion2.m +++ b/matlab/generated/+basic_types/GenericUnion2.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "basic_types.GenericUnion2") && other.index == self.index && isequal(self.value, other.value); + eq = isa(other, "basic_types.GenericUnion2") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+basic_types/Int32OrString.m b/matlab/generated/+basic_types/Int32OrString.m index b4bb4273..0afdbb22 100644 --- a/matlab/generated/+basic_types/Int32OrString.m +++ b/matlab/generated/+basic_types/Int32OrString.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "basic_types.Int32OrString") && other.index == self.index && all([self.value] == [other.value]); + eq = isa(other, "basic_types.Int32OrString") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+basic_types/RecordWithUnions.m b/matlab/generated/+basic_types/RecordWithUnions.m index da4d2813..4dc6416e 100644 --- a/matlab/generated/+basic_types/RecordWithUnions.m +++ b/matlab/generated/+basic_types/RecordWithUnions.m @@ -22,9 +22,9 @@ function res = eq(self, other) res = ... isa(other, "basic_types.RecordWithUnions") && ... - all([self.null_or_int_or_string] == [other.null_or_int_or_string]) && ... - all([self.date_or_datetime] == [other.date_or_datetime]) && ... - all([self.null_or_fruits_or_days_of_week] == [other.null_or_fruits_or_days_of_week]); + isequal(self.null_or_int_or_string, other.null_or_int_or_string) && ... + isequal(self.date_or_datetime, other.date_or_datetime) && ... + isequal(self.null_or_fruits_or_days_of_week, other.null_or_fruits_or_days_of_week); end function res = ne(self, other) diff --git a/matlab/generated/+basic_types/T0OrT1.m b/matlab/generated/+basic_types/T0OrT1.m index 0afe2808..6afa0b43 100644 --- a/matlab/generated/+basic_types/T0OrT1.m +++ b/matlab/generated/+basic_types/T0OrT1.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "basic_types.T0OrT1") && other.index == self.index && isequal(self.value, other.value); + eq = isa(other, "basic_types.T0OrT1") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+basic_types/TimeOrDatetime.m b/matlab/generated/+basic_types/TimeOrDatetime.m index 027738f1..d5d4ae72 100644 --- a/matlab/generated/+basic_types/TimeOrDatetime.m +++ b/matlab/generated/+basic_types/TimeOrDatetime.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "basic_types.TimeOrDatetime") && other.index == self.index && all([self.value] == [other.value]); + eq = isa(other, "basic_types.TimeOrDatetime") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/AcquisitionOrImage.m b/matlab/generated/+test_model/AcquisitionOrImage.m index 06cea23b..25da646e 100644 --- a/matlab/generated/+test_model/AcquisitionOrImage.m +++ b/matlab/generated/+test_model/AcquisitionOrImage.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.AcquisitionOrImage") && other.index == self.index && isequal(self.value, other.value); + eq = isa(other, "test_model.AcquisitionOrImage") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m b/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m index d2dfb4c2..6bd66c2a 100644 --- a/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m +++ b/matlab/generated/+test_model/AliasedIntOrSimpleRecord.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.AliasedIntOrSimpleRecord") && other.index == self.index && all([self.value] == [other.value]); + eq = isa(other, "test_model.AliasedIntOrSimpleRecord") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/AliasedMultiGenericOptional.m b/matlab/generated/+test_model/AliasedMultiGenericOptional.m index 2c08d7df..508d75ae 100644 --- a/matlab/generated/+test_model/AliasedMultiGenericOptional.m +++ b/matlab/generated/+test_model/AliasedMultiGenericOptional.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.AliasedMultiGenericOptional") && other.index == self.index && isequal(self.value, other.value); + eq = isa(other, "test_model.AliasedMultiGenericOptional") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m b/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m index 9e59827b..bba1a9e6 100644 --- a/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m +++ b/matlab/generated/+test_model/AliasedNullableIntSimpleRecord.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.AliasedNullableIntSimpleRecord") && other.index == self.index && all([self.value] == [other.value]); + eq = isa(other, "test_model.AliasedNullableIntSimpleRecord") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/ArrayOrScalar.m b/matlab/generated/+test_model/ArrayOrScalar.m index ed579da7..e756b2ee 100644 --- a/matlab/generated/+test_model/ArrayOrScalar.m +++ b/matlab/generated/+test_model/ArrayOrScalar.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.ArrayOrScalar") && other.index == self.index && isequal(self.value, other.value); + eq = isa(other, "test_model.ArrayOrScalar") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/GenericUnion3.m b/matlab/generated/+test_model/GenericUnion3.m index 08cae531..802ca942 100644 --- a/matlab/generated/+test_model/GenericUnion3.m +++ b/matlab/generated/+test_model/GenericUnion3.m @@ -42,7 +42,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.GenericUnion3") && other.index == self.index && isequal(self.value, other.value); + eq = isa(other, "test_model.GenericUnion3") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/GenericUnion3Alternate.m b/matlab/generated/+test_model/GenericUnion3Alternate.m index 3e76b8a5..ad7f4a1f 100644 --- a/matlab/generated/+test_model/GenericUnion3Alternate.m +++ b/matlab/generated/+test_model/GenericUnion3Alternate.m @@ -42,7 +42,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.GenericUnion3Alternate") && other.index == self.index && isequal(self.value, other.value); + eq = isa(other, "test_model.GenericUnion3Alternate") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m b/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m index 9b02413b..40797c2c 100644 --- a/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m +++ b/matlab/generated/+test_model/GenericUnionWithRepeatedTypeParameters.m @@ -42,7 +42,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.GenericUnionWithRepeatedTypeParameters") && other.index == self.index && isequal(self.value, other.value); + eq = isa(other, "test_model.GenericUnionWithRepeatedTypeParameters") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/ImageFloatOrImageDouble.m b/matlab/generated/+test_model/ImageFloatOrImageDouble.m index 79c65dfa..4d03fd94 100644 --- a/matlab/generated/+test_model/ImageFloatOrImageDouble.m +++ b/matlab/generated/+test_model/ImageFloatOrImageDouble.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.ImageFloatOrImageDouble") && other.index == self.index && isequal(self.value, other.value); + eq = isa(other, "test_model.ImageFloatOrImageDouble") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/Int32OrFloat32.m b/matlab/generated/+test_model/Int32OrFloat32.m index a58c0bc3..c29ac498 100644 --- a/matlab/generated/+test_model/Int32OrFloat32.m +++ b/matlab/generated/+test_model/Int32OrFloat32.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.Int32OrFloat32") && other.index == self.index && all([self.value] == [other.value]); + eq = isa(other, "test_model.Int32OrFloat32") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/Int32OrRecordWithVlens.m b/matlab/generated/+test_model/Int32OrRecordWithVlens.m index a2dbc8e0..1371fe86 100644 --- a/matlab/generated/+test_model/Int32OrRecordWithVlens.m +++ b/matlab/generated/+test_model/Int32OrRecordWithVlens.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.Int32OrRecordWithVlens") && other.index == self.index && all([self.value] == [other.value]); + eq = isa(other, "test_model.Int32OrRecordWithVlens") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/Int32OrSimpleRecord.m b/matlab/generated/+test_model/Int32OrSimpleRecord.m index a3b51c94..d12cd188 100644 --- a/matlab/generated/+test_model/Int32OrSimpleRecord.m +++ b/matlab/generated/+test_model/Int32OrSimpleRecord.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.Int32OrSimpleRecord") && other.index == self.index && all([self.value] == [other.value]); + eq = isa(other, "test_model.Int32OrSimpleRecord") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m b/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m index 66578f1d..304e05e1 100644 --- a/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m +++ b/matlab/generated/+test_model/IntOrGenericRecordWithComputedFields.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.IntOrGenericRecordWithComputedFields") && other.index == self.index && all([self.value] == [other.value]); + eq = isa(other, "test_model.IntOrGenericRecordWithComputedFields") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/MapOrScalar.m b/matlab/generated/+test_model/MapOrScalar.m index 872b14db..6770a2de 100644 --- a/matlab/generated/+test_model/MapOrScalar.m +++ b/matlab/generated/+test_model/MapOrScalar.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.MapOrScalar") && other.index == self.index && all([self.value] == [other.value]); + eq = isa(other, "test_model.MapOrScalar") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m b/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m index 68f63f12..aeaa92b3 100644 --- a/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m +++ b/matlab/generated/+test_model/RecordContainingNestedGenericRecords.m @@ -28,9 +28,9 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordContainingNestedGenericRecords") && ... - all([self.f1] == [other.f1]) && ... + isequal(self.f1, other.f1) && ... isequal(self.f1a, other.f1a) && ... - all([self.f2] == [other.f2]) && ... + isequal(self.f2, other.f2) && ... isequal(self.f2a, other.f2a) && ... isequal(self.nested, other.nested); end diff --git a/matlab/generated/+test_model/RecordNotUsedInProtocol.m b/matlab/generated/+test_model/RecordNotUsedInProtocol.m index 90bc5e1e..53cdef1c 100644 --- a/matlab/generated/+test_model/RecordNotUsedInProtocol.m +++ b/matlab/generated/+test_model/RecordNotUsedInProtocol.m @@ -19,8 +19,8 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordNotUsedInProtocol") && ... - all([self.u1] == [other.u1]) && ... - all([self.u2] == [other.u2]); + isequal(self.u1, other.u1) && ... + isequal(self.u2, other.u2); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/RecordWithComputedFields.m b/matlab/generated/+test_model/RecordWithComputedFields.m index 9cb98b2c..a278ba6a 100644 --- a/matlab/generated/+test_model/RecordWithComputedFields.m +++ b/matlab/generated/+test_model/RecordWithComputedFields.m @@ -531,30 +531,30 @@ isequal(self.array_field_map_dimensions, other.array_field_map_dimensions) && ... isequal(self.dynamic_array_field, other.dynamic_array_field) && ... isequal(self.fixed_array_field, other.fixed_array_field) && ... - all([self.int_field] == [other.int_field]) && ... - all([self.int8_field] == [other.int8_field]) && ... - all([self.uint8_field] == [other.uint8_field]) && ... - all([self.int16_field] == [other.int16_field]) && ... - all([self.uint16_field] == [other.uint16_field]) && ... - all([self.uint32_field] == [other.uint32_field]) && ... - all([self.int64_field] == [other.int64_field]) && ... - all([self.uint64_field] == [other.uint64_field]) && ... - all([self.size_field] == [other.size_field]) && ... - all([self.float32_field] == [other.float32_field]) && ... - all([self.float64_field] == [other.float64_field]) && ... - all([self.complexfloat32_field] == [other.complexfloat32_field]) && ... - all([self.complexfloat64_field] == [other.complexfloat64_field]) && ... - all([self.string_field] == [other.string_field]) && ... + isequal(self.int_field, other.int_field) && ... + isequal(self.int8_field, other.int8_field) && ... + isequal(self.uint8_field, other.uint8_field) && ... + isequal(self.int16_field, other.int16_field) && ... + isequal(self.uint16_field, other.uint16_field) && ... + isequal(self.uint32_field, other.uint32_field) && ... + isequal(self.int64_field, other.int64_field) && ... + isequal(self.uint64_field, other.uint64_field) && ... + isequal(self.size_field, other.size_field) && ... + isequal(self.float32_field, other.float32_field) && ... + isequal(self.float64_field, other.float64_field) && ... + isequal(self.complexfloat32_field, other.complexfloat32_field) && ... + isequal(self.complexfloat64_field, other.complexfloat64_field) && ... + isequal(self.string_field, other.string_field) && ... isequal(self.tuple_field, other.tuple_field) && ... - all([self.vector_field] == [other.vector_field]) && ... - all([self.vector_of_vectors_field] == [other.vector_of_vectors_field]) && ... - all([self.fixed_vector_field] == [other.fixed_vector_field]) && ... - all([self.fixed_vector_of_vectors_field] == [other.fixed_vector_of_vectors_field]) && ... + isequal(self.vector_field, other.vector_field) && ... + isequal(self.vector_of_vectors_field, other.vector_of_vectors_field) && ... + isequal(self.fixed_vector_field, other.fixed_vector_field) && ... + isequal(self.fixed_vector_of_vectors_field, other.fixed_vector_of_vectors_field) && ... isequal(self.optional_named_array, other.optional_named_array) && ... - all([self.int_float_union] == [other.int_float_union]) && ... - all([self.nullable_int_float_union] == [other.nullable_int_float_union]) && ... - all([self.union_with_nested_generic_union] == [other.union_with_nested_generic_union]) && ... - all([self.map_field] == [other.map_field]); + isequal(self.int_float_union, other.int_float_union) && ... + isequal(self.nullable_int_float_union, other.nullable_int_float_union) && ... + isequal(self.union_with_nested_generic_union, other.union_with_nested_generic_union) && ... + isequal(self.map_field, other.map_field); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/RecordWithEnums.m b/matlab/generated/+test_model/RecordWithEnums.m index b3b6a0a4..ab7b0a11 100644 --- a/matlab/generated/+test_model/RecordWithEnums.m +++ b/matlab/generated/+test_model/RecordWithEnums.m @@ -22,9 +22,9 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordWithEnums") && ... - all([self.enum] == [other.enum]) && ... - all([self.flags] == [other.flags]) && ... - all([self.flags_2] == [other.flags_2]); + isequal(self.enum, other.enum) && ... + isequal(self.flags, other.flags) && ... + isequal(self.flags_2, other.flags_2); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/RecordWithFixedCollections.m b/matlab/generated/+test_model/RecordWithFixedCollections.m index 8f761daa..6f80c8ad 100644 --- a/matlab/generated/+test_model/RecordWithFixedCollections.m +++ b/matlab/generated/+test_model/RecordWithFixedCollections.m @@ -19,7 +19,7 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordWithFixedCollections") && ... - all([self.fixed_vector] == [other.fixed_vector]) && ... + isequal(self.fixed_vector, other.fixed_vector) && ... isequal(self.fixed_array, other.fixed_array); end diff --git a/matlab/generated/+test_model/RecordWithFixedVectors.m b/matlab/generated/+test_model/RecordWithFixedVectors.m index 0cab98fd..4d40cb05 100644 --- a/matlab/generated/+test_model/RecordWithFixedVectors.m +++ b/matlab/generated/+test_model/RecordWithFixedVectors.m @@ -22,9 +22,9 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordWithFixedVectors") && ... - all([self.fixed_int_vector] == [other.fixed_int_vector]) && ... - all([self.fixed_simple_record_vector] == [other.fixed_simple_record_vector]) && ... - all([self.fixed_record_with_vlens_vector] == [other.fixed_record_with_vlens_vector]); + isequal(self.fixed_int_vector, other.fixed_int_vector) && ... + isequal(self.fixed_simple_record_vector, other.fixed_simple_record_vector) && ... + isequal(self.fixed_record_with_vlens_vector, other.fixed_record_with_vlens_vector); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/RecordWithKeywordFields.m b/matlab/generated/+test_model/RecordWithKeywordFields.m index 02a6ca77..22ec5fa0 100644 --- a/matlab/generated/+test_model/RecordWithKeywordFields.m +++ b/matlab/generated/+test_model/RecordWithKeywordFields.m @@ -41,9 +41,9 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordWithKeywordFields") && ... - all([self.int] == [other.int]) && ... + isequal(self.int, other.int) && ... isequal(self.sizeof, other.sizeof) && ... - all([self.if_] == [other.if_]); + isequal(self.if_, other.if_); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/RecordWithOptionalFields.m b/matlab/generated/+test_model/RecordWithOptionalFields.m index 55d15c6f..bb159ff8 100644 --- a/matlab/generated/+test_model/RecordWithOptionalFields.m +++ b/matlab/generated/+test_model/RecordWithOptionalFields.m @@ -22,9 +22,9 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordWithOptionalFields") && ... - all([self.optional_int] == [other.optional_int]) && ... - all([self.optional_int_alternate_syntax] == [other.optional_int_alternate_syntax]) && ... - all([self.optional_time] == [other.optional_time]); + isequal(self.optional_int, other.optional_int) && ... + isequal(self.optional_int_alternate_syntax, other.optional_int_alternate_syntax) && ... + isequal(self.optional_time, other.optional_time); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/RecordWithOptionalVector.m b/matlab/generated/+test_model/RecordWithOptionalVector.m index 37b85fec..14aab0bf 100644 --- a/matlab/generated/+test_model/RecordWithOptionalVector.m +++ b/matlab/generated/+test_model/RecordWithOptionalVector.m @@ -16,7 +16,7 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordWithOptionalVector") && ... - all([self.optional_vector] == [other.optional_vector]); + isequal(self.optional_vector, other.optional_vector); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/RecordWithPrimitiveAliases.m b/matlab/generated/+test_model/RecordWithPrimitiveAliases.m index 63411fde..3dd24585 100644 --- a/matlab/generated/+test_model/RecordWithPrimitiveAliases.m +++ b/matlab/generated/+test_model/RecordWithPrimitiveAliases.m @@ -40,15 +40,15 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordWithPrimitiveAliases") && ... - all([self.byte_field] == [other.byte_field]) && ... - all([self.int_field] == [other.int_field]) && ... - all([self.uint_field] == [other.uint_field]) && ... - all([self.long_field] == [other.long_field]) && ... - all([self.ulong_field] == [other.ulong_field]) && ... - all([self.float_field] == [other.float_field]) && ... - all([self.double_field] == [other.double_field]) && ... - all([self.complexfloat_field] == [other.complexfloat_field]) && ... - all([self.complexdouble_field] == [other.complexdouble_field]); + isequal(self.byte_field, other.byte_field) && ... + isequal(self.int_field, other.int_field) && ... + isequal(self.uint_field, other.uint_field) && ... + isequal(self.long_field, other.long_field) && ... + isequal(self.ulong_field, other.ulong_field) && ... + isequal(self.float_field, other.float_field) && ... + isequal(self.double_field, other.double_field) && ... + isequal(self.complexfloat_field, other.complexfloat_field) && ... + isequal(self.complexdouble_field, other.complexdouble_field); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/RecordWithPrimitives.m b/matlab/generated/+test_model/RecordWithPrimitives.m index 5041cacb..07dc6d91 100644 --- a/matlab/generated/+test_model/RecordWithPrimitives.m +++ b/matlab/generated/+test_model/RecordWithPrimitives.m @@ -64,23 +64,23 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordWithPrimitives") && ... - all([self.bool_field] == [other.bool_field]) && ... - all([self.int8_field] == [other.int8_field]) && ... - all([self.uint8_field] == [other.uint8_field]) && ... - all([self.int16_field] == [other.int16_field]) && ... - all([self.uint16_field] == [other.uint16_field]) && ... - all([self.int32_field] == [other.int32_field]) && ... - all([self.uint32_field] == [other.uint32_field]) && ... - all([self.int64_field] == [other.int64_field]) && ... - all([self.uint64_field] == [other.uint64_field]) && ... - all([self.size_field] == [other.size_field]) && ... - all([self.float32_field] == [other.float32_field]) && ... - all([self.float64_field] == [other.float64_field]) && ... - all([self.complexfloat32_field] == [other.complexfloat32_field]) && ... - all([self.complexfloat64_field] == [other.complexfloat64_field]) && ... - all([self.date_field] == [other.date_field]) && ... - all([self.time_field] == [other.time_field]) && ... - all([self.datetime_field] == [other.datetime_field]); + isequal(self.bool_field, other.bool_field) && ... + isequal(self.int8_field, other.int8_field) && ... + isequal(self.uint8_field, other.uint8_field) && ... + isequal(self.int16_field, other.int16_field) && ... + isequal(self.uint16_field, other.uint16_field) && ... + isequal(self.int32_field, other.int32_field) && ... + isequal(self.uint32_field, other.uint32_field) && ... + isequal(self.int64_field, other.int64_field) && ... + isequal(self.uint64_field, other.uint64_field) && ... + isequal(self.size_field, other.size_field) && ... + isequal(self.float32_field, other.float32_field) && ... + isequal(self.float64_field, other.float64_field) && ... + isequal(self.complexfloat32_field, other.complexfloat32_field) && ... + isequal(self.complexfloat64_field, other.complexfloat64_field) && ... + isequal(self.date_field, other.date_field) && ... + isequal(self.time_field, other.time_field) && ... + isequal(self.datetime_field, other.datetime_field); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/RecordWithStrings.m b/matlab/generated/+test_model/RecordWithStrings.m index 481c71e0..ffab134f 100644 --- a/matlab/generated/+test_model/RecordWithStrings.m +++ b/matlab/generated/+test_model/RecordWithStrings.m @@ -19,8 +19,8 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordWithStrings") && ... - all([self.a] == [other.a]) && ... - all([self.b] == [other.b]); + isequal(self.a, other.a) && ... + isequal(self.b, other.b); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/RecordWithUnionsOfContainers.m b/matlab/generated/+test_model/RecordWithUnionsOfContainers.m index 127a5f6b..95858917 100644 --- a/matlab/generated/+test_model/RecordWithUnionsOfContainers.m +++ b/matlab/generated/+test_model/RecordWithUnionsOfContainers.m @@ -22,8 +22,8 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordWithUnionsOfContainers") && ... - all([self.map_or_scalar] == [other.map_or_scalar]) && ... - all([self.vector_or_scalar] == [other.vector_or_scalar]) && ... + isequal(self.map_or_scalar, other.map_or_scalar) && ... + isequal(self.vector_or_scalar, other.vector_or_scalar) && ... isequal(self.array_or_scalar, other.array_or_scalar); end diff --git a/matlab/generated/+test_model/RecordWithVectorOfTimes.m b/matlab/generated/+test_model/RecordWithVectorOfTimes.m index 6c5845e2..25dc8d4a 100644 --- a/matlab/generated/+test_model/RecordWithVectorOfTimes.m +++ b/matlab/generated/+test_model/RecordWithVectorOfTimes.m @@ -16,7 +16,7 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordWithVectorOfTimes") && ... - all([self.times] == [other.times]); + isequal(self.times, other.times); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/RecordWithVectors.m b/matlab/generated/+test_model/RecordWithVectors.m index e2a10ad5..fdfd681a 100644 --- a/matlab/generated/+test_model/RecordWithVectors.m +++ b/matlab/generated/+test_model/RecordWithVectors.m @@ -22,9 +22,9 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordWithVectors") && ... - all([self.default_vector] == [other.default_vector]) && ... - all([self.default_vector_fixed_length] == [other.default_vector_fixed_length]) && ... - all([self.vector_of_vectors] == [other.vector_of_vectors]); + isequal(self.default_vector, other.default_vector) && ... + isequal(self.default_vector_fixed_length, other.default_vector_fixed_length) && ... + isequal(self.vector_of_vectors, other.vector_of_vectors); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/RecordWithVlenCollections.m b/matlab/generated/+test_model/RecordWithVlenCollections.m index c7d65562..158f5550 100644 --- a/matlab/generated/+test_model/RecordWithVlenCollections.m +++ b/matlab/generated/+test_model/RecordWithVlenCollections.m @@ -19,7 +19,7 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordWithVlenCollections") && ... - all([self.vector] == [other.vector]) && ... + isequal(self.vector, other.vector) && ... isequal(self.array, other.array); end diff --git a/matlab/generated/+test_model/RecordWithVlens.m b/matlab/generated/+test_model/RecordWithVlens.m index b7209a0e..6eb80c63 100644 --- a/matlab/generated/+test_model/RecordWithVlens.m +++ b/matlab/generated/+test_model/RecordWithVlens.m @@ -22,9 +22,9 @@ function res = eq(self, other) res = ... isa(other, "test_model.RecordWithVlens") && ... - all([self.a] == [other.a]) && ... - all([self.b] == [other.b]) && ... - all([self.c] == [other.c]); + isequal(self.a, other.a) && ... + isequal(self.b, other.b) && ... + isequal(self.c, other.c); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/SimpleAcquisition.m b/matlab/generated/+test_model/SimpleAcquisition.m index 681ab44f..3d502407 100644 --- a/matlab/generated/+test_model/SimpleAcquisition.m +++ b/matlab/generated/+test_model/SimpleAcquisition.m @@ -25,8 +25,8 @@ function res = eq(self, other) res = ... isa(other, "test_model.SimpleAcquisition") && ... - all([self.flags] == [other.flags]) && ... - all([self.idx] == [other.idx]) && ... + isequal(self.flags, other.flags) && ... + isequal(self.idx, other.idx) && ... isequal(self.data, other.data) && ... isequal(self.trajectory, other.trajectory); end diff --git a/matlab/generated/+test_model/SimpleEncodingCounters.m b/matlab/generated/+test_model/SimpleEncodingCounters.m index 848ef301..2cdbe684 100644 --- a/matlab/generated/+test_model/SimpleEncodingCounters.m +++ b/matlab/generated/+test_model/SimpleEncodingCounters.m @@ -25,10 +25,10 @@ function res = eq(self, other) res = ... isa(other, "test_model.SimpleEncodingCounters") && ... - all([self.e1] == [other.e1]) && ... - all([self.e2] == [other.e2]) && ... - all([self.slice] == [other.slice]) && ... - all([self.repetition] == [other.repetition]); + isequal(self.e1, other.e1) && ... + isequal(self.e2, other.e2) && ... + isequal(self.slice, other.slice) && ... + isequal(self.repetition, other.repetition); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/SimpleRecord.m b/matlab/generated/+test_model/SimpleRecord.m index df234d1b..fc3930ad 100644 --- a/matlab/generated/+test_model/SimpleRecord.m +++ b/matlab/generated/+test_model/SimpleRecord.m @@ -22,9 +22,9 @@ function res = eq(self, other) res = ... isa(other, "test_model.SimpleRecord") && ... - all([self.x] == [other.x]) && ... - all([self.y] == [other.y]) && ... - all([self.z] == [other.z]); + isequal(self.x, other.x) && ... + isequal(self.y, other.y) && ... + isequal(self.z, other.z); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/SmallBenchmarkRecord.m b/matlab/generated/+test_model/SmallBenchmarkRecord.m index 39ff0084..b9e62a52 100644 --- a/matlab/generated/+test_model/SmallBenchmarkRecord.m +++ b/matlab/generated/+test_model/SmallBenchmarkRecord.m @@ -22,9 +22,9 @@ function res = eq(self, other) res = ... isa(other, "test_model.SmallBenchmarkRecord") && ... - all([self.a] == [other.a]) && ... - all([self.b] == [other.b]) && ... - all([self.c] == [other.c]); + isequal(self.a, other.a) && ... + isequal(self.b, other.b) && ... + isequal(self.c, other.c); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/StringOrInt32.m b/matlab/generated/+test_model/StringOrInt32.m index 55eb1837..58bb97eb 100644 --- a/matlab/generated/+test_model/StringOrInt32.m +++ b/matlab/generated/+test_model/StringOrInt32.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.StringOrInt32") && other.index == self.index && all([self.value] == [other.value]); + eq = isa(other, "test_model.StringOrInt32") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/TupleWithRecords.m b/matlab/generated/+test_model/TupleWithRecords.m index 7c30a968..dbc507d8 100644 --- a/matlab/generated/+test_model/TupleWithRecords.m +++ b/matlab/generated/+test_model/TupleWithRecords.m @@ -19,8 +19,8 @@ function res = eq(self, other) res = ... isa(other, "test_model.TupleWithRecords") && ... - all([self.a] == [other.a]) && ... - all([self.b] == [other.b]); + isequal(self.a, other.a) && ... + isequal(self.b, other.b); end function res = ne(self, other) diff --git a/matlab/generated/+test_model/UOrV.m b/matlab/generated/+test_model/UOrV.m index e74776d3..9f6a006e 100644 --- a/matlab/generated/+test_model/UOrV.m +++ b/matlab/generated/+test_model/UOrV.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.UOrV") && other.index == self.index && isequal(self.value, other.value); + eq = isa(other, "test_model.UOrV") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/generated/+test_model/VectorOrScalar.m b/matlab/generated/+test_model/VectorOrScalar.m index 486d5eef..a51eca2c 100644 --- a/matlab/generated/+test_model/VectorOrScalar.m +++ b/matlab/generated/+test_model/VectorOrScalar.m @@ -34,7 +34,7 @@ end function eq = eq(self, other) - eq = isa(other, "test_model.VectorOrScalar") && other.index == self.index && all([self.value] == [other.value]); + eq = isa(other, "test_model.VectorOrScalar") && isequal(self.index, other.index) && isequal(self.value, other.value); end function ne = ne(self, other) diff --git a/matlab/test/EqualityTest.m b/matlab/test/EqualityTest.m index b82eeae7..a976c59a 100644 --- a/matlab/test/EqualityTest.m +++ b/matlab/test/EqualityTest.m @@ -241,5 +241,16 @@ function testGenericEquality(testCase) testCase.verifyEqual({a, b, c, d, e}, {b, a, d, c, e}); end + function testRecordWithComputedFieldsEquality(testCase) + a = test_model.RecordWithComputedFields(); + b = test_model.RecordWithComputedFields(); + testCase.verifyEqual(a, b); + testCase.verifyTrue(a == b); + testCase.verifyTrue(isequal(a, b)); + + b.vector_field = [1, 2, 3]; + testCase.verifyFalse(a == b); + testCase.verifyFalse(isequal(a, b)); + end end end diff --git a/tooling/internal/matlab/static_files/Optional.m b/tooling/internal/matlab/static_files/Optional.m index fa0ec206..574bd797 100644 --- a/tooling/internal/matlab/static_files/Optional.m +++ b/tooling/internal/matlab/static_files/Optional.m @@ -4,38 +4,40 @@ classdef Optional < handle properties (SetAccess=protected) has_value - value + end + + properties (Access=protected) + value_ end methods function self = Optional(varargin) if nargin > 0 - self.value = varargin{1}; + self.value_ = varargin{1}; self.has_value = true; else - self.value = NaN; self.has_value = false; end end - function v = get.value(self) + function v = value(self) if ~self.has_value throw(yardl.ValueError("Optional type does not have a value")); end - v = self.value; + v = self.value_; end function eq = eq(a, b) if isa(a, 'yardl.Optional') if isa(b, 'yardl.Optional') if all([a.has_value]) && all([b.has_value]) - eq = isequal([a.value], [b.value]); + eq = isequal([a.value_], [b.value_]); else eq = [a.has_value] == [b.has_value]; end else if all([a.has_value]) - eq = isequal(b, [a.value]); + eq = isequal(b, [a.value_]); else eq = false; end @@ -43,7 +45,7 @@ else % b is the Optional if all([b.has_value]) - eq = isequal(a, [b.value]); + eq = isequal(a, [b.value_]); else eq = false; end @@ -54,12 +56,12 @@ ne = ~eq(a, b); end - function isequal = isequal(a, b) - isequal = all(eq(a, b)); + function isequal = isequal(a, varargin) + isequal = all(eq(a, [varargin{:}])); end - function isequaln = isequaln(a, b) - isequaln = all(eq(a, b)); + function isequaln = isequaln(a, varargin) + isequaln = isequal(a, [varargin{:}]); end end diff --git a/tooling/internal/matlab/types/types.go b/tooling/internal/matlab/types/types.go index 5a6b1bb0..3a8a7a63 100644 --- a/tooling/internal/matlab/types/types.go +++ b/tooling/internal/matlab/types/types.go @@ -123,7 +123,7 @@ func writeUnionClass(w *formatting.IndentedWriter, className string, generalized w.WriteStringln("function eq = eq(self, other)") common.WriteBlockBody(w, func() { - fmt.Fprintf(w, "eq = isa(other, \"%s\") && other.index == self.index && %s;\n", qualifiedClassName, typeEqualityExpression(generalizedType, "self.value", "other.value")) + fmt.Fprintf(w, "eq = isa(other, \"%s\") && isequal(self.index, other.index) && isequal(self.value, other.value);\n", qualifiedClassName) }) w.WriteStringln("") w.WriteStringln("function ne = ne(self, other)") @@ -373,7 +373,7 @@ func writeRecord(fw *common.MatlabFileWriter, rec *dsl.RecordDefinition, st dsl. for _, field := range rec.Fields { w.WriteStringln(" && ...") fieldIdentifier := common.FieldIdentifierName(field.Name) - w.WriteString(typeEqualityExpression(field.Type, "self."+fieldIdentifier, "other."+fieldIdentifier)) + fmt.Fprintf(w, "isequal(%s, %s)", "self."+fieldIdentifier, "other."+fieldIdentifier) } w.WriteStringln(";") }) @@ -418,30 +418,6 @@ func writeZerosStaticMethod(w *formatting.IndentedWriter, typeSyntax string, def }) } -func typeEqualityExpression(t dsl.Type, a, b string) string { - if hasSimpleEquality(t) { - return fmt.Sprintf("all([%s] == [%s])", a, b) - } - - return fmt.Sprintf("isequal(%s, %s)", a, b) -} - -func hasSimpleEquality(t dsl.Node) bool { - res := true - dsl.Visit(t, func(self dsl.Visitor, node dsl.Node) { - switch t := node.(type) { - case *dsl.SimpleType: - self.Visit(t.ResolvedDefinition) - case *dsl.Array, *dsl.GenericTypeParameter: - res = false - return - } - - self.VisitChildren(node) - }) - return res -} - type tailHandler func(next func()) type tailWrapper struct { From 0b74fc9a494845dfc4389afc7a2a792d7a68afba Mon Sep 17 00:00:00 2001 From: John Stairs Date: Wed, 15 May 2024 12:34:46 -0400 Subject: [PATCH 32/32] Change MATLAB license file mounting (#149) Co-authored-by: Joe Naegele --- .devcontainer/Dockerfile | 3 ++- .devcontainer/devcontainer-on-create.sh | 11 +++++++++++ .devcontainer/devcontainer.json | 13 ++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100755 .devcontainer/devcontainer-on-create.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 298e5e35..8f757577 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -168,7 +168,8 @@ RUN wget -q https://www.mathworks.com/mpm/glnxa64/mpm \ || (echo "MPM Installation Failure. See below for more information:" && cat /tmp/mathworks_root.log && false) \ && sudo rm -f mpm /tmp/mathworks_root.log \ && sudo ln -s ${MATLAB_INSTALL_LOCATION}/bin/matlab /usr/local/bin/matlab \ - && sudo ln -s ${MATLAB_INSTALL_LOCATION} /opt/matlab/latest + && sudo ln -s ${MATLAB_INSTALL_LOCATION} /opt/matlab/latest \ + && sudo mkdir -p ${MATLAB_INSTALL_LOCATION}/licenses # Install workaround run-matlab-command script to unify local and CI invocations of `matlab -batch` # See https://github.com/matlab-actions/run-command/issues/53 diff --git a/.devcontainer/devcontainer-on-create.sh b/.devcontainer/devcontainer-on-create.sh new file mode 100755 index 00000000..ae7c7b4e --- /dev/null +++ b/.devcontainer/devcontainer-on-create.sh @@ -0,0 +1,11 @@ +#! /usr/bin/env bash + +set -euo pipefail + +host_license_file="/tmp/matlab.host.lic" + +if [ -s "${host_license_file}" ]; then + # We don't bind mount directly to $MATLAB_LICENSE_FILE so that we can write + # to it later without affecting the host. + sudo cp "${host_license_file}" "${MATLAB_LICENSE_FILE}" +fi diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 93545a0c..3e500711 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,13 +6,19 @@ "dockerfile": "Dockerfile", "context": ".." }, - "runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"], + "runArgs": [ + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined", + "--network=host" + ], "overrideCommand": false, "mounts": [ // Bind mount docker socket under an alias to support docker-from-docker "source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind", - "source=${localEnv:MATLAB_LICENSE_FILE:/dev/null},target=/opt/matlab/latest/licenses/license.lic,type=bind" + "source=${localEnv:MATLAB_LICENSE_FILE:/dev/null},target=/tmp/matlab.host.lic,type=bind,readonly" ], + "onCreateCommand": ".devcontainer/devcontainer-on-create.sh", "remoteUser": "vscode", // Configure tool-specific properties. @@ -120,6 +126,7 @@ "containerEnv": { "PYTHONPATH": "/workspaces/yardl/python", - "CGO_ENABLED": "0" + "CGO_ENABLED": "0", + "MATLAB_LICENSE_FILE": "/opt/matlab/latest/licenses/license.lic" } }