Adobe 27510753 Scripting Guide - Page 66

ExtendScript Reflection Interface, Reflection Object

Page 66 highlights

58 Using ExtendScript Tools and Features Adobe InDesign CS2 Scripting Guide Prop Class Name A second reference count for the number of properties that reference the object. The garbage collector uses this count to break circular references. If the reference count is not equal to the number of JavaScript properties that reference it, the object is considered to be used elsewhere and is not garbage collected. The class name of the object. The name of the object. This name does not reflect the name of the property the object has been stored into. The name is mostly relevant to Function objects, where it is the name of the function or method. Names in brackets are internal names of scripts. If the object has an ID, the last column displays that ID. ExtendScript Reflection Interface ExtendScript provides a reflection interface that allows you to find out everything about an object, including its name, a description, the expected data type for properties, the arguments and return value for methods, and any default values or limitations to the input values. Reflection Object Every object has a reflect property that returns a Reflection object that reports the contents of the object. You can, for example, show the values of all the properties of an object with code like this: var f= new File ("myfile"); var props = f.reflect.properties; for (var i = 0; i < props.length; i++) { $.writeln('this property ' + props[i].name + ' is ' + f[props[i].name]); } Reflection object properties All properties are read only. description String help String methods name properties Array of ReflectionInfo String Array of ReflectionInfo Short text describing the reflected object, or undefined if no description is available. Longer text describing the reflected object more completely, or undefined if no description is available. An Array of ReflectionInfo Objects containing all methods of the reflected object, defined in the class or in the specific instance. The class name of the reflected object. An Array of ReflectionInfo objects containing all properties of the reflected object, defined in the class or in the specific instance. For objects with dynamic properties (defined at runtime) the list contains only those dynamic properties that have already been accessed by the script. For example, in an object wrapping an HTML tag, the names of the HTML attributes are determined at run time.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184

58
Using ExtendScript Tools and Features
Adobe InDesign CS2 Scripting Guide
Prop
A second reference count for the number of properties that reference the object. The
garbage collector uses this count to break circular references. If the reference count is not
equal to the number of JavaScript properties that reference it, the object is considered to
be used elsewhere and is not garbage collected.
Class
The class name of the object.
Name
The name of the object. This name does not reflect the name of the property the object
has been stored into. The name is mostly relevant to Function objects, where it is the name
of the function or method. Names in brackets are internal names of scripts. If the object
has an ID, the last column displays that ID.
ExtendScript Reflection Interface
ExtendScript provides a reflection interface that allows you to find out everything about an object, including
its name, a description, the expected data type for properties, the arguments and return value for methods,
and any default values or limitations to the input values.
Reflection Object
Every object has a
reflect
property that returns a
Reflection
object that reports the contents of the
object. You can, for example, show the values of all the properties of an object with code like this:
var f= new File ("myfile");
var props = f.reflect.properties;
for (var i = 0; i < props.length; i++) {
$.writeln(‘this property ‘ + props[i].name + ‘ is ‘ + f[props[i].name]);
}
Reflection object properties
All properties are read only.
description
String
Short text describing the reflected object, or
undefined
if no de-
scription is available.
help
String
Longer text describing the reflected object more completely, or
un-
defined
if no description is available.
methods
Array of Re-
flectionInfo
An Array of
ReflectionInfo
Objects containing all methods of the
reflected object, defined in the class or in the specific instance.
name
String
The class name of the reflected object.
properties
Array of Re-
flectionInfo
An Array of
ReflectionInfo
objects containing all properties of
the reflected object, defined in the class or in the specific instance.
For objects with dynamic properties (defined at runtime) the list
contains only those dynamic properties that have already been ac-
cessed by the script. For example, in an object wrapping an HTML
tag, the names of the HTML attributes are determined at run time.