@@ -36,17 +36,19 @@ class_scales_list <- S7::new_S3_class("ScalesList")
3636# ' @keywords internal
3737# ' @export
3838class_theme <- S7 :: new_class(
39- " theme " , class_S3_gg ,
39+ " class_theme " , class_S3_gg ,
4040 properties = list (
4141 complete = S7 :: class_logical ,
4242 validate = S7 :: class_logical
4343 ),
4444 constructor = function (elements , complete , validate ) {
45- S7 :: new_object(
45+ out <- S7 :: new_object(
4646 elements ,
4747 complete = complete ,
4848 validate = validate
4949 )
50+ class(out ) <- c(" theme" , class(out ))
51+ out
5052 }
5153)
5254
@@ -61,8 +63,12 @@ class_theme <- S7::new_class(
6163# ' @keywords internal
6264# ' @export
6365class_labels <- S7 :: new_class(
64- " labels" , parent = class_S3_gg ,
65- constructor = function (labels ) S7 :: new_object(labels ),
66+ " class_labels" , parent = class_S3_gg ,
67+ constructor = function (labels ) {
68+ out <- S7 :: new_object(labels )
69+ class(out ) <- c(" labels" , class(out ))
70+ out
71+ },
6672 validator = function (self ) {
6773 if (! is.list(self )) {
6874 return (" labels must be a list." )
@@ -91,12 +97,12 @@ class_labels <- S7::new_class(
9197# ' @keywords internal
9298# ' @export
9399class_mapping <- S7 :: new_class(
94- " mapping " , parent = class_S3_gg ,
100+ " class_mapping " , parent = class_S3_gg ,
95101 constructor = function (x , env = globalenv()) {
96102 check_object(x , is.list , " a {.cls list}" )
97103 x <- lapply(x , new_aesthetic , env = env )
98104 x <- S7 :: new_object(x )
99- class(x ) <- union(c(" ggplot2::mapping" , " uneval" ), class(x ))
105+ class(x ) <- union(c(" ggplot2::mapping" , " uneval" , " mapping " ), class(x ))
100106 x
101107 }
102108)
@@ -125,7 +131,7 @@ class_mapping <- S7::new_class(
125131# ' @keywords internal
126132# ' @export
127133class_ggplot <- S7 :: new_class(
128- name = " ggplot " , parent = class_gg ,
134+ name = " class_ggplot " , parent = class_gg ,
129135 properties = list (
130136 data = S7 :: class_any ,
131137 layers = S7 :: class_list ,
@@ -146,7 +152,7 @@ class_ggplot <- S7::new_class(
146152 facet = facet_null(), layout = NULL ,
147153 labels = labs(), meta = list (),
148154 plot_env = parent.frame()) {
149- S7 :: new_object(
155+ out <- S7 :: new_object(
150156 S7 :: S7_object(),
151157 data = data ,
152158 layers = layers ,
@@ -161,6 +167,8 @@ class_ggplot <- S7::new_class(
161167 meta = meta ,
162168 plot_env = plot_env
163169 )
170+ class(out ) <- c(" ggplot" , class(out ))
171+ out
164172 }
165173)
166174
@@ -179,7 +187,7 @@ class_ggplot <- S7::new_class(
179187# ' @keywords internal
180188# ' @export
181189class_ggplot_built <- S7 :: new_class(
182- " ggplot_built " , parent = class_gg ,
190+ " class_ggplot_built " , parent = class_gg ,
183191 properties = list (
184192 data = S7 :: class_list ,
185193 layout = class_layout ,
@@ -191,9 +199,11 @@ class_ggplot_built <- S7::new_class(
191199 " The {.cls ggplot_built} class should be constructed by {.fn ggplot_build}."
192200 )
193201 }
194- S7 :: new_object(
202+ out <- S7 :: new_object(
195203 S7 :: S7_object(),
196204 data = data , layout = layout , plot = plot
197205 )
206+ class(out ) <- c(" ggplot_built" , class(out ))
207+ out
198208 }
199209)
0 commit comments