Skip to content

Replace STRING_PTR with STRING_PTR_RO - #1719

Merged
lionel- merged 2 commits into
r-lib:mainfrom
yutannihilation:remove-non-api-STRING_PTR
Jun 27, 2024
Merged

lionel- merged 2 commits into
r-lib:mainfrom
yutannihilation:remove-non-api-STRING_PTR

Conversation

@yutannihilation

@yutannihilation yutannihilation commented Jun 25, 2024 •

Copy link
Copy Markdown
Contributor

This is to fix one of many CRAN Notes related to newly-added "non-API"s.

Version: 1.1.4
Check: compiled code
Result: NOTE
  File ‘rlang/libs/rlang.so’:
    Found non-API calls to R: ‘ENVFLAGS’, ‘FRAME’, ‘HASHTAB’, ‘LEVELS’,
      ‘NAMED’, ‘PRENV’, ‘PRVALUE’, ‘RDEBUG’, ‘R_PromiseExpr’,
      ‘Rf_findVarInFrame3’, ‘SETLENGTH’, ‘SET_BODY’, ‘SET_CLOENV’,
      ‘SET_ENCLOS’, ‘SET_ENVFLAGS’, ‘SET_FORMALS’, ‘SET_GROWABLE_BIT’,
      ‘SET_RDEBUG’, ‘SET_TRUELENGTH’, ‘SET_TYPEOF’, ‘STRING_PTR’,
      ‘XTRUELENGTH’
  
  Compiled code should not call non-API entry points in R.

(https://cran.r-project.org/web/checks/check_results_rlang.html)

Comment thread src/rlang/vec.h Outdated
static inline
r_obj* const * r_chr_cbegin(r_obj* x) {
return (r_obj* const *) STRING_PTR(x);
return (r_obj* const *) STRING_PTR_RO(x);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast is no longer necessary I believe?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks for catching!

Comment thread src/rlang/vec.h
return ((r_obj* const *) STRING_PTR(x));
return ((r_obj* const *) STRING_PTR_RO(x));
#else
return ((r_obj* const *) DATAPTR_RO(x));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I remove the cast in this line for consistency?

@lionel-
lionel- merged commit cebbabf into r-lib:main Jun 27, 2024
@lionel-

lionel- commented Jun 27, 2024

Copy link
Copy Markdown
Member

Thanks!

@yutannihilation
yutannihilation deleted the remove-non-api-STRING_PTR branch June 27, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants