Skip to content

Support for declaring all roku types in typedefs #1412

@TwitchBronBron

Description

@TwitchBronBron

We should have a way to declare all (or almost all) built-in roku types in typedefs. This would provide several benefits:

  • more flexibility for contributors wanting to improve the documentation on the native types
  • more options for separating certain features into different libraries (like brightscript, brightsign, maybe future versions of brightscript with new features)
  • enables developers to use that same syntax to declare objects in their own code that might not be public knowledge (i.e. internal roku projects, select partners, etc).

I envision we move all of the built-in types and objects and components and interfaces into a single folder (maybe libs/brightscript.d.bs, and here is the syntax I'm currently envisioning.

  • the native interfaces can probably just use the existing interface keyword

    interface ifDateTime
        sub ToLocalTime() as Void
       ...etc
    end interface
  • "brightscript components" use the object keyword". We need a way to "spread" all of the functions of an interface onto the object. Maybe that's how "implements" works for object, or maybe we have some extra syntax to say "I'm not going to write them again, just copy them onto this thing".

    object roDateTime implements ifDateTime, ifToStr
        'objects can also have concrete methods declare on them, if you want to make an interface for them
        function someNonInteraceFunc() as integer
    end object
  • components would use the component keyword (like the component statement syntax mentioned in Component Statement #575)

    component "Rectangle" extends "Group"
        'callfuncs
        public getBoundingRect() as roAssociativeArray
        'fields
        public someField as roAssociativeArray
    end component
  • Declaring these items with the declare keyword in a d.bs file might allow them to be exposed globally to the program. Like this:

    declare function abs(num) as number

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions