<commit_before>#ifndef __RUBYMOTION_H_
#define __RUBYMOTION_H_

#include "cocos2d.h"

#if CC_TARGET_OS_IPHONE

#include <objc/runtime.h>
#include "macruby_internal.h"
#include "ruby/intern.h"
#include "ruby/node.h"
#include "ruby/io.h"
#include "id.h"
#include "vm.h"

#define rb_define_method(klass, name, imp, arity) \
    rb_objc_define_method(klass, name, (void *)imp, arity)

#define rb_define_singleton_method(klass, name, imp, arity) \
    rb_define_method(RB_GET_CLASS(klass), name, imp, arity)

#define rb_selector(str) sel_registerName(str)

#define rb_send(rcv, sel, argc, argv) rb_vm_call(rcv, sel, argc, argv)

struct rb_class_ptr {
    VALUE klass;
    VALUE flags;
    void *ptr;
};

static inline
VALUE
rb_class_wrap_new(void *ptr, VALUE klass)
{
    struct rb_class_ptr *obj =
	(struct rb_class_ptr *)class_createInstance((Class)klass,
		sizeof(struct rb_class_ptr));
    assert(obj != NULL);
    obj->klass = klass;
    obj->flags = T_NATIVE;
    obj->ptr = ptr;
    return (VALUE)obj;
}

#define rb_class_wrap_get_ptr(obj) \
    ((struct rb_class_ptr *)obj)->ptr
    
#define rb_retain(obj) (VALUE)rb_objc_retain((void *)obj)
#define rb_release(obj) (VALUE)rb_objc_release((void *)obj)

#define rb_current_block() (VALUE)rb_vm_current_block()
#define rb_block_call(block, argc, argv) \
    rb_vm_block_eval((rb_vm_block_t *)block, argc, argv)

#elif CC_TARGET_OS_ANDROID

#include "runtime.h"

#define NUM2DBL NUM2DOUBLE
#define DBL2NUM DOUBLE2NUM
<commit_msg>iOS c-ext api fixes<commit_after>#ifndef __RUBYMOTION_H_
#define __RUBYMOTION_H_

#include "cocos2d.h"

#if CC_TARGET_OS_IPHONE

#include <objc/runtime.h>
#include "macruby_internal.h"
#include "ruby/intern.h"
#include "ruby/node.h"
#include "ruby/io.h"
#include "id.h"
#include "vm.h"

#define rb_define_method(klass, name, imp, arity) \
    rb_objc_define_method(klass, name, (void *)imp, arity)

#define rb_define_singleton_method(klass, name, imp, arity) \
    rb_define_method(RB_GET_CLASS(klass), name, imp, arity)

#define rb_selector(str) sel_registerName(str)

#define rb_send(rcv, sel, argc, argv) rb_vm_call(rcv, sel, argc, argv)

struct rb_class_ptr {
    VALUE klass;
    VALUE flags;
    void *ptr;
};

static inline
VALUE
rb_class_wrap_new(void *ptr, VALUE klass)
{
    struct rb_class_ptr *obj =
	(struct rb_class_ptr *)class_createInstance((Class)klass,
		sizeof(struct rb_class_ptr));
    assert(obj != NULL);
    obj->klass = klass;
    obj->flags = T_NATIVE;
    obj->ptr = ptr;
    return (VALUE)obj;
}

#define rb_class_wrap_get_ptr(obj) \
    ((struct rb_class_ptr *)obj)->ptr
    
#define rb_retain(obj) \
    ({ \
	VALUE _obj = (VALUE)obj; \
	rb_objc_retain((void *)_obj); \
	_obj; \
    })
#define rb_release(obj) \
    ({ \
	VALUE _obj = (VALUE)obj; \
	rb_objc_release((void *)_obj); \
	_obj; \
    })

#define rb_current_block() \
    ({ \
	VALUE _b = (VALUE)rb_vm_current_block(); \
	_b == 0 ? Qnil : _b; \
    })

#define rb_block_call(block, argc, argv) \
    rb_vm_block_eval((rb_vm_block_t *)block, argc, argv)

#elif CC_TARGET_OS_ANDROID

#include "runtime.h"

#define NUM2DBL NUM2DOUBLE
#define DBL2NUM DOUBLE2NUM

{'fraction_non_alphanumeric': 0.13554987212276215, 'fraction_numerical': 0.003516624040920716, 'mean_word_length': 4.70985401459854, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '6153387', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1283, 'n_words': 257}