Skip to content

Commit

Permalink
Merge branch 'master' into huijbers/diff-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Oct 7, 2020
2 parents a65a18f + 818ce23 commit 6089cb9
Show file tree
Hide file tree
Showing 45 changed files with 5,978 additions and 5,302 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
with:
java-version: '8'
- name: Set up Node 12
uses: actions/setup-node@v2.1.1
uses: actions/setup-node@v2.1.2
with:
node-version: '12'
- name: Set up Python 3.6
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
with:
java-version: '8'
- name: Set up Node 12
uses: actions/setup-node@v2.1.1
uses: actions/setup-node@v2.1.2
with:
node-version: '12'
- name: Set up Python 3.6
Expand Down Expand Up @@ -239,7 +239,7 @@ jobs:
with:
java-version: ${{ matrix.java }}
- name: Set up Node ${{ matrix.node }}
uses: actions/setup-node@v2.1.1
uses: actions/setup-node@v2.1.2
with:
node-version: ${{ matrix.node }}
- name: Set up Python ${{ matrix.python }}
Expand Down Expand Up @@ -320,7 +320,7 @@ jobs:
with:
java-version: '8'
- name: Set up Node 10
uses: actions/setup-node@v2.1.1
uses: actions/setup-node@v2.1.2
with:
node-version: '10'
- name: Set up Python 3.6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/yarn-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/checkout@v2

- name: Set up Node
uses: actions/setup-node@v2.1.0
uses: actions/setup-node@v2.1.2
with:
node-version: 10

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"test:update": "lerna run test:update --concurrency=1 --stream"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.3.0",
"@typescript-eslint/parser": "^4.3.0",
"@typescript-eslint/eslint-plugin": "^4.4.0",
"@typescript-eslint/parser": "^4.4.0",
"eslint": "^7.10.0",
"eslint-config-prettier": "^6.12.0",
"eslint-import-resolver-node": "^0.3.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/@jsii/dotnet-runtime-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"@jsii/dotnet-runtime": "^0.0.0",
"@types/node": "^10.17.35",
"@types/node": "^10.17.37",
"jsii-calc": "^0.0.0",
"jsii-pacmak": "^0.0.0",
"typescript": "~3.9.7"
Expand Down
2 changes: 1 addition & 1 deletion packages/@jsii/dotnet-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"devDependencies": {
"@jsii/runtime": "^0.0.0",
"@types/node": "^10.17.35",
"@types/node": "^10.17.37",
"@types/semver": "^7.3.4",
"jsii-build-tools": "^0.0.0",
"semver": "^7.3.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public abstract class DeputyBase : IConvertible
/// </summary>
protected sealed class DeputyProps
{
public DeputyProps(object[]? arguments = null)
public DeputyProps(object?[]? arguments = null)
{
Arguments = arguments ?? Array.Empty<object>();
Arguments = arguments ?? Array.Empty<object?>();
}

public object[] Arguments { get; }
public object?[] Arguments { get; }
}

private const BindingFlags StaticMemberFlags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
Expand Down Expand Up @@ -220,18 +220,18 @@ private static void SetPropertyCore<T>(T value, JsiiPropertyAttribute propertyAt

#region InvokeMethod

protected static void InvokeStaticVoidMethod(System.Type type, System.Type[] parameterTypes, object[] arguments, [CallerMemberName] string methodName = "")
protected static void InvokeStaticVoidMethod(System.Type type, System.Type[] parameterTypes, object?[] arguments, [CallerMemberName] string methodName = "")
{
InvokeStaticMethod<object>(type, parameterTypes, arguments, methodName);
}

protected void InvokeInstanceVoidMethod(System.Type[] parameterTypes, object[] arguments, [CallerMemberName] string methodName = "")
protected void InvokeInstanceVoidMethod(System.Type[] parameterTypes, object?[] arguments, [CallerMemberName] string methodName = "")
{
InvokeInstanceMethod<object>(parameterTypes, arguments, methodName);
}

[return: MaybeNull]
protected static T InvokeStaticMethod<T>(System.Type type, System.Type[] parameterTypes, object[] arguments, [CallerMemberName] string methodName = "")
protected static T InvokeStaticMethod<T>(System.Type type, System.Type[] parameterTypes, object?[] arguments, [CallerMemberName] string methodName = "")
{
JsiiTypeAttributeBase.Load(type.Assembly);

Expand All @@ -251,7 +251,7 @@ protected static T InvokeStaticMethod<T>(System.Type type, System.Type[] paramet
}

[return: MaybeNull]
protected T InvokeInstanceMethod<T>(System.Type[] parameterTypes, object[] arguments, [CallerMemberName] string methodName = "")
protected T InvokeInstanceMethod<T>(System.Type[] parameterTypes, object?[] arguments, [CallerMemberName] string methodName = "")
{
var methodAttribute = GetInstanceMethodAttribute(methodName, parameterTypes);

Expand Down
6 changes: 2 additions & 4 deletions packages/@jsii/go-runtime/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
jsii-experimental/embedded/*
jsii-calc

!jsii-experimental/embedded/.gitkeep
/jsii-calc/
*.generated.go
75 changes: 67 additions & 8 deletions packages/@jsii/go-runtime/build-tools/gen.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,73 @@
#!/usr/bin/env npx ts-node

import { copyFileSync, readdirSync } from 'fs';
import { join, resolve } from 'path';
import { CodeMaker } from 'codemaker';
import { readdirSync, readFileSync } from 'fs';
import { resolve } from 'path';

const EMBEDDED_SOURCE = resolve(__dirname, '..', '..', 'runtime', 'webpack');
const EMBEDDED_RUNTIME_ROOT = resolve(
__dirname,
'..',
'..',
'runtime',
'webpack',
);

for (const filename of readdirSync(EMBEDDED_SOURCE)) {
const filepath = join(EMBEDDED_SOURCE, filename);
copyFileSync(
filepath,
resolve(__dirname, '..', 'jsii-experimental', 'embedded', filename),
const OUTPUT_DIR = resolve(__dirname, '..', 'jsii-experimental');

const RUNTIME_FILE = 'embeddedruntime.generated.go';
const VERSION_FILE = 'version.generated.go';

const code = new CodeMaker({ indentationLevel: 1, indentCharacter: '\t' });

code.openFile(RUNTIME_FILE);
code.line('package jsii');
code.line();
code.open('var embeddedruntime = map[string][]byte{');
const bytesPerLine = 16;
const files = readdirSync(EMBEDDED_RUNTIME_ROOT);
const fileSize: Record<string, number> = {};
for (const file of files) {
const byteSlice = getByteSlice(resolve(EMBEDDED_RUNTIME_ROOT, file));
fileSize[file] = byteSlice.length;
code.open(`${JSON.stringify(file)}: []byte{`);
for (let i = 0; i < byteSlice.length; i += bytesPerLine) {
const line = byteSlice.slice(i, i + bytesPerLine);
code.line(`${line.join(', ')},`);
}
code.close('},');
}
code.close('}');
code.line();
const mainKey = JSON.stringify(files.find((f) => f.endsWith('.js')))!;
code.line(`const embeddedruntimeMain = ${mainKey}`);
code.line();
// This performs sanity tests upon initialization
code.open('func init() {');
for (const [file, size] of Object.entries(fileSize)) {
code.open(`if len(embeddedruntime[${JSON.stringify(file)}]) != ${size} {`);
code.line(
`panic("Embedded runtime file ${file} does not have expected size of ${size} bytes!")`,
);
code.close('}');
}
code.close('}');
code.closeFile(RUNTIME_FILE);

code.openFile(VERSION_FILE);
code.line('package jsii');
code.line();
const thisVersion = require('../package.json').version;
code.line(`const version = ${JSON.stringify(thisVersion)}`);
code.closeFile(VERSION_FILE);

code.save(OUTPUT_DIR);

function getByteSlice(path: string) {
const fileData = readFileSync(path).toString('hex');
const result = [];
for (let i = 0; i < fileData.length; i += 2) {
result.push(`0x${fileData[i]}${fileData[i + 1]}`);
}

return result;
}
22 changes: 11 additions & 11 deletions packages/@jsii/go-runtime/jsii-calc-test/main.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package main

import (
// "log"
"fmt"
jsiicalc "github.com/aws-cdk/jsii/jsii-calc/golang/jsiicalc"
// "fmt"
calc "github.com/aws-cdk/jsii/jsii-calc/golang/jsiicalc"
"github.com/aws-cdk/jsii/jsii-experimental"
"math"
)

func main() {
fmt.Println("Hello, JSII")
// client, err := jsii.InitClient()
defer jsii.Close()

// if err !=nil {
// log.Fatal(err)
// }
fmt.Print(jsii.Client{RuntimeVersion: "100.100.100"})
calculator := calc.NewCalculator(calc.CalculatorProps{InitialValue: 0, MaximumValue: math.MaxFloat64})
calculator.Add(1337)
calculator.Mul(42)

// fmt.Printf("Client init successful\nRuntime version: %s", client.RuntimeVersion)
fmt.Println(jsiicalc.AbstractClass{})
if calculator.GetValue() != 1337.*42. {
// TODO: right now implementations are just NOOP.
// panic(fmt.Sprintf("Unexpected calculator value: expected %f, but received %f", 1337.*42., calculator.GetValue()))
}
}
5 changes: 4 additions & 1 deletion packages/@jsii/go-runtime/jsii-experimental/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,11 @@ type ErrorResponse struct {
Stack *string `json:stack`
}

// Custom unmarshalling implementation for response structs. Creating new types
// is required in order to avoid infinite recursion.
func (r *LoadResponse) UnmarshalJSON(data []byte) error {
return unmarshalKernelResponse(data, r)
type response LoadResponse
return unmarshalKernelResponse(data, (*response)(r))
}

// Custom unmarshaling for kernel responses, checks for presence of `error` key on json and returns if present
Expand Down
Loading

0 comments on commit 6089cb9

Please sign in to comment.