<commit_before>// TODO
// * free memory when raising

#include "extconf.h"

#include "ruby.h"
/*#include "ruby/st.h"*/
#include "CoreFoundation/CoreFoundation.h"
#include "CoreFoundation/CFStream.h"
#include "CoreFoundation/CFPropertyList.h"

VALUE Xcodeproj = Qnil;


static VALUE
cfstr_to_str(const void *cfstr) {
  long len = (long)CFStringGetLength(cfstr);
  char *buf = (char *)malloc(len+1);
  assert(buf != NULL);
  CFStringGetCString(cfstr, buf, len+1, kCFStringEncodingUTF8);
  register VALUE str = rb_str_new(buf, len);
  free(buf);
  return str;
}

// Coerces to String as well.
static CFStringRef
str_to_cfstr(VALUE str) {
  return CFStringCreateWithCString(NULL, RSTRING_PTR(rb_String(str)), kCFStringEncodingUTF8);
}

/* Generates a UUID. The original version is truncated, so this is not 100%
 * guaranteed to be unique. However, the `PBXObject#generate_uuid` method
 * checks that the UUID does not exist yet, in the project, before using it.
 *
 * @note Meant for internal use only.
 *
 * @return [String] A 24 characters long UUID.<commit_msg>I'm stupid.<commit_after>// TODO
// * free memory when raising

#include "extconf.h"

#include "ruby.h"
#include "ruby/st.h"
#include "CoreFoundation/CoreFoundation.h"
#include "CoreFoundation/CFStream.h"
#include "CoreFoundation/CFPropertyList.h"

VALUE Xcodeproj = Qnil;


static VALUE
cfstr_to_str(const void *cfstr) {
  long len = (long)CFStringGetLength(cfstr);
  char *buf = (char *)malloc(len+1);
  assert(buf != NULL);
  CFStringGetCString(cfstr, buf, len+1, kCFStringEncodingUTF8);
  register VALUE str = rb_str_new(buf, len);
  free(buf);
  return str;
}

// Coerces to String as well.
static CFStringRef
str_to_cfstr(VALUE str) {
  return CFStringCreateWithCString(NULL, RSTRING_PTR(rb_String(str)), kCFStringEncodingUTF8);
}

/* Generates a UUID. The original version is truncated, so this is not 100%
 * guaranteed to be unique. However, the `PBXObject#generate_uuid` method
 * checks that the UUID does not exist yet, in the project, before using it.
 *
 * @note Meant for internal use only.
 *
 * @return [String] A 24 characters long UUID.
{'fraction_non_alphanumeric': 0.11625708884688091, 'fraction_numerical': 0.008506616257088847, 'mean_word_length': 4.864265927977839, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4527469', 'n_tokens_mistral': 737, 'n_tokens_neox': 719, 'n_words': 216}