corba.js 0.1.3 → 0.1.6
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 +12 -13
- package/lib/idl/idl.cjs +3 -0
- package/lib/idl/idl.cjs.map +1 -1
- package/lib/src/idl/idl-parser.js +3 -0
- package/lib/src/idl/idl-parser.js.map +1 -1
- package/lib/src/net/browser.js +1 -0
- package/lib/src/net/browser.js.map +1 -1
- package/package.json +10 -6
package/README.md
CHANGED
|
@@ -229,23 +229,22 @@ and deserialize them based on their IDL description:
|
|
|
229
229
|
For each valuetype the IDL compiler will generate three variants
|
|
230
230
|
|
|
231
231
|
* _value.ts: the valuetypes as TypeScript interfaces with only the attributes
|
|
232
|
-
* _valuetype.ts: the
|
|
233
|
-
* _valueimpl.ts: the value types as classes with constructors, which can be initialized from JSON data
|
|
234
|
-
|
|
235
|
-
The last one will be used by the ORB to convert the received JSON data
|
|
236
|
-
into an object.
|
|
232
|
+
* _valuetype.ts: the valuestypes as TypeScript interface with attributes and methods
|
|
237
233
|
|
|
238
234
|
Unlike a pure JSON exchange, corba.js will also instantiate a user specified
|
|
239
235
|
class to represent the transmitted data, so that the object has methods we
|
|
240
236
|
can call.
|
|
241
237
|
|
|
242
|
-
Ie. the Rectangle class
|
|
243
|
-
be able to instantiate it:
|
|
238
|
+
Ie. for this the Rectangle class will need a special constructor:
|
|
244
239
|
|
|
245
240
|
```javascript
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
241
|
+
import { GIOPDecoder } from "corba.js"
|
|
242
|
+
import * as value from "../myapp_value"
|
|
243
|
+
import * as valuetype from "../myapp_valuetype"
|
|
244
|
+
|
|
245
|
+
export class Rectangle implements valuetype.Rectangle {
|
|
246
|
+
constructor(init?: Partial<value.Rectangle> | GIOPDecoder) {
|
|
247
|
+
value.initRectangle(this, init)
|
|
249
248
|
}
|
|
250
249
|
contains(p: Point): boolean {
|
|
251
250
|
return this.origin.x <= p.x && p.x <= this.origin.x + this.size.width &&
|
|
@@ -254,12 +253,12 @@ be able to instantiate it:
|
|
|
254
253
|
}
|
|
255
254
|
```
|
|
256
255
|
|
|
257
|
-
After the
|
|
256
|
+
After the valuetype implementations have been registered in the ORB on client and server
|
|
258
257
|
side
|
|
259
258
|
|
|
260
259
|
```javascript
|
|
261
|
-
ORB.registerValueType("Point",
|
|
262
|
-
ORB.registerValueType("Size",
|
|
260
|
+
ORB.registerValueType("Point", Point)
|
|
261
|
+
ORB.registerValueType("Size", Size)
|
|
263
262
|
ORB.registerValueType("Rectangle", Rectangle)
|
|
264
263
|
```
|
|
265
264
|
|
package/lib/idl/idl.cjs
CHANGED
|
@@ -1238,6 +1238,9 @@ function op_dcl() {
|
|
|
1238
1238
|
const t3 = parameter_dcls();
|
|
1239
1239
|
if (t3 === undefined) {
|
|
1240
1240
|
lexer.unlex(t2);
|
|
1241
|
+
if (t1.child.length != 0) {
|
|
1242
|
+
throw Error("expected parameter declaration after " + t2.toString());
|
|
1243
|
+
}
|
|
1241
1244
|
lexer.unlex(t1);
|
|
1242
1245
|
lexer.unlex(t0);
|
|
1243
1246
|
return undefined;
|