<commit_before>// @(#)root/pyroot:$Id$
// Author: <NAME>, Jan 2005

// Bindings
#include "PyROOT.h"
#include "PyStrings.h"
#include "ObjectProxy.h"
#include "Utility.h"

// ROOT
#include "TObject.h"
#include "TBufferFile.h"      // for pickling


//- data _______________________________________________________________________
R__EXTERN PyObject* gRootModule;

//____________________________________________________________________________
void PyROOT::op_dealloc_nofree( ObjectProxy* pyobj ) {
// Destroy the held C++ object, if owned; does not deallocate the proxy.
   if ( pyobj->fObject && ( pyobj->fFlags & ObjectProxy::kIsOwner ) ) {
      if ( ! (pyobj->fFlags & ObjectProxy::kIsValue) )
         pyobj->ObjectIsA()->Destructor( pyobj->fObject );
      else {
      // CLING WORKAROUND this dtor call should not be needed
         void* ptr = ((TInterpreterValue*)pyobj->fObject)->GetAsPointer();
         pyobj->ObjectIsA()->Destructor( ptr, kTRUE );
      // -- CLING WORKAROUND
         delete (TInterpreterValue*)pyobj->fObject;
      }
   } else if ( pyobj->fFlags & ObjectProxy::kIsValue )
      delete (TInterpreterValue*)pyobj->fObject;
   pyobj->fObject = NULL;
}


//____________________________________________________________________________
namespace PyROOT {

namespace {

//= PyROOT object proxy null-ness checking ===================================
   PyObject* op_nonzero( ObjectProxy* self )
   {
   // Null of the proxy is determined by null-ness of the held C++ object.
      PyObject* result = self->GetObject() ? Py_True : Py_False;
      Py_INCREF( result );
      return result;
   }


//= PyROOT object proxy pickle support =======================================
   PyObject* op_reduce( ObjectProxy* self )
   {
   // Turn the object proxy instance into a character stream and return for
   // pickle, together with the callable object that can restore the stream
   // into the object proxy instance.<commit_msg>From Wim: prevent the dtor from being called, now that StoredValue does it.<commit_after>// @(#)root/pyroot:$Id$
// Author: <NAME>, Jan 2005

// Bindings
#include "PyROOT.h"
#include "PyStrings.h"
#include "ObjectProxy.h"
#include "Utility.h"

// ROOT
#include "TObject.h"
#include "TBufferFile.h"      // for pickling


//- data _______________________________________________________________________
R__EXTERN PyObject* gRootModule;

//____________________________________________________________________________
void PyROOT::op_dealloc_nofree( ObjectProxy* pyobj ) {
// Destroy the held C++ object, if owned; does not deallocate the proxy.
   if ( pyobj->fObject && ( pyobj->fFlags & ObjectProxy::kIsOwner ) ) {
      if ( ! (pyobj->fFlags & ObjectProxy::kIsValue) )
         pyobj->ObjectIsA()->Destructor( pyobj->fObject );
      else
         delete (TInterpreterValue*)pyobj->fObject;
   } else if ( pyobj->fFlags & ObjectProxy::kIsValue )
      delete (TInterpreterValue*)pyobj->fObject;
   pyobj->fObject = NULL;
}


//____________________________________________________________________________
namespace PyROOT {

namespace {

//= PyROOT object proxy null-ness checking ===================================
   PyObject* op_nonzero( ObjectProxy* self )
   {
   // Null of the proxy is determined by null-ness of the held C++ object.
      PyObject* result = self->GetObject() ? Py_True : Py_False;
      Py_INCREF( result );
      return result;
   }


//= PyROOT object proxy pickle support =======================================
   PyObject* op_reduce( ObjectProxy* self )
   {
   // Turn the object proxy instance into a character stream and return for
   // pickle, together with the callable object that can restore the stream
   // into the object proxy instance.
{'fraction_non_alphanumeric': 0.14462033807351757, 'fraction_numerical': 0.0021464985242822645, 'mean_word_length': 3.8795811518324608, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4105023', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1027, 'n_words': 294}