| Line 1... |
Line 1... |
| 1 |
# File src/library/methods/R/is.R
|
1 |
# File src/library/methods/R/is.R
|
| 2 |
# Part of the R package, https://www.R-project.org
|
2 |
# Part of the R package, https://www.R-project.org
|
| 3 |
#
|
3 |
#
|
| 4 |
# Copyright (C) 1995-2015 The R Core Team
|
4 |
# Copyright (C) 1995-2019 The R Core Team
|
| 5 |
#
|
5 |
#
|
| 6 |
# This program is free software; you can redistribute it and/or modify
|
6 |
# This program is free software; you can redistribute it and/or modify
|
| 7 |
# it under the terms of the GNU General Public License as published by
|
7 |
# it under the terms of the GNU General Public License as published by
|
| 8 |
# the Free Software Foundation; either version 2 of the License, or
|
8 |
# the Free Software Foundation; either version 2 of the License, or
|
| 9 |
# (at your option) any later version.
|
9 |
# (at your option) any later version.
|
| Line 170... |
Line 170... |
| 170 |
stop(gettextf("class %s is sealed; new superclasses can not be defined, except by 'setClassUnion'",
|
170 |
stop(gettextf("class %s is sealed; new superclasses can not be defined, except by 'setClassUnion'",
|
| 171 |
dQuote(class1)),
|
171 |
dQuote(class1)),
|
| 172 |
domain = NA)
|
172 |
domain = NA)
|
| 173 |
prevIs <- !identical(possibleExtends(class1, class2,classDef, classDef2),
|
173 |
prevIs <- !identical(possibleExtends(class1, class2,classDef, classDef2),
|
| 174 |
FALSE) # used in checking for previous coerce
|
174 |
FALSE) # used in checking for previous coerce
|
| 175 |
if(is.null(extensionObject))
|
175 |
obj <- if(is.null(extensionObject))
|
| 176 |
obj <- makeExtends(class1, class2, coerce, test, replace, by,
|
176 |
makeExtends(class1, class2, coerce, test, replace, by,
|
| 177 |
classDef1 = classDef, classDef2 = classDef2,
|
177 |
classDef1 = classDef, classDef2 = classDef2,
|
| 178 |
package = getPackageName(where))
|
178 |
package = getPackageName(where))
|
| 179 |
else
|
179 |
else
|
| 180 |
obj <- extensionObject
|
180 |
extensionObject
|
| 181 |
## revise the superclass/subclass info in the stored class definition
|
181 |
## revise the superclass/subclass info in the stored class definition
|
| 182 |
ok <- .validExtends(class1, class2, classDef, classDef2, obj@simple)
|
182 |
ok <- .validExtends(class1, class2, classDef, classDef2, obj@simple)
|
| 183 |
if(!isTRUE(ok))
|
183 |
if(!isTRUE(ok))
|
| 184 |
stop(ok)
|
184 |
stop(ok)
|
| 185 |
where2 <- .findOrCopyClass(class2, classDef2, where, "subclass")
|
185 |
where2 <- .findOrCopyClass(class2, classDef2, where, "subclass")
|
| 186 |
classDef2@subclasses[[class1]] <- obj
|
186 |
classDef2@subclasses[[class1]] <- obj
|
| 187 |
if(doComplete)
|
187 |
if(doComplete)
|
| 188 |
classDef2@subclasses <- completeSubclasses(classDef2, class1, obj, where)
|
188 |
classDef2@subclasses <- completeSubclasses(classDef2, class1, obj, where)
|
| 189 |
## try to provide a valid prototype for virtual classes
|
189 |
## try to provide a valid prototype for virtual classes
|
| Line 193... |
Line 193... |
| 193 |
## prototype is an element of class1 or its prototype if VIRTUAL
|
193 |
## prototype is an element of class1 or its prototype if VIRTUAL
|
| 194 |
if(extends(classDef, "NULL"))
|
194 |
if(extends(classDef, "NULL"))
|
| 195 |
classDef2@prototype <- NULL
|
195 |
classDef2@prototype <- NULL
|
| 196 |
else if(is.null(classDef2@prototype)
|
196 |
else if(is.null(classDef2@prototype)
|
| 197 |
&& is.na(match("NULL", names(classDef2@subclasses)))) {
|
197 |
&& is.na(match("NULL", names(classDef2@subclasses)))) {
|
| - |
|
198 |
classDef2@prototype <-
|
| 198 |
if(classDef@virtual)
|
199 |
if(classDef@virtual)
|
| 199 |
classDef2@prototype <- classDef@prototype
|
200 |
classDef@prototype
|
| 200 |
else # new(), but without intialize(), which may require an arg.
|
201 |
else # new(), but without intialize(), which may require an arg.
|
| 201 |
classDef2@prototype <- .Call(C_new_object, classDef)
|
202 |
.Call(C_new_object, classDef)
|
| 202 |
}
|
203 |
}
|
| 203 |
}
|
204 |
}
|
| 204 |
assignClassDef(class2, classDef2, where2, TRUE)
|
205 |
assignClassDef(class2, classDef2, where2, TRUE)
|
| 205 |
.removePreviousCoerce(class1, class2, where, prevIs)
|
206 |
.removePreviousCoerce(class1, class2, where, prevIs)
|
| 206 |
where1 <- .findOrCopyClass(class1, classDef, where, "superClass")
|
207 |
where1 <- .findOrCopyClass(class1, classDef, where, "superClass")
|
| 207 |
## insert the direct contains information in a valid spot
|
208 |
## insert the direct contains information in a valid spot
|
| 208 |
.newDirectSuperclass(classDef@contains, class2, names(classDef2@contains)) <- obj
|
209 |
.newDirectSuperclass(classDef@contains, class2, names(classDef2@contains)) <- obj
|
| 209 |
if(doComplete) {
|
210 |
if(doComplete) {
|
| 210 |
classDef@contains <- completeExtends(classDef, class2, obj, where = where)
|
211 |
classDef@contains <- completeExtends(classDef, class2, obj, where = where)
|
| - |
|
212 |
## is needed at least during byte compilation of 'methods' itself :
|
| 211 |
if(!is(classDef, "ClassUnionRepresentation")) #unions are handled in assignClassDef
|
213 |
if(!is(classDef, "ClassUnionRepresentation")) #unions are handled in assignClassDef
|
| 212 |
.checkSubclasses(class1, classDef, class2, classDef2, where1, where2)
|
214 |
.checkSubclasses(class1, classDef, class2, classDef2, where1, where2)
|
| 213 |
}
|
215 |
}
|
| 214 |
assignClassDef(class1, classDef, where1, TRUE)
|
216 |
assignClassDef(class1, classDef, where1, TRUE)
|
| 215 |
invisible(classDef)
|
217 |
invisible(classDef)
|