Adobe 65007312 Programming Guide - Page 12
The Lightroom SDK scripting environment, Namespaces, classes, and objects
UPC - 883919154398
View all Adobe 65007312 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 12 highlights
CHAPTER 1: Using the Lightroom SDK The Lightroom SDK scripting environment 12 The Lightroom SDK scripting environment The SDK defines a Lua-language scripting API. The Lua scripting language is a fast, light-weight, embeddable scripting language. For information about the language, see http://www.lua.org/. The Lightroom scripting environment provides a programming structure that includes some enhancements to the basic Lua-language constructs. This section describes the API usage and terminology. X The API defined for the Lightroom SDK is fully documented in the Lightroom SDK API Reference, which is part of the SDK. When you have installed the SDK, the home page is at: LR_SDK_install_location/API Reference/index.html Namespaces, classes, and objects Lightroom defines a namespace as a table containing a suite of functions. This is somewhat like the Lua module; however, Lightroom does not use or support the module system that was introduced in Lua 5.1 (see http://www.lua.org/manual/5.1/manual.html#5.3). Lua does not have an object-oriented programming model, but it does allow Lua tables to be used in an object-like fashion, which the Lightroom SDK does. Lightroom's object and class model is derived from the one described in Chapter 16 of "Programming in Lua," available online at http://www.lua.org/pil/16.html. In Lightroom terminology, object and class are used in the typical object-oriented fashion: that is, a class is a description of a set of behaviors that are associated with a particular data structure, and an object is a single instance of that class. X The Lightroom SDK defines a set of namespaces and a set of classes; see "Accessing namespace functions directly" on page 12 and "Creating objects" on page 14. Plug-ins cannot define either namespaces or classes. X The Lua language defines built-in namespaces and global functions, of which a subset are accessible in the Lightroom SDK Lua environment. See "Using built-in Lua features" on page 19. Accessing namespace functions directly You can access a namespace by using the built-in function import(); it takes a single parameter, the name of the namespace to be loaded, and returns the table of functions, which you can then access using dot notation. For example: local LrMD5 = import 'LrMD5' -- assign namespace to local variable local digest = LrMD5.digest( 'some string' ) -- call "digest()" function in namespace This example shows the convention of assigning the namespace to a variable of the same name. This practice is not enforced in any way, but helps avoid confusion.