Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QueryR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Lopez
QueryR
Commits
576db467
Commit
576db467
authored
9 years ago
by
Lukas Stadler
Browse files
Options
Downloads
Patches
Plain Diff
some more native functions
parent
3395fb8f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
com.oracle.truffle.r.native/fficall/src/common/coerce_fastr.c
+72
-1
72 additions, 1 deletion
...oracle.truffle.r.native/fficall/src/common/coerce_fastr.c
com.oracle.truffle.r.native/fficall/src/common/inlined_fastr.c
+5
-1
5 additions, 1 deletion
...racle.truffle.r.native/fficall/src/common/inlined_fastr.c
with
77 additions
and
2 deletions
com.oracle.truffle.r.native/fficall/src/common/coerce_fastr.c
+
72
−
1
View file @
576db467
...
...
@@ -6,7 +6,7 @@
* Copyright (c) 1995, 1996, 1997 Robert Gentleman and Ross Ihaka
* Copyright (c) 1995-2014, The R Core Team
* Copyright (c) 2002-2008, The R Foundation
* Copyright (c) 2015, Oracle and/or its affiliates
* Copyright (c) 2015,
2016,
Oracle and/or its affiliates
*
* All rights reserved.
*/
...
...
@@ -55,6 +55,77 @@ RealFromInteger(int x, int *warn)
return
x
;
}
int
IntegerFromLogical
(
int
x
,
int
*
warn
)
{
return
(
x
==
NA_LOGICAL
)
?
NA_INTEGER
:
x
;
}
int
IntegerFromReal
(
double
x
,
int
*
warn
)
{
if
(
ISNAN
(
x
))
return
NA_INTEGER
;
else
if
(
x
>
INT_MAX
||
x
<=
INT_MIN
)
{
*
warn
|=
WARN_NA
;
return
NA_INTEGER
;
}
return
(
int
)
x
;
}
static
SEXP
coerceToInteger
(
SEXP
v
)
{
SEXP
ans
;
int
warn
=
0
;
R_xlen_t
i
,
n
;
PROTECT
(
ans
=
allocVector
(
INTSXP
,
n
=
XLENGTH
(
v
)));
#ifdef R_MEMORY_PROFILING
if
(
RTRACE
(
v
)){
memtrace_report
(
v
,
ans
);
SET_RTRACE
(
ans
,
1
);
}
#endif
DUPLICATE_ATTRIB
(
ans
,
v
);
switch
(
TYPEOF
(
v
))
{
case
LGLSXP
:
for
(
i
=
0
;
i
<
n
;
i
++
)
{
// if ((i+1) % NINTERRUPT == 0) R_CheckUserInterrupt();
INTEGER
(
ans
)[
i
]
=
IntegerFromLogical
(
LOGICAL
(
v
)[
i
],
&
warn
);
}
break
;
case
REALSXP
:
for
(
i
=
0
;
i
<
n
;
i
++
)
{
// if ((i+1) % NINTERRUPT == 0) R_CheckUserInterrupt();
INTEGER
(
ans
)[
i
]
=
IntegerFromReal
(
REAL
(
v
)[
i
],
&
warn
);
}
break
;
case
CPLXSXP
:
for
(
i
=
0
;
i
<
n
;
i
++
)
{
// if ((i+1) % NINTERRUPT == 0) R_CheckUserInterrupt();
INTEGER
(
ans
)[
i
]
=
IntegerFromComplex
(
COMPLEX
(
v
)[
i
],
&
warn
);
}
break
;
case
STRSXP
:
for
(
i
=
0
;
i
<
n
;
i
++
)
{
// if ((i+1) % NINTERRUPT == 0) R_CheckUserInterrupt();
INTEGER
(
ans
)[
i
]
=
IntegerFromString
(
STRING_ELT
(
v
,
i
),
&
warn
);
}
break
;
case
RAWSXP
:
for
(
i
=
0
;
i
<
n
;
i
++
)
{
// if ((i+1) % NINTERRUPT == 0) R_CheckUserInterrupt();
INTEGER
(
ans
)[
i
]
=
(
int
)
RAW
(
v
)[
i
];
}
break
;
default:
UNIMPLEMENTED_TYPE
(
"coerceToInteger"
,
v
);
}
if
(
warn
)
CoercionWarning
(
warn
);
UNPROTECT
(
1
);
return
ans
;
}
static
SEXP
coerceToReal
(
SEXP
v
)
{
SEXP
ans
;
...
...
This diff is collapsed.
Click to expand it.
com.oracle.truffle.r.native/fficall/src/common/inlined_fastr.c
+
5
−
1
View file @
576db467
...
...
@@ -6,7 +6,7 @@
* Copyright (c) 1995, 1996, 1997 Robert Gentleman and Ross Ihaka
* Copyright (c) 1995-2014, The R Core Team
* Copyright (c) 2002-2008, The R Foundation
* Copyright (c) 2015, Oracle and/or its affiliates
* Copyright (c) 2015,
2016,
Oracle and/or its affiliates
*
* All rights reserved.
*/
...
...
@@ -540,3 +540,7 @@ INLINE_FUN SEXP R_FixupRHS(SEXP x, SEXP y)
return
y
;
}
Rboolean
IS_BYTES
(
SEXP
x
)
{
return
FALSE
;
}
Rboolean
IS_LATIN1
(
SEXP
x
)
{
return
FALSE
;
}
Rboolean
IS_ASCII
(
SEXP
x
)
{
return
FALSE
;
}
Rboolean
IS_UTF8
(
SEXP
x
)
{
return
TRUE
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment