Objects, interfaces, and language integration, Brightscript objects, Wrapper objects – BrightSign BrightScript 3.0 Reference Manual User Manual

Page 20

Advertising
background image

15

OBJECTS, INTERFACES, AND LANGUAGE INTEGRATION

BrightScript Objects

Though BrightScript operates independently of its object architecture and library, they are both required for programming
BrightScript applications. The API of a BrightSign platform is exposed to BrightScript as a library objects: Platforms must
register a new BrightScript object to expose some part of its API.

BrightScript objects are written in C (or a compatible language such as C++), and are robust against version changes:
Scripts are generally backwards compatible with objects that have undergone revisions.

BrightScript objects keep a reference count; they delete themselves when the reference count reaches zero.

Wrapper Objects

All intrinsic BrightScript types (Boolean, Integer, Float, Double, String, and Invalid) have object equivalents. If one of these
intrinsic types is passed to a function that expects an object, the appropriate wrapper object will be created, assigned the
correct value, and passed to the function (this is sometimes referred to as "autoboxing"): This allows, for example, roArray
objects to store values (e.g. integers and strings) as well as objects.

Any expression that expects one of the above types will work with the corresponding wrapper object as well: roBoolean,
roInt, roFloat, roDouble, roString.

Example: The following examples illustrate how wrapper objects work.
Print 5.tostr()+"th"
Print "5".toint()+5

-5.tostr() 'This will cause an error. Instead, use the following:

Advertising