<commit_before>var fs = require('fs')
  , requests = JSON.parse(fs.readFileSync('xRequests.json'))
  , structs = JSON.parse(fs.readFileSync('xStructs.json'))
  , typeLookup = JSON.parse(fs.readFileSync('xTypes.json'))
  , jsTypes = typeLookup.xtojs
  , cTypes = typeLookup.xtoc
  , str = ""

function getXCBType(short) {
  return cTypes[short] ? cTypes[short] : ('xcb' + short + '_t') .replace(/[a-z][A-Z]/g, function(rep) {
    return rep[0] + '_' + rep[1]
  }).toLowerCase()
}

function getXCBReqName(short) {
  return ('xcb' + short) .replace(/[a-z][A-Z]/g, function(rep) {
    return rep[0] + '_' + rep[1]
  }).toLowerCase()
}

function prepPropName(propName) {
  return propName in { "class": true, "new": true, "delete": true } ? '_' + propName : propName
}

function getJSType(short,requestName) {
  var type = jsTypes[short]
  if (!type) return console.log("Couldn't find the appropriate V8 type for", short, "for to JS generation:", requestName)
  return type
}

str += "#ifndef __AUTOGENCTOJSXCBREQUESTS__\n"
str += "#define __AUTOGENCTOJSXCBREQUESTS__\n"
str += "#include <v8.h>\n\n"
str += "#include <config.h>\n\n"


str += "//{{{ BEGIN REQUESTS \n\n"
var f = 0;
Object.keys(requests).forEach(function(requestName, f) {
  var request = requests[requestName].field
    , valparam = requests[requestName].valueparam
    , params = []
  if (requests[requestName].list) return //Not handled yet
  str += "void xcbReq" + requestName + "(v8::Handle<v8::Object> obj) {\n"
  str += "\tv8::HandleScope scope;\n"
  if (request) Object.keys(request).forEach(function(propName) {
    var type = getJSType(request[propName], requestName)
    if (!type) return
    params.push(prepPropName(propName))
    str += "\t" + getXCBType(request[propName]) + " " + prepPropName(propName) + " = (" + getXCBType(request[propName])
        +  ") obj->Get(v8::String::New(\"" + propName + "\"))->"
        + type + "Value();\n"
  })
  if (valparam ) {
    var masktype = valparam['value-mask-type']
      , maskname = valparam['value-mask-name']
      , listname = valparam['value-list-name']
      , type = getJSType(masktype, requestName)
    if (!type) return
    if (params.indexOf(maskname) == -1) {
      params.push(maskname)
      str += "\t" + getXCBType(masktype) + " " + maskname + " = (" + getXCBType(masktype)<commit_msg>switch date val to pull from IntegerValue for now<commit_after>var fs = require('fs')
  , requests = JSON.parse(fs.readFileSync('xRequests.json'))
  , structs = JSON.parse(fs.readFileSync('xStructs.json'))
  , typeLookup = JSON.parse(fs.readFileSync('xTypes.json'))
  , jsTypes = typeLookup.xtojs
  , cTypes = typeLookup.xtoc
  , str = ""

function getXCBType(short) {
  return cTypes[short] ? cTypes[short] : ('xcb' + short + '_t') .replace(/[a-z][A-Z]/g, function(rep) {
    return rep[0] + '_' + rep[1]
  }).toLowerCase()
}

function getXCBReqName(short) {
  return ('xcb' + short) .replace(/[a-z][A-Z]/g, function(rep) {
    return rep[0] + '_' + rep[1]
  }).toLowerCase()
}

function prepPropName(propName) {
  return propName in { "class": true, "new": true, "delete": true } ? '_' + propName : propName
}

function getJSType(short,requestName) {
  var type = jsTypes[short]
  if (!type) return console.log("Couldn't find the appropriate V8 type for", short, "for to JS generation:", requestName)
  return type
}

str += "#ifndef __AUTOGENCTOJSXCBREQUESTS__\n"
str += "#define __AUTOGENCTOJSXCBREQUESTS__\n"
str += "#include <v8.h>\n\n"
str += "#include <config.h>\n\n"


str += "//{{{ BEGIN REQUESTS \n\n"
var f = 0;
Object.keys(requests).forEach(function(requestName, f) {
  var request = requests[requestName].field
    , valparam = requests[requestName].valueparam
    , params = []
  if (requests[requestName].list) return console.log('not generating', requestName)//Not handled yet
  str += "void xcbReq" + requestName + "(v8::Handle<v8::Object> obj) {\n"
  str += "\tv8::HandleScope scope;\n"
  if (request) Object.keys(request).forEach(function(propName) {
    var type = getJSType(request[propName], requestName)
    if (!type) return
    params.push(prepPropName(propName))
    str += "\t" + getXCBType(request[propName]) + " " + prepPropName(propName) + " = (" + getXCBType(request[propName])
        +  ") obj->Get(v8::String::New(\"" + propName + "\"))->"
        + (type == 'Date' ? 'Integer' : type) + "Value();\n"
  })
  if (valparam ) {
    var masktype = valparam['value-mask-type']
      , maskname = valparam['value-mask-name']
      , listname = valparam['value-list-name']
      , type = getJSType(masktype, requestName)
    if (!type) return
    if (params.indexOf(maskname) == -1) {
      params.push(maskname)
      str += "\t" + getXCBType(masktype) + " " + maskname + " = (" + getXCBType(masktype)
{'fraction_non_alphanumeric': 0.18354030730372553, 'fraction_numerical': 0.005051568090928225, 'mean_word_length': 3.9707112970711296, 'pattern_counts': {'":': 6, '<': 9, '<?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': '5352848', 'n_tokens_mistral': 1704, 'n_tokens_neox': 1704, 'n_words': 336}