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

Fix Vector2DFieldInterpolator.keyValue type #1339

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
29 changes: 27 additions & 2 deletions scripts/scrape-roku-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ class Runner {
constructors: [],
description: 'roIntrinsicDouble is the object equivalent for type \'Double\'.\n\nIt is a legacy object name, corresponding to the intrinsic Double object. Applications should use Double literal values and/or Double-typed variables directly.',
events: [],
methods: [],
interfaces: [
{
name: 'ifDouble',
Expand Down Expand Up @@ -815,7 +816,13 @@ class Runner {


private fixFunctionParams(text: string): string {
return text.replace(/to as /ig, 'toValue as ');
return text.replace(/to as /ig, 'toValue as ')
.replace(/as int$/ig, 'as integer')
.replace(/as int,/ig, 'as integer,')
.replace(/as int\)/ig, 'as integer)')
.replace(/as bool$/ig, 'as boolean')
.replace(/as bool,/ig, 'as boolean,')
.replace(/as bool\)/ig, 'as boolean)');
markwpearce marked this conversation as resolved.
Show resolved Hide resolved
}

private getMethod(text: string) {
Expand Down Expand Up @@ -1199,7 +1206,6 @@ class Runner {
name: 'trackImageUri',
type: 'uri'
},

{
accessPermission: 'READ_WRITE',
default: 'not sepcified',
Expand All @@ -1211,6 +1217,14 @@ class Runner {
interfaces: [],
name: 'ProgressBar',
url: 'https://developer.roku.com/en-ca/docs/references/scenegraph/media-playback-nodes/video.md#ui-fields'
},
vector2dfieldinterpolator: {
fields: [
{
name: 'keyValue',
type: 'array of array of floats'
}
]
}
},
components: {
Expand Down Expand Up @@ -1335,6 +1349,8 @@ class Runner {
}
});

fixFieldByName(this.result.nodes.vector2dfieldinterpolator, 'keyValue', { type: 'array of vector2d' });

// fix all overloaded methods in interfaces
for (const ifaceKey in this.result.interfaces) {
const iface = this.result.interfaces[ifaceKey];
Expand All @@ -1361,6 +1377,15 @@ class Runner {
}
}

function fixFieldByName(component: SceneGraphNode, fieldName: string, override: Partial<SceneGraphNodeField>) {
let fieldToChangeIndex = component.fields.findIndex((field) => {
return field.name.toLowerCase() === fieldName.toLowerCase();
});
if (fieldToChangeIndex >= 0) {
component.fields[fieldToChangeIndex] = deepmerge(component.fields[fieldToChangeIndex], override);
}
}

function fixOverloadedMethod(iface: RokuInterface, funcName: string) {
const originalOverloads = iface.methods.filter(method => method.name.toLowerCase() === funcName.toLowerCase());
if (originalOverloads.length === 0) {
Expand Down
8 changes: 8 additions & 0 deletions src/Program.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2990,6 +2990,14 @@ describe('Program', () => {
expect(socketAsyncType.name).to.eq('ifSocketAsync');
expectTypeToBe(socketAsyncType.getMemberType('setMessagePort', opts), TypedFunctionType);
expectTypeToBe(streamSocketType.getMemberType('setMessagePort', opts), TypedFunctionType);

const vector2dInterp = table.getSymbolType('roSGNodeVector2DFieldInterpolator', { flags: SymbolTypeFlag.typetime });
expectTypeToBe(vector2dInterp, ComponentType);

const vector2dKeyValueType = vector2dInterp.getMemberType('keyValue', opts) as ArrayType;
expectTypeToBe(vector2dKeyValueType, ArrayType);
expectTypeToBe(vector2dKeyValueType.defaultType, ArrayType);
expectTypeToBe((vector2dKeyValueType.defaultType as ArrayType).defaultType, FloatType);
});

});
Expand Down
Loading
Loading