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

refactor!: replaced None with nil in lua-generator #7731

Closed
wants to merge 6 commits into from
Closed
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
586 changes: 327 additions & 259 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blockly",
"version": "10.3.0",
"version": "11.0.0-beta.1",
"description": "Blockly is a library for building visual programming editors.",
"keywords": [
"blockly"
Expand Down Expand Up @@ -105,6 +105,9 @@
"yargs": "^17.2.1"
},
"dependencies": {
"jsdom": "22.1.0"
"jsdom": "23.0.0"
},
"engines": {
"node": ">=18"
}
}
1 change: 0 additions & 1 deletion scripts/gulpfiles/package_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ function packageDTS() {
return gulp.src(handwrittenSrcs, {base: 'typings'})
.pipe(gulp.src(`${TYPINGS_BUILD_DIR}/**/*.d.ts`, {ignore: [
`${TYPINGS_BUILD_DIR}/blocks/**/*`,
`${TYPINGS_BUILD_DIR}/generators/**/*`,
]}))
.pipe(gulp.replace('AnyDuringMigration', 'any'))
.pipe(gulp.dest(RELEASE_DIR));
Expand Down
24 changes: 24 additions & 0 deletions tests/typescript/src/generators/dart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

import * as Blockly from 'blockly-test/core';

/**
* Test: should be able to import a generator instance, class, and
* Order enum.
*/
import {dartGenerator, DartGenerator, Order} from 'blockly-test/dart';

/**
* Test: should be able to create a simple block generator function,
* correctly typed, and insert it into the .forBlock dictionary.
*/
dartGenerator.forBlock['the_answer'] = function (
_block: Blockly.Block,
_generator: DartGenerator,
): [string, Order] {
return ['42', Order.ATOMIC];
};
28 changes: 28 additions & 0 deletions tests/typescript/src/generators/javascript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

import * as Blockly from 'blockly-test/core';

/**
* Test: should be able to import a generator instance, class, and
* Order enum.
*/
import {
javascriptGenerator,
JavascriptGenerator,
Order,
} from 'blockly-test/javascript';

/**
* Test: should be able to create a simple block generator function,
* correctly typed, and insert it into the .forBlock dictionary.
*/
javascriptGenerator.forBlock['the_answer'] = function (
_block: Blockly.Block,
_generator: JavascriptGenerator,
): [string, Order] {
return ['42', Order.ATOMIC];
};
24 changes: 24 additions & 0 deletions tests/typescript/src/generators/lua.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

import * as Blockly from 'blockly-test/core';

/**
* Test: should be able to import a generator instance, class, and
* Order enum.
*/
import {luaGenerator, LuaGenerator, Order} from 'blockly-test/lua';

/**
* Test: should be able to create a simple block generator function,
* correctly typed, and insert it into the .forBlock dictionary.
*/
luaGenerator.forBlock['the_answer'] = function (
_block: Blockly.Block,
_generator: LuaGenerator,
): [string, Order] {
return ['42', Order.ATOMIC];
};
24 changes: 24 additions & 0 deletions tests/typescript/src/generators/php.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

import * as Blockly from 'blockly-test/core';

/**
* Test: should be able to import a generator instance, class, and
* Order enum.
*/
import {phpGenerator, PhpGenerator, Order} from 'blockly-test/php';

/**
* Test: should be able to create a simple block generator function,
* correctly typed, and insert it into the .forBlock dictionary.
*/
phpGenerator.forBlock['the_answer'] = function (
_block: Blockly.Block,
_generator: PhpGenerator,
): [string, Order] {
return ['42', Order.ATOMIC];
};
24 changes: 24 additions & 0 deletions tests/typescript/src/generators/python.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

import * as Blockly from 'blockly-test/core';

/**
* Test: should be able to import a generator instance, class, and
* Order enum.
*/
import {pythonGenerator, PythonGenerator, Order} from 'blockly-test/python';

/**
* Test: should be able to create a simple block generator function,
* correctly typed, and insert it into the .forBlock dictionary.
*/
pythonGenerator.forBlock['the_answer'] = function (
_block: Blockly.Block,
_generator: PythonGenerator,
): [string, Order] {
return ['42', Order.ATOMIC];
};
23 changes: 1 addition & 22 deletions typings/dart.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

export enum Order {
ATOMIC = 0, // 0 "" ...
UNARY_POSTFIX = 1, // expr++ expr-- () [] . ?.
UNARY_PREFIX = 2, // -expr !expr ~expr ++expr --expr
MULTIPLICATIVE = 3, // * / % ~/
ADDITIVE = 4, // + -
SHIFT = 5, // << >>
BITWISE_AND = 6, // &
BITWISE_XOR = 7, // ^
BITWISE_OR = 8, // |
RELATIONAL = 9, // >= > <= < as is is!
EQUALITY = 10, // == !=
LOGICAL_AND = 11, // &&
LOGICAL_OR = 12, // ||
IF_NULL = 13, // ??
CONDITIONAL = 14, // expr ? expr : expr
CASCADE = 15, // ..
ASSIGNMENT = 16, // = *= /= ~/= %= += -= <<= >>= &= ^= |=
NONE = 99, // (...)
}

export declare const dartGenerator: any;
export * from './generators/dart';
40 changes: 1 addition & 39 deletions typings/javascript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

export enum Order {
ATOMIC = 0, // 0 "" ...
NEW = 1.1, // new
MEMBER = 1.2, // . []
FUNCTION_CALL = 2, // ()
INCREMENT = 3, // ++
DECREMENT = 3, // --
BITWISE_NOT = 4.1, // ~
UNARY_PLUS = 4.2, // +
UNARY_NEGATION = 4.3, // -
LOGICAL_NOT = 4.4, // !
TYPEOF = 4.5, // typeof
VOID = 4.6, // void
DELETE = 4.7, // delete
AWAIT = 4.8, // await
EXPONENTIATION = 5.0, // **
MULTIPLICATION = 5.1, // *
DIVISION = 5.2, // /
MODULUS = 5.3, // %
SUBTRACTION = 6.1, // -
ADDITION = 6.2, // +
BITWISE_SHIFT = 7, // << >> >>>
RELATIONAL = 8, // < <= > >=
IN = 8, // in
INSTANCEOF = 8, // instanceof
EQUALITY = 9, // == != === !==
BITWISE_AND = 10, // &
BITWISE_XOR = 11, // ^
BITWISE_OR = 12, // |
LOGICAL_AND = 13, // &&
LOGICAL_OR = 14, // ||
CONDITIONAL = 15, // ?:
ASSIGNMENT = 16, // = += -= **= *= /= %= <<= >>= ...
YIELD = 17, // yield
COMMA = 18, // ,
NONE = 99, // (...)
}

export declare const javascriptGenerator: any;
export * from './generators/javascript';
17 changes: 1 addition & 16 deletions typings/lua.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

export enum Order {
ATOMIC = 0, // literals
// The next level was not explicit in documentation and inferred by Ellen.
HIGH = 1, // Function calls, tables[]
EXPONENTIATION = 2, // ^
UNARY = 3, // not # - ~
MULTIPLICATIVE = 4, // * / %
ADDITIVE = 5, // + -
CONCATENATION = 6, // ..
RELATIONAL = 7, // < > <= >= ~= ==
AND = 8, // and
OR = 9, // or
NONE = 99,
}

export declare const luaGenerator: any;
export * from './generators/lua';
42 changes: 1 addition & 41 deletions typings/php.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

export enum Order {
ATOMIC = 0, // 0 "" ...
CLONE = 1, // clone
NEW = 1, // new
MEMBER = 2.1, // []
FUNCTION_CALL = 2.2, // ()
POWER = 3, // **
INCREMENT = 4, // ++
DECREMENT = 4, // --
BITWISE_NOT = 4, // ~
CAST = 4, // (int) (float) (string) (array) ...
SUPPRESS_ERROR = 4, // @
INSTANCEOF = 5, // instanceof
LOGICAL_NOT = 6, // !
UNARY_PLUS = 7.1, // +
UNARY_NEGATION = 7.2, // -
MULTIPLICATION = 8.1, // *
DIVISION = 8.2, // /
MODULUS = 8.3, // %
ADDITION = 9.1, // +
SUBTRACTION = 9.2, // -
STRING_CONCAT = 9.3, // .
BITWISE_SHIFT = 10, // << >>
RELATIONAL = 11, // < <= > >=
EQUALITY = 12, // == != === !== <> <=>
REFERENCE = 13, // &
BITWISE_AND = 13, // &
BITWISE_XOR = 14, // ^
BITWISE_OR = 15, // |
LOGICAL_AND = 16, // &&
LOGICAL_OR = 17, // ||
IF_NULL = 18, // ??
CONDITIONAL = 19, // ?:
ASSIGNMENT = 20, // = += -= *= /= %= <<= >>= ...
LOGICAL_AND_WEAK = 21, // and
LOGICAL_XOR = 22, // xor
LOGICAL_OR_WEAK = 23, // or
NONE = 99, // (...)
}

export declare const phpGenerator: any;
export * from './generators/php';
26 changes: 1 addition & 25 deletions typings/python.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,4 @@
* SPDX-License-Identifier: Apache-2.0
*/

export enum Order {
ATOMIC = 0, // 0 "" ...
COLLECTION = 1, // tuples, lists, dictionaries
STRING_CONVERSION = 1, // `expression...`
MEMBER = 2.1, // . []
FUNCTION_CALL = 2.2, // ()
EXPONENTIATION = 3, // **
UNARY_SIGN = 4, // + -
BITWISE_NOT = 4, // ~
MULTIPLICATIVE = 5, // * / // %
ADDITIVE = 6, // + -
BITWISE_SHIFT = 7, // << >>
BITWISE_AND = 8, // &
BITWISE_XOR = 9, // ^
BITWISE_OR = 10, // |
RELATIONAL = 11, // in, not in, is, is not, >, >=, <>, !=, ==
LOGICAL_NOT = 12, // not
LOGICAL_AND = 13, // and
LOGICAL_OR = 14, // or
CONDITIONAL = 15, // if else
LAMBDA = 16, // lambda
NONE = 99, // (...)
}

export declare const pythonGenerator: any;
export * from './generators/python';