229.240508.0 • Published 2 days ago

@tutao/licc v229.240508.0

Weekly downloads
-
License
GPL-3.0
Repository
-
Last release
2 days ago

licc - the little interprocess communications compiler

usage info: type licc --help

output

there are four kinds of json files licc understands. they are distinguished by their top-level type property.

structs

"type": "struct" definitions are simply generated into the output directory as a single source file of the platform-appropriate language.

enums

"type": "enum" definitions are generated similarly to structs

facades

"type": "facade" definitions can lead to several output files, depending on the definitions senders and receivers fields:

  • senders and receivers: the interface containing all methods
  • senders: one implementation of the interface in form of the SendDispatcher. It takes a transport instance that does the actual sending of the message and must be implemented manually.
  • receivers: one ReceiveDispatcher. It takes the actual, working implementation of the interface during construction and dispatches to it.
  • additionally, every platform that is on the receiving side of any facades gets one GlobalDispatcher implementation that dispatches to all receive dispatchers.

this leads to the following flow, with manually implemented components marked with *:

SENDING SIDE: *caller* => SendDispatcher => *outgoing transport*
RECEIVING SIDE: *incoming transport* => GlobalDispatcher => ReceiveDispatcher => *facade implementation*

Dispatch is achieved via string identifiers; the incoming transport will call GlobalDispatcher.dispatch("FacadeName", "methodName", arrayOfArgs) which calls the ReceiveDispatcher for FacadeName with ReceiveDispatcher.dispatch("methodName", arrayOfArgs). This call will be dispatched to the appropriate method as facadeName.methodName(arrayOfArgs[0], ..., arrayOfArgs[-1]).

typerefs

"type": "typeref" definitions are used to refer to types that are not defined in a definition file and are not primitives (that the generator therefore has no knowledge of). They have to contain a language-specific path to a definition of the type that the generator will generate a reexport for, which can then be referred to by the facades (which don't actually know the difference between a generated struct and such a reexport).

definition syntax

the schema format is described in lib/common.ts. each schema is a JSON5 file with a single data type or facade definition. as discussed above, the type (struct, enum, facade or typeref) is given by the type property of the contained json5 object. facades must have a senders and a receivers property listing the appropriate platforms.

Note: there is minimal validation. we don't detect duplicate method or argument definitions and do not do a very good job to validate type syntax.

structs

struct fields are given as an object with "fieldName": "fieldType" properties.

{
	name: "Foo",
	type: "struct",
	doc: "optional doc comment that explains the type's purpose",
	fields: {
		fieldName: "fieldType",
		...
	}
}

enums

{
	name: "QuuxEnum",
	type: "enum",
	doc: "optional doc comment that explains the type's purpose",
	values: [
		"Value1",
		"Value2",
		...
	]
}

facades

{
	name: "BarFacade",
	type: "facade",
	senders: [
		"web"
	],
	receivers: [
		"desktop",
		"ios"
	],
	doc: "optional doc comment explaining the scope of the facade",
	methods: {
		"methodName": {
			doc: "optional comment explaining the contract and purpose of the method",
			arg: [
				{
					argName1: "argType1"
				},
				{
					argName2: "argType2"
				},
				...
			],
			ret: "returnType"
		},
		...
	}
}

Note: method arg must be given as a list of single-property objects as above to preserve argument order.

typerefs

{
	name: "BazType",
	type: "typeref",
	location: {
		typescript: "../../src/somedir/BazType.js",
		kotlin: "de.tutao.tutanota.BazType"
	}
}

Note the .js extension on the typescript reference. Reference paths are resolved relative to the json file containing the typeref.

supported types:

  • nullable types, denoted with a ? suffix: string?
  • List<elementType>
  • Map<keyType, valueType>
  • the primitives listed in dist/parser.ts
  • "external" types (the ones that don't fit any of the above but are otherwise valid identifiers)
  • any combination of these

all type names must be valid identifiers in all supported output languages.

Known issues

  • the bytes primitive types is generating DataWrapper types for mobile, because we can't directly send byte arrays over the bridge and need some kind of marker that distinguishes plain strings from encoded byte arrays. Currently, this requirement to wrap byte arrays leaks out to consumers of the generated classes.
  • struct definitions are generated for every language regardless if they're mentioned in that languages' generated files.
  • it's theoretically possible two separate compilations of the same source files to yield different output because field order in json objects is not defined. this was not observed yet and is unlikely to become a problem.
229.240508.0

2 days ago

228.240506.0

4 days ago

227.240502.0

8 days ago

227.240429.0

11 days ago

227.240426.0

14 days ago

227.240426.1

14 days ago

225.240417.0

23 days ago

220.240411.0

29 days ago

220.240410.0

29 days ago

220.240408.0

1 month ago

220.240405.0

1 month ago

220.240403.0

1 month ago

220.240327.1

1 month ago

220.240327.0

1 month ago

220.240321.0

2 months ago

220.240319.1

2 months ago

220.240318.0

2 months ago

220.240318.1

2 months ago

220.240315.0

2 months ago

220.240314.0

2 months ago

220.240313.0

2 months ago

220.240313.1

2 months ago

218.240311.0

2 months ago

218.240307.1

2 months ago

218.240307.0

2 months ago

218.240305.0

2 months ago

218.240226.0

2 months ago

218.240227.0

2 months ago

218.240226.1

2 months ago

218.240219.0

3 months ago

218.240215.0

3 months ago

3.122.5

3 months ago

3.122.4

3 months ago

3.122.3

3 months ago

3.122.2

3 months ago

3.122.1

3 months ago

3.122.0

3 months ago

3.121.4

4 months ago

3.121.3

4 months ago

3.121.2

4 months ago

3.121.1

4 months ago

3.121.0

4 months ago

3.120.5

4 months ago

3.120.6

4 months ago

3.120.3

4 months ago

3.120.4

4 months ago

3.120.2

4 months ago

3.120.1

4 months ago

3.120.0

5 months ago

3.119.10

5 months ago

3.119.9

5 months ago

3.119.8

5 months ago

3.119.7

5 months ago

3.119.5

5 months ago

3.119.4

5 months ago

3.119.6

5 months ago

3.119.3

5 months ago

3.118.31

6 months ago

3.119.1

5 months ago

3.119.0

6 months ago

3.119.2

5 months ago

3.116.0

10 months ago

3.116.2

9 months ago

3.116.1

9 months ago

3.116.4

9 months ago

3.116.3

9 months ago

3.116.6

9 months ago

3.116.5

9 months ago

3.116.8

9 months ago

3.117.0

9 months ago

3.118.30

6 months ago

3.118.19

7 months ago

3.118.18

7 months ago

3.118.0

9 months ago

3.114.4

11 months ago

3.118.13

7 months ago

3.118.12

8 months ago

3.118.11

8 months ago

3.118.10

8 months ago

3.118.16

7 months ago

3.118.15

7 months ago

3.118.29

6 months ago

3.118.24

6 months ago

3.118.23

6 months ago

3.118.22

7 months ago

3.118.21

7 months ago

3.118.28

6 months ago

3.118.27

6 months ago

3.118.26

6 months ago

3.118.25

6 months ago

3.118.9

8 months ago

3.118.20

7 months ago

3.118.2

8 months ago

3.118.1

9 months ago

3.114.5

10 months ago

3.118.4

8 months ago

3.118.3

8 months ago

3.118.6

8 months ago

3.118.5

8 months ago

3.118.8

8 months ago

3.118.7

8 months ago

3.115.1

10 months ago

3.115.0

10 months ago

3.115.2

10 months ago

3.114.0

11 months ago

3.114.2

11 months ago

3.114.1

11 months ago

3.114.3

11 months ago

3.113.1

11 months ago

3.113.0

1 year ago

3.113.3

11 months ago

3.113.2

11 months ago

3.112.14

12 months ago

3.112.15

12 months ago

3.112.12

12 months ago

3.112.13

12 months ago

3.112.10

1 year ago

3.112.11

1 year ago

3.112.8

1 year ago

3.112.9

1 year ago

3.112.0

1 year ago

3.110.1

1 year ago

3.112.1

1 year ago

3.112.4

1 year ago

3.112.6

1 year ago

3.112.5

1 year ago

3.112.7

1 year ago

3.111.0

1 year ago

3.110.0

1 year ago

3.109.9

1 year ago

3.109.8

1 year ago

3.109.5

1 year ago

3.109.4

1 year ago

3.109.10

1 year ago

3.109.11

1 year ago

3.109.12

1 year ago

3.109.13

1 year ago

3.109.2

1 year ago

3.109.0

1 year ago

3.109.3

1 year ago

3.108.10

1 year ago

3.108.12

1 year ago

3.108.11

1 year ago

3.108.8

1 year ago

3.108.9

1 year ago

3.108.7

1 year ago

3.107.3

1 year ago

3.105.5

1 year ago

3.107.1

1 year ago

3.107.2

1 year ago

3.105.9

1 year ago

3.105.7

1 year ago

3.105.8

1 year ago

3.106.0

1 year ago

3.106.1

1 year ago

3.108.2

1 year ago

3.106.4

1 year ago

3.108.3

1 year ago

3.106.5

1 year ago

3.106.2

1 year ago

3.106.3

1 year ago

3.108.6

1 year ago

3.108.4

1 year ago

3.108.5

1 year ago

3.107.0

1 year ago

3.105.3

1 year ago

3.104.4

1 year ago

3.105.4

1 year ago

3.104.5

1 year ago

3.103.0

2 years ago

3.102.1

2 years ago

3.105.1

1 year ago

3.104.2

1 year ago

3.103.3

2 years ago

3.105.2

1 year ago

3.104.0

1 year ago

3.103.1

2 years ago

3.102.2

2 years ago

3.105.0

1 year ago

3.104.1

1 year ago

3.103.2

2 years ago

3.102.3

2 years ago

3.98.23

2 years ago

3.98.24

2 years ago

3.102.0

2 years ago

3.101.1

2 years ago

3.100.2

2 years ago

3.100.0

2 years ago

3.101.0

2 years ago

3.100.1

2 years ago

3.98.22

2 years ago

3.98.21

2 years ago

3.98.20

2 years ago

3.98.17

2 years ago

3.98.16

2 years ago

3.98.14

2 years ago

3.98.13

2 years ago

3.98.12

2 years ago

3.98.11

2 years ago

3.98.10

2 years ago

3.98.9

2 years ago

3.98.8

2 years ago

3.98.7

2 years ago

3.98.6

2 years ago

3.98.5

2 years ago

3.98.4

2 years ago

3.98.3

2 years ago

3.98.2

2 years ago