<commit_before>/*
# Licensed Materials - Property of IBM
# Copyright IBM Corp. 2015,2016
*/

/*
 * Internal header file supporting Python
 * for com.ibm.streamsx.topology.
 *
 * This is not part of any public api for
 * the toolkit or toolkit with decorated
 * SPL Python operators.
 */


#ifndef __SPL__SPLPY_H
#define __SPL__SPLPY_H

#include "splpy_general.h"
#include "splpy_setup.h"
#include "splpy_op.h"

#include "Python.h"
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <memory>
#include <dlfcn.h>
#include <TopologySplpyResource.h>

#include <SPL/Runtime/Common/RuntimeException.h>
#include <SPL/Runtime/Type/Meta/BaseType.h>
#include <SPL/Runtime/ProcessingElement/PE.h>
#include <SPL/Runtime/Operator/Port/OperatorPort.h>
#include <SPL/Runtime/Operator/Port/OperatorInputPort.h>
#include <SPL/Runtime/Operator/Port/OperatorOutputPort.h>
#include <SPL/Runtime/Operator/OperatorContext.h>
#include <SPL/Runtime/Operator/Operator.h>


/**
 * Functionality for executing Python within IBM Streams.
 */

#if PY_MAJOR_VERSION == 3
#define TOPOLOGY_PYTHON_LIBNAME "libpython3.5m.so"
#else
#define TOPOLOGY_PYTHON_LIBNAME "libpython2.7.so"
#endif
    
#if PY_MAJOR_VERSION == 3
#define GET_PYTHON_ATTR_FROM_MEMORY(pbytes,psizeb)                       \
     PyMemoryView_FromMemory((char *) pbytes, psizeb, PyBUF_READ);
#else
#define GET_PYTHON_ATTR_FROM_MEMORY(pbytes,psizeb)                       \
     PyBuffer_FromMemory((void *)bytes, sizeb);
#endif

namespace streamsx {
  namespace topology {

    /*
    ** Conversion of Python objects to SPL values.
    */

    /*
    ** Convert to a SPL blob from a Python bytes object.
    */
    inline void pySplValueFromPyObject(SPL::blob & splv, PyObject * value) {
      long int size = PyBytes_Size(value);
      char * bytes = PyBytes_AsString(value);          
      splv.setData((const unsigned char *)bytes, size);
    }

    /*<commit_msg>Remove unused code<commit_after>/*
# Licensed Materials - Property of IBM
# Copyright IBM Corp. 2015,2016
*/

/*
 * Internal header file supporting Python
 * for com.ibm.streamsx.topology.
 *
 * This is not part of any public api for
 * the toolkit or toolkit with decorated
 * SPL Python operators.
 */


#ifndef __SPL__SPLPY_H
#define __SPL__SPLPY_H

#include "splpy_general.h"
#include "splpy_setup.h"
#include "splpy_op.h"

#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <memory>
#include <TopologySplpyResource.h>

#include <SPL/Runtime/Common/RuntimeException.h>
#include <SPL/Runtime/Type/Meta/BaseType.h>
#include <SPL/Runtime/ProcessingElement/PE.h>
#include <SPL/Runtime/Operator/Port/OperatorPort.h>
#include <SPL/Runtime/Operator/Port/OperatorInputPort.h>
#include <SPL/Runtime/Operator/Port/OperatorOutputPort.h>
#include <SPL/Runtime/Operator/OperatorContext.h>
#include <SPL/Runtime/Operator/Operator.h>


/**
 * Functionality for executing Python within IBM Streams.
 */

#if PY_MAJOR_VERSION == 3
#define GET_PYTHON_ATTR_FROM_MEMORY(pbytes,psizeb)                       \
     PyMemoryView_FromMemory((char *) pbytes, psizeb, PyBUF_READ);
#else
#define GET_PYTHON_ATTR_FROM_MEMORY(pbytes,psizeb)                       \
     PyBuffer_FromMemory((void *)bytes, sizeb);
#endif

namespace streamsx {
  namespace topology {

    /*
    ** Conversion of Python objects to SPL values.
    */

    /*
    ** Convert to a SPL blob from a Python bytes object.
    */
    inline void pySplValueFromPyObject(SPL::blob & splv, PyObject * value) {
      long int size = PyBytes_Size(value);
      char * bytes = PyBytes_AsString(value);          
      splv.setData((const unsigned char *)bytes, size);
    }

    /*
{'fraction_non_alphanumeric': 0.11829105473965287, 'fraction_numerical': 0.006141522029372497, 'mean_word_length': 3.7060301507537687, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, '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': '4327646', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1278, 'n_words': 291}