Sun-Solaris-Exacct

 view release on metacpan or  search on metacpan

Exacct.xs  view on Meta::CPAN

	xs_obj->perl_obj = NULL;
	sv_obj = NEWSV(0, 0);
	PERL_ASSERT(sv_obj != NULL);

	/*
	 * Initialise according to the type of the passed exacct object,
	 * and bless the perl object into the appropriate class.
	 */
	if (ea_obj->eo_type == EO_ITEM) {
		if ((ea_obj->eo_catalog & EXT_TYPE_MASK) == EXT_EXACCT_OBJECT) {
			INIT_EMBED_ITEM_FLAGS(xs_obj);
		} else {
			INIT_PLAIN_ITEM_FLAGS(xs_obj);
		}
		sv_setiv(newSVrv(sv_obj, NULL), PTR2IV(xs_obj));
		sv_bless(sv_obj, Sun_Solaris_Exacct_Object_Item_stash);
	} else {
		INIT_GROUP_FLAGS(xs_obj);
		sv_setiv(newSVrv(sv_obj, NULL), PTR2IV(xs_obj));
		sv_bless(sv_obj, Sun_Solaris_Exacct_Object_Group_stash);
	}

Exacct.xs  view on Meta::CPAN

	PERL_ASSERT(sv != NULL);
	xs_obj = INT2PTR(xs_ea_object_t *, SvIV(sv));
	PERL_ASSERT(xs_obj != NULL);
	ea_obj = xs_obj->ea_obj;
	PERL_ASSERT(ea_obj != NULL);

	/* Break any list this object is a part of. */
	ea_obj->eo_next = NULL;

	/* Deal with Items containing embedded Objects. */
	if (IS_EMBED_ITEM(xs_obj)) {
		xs_ea_object_t	*child_xs_obj;
		SV		*perl_obj;
		size_t		bufsz;

		/* Get the underlying perl object an deflate that in turn. */
		perl_obj = xs_obj->perl_obj;
		PERL_ASSERT(perl_obj != NULL);
		deflate_xs_ea_object(perl_obj);
		perl_obj = SvRV(perl_obj);
		PERL_ASSERT(perl_obj != NULL);

Object/Object.xs  view on Meta::CPAN

	if (IS_PLAIN_ITEM(src)) {
		dst->ea_obj = ea_copy_object_tree(src->ea_obj);
		PERL_ASSERT(dst->ea_obj != NULL);
		dst->perl_obj = NULL;

	/*
	 * Otherwise if it is an Item with a perl_obj part, it means that it
	 * must be an Item containing an unpacked nested Object.  In this case
	 * the nested Object can be copied by a recursive call.
	 */
	} else if (IS_EMBED_ITEM(src)) {
		dst->ea_obj = ea_copy_object(src->ea_obj);
		PERL_ASSERT(dst->ea_obj != NULL);
		dst->perl_obj = copy_xs_ea_object(src->perl_obj);

	/*
	 * If we get here it must be a Group, so perl_obj will point to a tied
	 * AV.  We therefore copy the exacct part then create a new tied array
	 * and recursively copy each Item individually.
	 */
	} else {

Object/Object.xs  view on Meta::CPAN

static int
inflate_xs_ea_object(xs_ea_object_t *xs_obj)
{
	ea_object_t	*ea_obj;

	/* Check there is not already a perl_obj part. */
	PERL_ASSERT(xs_obj != NULL);
	PERL_ASSERT(xs_obj->perl_obj == NULL);

	/* Deal with Items containing embedded Objects. */
	if (IS_EMBED_ITEM(xs_obj)) {
		/* unpack & wrap in an xs_ea_object_t. */
		if (ea_unpack_object(&ea_obj, EUP_ALLOC,
		    xs_obj->ea_obj->eo_item.ei_object,
		    xs_obj->ea_obj->eo_item.ei_size) == -1) {
			return (0);
		}
		xs_obj->perl_obj = new_xs_ea_object(ea_obj);

	/* Deal with Groups. */
	} else if (IS_GROUP(xs_obj)) {

Object/Object.xs  view on Meta::CPAN

		 * from the perl_obj part  when required.
		 */
		stash = SvROK(value) ? SvSTASH(SvRV(value)) : NULL;
		if (stash != Sun_Solaris_Exacct_Object_Item_stash &&
		    stash != Sun_Solaris_Exacct_Object_Group_stash) {
			croak("value is not of type " PKGBASE "::Object");
		}
		RETVAL->perl_obj = copy_xs_ea_object(value);
		ea_obj->eo_item.ei_object = NULL;
		ea_obj->eo_item.ei_size = 0;
		INIT_EMBED_ITEM_FLAGS(RETVAL);
		break;
	/*
	 * EXT_NONE is an invalid type,
	 * EXT_GROUP is created by the Group subclass constructor.
	 */
	case EXT_NONE:
	case EXT_GROUP:
	default:
		ea_free(RETVAL->ea_obj, sizeof (RETVAL->ea_obj));
		Safefree(RETVAL);

exacct_common.xh  view on Meta::CPAN

 */
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);



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