Skip to content

Commit

Permalink
update_display_data()
Browse files Browse the repository at this point in the history
  • Loading branch information
romainfrancois committed Oct 26, 2023
1 parent 46cbcc8 commit 4a68a91
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions share/jupyter/kernels/xr/resources/routines.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ display_data <- function(data = NULL, metadata = NULL) {
invisible(.Call("xeusr_display_data", jsonlite::toJSON(data), jsonlite::toJSON(metadata), PACKAGE = "(embedding)"))
}

update_display_data <- function(data = NULL, metadata = NULL) {
invisible(.Call("xeusr_update_display_data", jsonlite::toJSON(data), jsonlite::toJSON(metadata), PACKAGE = "(embedding)"))
}

kernel_info_request <- function() {
.Call("xeusr_kernel_info_request", PACKAGE = "(embedding)")
}
13 changes: 13 additions & 0 deletions src/routines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ SEXP display_data(SEXP js_data, SEXP js_metadata){
return R_NilValue;
}

SEXP update_display_data(SEXP js_data, SEXP js_metadata){
auto data = nl::json::parse(CHAR(STRING_ELT(js_data, 0)));
auto metadata = nl::json::parse(CHAR(STRING_ELT(js_metadata, 0)));

xeus_r::get_interpreter()->update_display_data(
std::move(data), std::move(metadata), /* transient = */ nl::json::object()
);

return R_NilValue;
}


}

void register_r_routines() {
Expand All @@ -75,6 +87,7 @@ void register_r_routines() {
{"xeusr_publish_execution_error" , (DL_FUNC) &routines::publish_execution_error , 3},
{"xeusr_publish_execution_result", (DL_FUNC) &routines::publish_execution_result, 3},
{"xeusr_display_data" , (DL_FUNC) &routines::display_data , 2},
{"xeusr_update_display_data" , (DL_FUNC) &routines::update_display_data , 2},

{NULL, NULL, 0}
};
Expand Down

0 comments on commit 4a68a91

Please sign in to comment.