<commit_before>/*!
 * MPT core library
 *  basic types and definitions
 */

#ifndef _MPT_CORE_H
#define _MPT_CORE_H  @INTERFACE_VERSION@

#include <sys/types.h>
#include <stdint.h>
#include <stdarg.h>

/* localisation makro */
#ifndef MPT_tr
# define MPT_tr(s) (s)
#endif

#ifndef MPT_ABORT
# define MPT_ABORT(t) _mpt_abort(t, __func__, __FILE__, __LINE__)
#endif

#ifdef __cplusplus

# include <ostream>

# if __cplusplus >= 201103L
#  define __MPT_CONST_EXPR constexpr
#  define __MPT_OVERRIDE override
# else
#  define __MPT_CONST_EXPR
#  define __MPT_OVERRIDE
# endif

# if defined(__clang__)
#  define __MPT_CONST_TYPE
# else
#  define __MPT_CONST_TYPE __MPT_CONST_EXPR
# endif

# define __MPT_NAMESPACE_BEGIN namespace mpt {
# define __MPT_NAMESPACE_END   }
# define __MPT_EXTDECL_BEGIN   extern "C" {
# define __MPT_EXTDECL_END     }

# define __MPT_DEFPAR(v) = (v)

# define MPT_INTERFACE(i) class i
# define MPT_STRUCT(s)    struct s
# define MPT_ENUM(e)      e
# define MPT_TYPE(t)      t
# define MPT_ERROR(t)     t
#else
# define MPT_INTERFACE_VPTR(v) struct _mpt_vptr_##v
# define MPT_INTERFACE(i)      struct mpt_##i
# define MPT_STRUCT(s)         struct mpt_##s
# define MPT_ENUM(e)           MPT_##e
# define MPT_TYPE(t)           Mpt##t
# define MPT_ERROR(t)          MPT_ERROR_##t

# define __MPT_DEFPAR(v)

# define __MPT_NAMESPACE_BEGIN
# define __MPT_NAMESPACE_END
# define __MPT_EXTDECL_BEGIN
# define __MPT_EXTDECL_END
#endif

struct iovec;

__MPT_NAMESPACE_BEGIN

MPT_INTERFACE(metatype);
MPT_INTERFACE(iterator);

#define MPT_arrsize(a)        (sizeof(a) / sizeof(*(a)))
#define MPT_align(x)          ((x) + ((sizeof(void *))-1) - (((x)-1)&((sizeof(void *))-1)))
#define MPT_offset(s,e)       ((size_t) &(((MPT_STRUCT(s) *) 0)->e))
#define MPT_baseaddr(t,p,m)   ((MPT_STRUCT(t) *) (((int8_t *) (p)) - MPT_offset(t,m)))

enum MPT_ENUM(Types)
{
	/* system types */
	MPT_ENUM(TypeSocket)    = 0x1,   /* SOH */
	/* system pointer types */
	MPT_ENUM(TypeFile)      = 0x4,   /* EOT */
	MPT_ENUM(TypeAddress)   = 0x5,   /* ENQ */
	
	/* format types (scalar) */
	MPT_ENUM(TypeValFmt)    = 0x8,   /* BS '\b' */
	MPT_ENUM(TypeValue)     = 0x9,   /* HT '\t' */
	MPT_ENUM(TypeProperty)  = 0xa,   /* LF '\n' */
	MPT_ENUM(TypeCommand)   = 0xb,   /* FF '\v' */
	
	/* special pointer types */
	MPT_ENUM(TypeNode)      = 0xc,   /* FF '\f' */
	MPT_ENUM(TypeReplyData) = 0xd,   /* CR '\r' */
	
	/* reserve range for layout types */
#define MPT_value_isLayout(v)  ((v) >= 0x10 && (v) <= 0x1f)
	
	/* reserve ranges for special/format types */
#define MPT_value_isSpecial(v)  (((v) >= 0x20 && (v) <= 0x3f) \
                              || ((v) >= 0x5b && (v) <= 0x5f) \
                              || ((v) >= 0x7b && (v) <= 0x7f))
	/* range for generic base types */
	MPT_ENUM(_TypeVectorBase)    = 0x40,
#define MPT_value_isVector(v)   (MPT_value_fromVector(v) >= 0)
	MPT_ENUM(TypeVector)         = '@',   /* 0x40: generic data */
#define MPT_value_toVector(v)   (MPT_value_isScalar(v) \
                               ? (v) - MPT_ENUM(_TypeScalarBase) + MPT_ENUM(_TypeVectorBase) \
                               : 0)
	MPT_ENUM(_TypeScalarBase)    = 0x60,
	MPT_ENUM(_TypeScalarMax)     = 0x7a,
	MPT_ENUM(_TypeScalarSize)    = MPT_ENUM(_TypeScalarBase) - MPT_ENUM(_TypeVectorBase),
#define MPT_value_isScalar(v)   ((v) & MPT_ENUM(_TypeDynamic) \
                               ? ((v) >= (MPT_ENUM(_TypeDynamic) + MPT_ENUM(_TypeScalarBase)) && (v) < 0x100) \
                               : ((v) > MPT_ENUM(_TypeScalarBase) && (v) <= MPT_ENUM(_TypeScalarMax)))
	
	MPT_ENUM(TypeMeta)           = '`',   /* 0x60: generic type */
	/* scalar types ('a'..'z') */
	MPT_ENUM(TypeArray)          = 'a',   /* array content */
#define MPT_value_fromVector(v) (((v) == MPT_ENUM(TypeVector)) \
                               ? 0 \
                               : (MPT_value_isScalar((v) - MPT_ENUM(_TypeVectorBase) + MPT_ENUM(_TypeScalarBase)) \
                                ? (v) - MPT_ENUM(_TypeVectorBase) + MPT_ENUM(_TypeScalarBase) \
                                : MPT_ERROR(BadType)))
	
#define MPT_value_isBasic(v)  (MPT_value_isScalar(v) \
                            || MPT_value_isVector(v) \
                            || MPT_value_isLayout(v))
	
	/* range for type allocations */
	MPT_ENUM(_TypeDynamic)       = 0x80,
	
	/* config interface types */
	MPT_ENUM(TypeObject)         = 0x80,
	MPT_ENUM(TypeConfig)         = 0x81,
	/* input interface types */
	MPT_ENUM(TypeIterator)       = 0x82,
	MPT_ENUM(TypeSolver)         = 0x83,
	/* output interfaces */
	MPT_ENUM(TypeLogger)         = 0x84,
	MPT_ENUM(TypeReply)          = 0x85,
	MPT_ENUM(TypeOutput)         = 0x86,
	/* range for dynamic interfaces */
	MPT_ENUM(_TypeInterfaceBase) = MPT_ENUM(_TypeDynamic) + 0x10,
	MPT_ENUM(_TypeInterfaceMax)  = MPT_ENUM(_TypeDynamic) + 0x3f,
#define MPT_value_isInterface(v)  ((v) >= MPT_ENUM(_TypeDynamic) \
                                && (v) < MPT_ENUM(_TypeInterfaceMax))
	
	/* range for metatype extensions */
	MPT_ENUM(_TypeMetaBase)      = 0x0100,
	MPT_ENUM(_TypeMetaMax)       = 0x01ff,
#define MPT_value_isMetatype(v)  (((v) == MPT_ENUM(TypeMeta)) \
                               || ((v) >= MPT_ENUM(_TypeMetaBase) && (v) <= (MPT_ENUM(_TypeMetaMax))))
	
	/* range for generic type extensions */
	MPT_ENUM(_TypeGenericBase)   = 0x0200,
	MPT_ENUM(_TypeGenericMax)    = 0x0fff,
	
	/* automatic range types */
	MPT_ENUM(_TypeReferenceBase) = 0x1000,
	MPT_ENUM(_TypeItemBase)      = 0x2000,
	
	/* range for map element types */
	MPT_ENUM(_TypeMapBase)       = 0x4000,
	MPT_ENUM(_TypeMapMax)        = 0x4fff,
	
	MPT_ENUM(_TypeUserMin)       = 0x10000
};

/* tree and list operation flags */
enum MPT_ENUM(TraverseFlags) {
	/* node traverse operations */
	MPT_ENUM(TraverseLeafs)       = 0x00000001,<commit_msg>make solver `other` interface type<commit_after>/*!
 * MPT core library
 *  basic types and definitions
 */

#ifndef _MPT_CORE_H
#define _MPT_CORE_H  @INTERFACE_VERSION@

#include <sys/types.h>
#include <stdint.h>
#include <stdarg.h>

/* localisation makro */
#ifndef MPT_tr
# define MPT_tr(s) (s)
#endif

#ifndef MPT_ABORT
# define MPT_ABORT(t) _mpt_abort(t, __func__, __FILE__, __LINE__)
#endif

#ifdef __cplusplus

# include <ostream>

# if __cplusplus >= 201103L
#  define __MPT_CONST_EXPR constexpr
#  define __MPT_OVERRIDE override
# else
#  define __MPT_CONST_EXPR
#  define __MPT_OVERRIDE
# endif

# if defined(__clang__)
#  define __MPT_CONST_TYPE
# else
#  define __MPT_CONST_TYPE __MPT_CONST_EXPR
# endif

# define __MPT_NAMESPACE_BEGIN namespace mpt {
# define __MPT_NAMESPACE_END   }
# define __MPT_EXTDECL_BEGIN   extern "C" {
# define __MPT_EXTDECL_END     }

# define __MPT_DEFPAR(v) = (v)

# define MPT_INTERFACE(i) class i
# define MPT_STRUCT(s)    struct s
# define MPT_ENUM(e)      e
# define MPT_TYPE(t)      t
# define MPT_ERROR(t)     t
#else
# define MPT_INTERFACE_VPTR(v) struct _mpt_vptr_##v
# define MPT_INTERFACE(i)      struct mpt_##i
# define MPT_STRUCT(s)         struct mpt_##s
# define MPT_ENUM(e)           MPT_##e
# define MPT_TYPE(t)           Mpt##t
# define MPT_ERROR(t)          MPT_ERROR_##t

# define __MPT_DEFPAR(v)

# define __MPT_NAMESPACE_BEGIN
# define __MPT_NAMESPACE_END
# define __MPT_EXTDECL_BEGIN
# define __MPT_EXTDECL_END
#endif

struct iovec;

__MPT_NAMESPACE_BEGIN

MPT_INTERFACE(metatype);
MPT_INTERFACE(iterator);

#define MPT_arrsize(a)        (sizeof(a) / sizeof(*(a)))
#define MPT_align(x)          ((x) + ((sizeof(void *))-1) - (((x)-1)&((sizeof(void *))-1)))
#define MPT_offset(s,e)       ((size_t) &(((MPT_STRUCT(s) *) 0)->e))
#define MPT_baseaddr(t,p,m)   ((MPT_STRUCT(t) *) (((int8_t *) (p)) - MPT_offset(t,m)))

enum MPT_ENUM(Types)
{
	/* system types */
	MPT_ENUM(TypeSocket)    = 0x1,   /* SOH */
	/* system pointer types */
	MPT_ENUM(TypeFile)      = 0x4,   /* EOT */
	MPT_ENUM(TypeAddress)   = 0x5,   /* ENQ */
	
	/* format types (scalar) */
	MPT_ENUM(TypeValFmt)    = 0x8,   /* BS '\b' */
	MPT_ENUM(TypeValue)     = 0x9,   /* HT '\t' */
	MPT_ENUM(TypeProperty)  = 0xa,   /* LF '\n' */
	MPT_ENUM(TypeCommand)   = 0xb,   /* FF '\v' */
	
	/* special pointer types */
	MPT_ENUM(TypeNode)      = 0xc,   /* FF '\f' */
	MPT_ENUM(TypeReplyData) = 0xd,   /* CR '\r' */
	
	/* reserve range for layout types */
#define MPT_value_isLayout(v)  ((v) >= 0x10 && (v) <= 0x1f)
	
	/* reserve ranges for special/format types */
#define MPT_value_isSpecial(v)  (((v) >= 0x20 && (v) <= 0x3f) \
                              || ((v) >= 0x5b && (v) <= 0x5f) \
                              || ((v) >= 0x7b && (v) <= 0x7f))
	/* range for generic base types */
	MPT_ENUM(_TypeVectorBase)    = 0x40,
#define MPT_value_isVector(v)   (MPT_value_fromVector(v) >= 0)
	MPT_ENUM(TypeVector)         = '@',   /* 0x40: generic data */
#define MPT_value_toVector(v)   (MPT_value_isScalar(v) \
                               ? (v) - MPT_ENUM(_TypeScalarBase) + MPT_ENUM(_TypeVectorBase) \
                               : 0)
	MPT_ENUM(_TypeScalarBase)    = 0x60,
	MPT_ENUM(_TypeScalarMax)     = 0x7a,
	MPT_ENUM(_TypeScalarSize)    = MPT_ENUM(_TypeScalarBase) - MPT_ENUM(_TypeVectorBase),
#define MPT_value_isScalar(v)   ((v) & MPT_ENUM(_TypeDynamic) \
                               ? ((v) >= (MPT_ENUM(_TypeDynamic) + MPT_ENUM(_TypeScalarBase)) && (v) < 0x100) \
                               : ((v) > MPT_ENUM(_TypeScalarBase) && (v) <= MPT_ENUM(_TypeScalarMax)))
	
	MPT_ENUM(TypeMeta)           = '`',   /* 0x60: generic type */
	/* scalar types ('a'..'z') */
	MPT_ENUM(TypeArray)          = 'a',   /* array content */
#define MPT_value_fromVector(v) (((v) == MPT_ENUM(TypeVector)) \
                               ? 0 \
                               : (MPT_value_isScalar((v) - MPT_ENUM(_TypeVectorBase) + MPT_ENUM(_TypeScalarBase)) \
                                ? (v) - MPT_ENUM(_TypeVectorBase) + MPT_ENUM(_TypeScalarBase) \
                                : MPT_ERROR(BadType)))
	
#define MPT_value_isBasic(v)  (MPT_value_isScalar(v) \
                            || MPT_value_isVector(v) \
                            || MPT_value_isLayout(v))
	
	/* range for type allocations */
	MPT_ENUM(_TypeDynamic)       = 0x80,
	
	/* config interface types */
	MPT_ENUM(TypeObject)         = 0x80,
	MPT_ENUM(TypeConfig)         = 0x81,
	/* input interface types */
	MPT_ENUM(TypeIterator)       = 0x82,
	/* output interface types */
	MPT_ENUM(TypeLogger)         = 0x84,
	MPT_ENUM(TypeReply)          = 0x85,
	MPT_ENUM(TypeOutput)         = 0x86,
	/* other interface types */
	MPT_ENUM(TypeSolver)         = 0x88,
	/* range for dynamic interfaces */
	MPT_ENUM(_TypeInterfaceBase) = MPT_ENUM(_TypeDynamic) + 0x10,
	MPT_ENUM(_TypeInterfaceMax)  = MPT_ENUM(_TypeDynamic) + 0x3f,
#define MPT_value_isInterface(v)  ((v) >= MPT_ENUM(_TypeDynamic) \
                                && (v) < MPT_ENUM(_TypeInterfaceMax))
	
	/* range for metatype extensions */
	MPT_ENUM(_TypeMetaBase)      = 0x0100,
	MPT_ENUM(_TypeMetaMax)       = 0x01ff,
#define MPT_value_isMetatype(v)  (((v) == MPT_ENUM(TypeMeta)) \
                               || ((v) >= MPT_ENUM(_TypeMetaBase) && (v) <= (MPT_ENUM(_TypeMetaMax))))
	
	/* range for generic type extensions */
	MPT_ENUM(_TypeGenericBase)   = 0x0200,
	MPT_ENUM(_TypeGenericMax)    = 0x0fff,
	
	/* automatic range types */
	MPT_ENUM(_TypeReferenceBase) = 0x1000,
	MPT_ENUM(_TypeItemBase)      = 0x2000,
	
	/* range for map element types */
	MPT_ENUM(_TypeMapBase)       = 0x4000,
	MPT_ENUM(_TypeMapMax)        = 0x4fff,
	
	MPT_ENUM(_TypeUserMin)       = 0x10000
};

/* tree and list operation flags */
enum MPT_ENUM(TraverseFlags) {
	/* node traverse operations */
	MPT_ENUM(TraverseLeafs)       = 0x00000001,
{'fraction_non_alphanumeric': 0.13913340740107683, 'fraction_numerical': 0.02392957866848987, 'mean_word_length': 2.7243793761935073, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5472838', 'n_tokens_mistral': 4721, 'n_tokens_neox': 4582, 'n_words': 809}