Skip to content

Commit

Permalink
Use different namespacing. .ps -> .ark and ark_variables -> `po…
Browse files Browse the repository at this point in the history
…sitron_variables`.
  • Loading branch information
dfalbel committed Oct 9, 2024
1 parent 27b7f02 commit a21dc37
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions crates/ark/src/modules/positron/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#

ark_methods_table <- new.env(parent = emptyenv())
ark_methods_table$ark_variable_display_value <- new.env(parent = emptyenv())
ark_methods_table$ark_variable_display_type <- new.env(parent = emptyenv())
ark_methods_table$ark_variable_has_children <- new.env(parent = emptyenv())
ark_methods_table$ark_variable_kind <- new.env(parent = emptyenv())
ark_methods_table$positron_variable_display_value <- new.env(parent = emptyenv())
ark_methods_table$positron_variable_display_type <- new.env(parent = emptyenv())
ark_methods_table$positron_variable_has_children <- new.env(parent = emptyenv())
ark_methods_table$positron_variable_kind <- new.env(parent = emptyenv())
lockEnvironment(ark_methods_table, TRUE)

#' Register the methods with the Positron runtime
Expand All @@ -18,14 +18,14 @@ lockEnvironment(ark_methods_table, TRUE)
#' @param class Class name as a character
#' @param method A method to be registered. Should be a call object.
#' @export
.ps.register_ark_method <- function(generic, class, method) {
.ark.register_ark_method <- function(generic, class, method) {

This comment has been minimized.

Copy link
@lionel-

lionel- Oct 10, 2024

Contributor

I think this could be .ark.register_method() so that "ark" is not repeated?

stopifnot(
is_string(generic),
generic %in% c(
"ark_variable_display_value",
"ark_variable_display_type",
"ark_variable_has_children",
"ark_variable_kind"
"positron_variable_display_value",
"positron_variable_display_type",
"positron_variable_has_children",
"positron_variable_kind"
),
typeof(class) == "character"
)
Expand Down
10 changes: 5 additions & 5 deletions crates/ark/src/variables/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ use crate::modules::ARK_ENVS;

#[derive(Debug, PartialEq, EnumString, EnumIter, IntoStaticStr, Display, Eq, Hash, Clone)]
pub enum ArkGenerics {
#[strum(serialize = "ark_variable_display_value")]
#[strum(serialize = "positron_variable_display_value")]
VariableDisplayValue,

#[strum(serialize = "ark_variable_display_type")]
#[strum(serialize = "positron_variable_display_type")]
VariableDisplayType,

#[strum(serialize = "ark_variable_has_children")]
#[strum(serialize = "positron_variable_has_children")]
VariableHasChildren,

#[strum(serialize = "ark_variable_kind")]
#[strum(serialize = "positron_variable_kind")]
VariableKind,
}

Expand Down Expand Up @@ -85,7 +85,7 @@ impl ArkGenerics {

pub fn register_method(&self, class: &str, method: RObject) -> anyhow::Result<()> {
let generic_name: &str = self.into();
RFunction::new("", ".ps.register_ark_method")
RFunction::new("", ".ark.register_ark_method")
.add(RObject::try_from(generic_name)?)
.add(RObject::try_from(class)?)
.add(method)
Expand Down
8 changes: 4 additions & 4 deletions crates/ark/src/variables/variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1368,20 +1368,20 @@ mod tests {
// Register the display value method
harp::parse_eval_global(
r#"
.ps.register_ark_method("ark_variable_display_value", "foo", function(x, width) {
.ark.register_ark_method("positron_variable_display_value", "foo", function(x, width) {
# We return a large string and make sure it gets truncated.
paste0(rep("a", length.out = 2*width), collapse="")
})
.ps.register_ark_method("ark_variable_display_type", "foo", function(x, include_length) {
.ark.register_ark_method("positron_variable_display_type", "foo", function(x, include_length) {
paste0("foo (", length(x), ")")
})
.ps.register_ark_method("ark_variable_has_children", "foo", function(x) {
.ark.register_ark_method("positron_variable_has_children", "foo", function(x) {
FALSE
})
.ps.register_ark_method("ark_variable_kind", "foo", function(x) {
.ark.register_ark_method("positron_variable_kind", "foo", function(x) {
"other"
})
Expand Down

0 comments on commit a21dc37

Please sign in to comment.