Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(jsii): support multiple class declaration sites #348

Merged
merged 3 commits into from
Feb 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7,667 changes: 0 additions & 7,667 deletions package-lock.json

This file was deleted.

868 changes: 207 additions & 661 deletions packages/codemaker/package-lock.json

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,18 @@ export class JsiiAgent {
}
};

// To support module augmentation classes must support multiple declaration sites
// (the tail of which must be interfaces)
export class AugmentableClass {
public methodOne(): void {
console.log('methodOne');
}
}

export interface AugmentableClass {
methodTwo(): void;
}

// Ensure the JSII kernel tags instances with the "most appropriate" FQN type label, so that runtimes are able to
// correctly choose the implementation proxy that should be used. Failure to do so could cause situations where userland
// needs to up-cast an instance to an incompatible type, which certain runtimes (such as Java) will prevent.
Expand Down
19 changes: 18 additions & 1 deletion packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,23 @@
],
"name": "AsyncVirtualMethods"
},
"jsii-calc.AugmentableClass": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.AugmentableClass",
"initializer": {
"initializer": true
},
"kind": "class",
"methods": [
{
"name": "methodOne"
},
{
"name": "methodTwo"
}
],
"name": "AugmentableClass"
},
"jsii-calc.BinaryOperation": {
"abstract": true,
"assembly": "jsii-calc",
Expand Down Expand Up @@ -3825,5 +3842,5 @@
}
},
"version": "0.7.13",
"fingerprint": "WNp0Sw1d2+3FaQD0Fn01K4wYQi7Ms3w+NQatOylD1kM="
"fingerprint": "aAWhjTLeZrF20RGP+ziDi3xp7D9syctn1izqVdgXi7E="
}
18 changes: 9 additions & 9 deletions packages/jsii-pacmak/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,23 @@
],
"name": "AsyncVirtualMethods"
},
"jsii-calc.AugmentableClass": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.AugmentableClass",
"initializer": {
"initializer": true
},
"kind": "class",
"methods": [
{
"name": "methodOne"
},
{
"name": "methodTwo"
}
],
"name": "AugmentableClass"
},
"jsii-calc.BinaryOperation": {
"abstract": true,
"assembly": "jsii-calc",
Expand Down Expand Up @@ -3825,5 +3842,5 @@
}
},
"version": "0.7.13",
"fingerprint": "WNp0Sw1d2+3FaQD0Fn01K4wYQi7Ms3w+NQatOylD1kM="
"fingerprint": "aAWhjTLeZrF20RGP+ziDi3xp7D9syctn1izqVdgXi7E="
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Amazon.JSII.Runtime.Deputy;

namespace Amazon.JSII.Tests.CalculatorNamespace
{
[JsiiClass(typeof(AugmentableClass), "jsii-calc.AugmentableClass", "[]")]
public class AugmentableClass : DeputyBase
{
public AugmentableClass(): base(new DeputyProps(new object[]{}))
{
}

protected AugmentableClass(ByRefValue reference): base(reference)
{
}

protected AugmentableClass(DeputyProps props): base(props)
{
}

[JsiiMethod("methodOne", null, "[]")]
public virtual void MethodOne()
{
InvokeInstanceVoidMethod(new object[]{});
}

[JsiiMethod("methodTwo", null, "[]")]
public virtual void MethodTwo()
{
InvokeInstanceVoidMethod(new object[]{});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protected Class<?> resolveClass(final String fqn) throws ClassNotFoundException
case "jsii-calc.AllTypesEnum": return software.amazon.jsii.tests.calculator.AllTypesEnum.class;
case "jsii-calc.AllowedMethodNames": return software.amazon.jsii.tests.calculator.AllowedMethodNames.class;
case "jsii-calc.AsyncVirtualMethods": return software.amazon.jsii.tests.calculator.AsyncVirtualMethods.class;
case "jsii-calc.AugmentableClass": return software.amazon.jsii.tests.calculator.AugmentableClass.class;
case "jsii-calc.BinaryOperation": return software.amazon.jsii.tests.calculator.BinaryOperation.class;
case "jsii-calc.Calculator": return software.amazon.jsii.tests.calculator.Calculator.class;
case "jsii-calc.CalculatorProps": return software.amazon.jsii.tests.calculator.CalculatorProps.class;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package software.amazon.jsii.tests.calculator;

@javax.annotation.Generated(value = "jsii-pacmak")
@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.AugmentableClass")
public class AugmentableClass extends software.amazon.jsii.JsiiObject {
protected AugmentableClass(final software.amazon.jsii.JsiiObject.InitializationMode mode) {
super(mode);
}
public AugmentableClass() {
super(software.amazon.jsii.JsiiObject.InitializationMode.Jsii);
software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this);
}

public void methodOne() {
this.jsiiCall("methodOne", Void.class);
}

public void methodTwo() {
this.jsiiCall("methodTwo", Void.class);
}
}
36 changes: 36 additions & 0 deletions packages/jsii-pacmak/test/expected.jsii-calc/sphinx/jsii-calc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,42 @@ AsyncVirtualMethods
:rtype: number


AugmentableClass
^^^^^^^^^^^^^^^^

.. py:class:: AugmentableClass()

**Language-specific names:**

.. tabs::

.. code-tab:: c#

using Amazon.JSII.Tests.CalculatorNamespace;

.. code-tab:: java

import software.amazon.jsii.tests.calculator.AugmentableClass;

.. code-tab:: javascript

const { AugmentableClass } = require('jsii-calc');

.. code-tab:: typescript

import { AugmentableClass } from 'jsii-calc';




.. py:method:: methodOne()



.. py:method:: methodTwo()



BinaryOperation
^^^^^^^^^^^^^^^

Expand Down
Loading