Graphics-MNG
view release on metacpan or search on metacpan
#else
#define _MNG_GET_LASTBACKCHUNK(hndl,red,green,blue,mand) \
(warn("mng_get_lastbackchunk() is not implemented in this version of libmng\n" \
"Please update your version of libmng to at least 1.0.3\n"), \
MNG_FUNCTIONINVALID)
#endif
//==============================================================================
// Min / Max Macros
//==============================================================================
#ifndef min
#define min(x,y) ((x)<(y)?(x):(y))
#endif
#ifndef max
#define max(x,y) ((x)>(y)?(x):(y))
#endif
//==============================================================================
// Convenience Macros
//==============================================================================
// this is used in the typemap file
#define _MNG_GET_HANDLE(arg) (*(hv_fetch((HV*)SvRV((arg)), _MNG_HANDLE, strlen(_MNG_HANDLE), 0)))
// this gives us an element of the hash in the userdata from the MNG handle
// it will create the entry if it doesn't already exist
#define _MNG_GETPRIVATE(hndl,field) (*hv_fetch((HV*)mng_get_userdata(hndl), field, strlen(field), 1))
// this will get us a reference to our object, given the handle
#define _MNG_GETOBJREF(hndl) newRV_inc((SV*)mng_get_userdata(hndl))
// every place that uses this should be changed to construct a PERL array
// in memory and return that array as a reference.
#define CHAR_PTR_CAST(x) ((char*)x)
//==============================================================================
// Macros for writing callback functionality
//==============================================================================
static void my_warn( const char *pat, ... )
{
// do warnings if:
// 1. (PL_dowarn & G_WARN_ALL_OFF) is false and
// 2. (PL_dowarn & G_WARN_ALL_ON) is true or
// 3. ckWARN(warn_category) is true
// bool do_ckWarn_d = ckWARN_d(warn_category);
bool do_ckWarn = ckWARN(warn_category);
bool do_warn = !(PL_dowarn & G_WARN_ALL_OFF) && ( PL_dowarn & G_WARN_ALL_ON || do_ckWarn );
va_list marker;
va_start( marker, pat );
if ( do_warn ) warn(pat, marker);
// warn("Warnings are %s (PL_dowarn=0x%x)(do_ckWarn=%d,do_ckWarn_d=%d)\n", do_warn ? "on":"off", PL_dowarn,do_ckWarn,do_ckWarn_d);
va_end(marker);
}
//==============================================================================
// Macros for writing callback functionality
//==============================================================================
#define VERIFY_CBFN_OR_RETURN( hHandle, error, fnname ) \
SV * cbfn = _MNG_GETPRIVATE(hHandle, fnname); \
\
while ( cbfn != NULL && SvROK(cbfn) ) { cbfn=SvRV(cbfn); } \
\
/* The first case doesn't seem to work. \
The second case is an empirical hack. \
Return if they've assigned 'undef' to the callback function */ \
count = perl_call_sv( cbfn, G_SCALAR ); \
SPAGAIN; \
while (count-- > 0) retval = op; /* eat the return stack */ \
FREETMPS; \
LEAVE; \
// this space intentionally left blank
//==============================================================================
// Function and Macro for writing Perl XS code
//==============================================================================
int check_cbfn( mng_handle hHandle, const char * fnname )
{
VERIFY_CBFN_OR_RETURN( hHandle, 0, fnname );
return 1;
}
int store_cbfn( mng_handle hHandle, const char * fnname, SV *cbfn )
{
RETVAL=mng_setcb_##procname( hHandle, &_mng_##procname ); \
} \
else \
{ \
RETVAL=mng_setcb_##procname( hHandle, NULL ); \
} \
// this space intentionally left blank
//==============================================================================
// Macro to fix NULL return pointers that will be represented as PERL strings
//==============================================================================
// We often make a PERL string by specifying the pointer and length.
// if that length is zero, PERL will go off and call strlen() on the string.
// That's bad. Make sure that PERL gets a NUL terminated empty string in this
// case.
#define FIX_NULL_PTR(ptr,len) \
if ( ptr == NULL || len == 0 ) { \
len = 0; \
((char*)ptr) = "\0\0\0\0"; \
include/libmng.h view on Meta::CPAN
/* * dXxxx = a float * */
/* * pXxxx = a pointer * */
/* * bXxxx = a boolean * */
/* * eXxxx = an enumeration * */
/* * hXxxx = a handle * */
/* * zXxxx = a zero-terminated string (pchar) * */
/* * fXxxx = a pointer to a function (callback) * */
/* * aXxxx = an array * */
/* * sXxxx = a structure * */
/* * * */
/* * Macros & defines are in all uppercase. * */
/* * Functions & typedefs in all lowercase. * */
/* * Exported stuff is prefixed with MNG_ or mng_ respectively. * */
/* * * */
/* * (I may have missed a couple; don't hesitate to let me know!) * */
/* * * */
/* ************************************************************************** */
/* ************************************************************************** */
/* * * */
/* * project : libmng * */
( run in 0.675 second using v1.01-cache-2.11-cpan-49f99fa48dc )