Roku objects, interfaces, and language integration – BrightSign BrightScript 2 Reference Guide User Manual
Page 14
14
Roku Objects, Interfaces, and Language Integration
[note: the name of Roku Objects will change to BrightScript Components]
The Roku Object architecture and library are separate from BrightScript, but BrightScript
requires them.
All APIs exposed to BrightScript are exposed as Roku Objects. In other words, if
a platform wants to expose APIs to be scripted, the platform must register a new
Roku Object. The Roku Object will most likely be written in C or C++.
BrightScript has language features that are designed to work with Roku Object
Interfaces. These include: for each, print, the array operator, and intrinsic
objects.
Fundamental BrightScript building blocks are implemented as Roku Objects. For
example: Lists, Vector Arrays, Associative Arrays, and Objects.
A Brief Summary of Roku Objects
Roku Objects are light weight components that are implemented in C (or a C compatible
language such as C++). C++ templates exist to help C++ programmers implement the
key C functions needed to implement a Roku Object.
Roku Objects can be used in BrightScript, and they can be used by a C compatible
language.
Roku Objects are robust against version changes. In other words, scripts are generally
backwards compatible with Objects that have undergone version improvements.
Roku Objects keep a reference count and delete themselves when the reference count
goes to zero.
A key Roku Object concept is the Interface. The term Interface is used here as it is in
Java or Microsoft COM. An interface is a known set of member functions that
implement a set of logic. In some ways an Interface is like a virtual base class in C++.
Any script or C-compatible program can use an object‟s interface without regard to what
type of object it is a part of, as long as it is familiar with a particular interface.
For example, the standard BrightScript serial interface (RS-232) object implements three
interfaces: “ifSerialControl”, “ifStreamReceive”, and “ifStreamSend”. Since the
BrightScript “print” statement sends its output to any object that has an “ifStreamSend”
interface, it works with the serial object (and others).
BrightScript statements that work with Roku Object Interfaces
For each