<commit_before>#include "csoundCore.h"
#include "csound_standard_types.h" 
#include "pstream.h"
#include <stdlib.h>

//#define Wfloats (((int) sizeof(SPECDAT) + 7) / (int) sizeof(MYFLT))
//#define Pfloats (((int) sizeof(PVSDAT) + 7) / (int) sizeof(MYFLT))

void updateAsigMemBlock(void* csound, CS_VARIABLE* var) {
    CSOUND* cs = (CSOUND*)csound;
    int ksmps = cs->ksmps;    
    var->memBlockSize = ksmps * sizeof (MYFLT);
}

CS_VARIABLE* createAsig(void* cs, void* p) {
    int ksmps;
    CSOUND* csound = (CSOUND*)cs;
    
    //FIXME - this needs to take into account local ksmps, once context work is complete
//    if(instr != NULL) {
//      OPDS* p = (OPDS*)instr;
//      ksmps = CS_KSMPS;
//    } else {
      ksmps = csound->ksmps;
//    }
    
    CS_VARIABLE* var = mcalloc(cs, sizeof (CS_VARIABLE));
    var->memBlockSize = ksmps * sizeof (MYFLT);
    var->updateMemBlockSize = &updateAsigMemBlock;

    return var;
}

CS_VARIABLE* createMyflt(void* csound, void* p) {
    CSOUND* cs = (CSOUND*)csound;    
    CS_VARIABLE* var = mcalloc(cs, sizeof (CS_VARIABLE));
    var->memBlockSize = sizeof (MYFLT);
    return var;
}

CS_VARIABLE* createBool(void* csound, void* p) {
    CSOUND* cs = (CSOUND*)csound;    
    CS_VARIABLE* var = mcalloc(cs, sizeof (CS_VARIABLE));
    var->memBlockSize = sizeof (MYFLT);
    return var;
}

CS_VARIABLE* createWsig(void* csound, void* p) {
    CSOUND* cs = (CSOUND*)csound;    
    CS_VARIABLE* var = mcalloc(cs, sizeof (CS_VARIABLE));
    var->memBlockSize = sizeof(SPECDAT);
    return var;
}

CS_VARIABLE* createFsig(void* csound, void* p) {
    CSOUND* cs = (CSOUND*)csound;    
    CS_VARIABLE* var = mcalloc(cs, sizeof (CS_VARIABLE));
    var->memBlockSize = sizeof(PVSDAT);
    return var;
}

void arrayInitMemory(CS_VARIABLE* var, MYFLT* memblock) {
    ARRAYDAT* dat = (ARRAYDAT*)memblock;
    dat->arrayType = var->subType;
}

CS_VARIABLE* createArray(void* csound, void* p) {
    CSOUND* cs = (CSOUND*)csound;
    ARRAY_VAR_INIT* state = (ARRAY_VAR_INIT*)p;
    
    CS_TYPE* type = state->type;
    CS_VARIABLE* var = mcalloc(cs, sizeof (CS_VARIABLE));
    var->memBlockSize = sizeof(ARRAYDAT);
    var->subType = type;
    var->initializeVariableMemory = &arrayInitMemory;
    var->dimensions = state->dimensions;
    return var; 
}


//#define ARGTYP_S        0x00000040L     /* string constant or variable */
//#define ARGTYP_l        0x00000800L     /* label */

const CS_TYPE CS_VAR_TYPE_A = {
  "a", "audio rate vector", CS_ARG_TYPE_BOTH, createAsig, NULL
};

const CS_TYPE CS_VAR_TYPE_K = {
  "k", "control rate var", CS_ARG_TYPE_BOTH, createMyflt, NULL
};

const CS_TYPE CS_VAR_TYPE_I = {
  "i", "init time var", CS_ARG_TYPE_BOTH, createMyflt, NULL
};

const CS_TYPE CS_VAR_TYPE_S = {
    "S", "String var", CS_ARG_TYPE_BOTH, createMyflt, NULL
};

const CS_TYPE CS_VAR_TYPE_P = {<commit_msg>fixed issue with Strings not allocating enough space<commit_after>#include "csoundCore.h"
#include "csound_standard_types.h" 
#include "pstream.h"
#include <stdlib.h>

//#define Wfloats (((int) sizeof(SPECDAT) + 7) / (int) sizeof(MYFLT))
//#define Pfloats (((int) sizeof(PVSDAT) + 7) / (int) sizeof(MYFLT))

void updateAsigMemBlock(void* csound, CS_VARIABLE* var) {
    CSOUND* cs = (CSOUND*)csound;
    int ksmps = cs->ksmps;    
    var->memBlockSize = ksmps * sizeof (MYFLT);
}

CS_VARIABLE* createAsig(void* cs, void* p) {
    int ksmps;
    CSOUND* csound = (CSOUND*)cs;
    
    //FIXME - this needs to take into account local ksmps, once context work is complete
//    if(instr != NULL) {
//      OPDS* p = (OPDS*)instr;
//      ksmps = CS_KSMPS;
//    } else {
      ksmps = csound->ksmps;
//    }
    
    CS_VARIABLE* var = mcalloc(cs, sizeof (CS_VARIABLE));
    var->memBlockSize = ksmps * sizeof (MYFLT);
    var->updateMemBlockSize = &updateAsigMemBlock;

    return var;
}

CS_VARIABLE* createMyflt(void* csound, void* p) {
    CSOUND* cs = (CSOUND*)csound;    
    CS_VARIABLE* var = mcalloc(cs, sizeof (CS_VARIABLE));
    var->memBlockSize = sizeof (MYFLT);
    return var;
}

CS_VARIABLE* createBool(void* csound, void* p) {
    CSOUND* cs = (CSOUND*)csound;    
    CS_VARIABLE* var = mcalloc(cs, sizeof (CS_VARIABLE));
    var->memBlockSize = sizeof (MYFLT);
    return var;
}

CS_VARIABLE* createWsig(void* csound, void* p) {
    CSOUND* cs = (CSOUND*)csound;    
    CS_VARIABLE* var = mcalloc(cs, sizeof (CS_VARIABLE));
    var->memBlockSize = sizeof(SPECDAT);
    return var;
}

CS_VARIABLE* createFsig(void* csound, void* p) {
    CSOUND* cs = (CSOUND*)csound;    
    CS_VARIABLE* var = mcalloc(cs, sizeof (CS_VARIABLE));
    var->memBlockSize = sizeof(PVSDAT);
    return var;
}

void arrayInitMemory(CS_VARIABLE* var, MYFLT* memblock) {
    ARRAYDAT* dat = (ARRAYDAT*)memblock;
    dat->arrayType = var->subType;
}

CS_VARIABLE* createString(void* csound, void* p) {
    CSOUND* cs = (CSOUND*)csound;
    CS_VARIABLE* var = mcalloc(cs, sizeof (CS_VARIABLE));
    var->memBlockSize = sizeof (MYFLT) * 256;
    return var;
}

CS_VARIABLE* createArray(void* csound, void* p) {
    CSOUND* cs = (CSOUND*)csound;
    ARRAY_VAR_INIT* state = (ARRAY_VAR_INIT*)p;
    
    CS_TYPE* type = state->type;
    CS_VARIABLE* var = mcalloc(cs, sizeof (CS_VARIABLE));
    var->memBlockSize = sizeof(ARRAYDAT);
    var->subType = type;
    var->initializeVariableMemory = &arrayInitMemory;
    var->dimensions = state->dimensions;
    return var; 
}


//#define ARGTYP_S        0x00000040L     /* string constant or variable */
//#define ARGTYP_l        0x00000800L     /* label */

const CS_TYPE CS_VAR_TYPE_A = {
  "a", "audio rate vector", CS_ARG_TYPE_BOTH, createAsig, NULL
};

const CS_TYPE CS_VAR_TYPE_K = {
  "k", "control rate var", CS_ARG_TYPE_BOTH, createMyflt, NULL
};

const CS_TYPE CS_VAR_TYPE_I = {
  "i", "init time var", CS_ARG_TYPE_BOTH, createMyflt, NULL
};

const CS_TYPE CS_VAR_TYPE_S = {
    "S", "String var", CS_ARG_TYPE_BOTH, createString, NULL
};

const CS_TYPE CS_VAR_TYPE_P = {
{'fraction_non_alphanumeric': 0.1391304347826087, 'fraction_numerical': 0.0071906354515050164, 'mean_word_length': 3.5276305828917485, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 40, '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': '2949953', 'n_tokens_mistral': 2420, 'n_tokens_neox': 2330, 'n_words': 518}