<commit_before>// v8
#include <v8.h>

// node
#include <node.h>
#include <node_buffer.h>
#include <node_version.h>

/* dlopen(), dlsym() */
#include <dlfcn.h> 

// mapnik
#include <mapnik/map.hpp>
#include <mapnik/projection.hpp>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/font_engine_freetype.hpp>
#include <mapnik/agg_renderer.hpp>
#include <mapnik/filter_factory.hpp>
#include <mapnik/color_factory.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/config_error.hpp>
#include <mapnik/load_map.hpp>
#include <mapnik/query.hpp>
#include <mapnik/filter_featureset.hpp>
#include <mapnik/hit_test_filter.hpp>
#include <mapnik/memory_datasource.hpp>
#include <mapnik/memory_featureset.hpp>
#include <mapnik/version.hpp>

//#ifdef MAPNIK_THREADSAFE
//#include <boost/thread/mutex.hpp>
//#endif

#if MAPNIK_VERSION >= 800
   #include <mapnik/box2d.hpp>
   #define Image32 image_32
   #define ImageData32 image_data_32
   #define Envelope box2d
#else
   #include <mapnik/envelope.hpp>
   #define get_current_extent getCurrentExtent
   #define width getWidth
   #define height getHeight
   #define zoom_to_box zoomToBox
   #define image_32 Image32
   #define image_data_32 ImageData32
   #define box2d Envelope
   #define layer Layer
   #define set_background setBackground
#endif

using namespace node;
using namespace v8;

#define TOSTR(obj) (*String::Utf8Value((obj)->ToString()))

#define FUNCTION_ARG(I, VAR)                                            \
  if (args.Length() <= (I) || !args[I]->IsFunction())                   \
    return ThrowException(Exception::TypeError(                         \
                  String::New("Argument " #I " must be a function")));  \
  Local<Function> VAR = Local<Function>::Cast(args[I]);

class Map: ObjectWrap
{
private:
  mapnik::Map* map_;
public:

  static Persistent<FunctionTemplate> m_template;
  static void Init(Handle<Object> target)
  {
    HandleScope scope;

    Local<FunctionTemplate> t = FunctionTemplate::New(NewMap);

    m_template = Persistent<FunctionTemplate>::New(t);
    m_template->InstanceTemplate()->SetInternalFieldCount(1);
    m_template->SetClassName(String::NewSymbol("Map"));

    NODE_SET_PROTOTYPE_METHOD(m_template, "load", load);
    NODE_SET_PROTOTYPE_METHOD(m_template, "resize", resize);
    NODE_SET_PROTOTYPE_METHOD(m_template, "buffer_size", buffer_size);<commit_msg>use boost::shared_ptr to manage map instance<commit_after>// v8
#include <v8.h>

// node
#include <node.h>
#include <node_buffer.h>
#include <node_version.h>

/* dlopen(), dlsym() */
#include <dlfcn.h> 

// mapnik
#include <mapnik/map.hpp>
#include <mapnik/projection.hpp>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/font_engine_freetype.hpp>
#include <mapnik/agg_renderer.hpp>
#include <mapnik/filter_factory.hpp>
#include <mapnik/color_factory.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/config_error.hpp>
#include <mapnik/load_map.hpp>
#include <mapnik/query.hpp>
#include <mapnik/filter_featureset.hpp>
#include <mapnik/hit_test_filter.hpp>
#include <mapnik/memory_datasource.hpp>
#include <mapnik/memory_featureset.hpp>
#include <mapnik/version.hpp>

// boost
#include <boost/shared_ptr.hpp>

//#ifdef MAPNIK_THREADSAFE
//#include <boost/thread/mutex.hpp>
//#endif

#if MAPNIK_VERSION >= 800
   #include <mapnik/box2d.hpp>
   #define Image32 image_32
   #define ImageData32 image_data_32
   #define Envelope box2d
#else
   #include <mapnik/envelope.hpp>
   #define get_current_extent getCurrentExtent
   #define width getWidth
   #define height getHeight
   #define zoom_to_box zoomToBox
   #define image_32 Image32
   #define image_data_32 ImageData32
   #define box2d Envelope
   #define layer Layer
   #define set_background setBackground
#endif

using namespace node;
using namespace v8;

#define TOSTR(obj) (*String::Utf8Value((obj)->ToString()))

#define FUNCTION_ARG(I, VAR)                                            \
  if (args.Length() <= (I) || !args[I]->IsFunction())                   \
    return ThrowException(Exception::TypeError(                         \
                  String::New("Argument " #I " must be a function")));  \
  Local<Function> VAR = Local<Function>::Cast(args[I]);

typedef boost::shared_ptr<mapnik::Map> map_ptr;

class Map: ObjectWrap
{
private:
  map_ptr map_;
public:

  static Persistent<FunctionTemplate> m_template;
  static void Init(Handle<Object> target)
  {
    HandleScope scope;

    Local<FunctionTemplate> t = FunctionTemplate::New(NewMap);

    m_template = Persistent<FunctionTemplate>::New(t);
    m_template->InstanceTemplate()->SetInternalFieldCount(1);
    m_template->SetClassName(String::NewSymbol("Map"));

    NODE_SET_PROTOTYPE_METHOD(m_template, "load", load);
    NODE_SET_PROTOTYPE_METHOD(m_template, "resize", resize);
    NODE_SET_PROTOTYPE_METHOD(m_template, "buffer_size", buffer_size);
{'fraction_non_alphanumeric': 0.1282684784846613, 'fraction_numerical': 0.011117974058060531, 'mean_word_length': 4.286180631120783, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1493921', 'n_tokens_mistral': 1678, 'n_tokens_neox': 1617, 'n_words': 324}