skir-java-gen 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,22 +5,23 @@
5
5
 
6
6
  Official plugin for generating Java code from [.skir](https://github.com/gepheum/skir) files.
7
7
 
8
- ## Installation
9
-
10
- From your project's root directory, run `npm i --save-dev skir-java-gen`.
8
+ ## Set up
11
9
 
12
10
  In your `skir.yml` file, add the following snippet under `generators`:
13
11
  ```yaml
14
12
  - mod: skir-java-gen
13
+ outDir: ./src/main/java/skirout
15
14
  config: {}
15
+ # Alternatively:
16
+ # outDir: ./src/main/kotlin/my/project/skirout
17
+ # config:
18
+ # packagePrefix: my.project.
16
19
  ```
17
20
 
18
- The `npm run skirc` command will now generate .java files within the `skirout` directory.
19
-
20
- The generated Java code has a runtime dependency on `build.skir:skir-kotlin-client`. Add this line to your `build.gradle` file in the `dependencies` section:
21
+ The generated Java code has a runtime dependency on `build.skir:skir-client`. Add this line to your `build.gradle` file in the `dependencies` section:
21
22
 
22
23
  ```gradle
23
- implementation 'build.skir:skir-kotlin-client:1.1.4' // Pick the latest version
24
+ implementation 'build.skir:skir-client:latest.release'
24
25
  ```
25
26
 
26
27
  For more information, see this Java project [example](https://github.com/gepheum/skir-java-example).
@@ -229,7 +230,7 @@ System.out.println(serializer.toJsonCode(john, JsonFlavor.READABLE));
229
230
  // }
230
231
 
231
232
  // The dense JSON flavor is the flavor you should pick if you intend to
232
- // deserialize the value in the future. skir allows fields to be renamed,
233
+ // deserialize the value in the future. Skir allows fields to be renamed,
233
234
  // and because field names are not part of the dense JSON, renaming a field
234
235
  // does not prevent you from deserializing the value.
235
236
  // You should pick the readable flavor mostly for debugging purposes.
@@ -266,8 +267,8 @@ assert reserializedJane.equals(jane);
266
267
  ### Frozen lists and copies
267
268
 
268
269
  ```java
269
- // Since all skir objects are deeply immutable, all lists contained in a
270
- // skir object are also deeply immutable.
270
+ // Since all Skir objects are deeply immutable, all lists contained in a
271
+ // Skir object are also deeply immutable.
271
272
  // This section helps understand when lists are copied and when they are
272
273
  // not.
273
274
 
@@ -289,12 +290,9 @@ final User jade =
289
290
  User.partialBuilder()
290
291
  .setName("Jade")
291
292
  .setPets(pets)
292
- // 'pets' is mutable, so skir makes an immutable shallow copy of it
293
+ // 'pets' is mutable, so Skir makes an immutable shallow copy of it
293
294
  .build();
294
295
 
295
- // jade.pets().clear();
296
- // ^ Runtime error: pets is a frozen list
297
-
298
296
  assert pets.equals(jade.pets());
299
297
  assert pets != jade.pets();
300
298
 
@@ -302,7 +300,7 @@ final User jack =
302
300
  User.partialBuilder()
303
301
  .setName("Jack")
304
302
  .setPets(jade.pets())
305
- // The list is already immutable, so skir does not make a copy
303
+ // The list is already immutable, so Skir does not make a copy
306
304
  .build();
307
305
 
308
306
  assert jack.pets() == jade.pets();
@@ -314,7 +312,7 @@ assert jack.pets() == jade.pets();
314
312
  final UserRegistry userRegistry =
315
313
  UserRegistry.builder().setUsers(List.of(john, jane, evilJohn)).build();
316
314
 
317
- // findByKey() returns the user with the given key (specified in the .skir file).
315
+ // find() returns the user with the given key (specified in the .skir file).
318
316
  // In this example, the key is the user id.
319
317
  // The first lookup runs in O(N) time, and the following lookups run in O(1)
320
318
  // time.
@@ -421,4 +419,4 @@ While Java and Kotlin code can interoperate seamlessly, skir provides separate c
421
419
 
422
420
  Although it's technically feasible to use Kotlin-generated code in a Java project (or vice versa), doing so results in an API that feels unnatural and cumbersome in the calling language. For the best developer experience, use the code generator that matches your project's primary language.
423
421
 
424
- Note that both the Java and Kotlin generated code share the same runtime dependency: `build.skir:skir-kotlin-client`.
422
+ Note that both the Java and Kotlin generated code share the same runtime dependency: `build.skir:skir-client`.
package/dist/index.js CHANGED
@@ -550,7 +550,7 @@ class JavaSourceFileGenerator {
550
550
  return "false";
551
551
  case "int32":
552
552
  case "int64":
553
- case "uint64":
553
+ case "hash64":
554
554
  return "0";
555
555
  case "float32":
556
556
  return "0.0f";
@@ -602,7 +602,7 @@ class JavaSourceFileGenerator {
602
602
  case "bool":
603
603
  case "int32":
604
604
  case "int64":
605
- case "uint64":
605
+ case "hash64":
606
606
  case "float32":
607
607
  case "float64":
608
608
  return inputExpr;
@@ -61,7 +61,7 @@ export class TypeSpeller {
61
61
  case "int32":
62
62
  return "java.lang.Integer";
63
63
  case "int64":
64
- case "uint64":
64
+ case "hash64":
65
65
  return "java.lang.Long";
66
66
  case "float32":
67
67
  return "java.lang.Float";
@@ -86,7 +86,7 @@ export class TypeSpeller {
86
86
  case "int32":
87
87
  return "int";
88
88
  case "int64":
89
- case "uint64":
89
+ case "hash64":
90
90
  return "long";
91
91
  case "float32":
92
92
  return "float";
@@ -121,8 +121,8 @@ export class TypeSpeller {
121
121
  return "build.skir.Serializers.int32()";
122
122
  case "int64":
123
123
  return "build.skir.Serializers.int64()";
124
- case "uint64":
125
- return "build.skir.Serializers.javaUint64()";
124
+ case "hash64":
125
+ return "build.skir.Serializers.javaHash64()";
126
126
  case "float32":
127
127
  return "build.skir.Serializers.float32()";
128
128
  case "float64":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skir-java-gen",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "lint:fix": "eslint src/**/*.ts --fix"
34
34
  },
35
35
  "dependencies": {
36
- "skir-internal": "^0.0.8",
36
+ "skir-internal": "^0.1.0",
37
37
  "zod": "^4.2.1"
38
38
  },
39
39
  "devDependencies": {
@@ -47,7 +47,7 @@
47
47
  "mocha": "^11.7.5",
48
48
  "prettier": "^3.2.4",
49
49
  "prettier-plugin-organize-imports": "^4.2.0",
50
- "skir": "^0.0.7",
50
+ "skir": "^1.0.11",
51
51
  "ts-node": "^10.9.2",
52
52
  "tsx": "^4.21.0",
53
53
  "typescript": "^5.2.2",
package/src/index.ts CHANGED
@@ -874,7 +874,7 @@ class JavaSourceFileGenerator {
874
874
  return "false";
875
875
  case "int32":
876
876
  case "int64":
877
- case "uint64":
877
+ case "hash64":
878
878
  return "0";
879
879
  case "float32":
880
880
  return "0.0f";
@@ -931,7 +931,7 @@ class JavaSourceFileGenerator {
931
931
  case "bool":
932
932
  case "int32":
933
933
  case "int64":
934
- case "uint64":
934
+ case "hash64":
935
935
  case "float32":
936
936
  case "float64":
937
937
  return inputExpr;
@@ -74,7 +74,7 @@ export class TypeSpeller {
74
74
  case "int32":
75
75
  return "java.lang.Integer";
76
76
  case "int64":
77
- case "uint64":
77
+ case "hash64":
78
78
  return "java.lang.Long";
79
79
  case "float32":
80
80
  return "java.lang.Float";
@@ -98,7 +98,7 @@ export class TypeSpeller {
98
98
  case "int32":
99
99
  return "int";
100
100
  case "int64":
101
- case "uint64":
101
+ case "hash64":
102
102
  return "long";
103
103
  case "float32":
104
104
  return "float";
@@ -135,8 +135,8 @@ export class TypeSpeller {
135
135
  return "build.skir.Serializers.int32()";
136
136
  case "int64":
137
137
  return "build.skir.Serializers.int64()";
138
- case "uint64":
139
- return "build.skir.Serializers.javaUint64()";
138
+ case "hash64":
139
+ return "build.skir.Serializers.javaHash64()";
140
140
  case "float32":
141
141
  return "build.skir.Serializers.float32()";
142
142
  case "float64":