| Q B A S E D E C L ( )
| | | | | SOURCE: qdev_macros.txt 1.16 (12/09/2014) English
AMIGA - PUBLIC
----------------------------------------------------------------------------
NAME
QBASEDECL() - In-function (internal) library base decl.
macro.
SYNOPSIS
QBASEDECL(t, b, i...);
QBASEDECL(<type>, <base_name>, [init_value]);
FUNCTION
This macro allows to declare (function private) library
base as cached. When LBS(Local Base Support) is enabled
then this macro assigns proper pointers to so called
main and local bases.
INPUTS
t - Library specific structure/type (struct Library *).
b - Base name/symbol.
i - QBASEPOINTER(xxxBase). Do not pass NULL nor random
pointers!
RETURNS
No output.
BASES
None.
NOTES
If you want to be able to alter jump table of some lib.
at runtime for use in current context only and you need
to cache library bases because they may be unavailable
as globals at some point then use this macro so that
inlines will not reference global symbols.
SEE ALSO
QBASEDECL2(), QBASEASSIGN2(), QBASEASSIGN(),
QBASELOCAL(), QBASEPOINTER(), QBASEJUMPTAB(),
QBASESLOTS(), QBASERESOLVE()
EXAMPLE
#include <qlbs.h> // This must be the first header!
#include <proto/exec.h>
#include <proto/dos.h>
#include <qdev.h>
/*
* Suppose you need to cache DOSBase for some reason.
*/
struct mycache
{
struct DosLibrary *mc_dos;
};
struct mycache *docache(void)
{
struct mycache *mc;
if ((mc =
AllocVec(sizeof(struct mycache), MEMF_PUBLIC)))
{
/*
* You want to cache the alias which is resolvable
* with QBASEPOINTER(). The reason for doing this
* is that it may provide custom jump table.
*/
mc->mc_dos = QBASEPOINTER(DOSBase);
}
return mc;
}
/*
* Then you want to call "dos.library" function using
* that cached base.
*/
LONG Output_cached(struct mycache *mc)
{
/*
* What happens here is that if 'qlbs.h' was included
* then there are two declarations! One is 'DOSBase'
* (main) and the other is 'L_DOSBase' that points at
* redefinable alias which is used in a function call.
*/
QBASEDECL(struct DosLibrary *, DOSBase, mc->mc_dos);
return Output();
}
BUGS
None known.
----------------------------------------------------------------------------
| |
| |