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

Adds Native Brightscript Component Types and Custom Components (Nodes) to Type System #891

Merged
merged 34 commits into from
Sep 19, 2023

Conversation

markwpearce
Copy link
Collaborator

@markwpearce markwpearce commented Sep 18, 2023

Additions:

  • All native Brightscript Components (eg. roDeviceInfo, roBitmap, roDateTime, etc.) as types usable in Brighterscript, including completions on methods and documentation
  • Same for native interfaces (ifDraw2d, ifAppManager, etc)
  • Same for native events (roInputEvent, roSGNodeEvent)
  • Adds AssociativeArrayType that can be built from an AA literal (eg. myAA = {name: "Mark", coolFactor: 100}, and will correctly be compatible with interface types that have declared the same members, eg:
interface Developer
   name as string
   coolFactor as integer
end interface

sub takesDeveloper(dev as Developer)
     print dev
end sub

sub foo()
     takesDeveloper({name: "Mark", coolFactor: 100}) ' no validation error, because AA meets required interface
end sub
  • Adds Scenegraph nodes to type system. The type's name is the component's name prefixed with roSGNode ... so roSGNodePoster, roSGNodeRowList, roSGNodeStdDlgTextItem are all available as types (with completions, documentation, etc)

  • Custom components are also added (again, prefixed with roSgNode). Eg:

<?xml version="1.0" encoding="utf-8" ?>
<component name="Widget" extends="Group">
    <interface>
        <field id="alpha" type="assocArray" />
        <field id="beta" type="float" />
        <field id="charlie" type="nodeArray" />
    </interface>
</component>

will create a type in the type system with name roSGNodeWidget, with completions and type inferences for properties alpha, beta, charlie, as well as validation on methods like 'getChildren(), subType(), etc.

NOTE: CallFunc's are a pain, because they cross scope boundaries. More work needs to be done to fully support callFuncs with validation and return type inference

markwpearce and others added 25 commits August 3, 2023 15:44
Copy link
Member

@TwitchBronBron TwitchBronBron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome! Just a few comments and then this is good to go.

src/Program.ts Show resolved Hide resolved
src/Program.ts Outdated Show resolved Hide resolved
src/Program.ts Show resolved Hide resolved
src/Program.ts Outdated Show resolved Hide resolved
src/Scope.ts Outdated Show resolved Hide resolved
src/interfaces.ts Outdated Show resolved Hide resolved
Copy link
Member

@TwitchBronBron TwitchBronBron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@markwpearce markwpearce merged commit 3b4ddbc into release-0.66.0 Sep 19, 2023
5 checks passed
@markwpearce markwpearce deleted the native_component_types branch September 19, 2023 13:20
@TwitchBronBron TwitchBronBron added this to the v1.0.0 milestone Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants