From roebuck at odin.mdacc.tmc.edu  Wed Jul 27 00:16:49 2005
From: roebuck at odin.mdacc.tmc.edu (Paul Roebuck)
Date: Tue, 26 Jul 2005 17:16:49 -0500 (CDT)
Subject: [Rd] Error registering finalizer
Message-ID: <Pine.OSF.4.58.0507261702310.390023@odin.mdacc.tmc.edu>

What exactly is a reference object? I'm getting this error
message attempting to register a finalizer:

        can only weakly reference/finalize reference objects

I don't see any problem with the code... Here's what appears
to be the relevant portions.


setClass("PDNNObject",
         representation(handle = "externalptr",
                        id     = "character",
                        "VIRTUAL"),
         prototype=list(handle = NULL))
setClass("ProbesetGE",
         representation("PDNNObject"))

----

static void ProbesetGE_finalizer(SEXP vntData)
{
    Rprintf("In ProbesetGE_finalizer()\n");
    /* Deallocate memory of structure fields */
}

static SEXP AllocateProbesetGEPtr(unsigned count)
{
    return R_AllocatePtr(count,
                         sizeof(ProbesetGE_t),
                         ProbesetGETypeTag));
}

SEXP R_PDNN_newProbesetGE(unsigned count)
{
    SEXP vntObj;
    SEXP vntClassDef;
    SEXP vntData;
    SEXP vntAttr;
    SEXP vntHandle;
    unsigned n = 0;

    PROTECT(vntClassDef = MAKE_CLASS(PROBESET_GE_CLASS_NAME)); n++;
    PROTECT(vntObj      = NEW_OBJECT(vntClassDef)); n++;
    PROTECT(vntHandle   = AllocateProbesetGEPtr(count)); n++;
    SET_SLOT(vntObj, HandleSlotSymbol, vntHandle);

    PROTECT(vntData = R_ExternalPtrProtected(vntHandle)); n++;
    PROTECT(vntAttr = NEW_INTEGER(1)); n++;
    INTEGER(vntAttr)[0] = count;
    SET_COUNT(vntData, vntAttr);

>>>>> Problem comes here <<<<<<
    R_RegisterCFinalizer(vntData, (R_CFinalizer_t)ProbesetGE_finalizer);

    UNPROTECT(n);

    return vntObj;
}


Thanks for any pointers...

----------------------------------------------------------
SIGSIG -- signature too long (core dumped)



[Rd] Error registering finalizer
Paul Roebuck