nscn.polaris2.pdefgen

Members list

Type members

Classlikes

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class FunctionalPrinter(content: Vector[String] = ..., indentLevel: Int = ...)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class Pdef(name: String, customTypeDefs: VectorMap[String, PdefCustomTypeDef], fields: VectorMap[String, PdefField])

A validated .pdef: the custom types it declares plus its top-level fields, which become a struct called name.

A validated .pdef: the custom types it declares plus its top-level fields, which become a struct called name.

Both maps are insertion-ordered on purpose. A pdef describes a flat binary layout, so the declaration order of the top-level fields IS the wire order - reordering them silently produces a codec that decodes the wrong bytes into the wrong fields. The type defs are ordered for the weaker reason that generated sources should be stable across runs, so an unchanged .pdef does not invalidate downstream build caches.

Keying by name is only lossless because PdefValidator has already rejected duplicate names: a repeated key would silently replace the earlier field.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class PdefArray(t: PdefType, size: Int) extends PdefType

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait PdefType
class Object
trait Matchable
class Any
Show all
case object PdefBool extends PdefType

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait PdefType
class Object
trait Matchable
class Any
Show all
Self type
PdefBool.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case class PdefCustomType(name: String) extends PdefType

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait PdefType
class Object
trait Matchable
class Any
Show all
sealed trait PdefCustomTypeDef extends PdefStatement

Attributes

Supertypes
trait Positional
class Object
trait Matchable
class Any
Known subtypes
case class PdefEnumDef(name: String, variants: Vector[String]) extends PdefCustomTypeDef

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Positional
class Object
trait Matchable
class Any
Show all
case class PdefEnumMap(t: PdefType, enumName: String) extends PdefType

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait PdefType
class Object
trait Matchable
class Any
Show all
case class PdefField(`type`: PdefType, name: String) extends PdefStatement

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Positional
class Object
trait Matchable
class Any
Show all
case class PdefFile(origin: String, name: String, statements: Vector[PdefStatement])

One .pdef as parsed, before PdefValidator has looked at it.

One .pdef as parsed, before PdefValidator has looked at it.

Value parameters

name

the struct the top-level fields become - the file's base name

origin

where the source came from; problems are reported against it

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case object PdefFloat extends PdefType

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait PdefType
class Object
trait Matchable
class Any
Show all
Self type
PdefFloat.type
case class PdefGenError(problems: Seq[PdefProblem]) extends Exception

Generation stopped: every problem found in the .pdef files, one per line.

Generation stopped: every problem found in the .pdef files, one per line.

Attributes

Supertypes
trait Product
trait Equals
class Exception
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Show all
case object PdefInt extends PdefType

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait PdefType
class Object
trait Matchable
class Any
Show all
Self type
PdefInt.type
trait PdefModule extends ScalaModule

Generates scodec codecs from .pdef binary layout definitions.

Generates scodec codecs from .pdef binary layout definitions.

This is the Mill counterpart of sbt-pdef-gen's PdefGenPlugin. Where the sbt plugin hooks a task into Compile / sourceGenerators, this module owns the whole invocation: every .pdef under pdefSources is parsed, the lot is checked by PdefValidator, and each is rendered into one Scala file named after it, all of them wired into generatedSources.

object app extends ScalaModule, PdefModule {
 def scalaVersion = "3.9.0"
 // .pdef files live in `app/pdef` by default
}

A file Foo.pdef yields case class Foo(...) plus codec_Foo, alongside a case class/enum and a codec_<name> for every $STRUCT_START/$ENUM_START block it declares.

Attributes

Companion
object
Supertypes
trait ScalaModule
trait ScalaModuleApi
trait ScalaModuleBase
trait JavaModule
trait JavaModuleApi
trait JdkCommandsModule
trait AssemblyModule
trait SemanticDbJavaModule
trait SemanticDbJavaModuleApi
trait OfflineSupportModule
trait GenIdeaModule
trait GenIdeaModuleApi
trait RunModule
trait RunModuleApi
trait DefaultTaskModule
trait JavaModuleBase
trait BspModule
trait BspModuleApi
trait WithJvmWorkerModule
trait JavaHomeModule
trait CoursierModule
trait Module
trait ModuleApi
trait Wrapper
class BaseClass
trait Cacher
trait Cacher
class Object
trait Matchable
class Any
Show all
object PdefModule

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
PdefModule.type
object PdefParsers extends JavaTokenParsers, PackratParsers

The pdef grammar. Syntax only: whether a parsed file can actually be generated from is PdefValidator's business.

The pdef grammar. Syntax only: whether a parsed file can actually be generated from is PdefValidator's business.

Attributes

Supertypes
trait PackratParsers
trait JavaTokenParsers
trait RegexParsers
trait Parsers
class Object
trait Matchable
class Any
Show all
Self type
case class PdefProblem(origin: String, line: Int, column: Int, message: String)

Something wrong with a .pdef, located at the line and column it was found.

Something wrong with a .pdef, located at the line and column it was found.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
sealed trait PdefStatement extends Positional

An entry in a .pdef, positioned so problems with it can be reported where it is.

An entry in a .pdef, positioned so problems with it can be reported where it is.

Attributes

Supertypes
trait Positional
class Object
trait Matchable
class Any
Known subtypes
case class PdefString(size: Int) extends PdefType

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait PdefType
class Object
trait Matchable
class Any
Show all
case class PdefStructDef(name: String, fields: Vector[PdefField]) extends PdefCustomTypeDef

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Positional
class Object
trait Matchable
class Any
Show all
sealed trait PdefType

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class PdefArray
object PdefBool
class PdefEnumMap
object PdefFloat
object PdefInt
class PdefString
Show all
object PdefValidator

Checks parsed .pdef files before anything is generated from them.

Checks parsed .pdef files before anything is generated from them.

Every problem caught here would otherwise turn up later and worse: as a scalac error pointing into generated code, or - for a field declared twice - as no error at all, just a codec one field short.

The files are checked as one unit because they are generated into one package: a type declared in one file is in scope in all of them, and a name declared twice collides whichever files the two declarations are in.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type