Sun-Solaris-Exacct

 view release on metacpan or  search on metacpan

exacct_common.xh  view on Meta::CPAN

	0))
#define	PERL_ASSERTMSG(EXPR, MSG) ((void)((EXPR) || \
	(croak("%s(%d) %s", __FILE__ __LINE__, MSG), 0), 0))
#else
#define	PERL_ASSERT(EXP)		((void)0)
#define	PERL_ASSERTMSG(EXP, MSG)	((void)0)
#endif

/*
 * Object stash pointers - caching these speeds up the creation and
 * typechecking of perl objects by removing the need to do a hash lookup.
 * The peculiar variable names are so that typemaps can generate the correct
 * package name using the typemap '$Package' variable as the root of the name.
 */
extern HV *Sun_Solaris_Exacct_Catalog_stash;
extern HV *Sun_Solaris_Exacct_File_stash;
extern HV *Sun_Solaris_Exacct_Object_Item_stash;
extern HV *Sun_Solaris_Exacct_Object_Group_stash;
extern HV *Sun_Solaris_Exacct_Object__Array_stash;

/* Populate the stash pointers, provided by Exacct.xs. */
extern void init_stashes(void);

/*
 * Pointer to part of the hash tree built by define_catalog_constants in
 * Catalog.xs.  This is used by catalog_id_str() in Exacct.xs when mapping
 * from a catalog to an id string.
 */
extern HV *IdValueHash;
extern char *catalog_id_str(ea_catalog_t catalog);

/*
 * Structure for holding an ::Exacct::Object.  Different bits of this structure
 * will be populated depending on the type of Object (Item or Group), and on
 * how the Object was created (read from file or by the script).
 *
 * Simple Items
 * Only the ea_obj part is populated, and that points to an ea_object_t
 * that is used to hold the Item.
 *
 * Items containing embedded Objects
 * If an Item of this type has been read from file and has not been accessed,
 * just the ea_obj part will be populated.  If the object has been accessed, or
 * if it has been created from within the script, the perl_obj part will be
 * populated.
 *
 * Groups
 * If a Group has been read from file and has not been accessed, just the
 * ea_obj part will be populated.  If the object has been accessed, or if it has
 * been created from within the script, the perl_obj part will be populated.
 */
typedef struct {
	ea_object_t	*ea_obj;	/* Underlying exacct object. */
	SV		*perl_obj;	/* Underlying perl object. */
	uchar_t		flags;		/* Object type and status. */
} xs_ea_object_t;

/* Macros for manipulating flag bits. */
#define	TYPE_MASK	0x03
#define	PLAIN_ITEM	0x00
#define	EMBED_ITEM	0x01
#define	GROUP		0x02

#define	GET_TYPE_BITS(X)	((X)->flags & TYPE_MASK)
#define	SET_TYPE_BITS(X, Y)	((X)->flags = (((X)->flags & ~TYPE_MASK) | Y)
#define	SET_PLAIN_ITEM(X)	(SET_TYPE_BITS(X, PLAIN_ITEM))
#define	SET_EMBED_ITEM(X)	(SET_TYPE_BITS(X, EMBED_ITEM))
#define	SET_GROUP(X)		(SET_TYPE_BITS(X, GROUP))
#define	IS_ITEM(X)		(GET_TYPE_BITS(X) < GROUP)
#define	IS_PLAIN_ITEM(X)	(GET_TYPE_BITS(X) == PLAIN_ITEM)
#define	IS_EMBED_ITEM(X)	(GET_TYPE_BITS(X) == EMBED_ITEM)
#define	IS_GROUP(X)		(GET_TYPE_BITS(X) == GROUP)

#define	INIT_PLAIN_ITEM_FLAGS(X)	((X)->flags = PLAIN_ITEM)
#define	INIT_EMBED_ITEM_FLAGS(X)	((X)->flags = EMBED_ITEM)
#define	INIT_GROUP_FLAGS(X)		((X)->flags = GROUP)

/* Fast way to make catalog objects, provided by Exacct.xs. */
extern SV *new_catalog(ea_catalog_t cat);

/* Return the integer catalog value from the passed object or SV. */
extern ea_catalog_t catalog_value(SV *catalog);

/* Fast way to make exacct objects, provided by Exacct.xs. */
extern SV *new_xs_ea_object(ea_object_t *obj);

/* Deflate an xs_ea_object, provided by Exacct.xs. */
extern ea_object_t *deflate_xs_ea_object(SV *sv);

/*
 * Structure and associated function for creating perl constants
 * and populating @_Constants, used for constant lookup by the modules.
 * See Exacct.xs for the definition of define_constants().
 */
typedef enum { other = 0, type, catlg, id } consttype_t;
typedef struct {
	const char		*name;
	const int		len;
	const consttype_t	consttype;
	const unsigned int	value;
} constval_t;
extern void define_constants(const char *pkg, constval_t *dvp);

#endif	/* _EXACCT_COMMON_H */



( run in 0.586 second using v1.01-cache-2.11-cpan-71847e10f99 )