Skip to content

Commit

Permalink
typeId in conversion meta
Browse files Browse the repository at this point in the history
  • Loading branch information
pshirshov committed Dec 17, 2024
1 parent 985089f commit 99f9f11
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ class CSBaboonTranslator(defnTranslator: CSDefnTranslator,
| public $csString VersionFrom();
| public $csTpe TypeTo();
| public $csString VersionTo();
| public $csString TypeId();
|}
|
|public interface IBaboonGeneratedConversion : IConversion
Expand Down Expand Up @@ -396,9 +397,11 @@ class CSBaboonTranslator(defnTranslator: CSDefnTranslator,
| return typeof(TTo);
| }
|
| public abstract String VersionFrom();
| public abstract $csString VersionFrom();
|
| public abstract String VersionTo();
| public abstract $csString VersionTo();
|
| public abstract $csString TypeId();
|}
|
|public interface IBaboonCodecData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class IndividualConversionHandler(trans: CSTypeTranslator,
|
|public override $csString VersionTo() {
| return "${domain.version.version}";
|}""".stripMargin.shift(4).trim
|}""".stripMargin

rules.conversions.map { conv =>
val convname = makeName("Convert", conv)
Expand All @@ -80,14 +80,22 @@ class IndividualConversionHandler(trans: CSTypeTranslator,
transfer(TypeRef.Scalar(tpe), ref)
}

val fullMeta =
q"""|$versionsMeta
|
|public override $csString TypeId()
|{
| return "${conv.sourceTpe.toString}";
|}""".stripMargin.shift(4).trim

conv match {
case _: Conversion.CustomConversionRequired =>
val cdefn =
q"""public abstract class ${convname} : $abstractConversion<${tin}, ${tout}>
|{
| public abstract override ${tout} Convert<C>(C? context, $abstractBaboonConversions conversions, ${tin} from) where C: default;
|
| $versionsMeta
| $fullMeta
|}""".stripMargin
val ctree = tools.inNs(pkg.parts.toSeq, cdefn)

Expand Down Expand Up @@ -124,7 +132,7 @@ class IndividualConversionHandler(trans: CSTypeTranslator,
| }
| }
|
| $versionsMeta
| $fullMeta
|}""".stripMargin
val ctree = tools.inNs(pkg.parts.toSeq, cdefn)
val regtree = q"Register(new ${convname}());"
Expand Down Expand Up @@ -153,7 +161,7 @@ class IndividualConversionHandler(trans: CSTypeTranslator,
| ${branches.join("\nelse\n").shift(8).trim}
| }
|
| $versionsMeta
| $fullMeta
|}""".stripMargin
val ctree = tools.inNs(pkg.parts.toSeq, cdefn)
val regtree = q"Register(new ${convname}());"
Expand Down Expand Up @@ -328,7 +336,7 @@ class IndividualConversionHandler(trans: CSTypeTranslator,
| );
| }
|
| $versionsMeta
| $fullMeta
|}""".stripMargin

val ctree = tools.inNs(pkg.parts.toSeq, cdefn)
Expand Down

0 comments on commit 99f9f11

Please sign in to comment.