\HeaderA{getCallingDLL}{Compute DLL for Native Interface Call}{getCallingDLL}
\aliasA{getCallingDLLe}{getCallingDLL}{getCallingDLLe}
\keyword{internal}{getCallingDLL}
\begin{Description}\relax
This is an internal function that is called from \R's C code to
determine the enclosing name space of a
\code{.C}/\code{.Call}/\code{.Fortran}/\code{.External} call which has
no \code{PACKAGE} argument. If the call has been made from a function
within a name space, then we can find the DLL associated with that
name space. The purpose of this is to avoid having to use the
\code{PACKAGE} argument in these native calls and so better support
versions of packages.

This is an internal function that may be migrated to internal C
code in the future and so should not be used by \R{} programmers.
\end{Description}
\begin{Usage}
\begin{verbatim}
getCallingDLL(f = sys.function(-1), doStop = FALSE)
getCallingDLLe(e)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{f}] the function whose name space and DLL are to be found.
By default, this is the current function being called which
is the one in which the native routine is being invoked.
\item[\code{doStop}] a logical value indicating whether failure to find
a name space and/or DLL is an error (\code{TRUE}) or not
(\code{FALSE}).  The default is \code{FALSE} so that when this is
called because there is no \code{PACKAGE} argument in a
\code{\LinkA{.C}{.C}}, \code{\LinkA{.Call}{.Call}}, \code{\LinkA{.Fortran}{.Fortran}},
\code{\LinkA{.External}{.External}} call,  no error occurs and the regular lookup
is performed by searching all DLLs in order.
\item[\code{e}] an environment.
\end{ldescription}
\end{Arguments}
\begin{SeeAlso}\relax
\code{\LinkA{.C}{.C}},
\code{\LinkA{.Call}{.Call}},
\code{\LinkA{.Fortran}{.Fortran}},
\code{\LinkA{.External}{.External}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
if(exists("ansari.test"))
   getCallingDLL(ansari.test)
\end{ExampleCode}
\end{Examples}

