<commit_before>/* $Id: rmagick.h,v 1.221 2008/01/17 23:48:19 rmagick Exp $ */
/*=============================================================================
|               Copyright (C) 2008 by <NAME>
| Name:     rmagick.h
| Purpose:  RMagick declarations and definitions
| Author:   <NAME>
\============================================================================*/

#ifndef _RMAGICK_H_
#define _RMAGICK_H_

// Suppress warnings about deprecated functions on Windows
#define _CRT_SECURE_NO_DEPRECATE 1

#include <assert.h>
#include <stdio.h>
#include <ctype.h>
#if defined(HAVE_STDINT_H)
#include <stdint.h>
#endif
#include <stdlib.h>
#include <math.h>
#include <time.h>
#if defined(HAVE_SYS_TYPES_H)
#include <sys/types.h>
#endif
#include "ruby.h"
#include "rubyio.h"


// Undef Ruby's versions of these symbols
#undef PACKAGE_VERSION
#undef PACKAGE_NAME
#undef PACKAGE_STRING
#undef PACKAGE_BUGREPORT
#undef PACKAGE_TARNAME
#undef WORDS_BIGENDIAN

#include "magick/MagickCore.h"

// Undef ImageMagick's versions of these symbols
#undef PACKAGE_STRING


#include "extconf.h"


// For quoting preprocessor symbols
#define Q2(q) #q
#define Q(q) Q2(q)


// Trace new image creation in bang methods
#define UPDATE_DATA_PTR(_obj_, _new_) \
    do { (void) rm_trace_creation(_new_);\
    DATA_PTR(_obj_) = (void *)(_new_);\
    } while(0)


// Handle Quantum <-> Ruby Numeric object conversion
#if (QuantumDepth == 8 || QuantumDepth == 16)
#define QUANTUM2NUM(q) INT2FIX((q))
#define NUM2QUANTUM(n) (Quantum)NUM2UINT((n))
#elif (QuantumDepth == 32)
#define QUANTUM2NUM(q) UINT2NUM((q))
#define NUM2QUANTUM(n) (Quantum)NUM2UINT((n))
#elif (QuantumDepth == 64)
#define QUANTUM2NUM(q) ULL2NUM((q))
#define NUM2QUANTUM(n) (Quantum)NUM2ULL((n))
#else
#error Specified QuantumDepth is not supported.
#endif
// Convert user-supplied objects to Quantum
#define APP2QUANTUM(n) rm_app2quantum((n))

#undef DegreesToRadians     // defined in ImageMagick.h in 6.0.2
#define DegreesToRadians(x) ((x)*3.14159265358979323846/180.0)

#define PIXEL_INTENSITY(q) \
        ((Quantum)(0.299*(q)->red + 0.587*(q)->green + 0.114*(q)->blue + 0.5))

#define LMAX(a,b) ((((long)(a))>((long)(b)))?((long)(a)):((long)(b)))
#define FMAX(a,b) ((((double)(a))>((double)(b)))?((double)(a)):((double)(b)))
#define FMIN(a,b) ((((double)(a))<=((double)(b)))?((double)(a)):((double)(b)))
#define RMAGICK_PI 3.14159265358979
#define ROUND_TO_QUANTUM(value) ((Quantum) ((value) > (Quantum)QuantumRange ? QuantumRange : (value) + 0.5))


// Ruby 1.9.0 changed the name to rb_frame_this_func
#if defined(HAVE_RB_FRAME_THIS_FUNC)
#define THIS_FUNC() rb_frame_this_func()
#else
#define THIS_FUNC() rb_frame_last_func()
#endif

// GetReadFile doesn't exist in Ruby 1.9.0
#if !defined(GetReadFile)
#define GetReadFile(fptr) rb_io_stdio_file(fptr)
#define GetWriteFile(fptr) rb_io_stdio_file(fptr)
#endif

// rb_io_t replaces OpenFile in Ruby 1.9.0
#if defined(HAVE_RB_IO_T)
#undef OpenFile
#define OpenFile rb_io_t
#endif

// These macros are needed in 1.9.0 but aren't defined prior to 1.8.6.
#if !defined(RSTRING_LEN)
#define RSTRING_LEN(s) (RSTRING(s)->len)
#endif
#if !defined(RSTRING_PTR)
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
#endif

// Backport these two macros to 1.8
#if !defined(RARRAY_LEN)
#define RARRAY_LEN(a) RARRAY(a)->len
#endif
#if !defined(RARRAY_PTR)
#define RARRAY_PTR(a) RARRAY(a)->ptr
#endif

// ImageLayerMethod replaced MagickLayerMethod starting with 6.3.6
#if defined(HAVE_TYPE_IMAGELAYERMETHOD)
#define LAYERMETHODTYPE ImageLayerMethod
#define CLASS_LAYERMETHODTYPE Class_ImageLayerMethod
#define LAYERMETHODTYPE_NAME ImageLayerMethod_name
#define LAYERMETHODTYPE_NEW  ImageLayerMethod_new
#else
#define LAYERMETHODTYPE MagickLayerMethod
#define CLASS_LAYERMETHODTYPE Class_MagickLayerMethod
#define LAYERMETHODTYPE_NAME MagickLayerMethod_name
#define LAYERMETHODTYPE_NEW  MagickLayerMethod_new
#endif


typedef ImageInfo Info; // Make type name match class name
typedef PixelPacket Pixel;

// Montage
typedef struct
{
    CompositeOperator compose;
    MontageInfo *info;
} Montage;

// Draw
struct TmpFile_Name<commit_msg>Protect arguments in macros<commit_after>/* $Id: rmagick.h,v 1.222 2008/01/20 21:02:22 rmagick Exp $ */
/*=============================================================================
|               Copyright (C) 2008 by <NAME>
| Name:     rmagick.h
| Purpose:  RMagick declarations and definitions
| Author:   <NAME>
\============================================================================*/

#ifndef _RMAGICK_H_
#define _RMAGICK_H_

// Suppress warnings about deprecated functions on Windows
#define _CRT_SECURE_NO_DEPRECATE 1

#include <assert.h>
#include <stdio.h>
#include <ctype.h>
#if defined(HAVE_STDINT_H)
#include <stdint.h>
#endif
#include <stdlib.h>
#include <math.h>
#include <time.h>
#if defined(HAVE_SYS_TYPES_H)
#include <sys/types.h>
#endif
#include "ruby.h"
#include "rubyio.h"


// Undef Ruby's versions of these symbols
#undef PACKAGE_VERSION
#undef PACKAGE_NAME
#undef PACKAGE_STRING
#undef PACKAGE_BUGREPORT
#undef PACKAGE_TARNAME
#undef WORDS_BIGENDIAN

#include "magick/MagickCore.h"

// Undef ImageMagick's versions of these symbols
#undef PACKAGE_STRING


#include "extconf.h"


// For quoting preprocessor symbols
#define Q2(q) #q
#define Q(q) Q2(q)


// Trace new image creation in bang methods
#define UPDATE_DATA_PTR(_obj_, _new_) \
    do { (void) rm_trace_creation(_new_);\
    DATA_PTR(_obj_) = (void *)(_new_);\
    } while(0)


// Handle Quantum <-> Ruby Numeric object conversion
#if (QuantumDepth == 8 || QuantumDepth == 16)
#define QUANTUM2NUM(q) INT2FIX((q))
#define NUM2QUANTUM(n) (Quantum)NUM2UINT((n))
#elif (QuantumDepth == 32)
#define QUANTUM2NUM(q) UINT2NUM((q))
#define NUM2QUANTUM(n) (Quantum)NUM2UINT((n))
#elif (QuantumDepth == 64)
#define QUANTUM2NUM(q) ULL2NUM((q))
#define NUM2QUANTUM(n) (Quantum)NUM2ULL((n))
#else
#error Specified QuantumDepth is not supported.
#endif
// Convert user-supplied objects to Quantum
#define APP2QUANTUM(n) rm_app2quantum((n))

#undef DegreesToRadians     // defined in ImageMagick.h in 6.0.2
#define DegreesToRadians(x) ((x)*3.14159265358979323846/180.0)

#define PIXEL_INTENSITY(q) \
        ((Quantum)(0.299*(q)->red + 0.587*(q)->green + 0.114*(q)->blue + 0.5))

#define LMAX(a,b) ((((long)(a))>((long)(b)))?((long)(a)):((long)(b)))
#define FMAX(a,b) ((((double)(a))>((double)(b)))?((double)(a)):((double)(b)))
#define FMIN(a,b) ((((double)(a))<=((double)(b)))?((double)(a)):((double)(b)))
#define RMAGICK_PI 3.14159265358979
#define ROUND_TO_QUANTUM(value) ((Quantum) ((value) > (Quantum)QuantumRange ? QuantumRange : (value) + 0.5))


// Ruby 1.9.0 changed the name to rb_frame_this_func
#if defined(HAVE_RB_FRAME_THIS_FUNC)
#define THIS_FUNC() rb_frame_this_func()
#else
#define THIS_FUNC() rb_frame_last_func()
#endif

// GetReadFile doesn't exist in Ruby 1.9.0
#if !defined(GetReadFile)
#define GetReadFile(fptr) rb_io_stdio_file(fptr)
#define GetWriteFile(fptr) rb_io_stdio_file(fptr)
#endif

// rb_io_t replaces OpenFile in Ruby 1.9.0
#if defined(HAVE_RB_IO_T)
#undef OpenFile
#define OpenFile rb_io_t
#endif

// These macros are needed in 1.9.0 but aren't defined prior to 1.8.6.
#if !defined(RSTRING_LEN)
#define RSTRING_LEN(s) (RSTRING((s))->len)
#endif
#if !defined(RSTRING_PTR)
#define RSTRING_PTR(s) (RSTRING((s))->ptr)
#endif

// Backport these two macros to 1.8
#if !defined(RARRAY_LEN)
#define RARRAY_LEN(a) RARRAY((a))->len
#endif
#if !defined(RARRAY_PTR)
#define RARRAY_PTR(a) RARRAY((a))->ptr
#endif

// ImageLayerMethod replaced MagickLayerMethod starting with 6.3.6
#if defined(HAVE_TYPE_IMAGELAYERMETHOD)
#define LAYERMETHODTYPE ImageLayerMethod
#define CLASS_LAYERMETHODTYPE Class_ImageLayerMethod
#define LAYERMETHODTYPE_NAME ImageLayerMethod_name
#define LAYERMETHODTYPE_NEW  ImageLayerMethod_new
#else
#define LAYERMETHODTYPE MagickLayerMethod
#define CLASS_LAYERMETHODTYPE Class_MagickLayerMethod
#define LAYERMETHODTYPE_NAME MagickLayerMethod_name
#define LAYERMETHODTYPE_NEW  MagickLayerMethod_new
#endif


typedef ImageInfo Info; // Make type name match class name
typedef PixelPacket Pixel;

// Montage
typedef struct
{
    CompositeOperator compose;
    MontageInfo *info;
} Montage;

// Draw
struct TmpFile_Name
{'fraction_non_alphanumeric': 0.17284848484848483, 'fraction_numerical': 0.030545454545454546, 'mean_word_length': 6.125215889464594, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 45, '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': '1419351', 'n_tokens_mistral': 3270, 'n_tokens_neox': 2980, 'n_words': 704}