| Line 55... |
Line 55... |
| 55 |
|
55 |
|
| 56 |
getGroup(fdef, recursive, where)
|
56 |
getGroup(fdef, recursive, where)
|
| 57 |
|
57 |
|
| 58 |
getMethodsMetaData(f, where)
|
58 |
getMethodsMetaData(f, where)
|
| 59 |
assignMethodsMetaData (f, value, fdef, where, deflt)
|
59 |
assignMethodsMetaData (f, value, fdef, where, deflt)
|
| 60 |
mlistMetaName (name, package)
|
60 |
mlistMetaName (name, package)
|
| 61 |
|
61 |
|
| 62 |
makeGeneric(f, fdef, fdefault, group=character(),
|
62 |
makeGeneric(f, fdef, fdefault, group=list(), valueClass=character(),
|
| 63 |
valueClass=character(), package, signature, genericFunction)
|
63 |
package, signature = NULL, genericFunction = NULL)
|
| 64 |
|
64 |
|
| 65 |
makeStandardGeneric(f, fdef)
|
65 |
makeStandardGeneric(f, fdef)
|
| 66 |
|
66 |
|
| 67 |
generic.skeleton(name, fdef, fdefault)
|
67 |
generic.skeleton(name, fdef, fdefault)
|
| 68 |
|
68 |
|
| 69 |
defaultDumpName(generic, signature)
|
69 |
defaultDumpName(generic, signature)
|
| 70 |
|
70 |
|
| 71 |
getAllMethods(f, fdef, where)
|
71 |
getAllMethods(f, fdef, where)
|
| 72 |
|
72 |
|
| 73 |
doPrimitiveMethod(name, def, call=sys.call(-1), ev=sys.frame(-2))
|
73 |
doPrimitiveMethod(name, def, call= sys.call(-1), ev= sys.frame(sys.parent(2)))
|
| 74 |
|
74 |
|
| 75 |
conformMethod(signature, mnames, fnames, f)
|
75 |
conformMethod(signature, mnames, fnames, f)
|
| 76 |
|
76 |
|
| 77 |
matchSignature(signature, fun, where)
|
77 |
matchSignature(signature, fun, where)
|
| 78 |
|
78 |
|
| Line 102... |
Line 102... |
| 102 |
asMethodDefinition(def, signature, sealed = FALSE)
|
102 |
asMethodDefinition(def, signature, sealed = FALSE)
|
| 103 |
|
103 |
|
| 104 |
addNextMethod(method, f, mlist, optional, envir)
|
104 |
addNextMethod(method, f, mlist, optional, envir)
|
| 105 |
}
|
105 |
}
|
| 106 |
\section{Summary of Functions}{
|
106 |
\section{Summary of Functions}{
|
| 107 |
|
107 |
|
| 108 |
\describe{
|
108 |
\describe{
|
| 109 |
|
109 |
|
| 110 |
\item{\code{getGeneric}:}{
|
110 |
\item{\code{getGeneric}:}{
|
| 111 |
return the definition of the function named \code{f} as a generic.
|
111 |
return the definition of the function named \code{f} as a generic.
|
| 112 |
|
112 |
|
| 113 |
If no definition is found, throws an
|
113 |
If no definition is found, throws an
|
| 114 |
error or returns \code{NULL} according to the value of
|
114 |
error or returns \code{NULL} according to the value of
|
| 115 |
\code{mustFind}. By default, searches in the top-level
|
115 |
\code{mustFind}. By default, searches in the top-level
|
| Line 121... |
Line 121... |
| 121 |
formal definition used for assigning methods to this primitive.
|
121 |
formal definition used for assigning methods to this primitive.
|
| 122 |
Not all primitives can have methods; if this one can't, then
|
122 |
Not all primitives can have methods; if this one can't, then
|
| 123 |
\code{getGeneric} returns \code{NULL} or throws an error.
|
123 |
\code{getGeneric} returns \code{NULL} or throws an error.
|
| 124 |
}
|
124 |
}
|
| 125 |
|
125 |
|
| 126 |
\item{\code{getGroup}:}{
|
126 |
\item{\code{getGroup}:}{
|
| 127 |
return the groups to which this generic belongs, searching from
|
127 |
return the groups to which this generic belongs, searching from
|
| 128 |
environment \code{where} (the global environment normally by default).
|
128 |
environment \code{where} (the global environment normally by default).
|
| 129 |
|
129 |
|
| 130 |
If \code{recursive=TRUE}, also all the group(s) of these groups.
|
130 |
If \code{recursive=TRUE}, also all the group(s) of these groups.
|
| 131 |
}
|
131 |
}
|
| 132 |
|
132 |
|
| 133 |
\item{\code{getMethodsMetaData},
|
133 |
\item{\code{getMethodsMetaData},
|
| 134 |
\code{assignMethodsMetaData},
|
134 |
\code{assignMethodsMetaData},
|
| 135 |
\code{mlistMetaName}:}{
|
135 |
\code{mlistMetaName}:}{
|
| 136 |
Utilities to get (\code{getMethodsMetaData}) and assign (\code{assignMethodsMetaData}) the metadata object recording the
|
136 |
Utilities to get (\code{getMethodsMetaData}) and assign (\code{assignMethodsMetaData}) the metadata object recording the
|
| 137 |
methods defined in a particular package, or to return the
|
137 |
methods defined in a particular package, or to return the
|
| 138 |
mangled name for that object (\code{mlistMetaName}).
|
138 |
mangled name for that object (\code{mlistMetaName}).
|
| 139 |
|
139 |
|
| 140 |
The assign function should not be used directly. The get
|
140 |
The assign function should not be used directly. The get
|
| Line 150... |
Line 150... |
| 150 |
\code{signature} will be \code{"ANY"} in the value, but extra
|
150 |
\code{signature} will be \code{"ANY"} in the value, but extra
|
| 151 |
trailing \code{"ANY"}'s are removed. When the input signature is
|
151 |
trailing \code{"ANY"}'s are removed. When the input signature is
|
| 152 |
empty, the returned signature is a single \code{"ANY"} matching
|
152 |
empty, the returned signature is a single \code{"ANY"} matching
|
| 153 |
the first formal argument (so the returned value is always
|
153 |
the first formal argument (so the returned value is always
|
| 154 |
non-empty).
|
154 |
non-empty).
|
| 155 |
|
155 |
|
| 156 |
Generates an error if any of the supplied signature names are
|
156 |
Generates an error if any of the supplied signature names are
|
| 157 |
not legal; that is, not in the signature slot of the generic
|
157 |
not legal; that is, not in the signature slot of the generic
|
| 158 |
function.
|
158 |
function.
|
| 159 |
|
159 |
|
| 160 |
If argument \code{where} is supplied, a warning will be issued
|
160 |
If argument \code{where} is supplied, a warning will be issued
|
| Line 167... |
Line 167... |
| 167 |
argument to \code{methodClass}, the class for which the method is
|
167 |
argument to \code{methodClass}, the class for which the method is
|
| 168 |
explicitly defined. Only modifies the method if an explicit
|
168 |
explicitly defined. Only modifies the method if an explicit
|
| 169 |
coerce is required to coerce from \code{thisClass} to
|
169 |
coerce is required to coerce from \code{thisClass} to
|
| 170 |
\code{methodClass}.
|
170 |
\code{methodClass}.
|
| 171 |
}
|
171 |
}
|
| 172 |
|
172 |
|
| 173 |
\item{\code{is.primitive}:}{
|
173 |
\item{\code{is.primitive}:}{
|
| 174 |
Is this object a primitive function (either a builtin or special)?
|
174 |
Is this object a primitive function (either a builtin or special)?
|
| 175 |
}
|
175 |
}
|
| 176 |
|
176 |
|
| 177 |
\item{\code{removeMethodsObject}:}{
|
177 |
\item{\code{removeMethodsObject}:}{
|
| 178 |
remove the metadata object containing methods for \code{f}.
|
178 |
remove the metadata object containing methods for \code{f}.
|
| 179 |
}
|
179 |
}
|
| 180 |
|
180 |
|
| 181 |
\item{\code{findUnique}:}{
|
181 |
\item{\code{findUnique}:}{
|
| 182 |
Return the list of environments (or equivalent) having an object named
|
182 |
Return the list of environments (or equivalent) having an object named
|
| 183 |
\code{what}, using environment \code{where} and its parent
|
183 |
\code{what}, using environment \code{where} and its parent
|
| 184 |
environments. If more than one is found, a warning message is
|
184 |
environments. If more than one is found, a warning message is
|
| 185 |
generated, using \code{message} to identify what was being
|
185 |
generated, using \code{message} to identify what was being
|
| 186 |
searched for, unless \code{message} is the empty string.
|
186 |
searched for, unless \code{message} is the empty string.
|
| 187 |
}
|
187 |
}
|
| 188 |
|
188 |
|
| 189 |
\item{\code{cacheMetaData},
|
189 |
\item{\code{cacheMetaData},
|
| 190 |
\code{cacheGenericsMetaData},
|
190 |
\code{cacheGenericsMetaData},
|
| 191 |
\code{setPrimitiveMethods}:}{
|
191 |
\code{setPrimitiveMethods}:}{
|
| 192 |
Utilities for ensuring that the internal information about
|
192 |
Utilities for ensuring that the internal information about
|
| 193 |
class and method definitions is up to date. Should normally be
|
193 |
class and method definitions is up to date. Should normally be
|
| Line 234... |
Line 234... |
| 234 |
suitable for calling \code{\link{MethodsListSelect}}, with
|
234 |
suitable for calling \code{\link{MethodsListSelect}}, with
|
| 235 |
\code{evalArgs=FALSE}, to select a method corresponding to the
|
235 |
\code{evalArgs=FALSE}, to select a method corresponding to the
|
| 236 |
signature. Usually not called directly: see
|
236 |
signature. Usually not called directly: see
|
| 237 |
\code{\link{selectMethod}}.
|
237 |
\code{\link{selectMethod}}.
|
| 238 |
}
|
238 |
}
|
| 239 |
|
239 |
|
| 240 |
\item{\code{.saveImage}:}{
|
240 |
\item{\code{.saveImage}:}{
|
| 241 |
Flag, used in dynamically initializing the methods package from
|
241 |
Flag, used in dynamically initializing the methods package from
|
| 242 |
\code{.First.lib}
|
242 |
\code{.First.lib}
|
| 243 |
}
|
243 |
}
|
| 244 |
|
244 |
|
| Line 267... |
Line 267... |
| 267 |
method to the methods list, which it then returns. It uses
|
267 |
method to the methods list, which it then returns. It uses
|
| 268 |
methods defined suitably for ordinary methods and for methods with
|
268 |
methods defined suitably for ordinary methods and for methods with
|
| 269 |
calls to \code{\link{callNextMethod}}.
|
269 |
calls to \code{\link{callNextMethod}}.
|
| 270 |
}
|
270 |
}
|
| 271 |
}
|
271 |
}
|
| 272 |
|
272 |
|
| 273 |
\item{\code{makeGeneric}:}{
|
273 |
\item{\code{makeGeneric}:}{
|
| 274 |
Makes a generic function object corresponding to the given
|
274 |
Makes a generic function object corresponding to the given
|
| 275 |
function name, optional definition and optional default method.
|
275 |
function name, optional definition and optional default method.
|
| 276 |
Other arguments supply optional elements for the slots of
|
276 |
Other arguments supply optional elements for the slots of
|
| 277 |
\code{\link{genericFunction-class}}.
|
277 |
\code{\link{genericFunction-class}}.
|
| 278 |
}
|
278 |
}
|
| 279 |
|
279 |
|
| 280 |
\item{\code{makeStandardGeneric}:}{
|
280 |
\item{\code{makeStandardGeneric}:}{
|
| 281 |
a utility function that makes a valid function calling
|
281 |
a utility function that makes a valid function calling
|
| 282 |
\code{standardGeneric} for name \code{f}. Works (more or less)
|
282 |
\code{standardGeneric} for name \code{f}. Works (more or less)
|
| 283 |
even if the actual definition, \code{fdef}, is not a proper
|
283 |
even if the actual definition, \code{fdef}, is not a proper
|
| 284 |
function, that is, it's a primitive or internal.
|
284 |
function, that is, it's a primitive or internal.
|
| 285 |
}
|
285 |
}
|
| 286 |
|
286 |
|
| 287 |
\item{\code{conformMethod}:}{
|
287 |
\item{\code{conformMethod}:}{
|
| 288 |
If the formal arguments, \code{mnames}, are not identical to the
|
288 |
If the formal arguments, \code{mnames}, are not identical to the
|
| 289 |
formal arguments to the function, \code{fnames},
|
289 |
formal arguments to the function, \code{fnames},
|
| 290 |
\code{conformMethod} determines whether the signature and the two
|
290 |
\code{conformMethod} determines whether the signature and the two
|
| 291 |
sets of arguments conform, and returns the signature, possibly
|
291 |
sets of arguments conform, and returns the signature, possibly
|
| Line 300... |
Line 300... |
| 300 |
method that are not arguments to the function; and (3) the omitted
|
300 |
method that are not arguments to the function; and (3) the omitted
|
| 301 |
formal arguments do not appear as explicit classes in the
|
301 |
formal arguments do not appear as explicit classes in the
|
| 302 |
signature.
|
302 |
signature.
|
| 303 |
}
|
303 |
}
|
| 304 |
|
304 |
|
| 305 |
\item{\code{defaultDumpName}:}{
|
305 |
\item{\code{defaultDumpName}:}{
|
| 306 |
the default name to be used for dumping a method.
|
306 |
the default name to be used for dumping a method.
|
| 307 |
}
|
307 |
}
|
| 308 |
|
308 |
|
| 309 |
\item{\code{getAllMethods}:}{
|
309 |
\item{\code{getAllMethods}:}{
|
| 310 |
A generic function (with methods) representing the merge of all
|
310 |
A generic function (with methods) representing the merge of all
|
| 311 |
the methods defined for this generic starting from environment
|
311 |
the methods defined for this generic starting from environment
|
| 312 |
\code{where}, including all parent environments. By default,
|
312 |
\code{where}, including all parent environments. By default,
|
| 313 |
uses the global environment (and therefore all packages on the
|
313 |
uses the global environment (and therefore all packages on the
|
| 314 |
search list). This function exists largely
|
314 |
search list). This function exists largely
|
| Line 318... |
Line 318... |
| 318 |
should not be needed.
|
318 |
should not be needed.
|
| 319 |
|
319 |
|
| 320 |
If the generic \code{f} has a group generic, methods for this
|
320 |
If the generic \code{f} has a group generic, methods for this
|
| 321 |
group generic (and further generations of group generics, if any)
|
321 |
group generic (and further generations of group generics, if any)
|
| 322 |
are also merged.
|
322 |
are also merged.
|
| 323 |
|
323 |
|
| 324 |
The merging rule is as follows: each generic is merged across
|
324 |
The merging rule is as follows: each generic is merged across
|
| 325 |
packages, and the group generics are then merged, finally adding
|
325 |
packages, and the group generics are then merged, finally adding
|
| 326 |
the directly defined methods of \code{f}.
|
326 |
the directly defined methods of \code{f}.
|
| 327 |
|
327 |
|
| 328 |
The effect of the merging rule is that any method directly defined
|
328 |
The effect of the merging rule is that any method directly defined
|
| Line 338... |
Line 338... |
| 338 |
|
338 |
|
| 339 |
The slot \code{"allMethods"} of the merged methods list is set to
|
339 |
The slot \code{"allMethods"} of the merged methods list is set to
|
| 340 |
a copy of the methods slot; this is the slot where inherited
|
340 |
a copy of the methods slot; this is the slot where inherited
|
| 341 |
methods are stored.
|
341 |
methods are stored.
|
| 342 |
}
|
342 |
}
|
| 343 |
|
343 |
|
| 344 |
\item{\code{doPrimitiveMethod}:}{
|
344 |
\item{\code{doPrimitiveMethod}:}{
|
| 345 |
do a primitive call to builtin function \code{name} the definition
|
345 |
do a primitive call to builtin function \code{name} the definition
|
| 346 |
and call provided, and carried out in the environment \code{ev}.
|
346 |
and call provided, and carried out in the environment \code{ev}.
|
| 347 |
|
347 |
|
| 348 |
A call to \code{doPrimitiveMethod} is used when the actual method
|
348 |
A call to \code{doPrimitiveMethod} is used when the actual method
|
| 349 |
is a .Primitive. (Because primitives don't behave correctly as
|
349 |
is a .Primitive. (Because primitives don't behave correctly as
|