Skip to content

Commit 18b9273

Browse files
committed
resolve merge conflict
Merge branch 'S7_objects' into S7_elements # Conflicts: # NAMESPACE # R/plot-construction.R # R/theme.R # R/zzz.R # man/ggplot_add.Rd # tests/testthat/test-theme.R
2 parents 5797664 + 38ae287 commit 18b9273

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+941
-647
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Collate:
9494
'compat-plyr.R'
9595
'utilities.R'
9696
'aes.R'
97+
'all-classes.R'
9798
'utilities-checks.R'
9899
'legend-draw.R'
99100
'geom-.R'

NAMESPACE

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
# Generated by roxygen2: do not edit by hand
22

33
S3method("$","ggplot2::element")
4+
S3method("$","ggplot2::gg")
5+
S3method("$","ggplot2::theme")
46
S3method("$",ggproto)
57
S3method("$",ggproto_parent)
6-
S3method("$",theme)
78
S3method("$<-","ggplot2::element")
8-
S3method("$<-",uneval)
9-
S3method("+",gg)
9+
S3method("$<-","ggplot2::gg")
10+
S3method("$<-","ggplot2::mapping")
1011
S3method("[","ggplot2::element")
12+
S3method("[","ggplot2::gg")
13+
S3method("[","ggplot2::mapping")
1114
S3method("[",mapped_discrete)
12-
S3method("[",uneval)
1315
S3method("[<-","ggplot2::element")
16+
S3method("[<-","ggplot2::gg")
17+
S3method("[<-","ggplot2::mapping")
1418
S3method("[<-",mapped_discrete)
15-
S3method("[<-",uneval)
1619
S3method("[[","ggplot2::element")
20+
S3method("[[","ggplot2::gg")
1721
S3method("[[",ggproto)
1822
S3method("[[<-","ggplot2::element")
19-
S3method("[[<-",uneval)
23+
S3method("[[<-","ggplot2::gg")
24+
S3method("[[<-","ggplot2::mapping")
2025
S3method(.DollarNames,ggproto)
2126
S3method(as.data.frame,mapped_discrete)
22-
S3method(as.gtable,ggplot)
23-
S3method(as.gtable,ggplot_built)
2427
S3method(as.list,ggproto)
2528
S3method(autolayer,default)
2629
S3method(autoplot,default)
@@ -51,30 +54,7 @@ S3method(fortify,sfg)
5154
S3method(fortify,summary.glht)
5255
S3method(fortify,tbl)
5356
S3method(fortify,tbl_df)
54-
S3method(get_alt_text,ggplot)
55-
S3method(get_alt_text,ggplot_built)
56-
S3method(get_alt_text,gtable)
57-
S3method(ggplot,"function")
58-
S3method(ggplot,default)
59-
S3method(ggplot_add,"NULL")
60-
S3method(ggplot_add,"function")
61-
S3method(ggplot_add,Coord)
62-
S3method(ggplot_add,Facet)
63-
S3method(ggplot_add,Guides)
64-
S3method(ggplot_add,Layer)
65-
S3method(ggplot_add,Scale)
66-
S3method(ggplot_add,by)
67-
S3method(ggplot_add,data.frame)
68-
S3method(ggplot_add,default)
69-
S3method(ggplot_add,labels)
70-
S3method(ggplot_add,list)
71-
S3method(ggplot_add,theme)
72-
S3method(ggplot_add,uneval)
73-
S3method(ggplot_build,ggplot)
74-
S3method(ggplot_build,ggplot_built)
75-
S3method(ggplot_gtable,ggplot_built)
7657
S3method(grid.draw,absoluteGrob)
77-
S3method(grid.draw,ggplot)
7858
S3method(grobHeight,absoluteGrob)
7959
S3method(grobHeight,zeroGrob)
8060
S3method(grobWidth,absoluteGrob)
@@ -99,19 +79,18 @@ S3method(pattern_alpha,GridPattern)
9979
S3method(pattern_alpha,GridTilingPattern)
10080
S3method(pattern_alpha,default)
10181
S3method(pattern_alpha,list)
102-
S3method(plot,ggplot)
10382
S3method(predictdf,default)
10483
S3method(predictdf,glm)
10584
S3method(predictdf,locfit)
10685
S3method(predictdf,loess)
86+
S3method(print,"ggplot2::ggplot")
87+
S3method(print,"ggplot2::mapping")
88+
S3method(print,"ggplot2::theme")
10789
S3method(print,element)
108-
S3method(print,ggplot)
10990
S3method(print,ggplot2_bins)
11091
S3method(print,ggproto)
11192
S3method(print,ggproto_method)
11293
S3method(print,rel)
113-
S3method(print,theme)
114-
S3method(print,uneval)
11594
S3method(scale_type,Date)
11695
S3method(scale_type,POSIXt)
11796
S3method(scale_type,character)
@@ -125,7 +104,6 @@ S3method(scale_type,logical)
125104
S3method(scale_type,numeric)
126105
S3method(scale_type,ordered)
127106
S3method(scale_type,sfc)
128-
S3method(summary,ggplot)
129107
S3method(vec_cast,character.mapped_discrete)
130108
S3method(vec_cast,double.mapped_discrete)
131109
S3method(vec_cast,factor.mapped_discrete)
@@ -304,6 +282,11 @@ export(binned_scale)
304282
export(borders)
305283
export(calc_element)
306284
export(check_device)
285+
export(class_ggplot)
286+
export(class_ggplot_built)
287+
export(class_labels)
288+
export(class_mapping)
289+
export(class_theme)
307290
export(combine_vars)
308291
export(complete_theme)
309292
export(continuous_scale)

R/aes.R

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ NULL
4646
#' 'AsIs' variables.
4747
#'
4848
#' @family aesthetics documentation
49-
#' @return A list with class `uneval`. Components of the list are either
50-
#' quosures or constants.
49+
#' @return An S7 object representing a list with class `mapping`. Components of
50+
#' the list are either quosures or constants.
5151
#' @export
5252
#' @examples
5353
#' aes(x = mpg, y = wt)
@@ -105,13 +105,12 @@ aes <- function(x, y, ...) {
105105
inject(aes(!!!args))
106106
})
107107

108-
aes <- new_aes(args, env = parent.frame())
109-
rename_aes(aes)
108+
class_mapping(rename_aes(args), env = parent.frame())
110109
}
111110

112111
#' @export
113112
#' @rdname is_tests
114-
is_mapping <- function(x) inherits(x, "uneval")
113+
is_mapping <- function(x) S7::S7_inherits(x, class_mapping)
115114

116115
# Wrap symbolic objects in quosures but pull out constants out of
117116
# quosures for backward-compatibility
@@ -130,14 +129,10 @@ new_aesthetic <- function(x, env = globalenv()) {
130129

131130
x
132131
}
133-
new_aes <- function(x, env = globalenv()) {
134-
check_object(x, is.list, "a {.cls list}")
135-
x <- lapply(x, new_aesthetic, env = env)
136-
structure(x, class = "uneval")
137-
}
138132

139133
#' @export
140-
print.uneval <- function(x, ...) {
134+
# TODO: should convert to proper S7 method once bug in S7 is resolved
135+
`print.ggplot2::mapping` <- function(x, ...) {
141136
cat("Aesthetic mapping: \n")
142137

143138
if (length(x) == 0) {
@@ -152,26 +147,24 @@ print.uneval <- function(x, ...) {
152147
invisible(x)
153148
}
154149

150+
# TODO: should convert to proper S7 method once bug in S7 is resolved
155151
#' @export
156-
"[.uneval" <- function(x, i, ...) {
157-
new_aes(NextMethod())
152+
"[.ggplot2::mapping" <- function(x, i, ...) {
153+
class_mapping(NextMethod())
158154
}
159155

160156
# If necessary coerce replacements to quosures for compatibility
161157
#' @export
162-
"[[<-.uneval" <- function(x, i, value) {
163-
new_aes(NextMethod())
158+
"[[<-.ggplot2::mapping" <- function(x, i, value) {
159+
class_mapping(NextMethod())
164160
}
165161
#' @export
166-
"$<-.uneval" <- function(x, i, value) {
167-
# Can't use NextMethod() because of a bug in R 3.1
168-
x <- unclass(x)
169-
x[[i]] <- value
170-
new_aes(x)
162+
"$<-.ggplot2::mapping" <- function(x, i, value) {
163+
class_mapping(NextMethod())
171164
}
172165
#' @export
173-
"[<-.uneval" <- function(x, i, value) {
174-
new_aes(NextMethod())
166+
"[<-.ggplot2::mapping" <- function(x, i, value) {
167+
class_mapping(NextMethod())
175168
}
176169

177170
#' Standardise aesthetic names
@@ -212,8 +205,7 @@ substitute_aes <- function(x, fun = standardise_aes_symbols, ...) {
212205
x <- lapply(x, function(aesthetic) {
213206
as_quosure(fun(quo_get_expr(aesthetic), ...), env = environment(aesthetic))
214207
})
215-
class(x) <- "uneval"
216-
x
208+
class_mapping(x)
217209
}
218210
# x is a quoted expression from inside aes()
219211
standardise_aes_symbols <- function(x) {
@@ -311,7 +303,7 @@ aes_ <- function(x, y, ...) {
311303
}
312304
}
313305
mapping <- lapply(mapping, as_quosure_aes)
314-
structure(rename_aes(mapping), class = "uneval")
306+
class_mapping(rename_aes(mapping))
315307
}
316308

317309
#' @rdname aes_
@@ -337,7 +329,7 @@ aes_string <- function(x, y, ...) {
337329
new_aesthetic(x, env = caller_env)
338330
})
339331

340-
structure(rename_aes(mapping), class = "uneval")
332+
class_mapping(rename_aes(mapping))
341333
}
342334

343335
#' @export
@@ -358,10 +350,9 @@ aes_all <- function(vars) {
358350

359351
# Quosure the symbols in the empty environment because they can only
360352
# refer to the data mask
361-
structure(
362-
lapply(vars, function(x) new_quosure(as.name(x), emptyenv())),
363-
class = c("unlabelled_uneval", "uneval")
364-
)
353+
x <- class_mapping(lapply(vars, function(x) new_quosure(as.name(x), emptyenv())))
354+
class(x) <- union("unlabelled", class(x))
355+
x
365356
}
366357

367358
#' Automatic aesthetic mapping

0 commit comments

Comments
 (0)