<commit_before>/* 
 * jcom.dataspace
 * External for Jamoma: map input to output: y=f(x)
 * Copyright © 2007
 * 
 * License: This code is licensed under the terms of the "New BSD License"
 * http://creativecommons.org/licenses/BSD/
 */

#include "TTClassWrapperMax.h"


// Data Structure for this object
typedef struct _dataspace{
	Object			ob;
	TTPtr			outlet_native;
	TTObjectPtr		dataspace;
	SymbolPtr		attr_dataspace;			// name of the dataspace -- e.g. "temperature"
	SymbolPtr		attr_dataspace_active;	// name of the current unit within the dataspace -- e.g. "celsius"
	SymbolPtr		attr_dataspace_native;	// name of the desired native unit within the dataspace -- e.g. "celsius"
} t_dataspace;


// Prototypes for methods
void*		dataspace_new(t_symbol *name, long argc, t_atom *argv);
void		dataspace_free(t_dataspace *self);
void		dataspace_assist(t_dataspace *self, void *b, long m, long a, char *s);
void		dataspace_int(t_dataspace *self, long x);
void		dataspace_float(t_dataspace *self, double x);
void		dataspace_list(t_dataspace *self, t_symbol *msg, long argc, t_atom *argv);
void		dataspace_getDataspaces(t_dataspace *self);
void		dataspace_getUnits(t_dataspace *self);
t_max_err	dataspace_setDataspace(t_dataspace *self, void *attr, long argc, t_atom *argv);
t_max_err	dataspace_setDataspaceActive(t_dataspace *self, void *attr, long argc, t_atom *argv);
t_max_err	dataspace_setDataspaceNative(t_dataspace *self, void *attr, long argc, t_atom *argv);


// Globals
static ClassPtr dataspace_class;


#pragma mark -
#pragma mark main
/************************************************************************************/
// Main() Function

int TTCLASSWRAPPERMAX_EXPORT main(void)
{
	ClassPtr c;
	
	TTFoundationInit();
	common_symbols_init();
	
	// Define our class
	c = class_new("jcom.dataspace",(method)dataspace_new, (method)dataspace_free, sizeof(t_dataspace), (method)0L, A_GIMME, 0);
	
	// Make methods accessible for our class:
	class_addmethod(c, (method)dataspace_int,			"int",				A_GIMME, 0);
	class_addmethod(c, (method)dataspace_float,			"float",			A_GIMME, 0);
	class_addmethod(c, (method)dataspace_list,			"list",				A_GIMME, 0);
	class_addmethod(c, (method)dataspace_getDataspaces,	"dataspaces.get",	0);
 	class_addmethod(c, (method)dataspace_getUnits,		"units.get",		A_GIMME, 0);
	class_addmethod(c, (method)dataspace_assist,		"assist",			A_CANT, 0); 
    class_addmethod(c, (method)object_obex_dumpout, 	"dumpout",			A_CANT, 0);
	
	class_addattr(c, 
				  attr_offset_new("dataspace", _sym_symbol, 0,
								  (method)0, (method)dataspace_setDataspace, calcoffset(t_dataspace, attr_dataspace)));

	CLASS_ATTR_SYM(c,		"input",	0,		t_dataspace,	attr_dataspace_active);
	CLASS_ATTR_ACCESSORS(c,	"input",	NULL,	dataspace_setDataspaceActive);
	
	CLASS_ATTR_SYM(c,		"output",	0,		t_dataspace,	attr_dataspace_native);
	CLASS_ATTR_ACCESSORS(c,	"output",	NULL,	dataspace_setDataspaceNative);
	
	// Finalize our class
	class_register(CLASS_BOX, c);
	dataspace_class = c;
	return 0;
}


#pragma mark -
#pragma mark life cycle
/************************************************************************************/
// Object Life

void *dataspace_new(t_symbol *name, long argc, t_atom *argv)
{
	t_dataspace *self;
	
	self = (t_dataspace *)object_alloc(dataspace_class);
	if (self) {
		object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL));
	    self->outlet_native = outlet_new(self, 0);
		TTObjectInstantiate(TT("dataspace"), &self->dataspace, kTTValNONE);
		
		attr_args_process(self, argc, argv);
		if (!self->dataspace)
			object_attr_setsym(self, gensym("dataspace"), gensym("temperature"));
	}
	return self;
}


void dataspace_free(t_dataspace *self)
{
	TTObjectRelease(&self->dataspace);
}



#pragma mark -
#pragma mark methods
/************************************************************************************/
// Methods bound to input/inlets

// Method for Assistance Messages
void dataspace_assist(t_dataspace *self, void *b, long msg, long arg, char *dst)<commit_msg>Ensuring that TTenvironment sample rate is updated when jcom.dataspace is instantiated<commit_after>/* 
 * jcom.dataspace
 * External for Jamoma: map input to output: y=f(x)
 * Copyright © 2007
 * 
 * License: This code is licensed under the terms of the "New BSD License"
 * http://creativecommons.org/licenses/BSD/
 */

#include "TTClassWrapperMax.h"


// Data Structure for this object
typedef struct _dataspace{
	Object			ob;
	TTPtr			outlet_native;
	TTObjectPtr		dataspace;
	SymbolPtr		attr_dataspace;			// name of the dataspace -- e.g. "temperature"
	SymbolPtr		attr_dataspace_active;	// name of the current unit within the dataspace -- e.g. "celsius"
	SymbolPtr		attr_dataspace_native;	// name of the desired native unit within the dataspace -- e.g. "celsius"
} t_dataspace;


// Prototypes for methods
void*		dataspace_new(t_symbol *name, long argc, t_atom *argv);
void		dataspace_free(t_dataspace *self);
void		dataspace_assist(t_dataspace *self, void *b, long m, long a, char *s);
void		dataspace_int(t_dataspace *self, long x);
void		dataspace_float(t_dataspace *self, double x);
void		dataspace_list(t_dataspace *self, t_symbol *msg, long argc, t_atom *argv);
void		dataspace_getDataspaces(t_dataspace *self);
void		dataspace_getUnits(t_dataspace *self);
t_max_err	dataspace_setDataspace(t_dataspace *self, void *attr, long argc, t_atom *argv);
t_max_err	dataspace_setDataspaceActive(t_dataspace *self, void *attr, long argc, t_atom *argv);
t_max_err	dataspace_setDataspaceNative(t_dataspace *self, void *attr, long argc, t_atom *argv);


// Globals
static ClassPtr dataspace_class;


#pragma mark -
#pragma mark main
/************************************************************************************/
// Main() Function

int TTCLASSWRAPPERMAX_EXPORT main(void)
{
	ClassPtr c;
	
	TTFoundationInit();
	common_symbols_init();
	
	// Define our class
	c = class_new("jcom.dataspace",(method)dataspace_new, (method)dataspace_free, sizeof(t_dataspace), (method)0L, A_GIMME, 0);
	
	// Make methods accessible for our class:
	class_addmethod(c, (method)dataspace_int,			"int",				A_GIMME, 0);
	class_addmethod(c, (method)dataspace_float,			"float",			A_GIMME, 0);
	class_addmethod(c, (method)dataspace_list,			"list",				A_GIMME, 0);
	class_addmethod(c, (method)dataspace_getDataspaces,	"dataspaces.get",	0);
 	class_addmethod(c, (method)dataspace_getUnits,		"units.get",		A_GIMME, 0);
	class_addmethod(c, (method)dataspace_assist,		"assist",			A_CANT, 0); 
    class_addmethod(c, (method)object_obex_dumpout, 	"dumpout",			A_CANT, 0);
	
	class_addattr(c, 
				  attr_offset_new("dataspace", _sym_symbol, 0,
								  (method)0, (method)dataspace_setDataspace, calcoffset(t_dataspace, attr_dataspace)));

	CLASS_ATTR_SYM(c,		"input",	0,		t_dataspace,	attr_dataspace_active);
	CLASS_ATTR_ACCESSORS(c,	"input",	NULL,	dataspace_setDataspaceActive);
	
	CLASS_ATTR_SYM(c,		"output",	0,		t_dataspace,	attr_dataspace_native);
	CLASS_ATTR_ACCESSORS(c,	"output",	NULL,	dataspace_setDataspaceNative);
	
	// Finalize our class
	class_register(CLASS_BOX, c);
	dataspace_class = c;
	return 0;
}


#pragma mark -
#pragma mark life cycle
/************************************************************************************/
// Object Life

void *dataspace_new(t_symbol *name, long argc, t_atom *argv)
{
	t_dataspace *self;
	
	self = (t_dataspace *)object_alloc(dataspace_class);
	if (self) {
		object_obex_store((void*)self, _sym_dumpout, (object*)outlet_new(self, NULL));

        // Make sure that environment sample rate is set correctly at instantiated,
        // as it is used by time dataspace for conversions to and from sample
        TTValue		sr(sys_getsr());
        ttEnvironment->setAttributeValue(kTTSym_sampleRate, sr);
        
        self->outlet_native = outlet_new(self, 0);
		TTObjectInstantiate(TT("dataspace"), &self->dataspace, kTTValNONE);
		
		attr_args_process(self, argc, argv);
		if (!self->dataspace)
			object_attr_setsym(self, gensym("dataspace"), gensym("temperature"));
	}
	return self;
}


void dataspace_free(t_dataspace *self)
{
	TTObjectRelease(&self->dataspace);
}



#pragma mark -
#pragma mark methods
/************************************************************************************/
// Methods bound to input/inlets

// Method for Assistance Messages
void dataspace_assist(t_dataspace *self, void *b, long msg, long arg, char *dst)
{'fraction_non_alphanumeric': 0.16998213222156044, 'fraction_numerical': 0.004526503871351995, 'mean_word_length': 5.554254488680718, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '977067', 'n_tokens_mistral': 3265, 'n_tokens_neox': 2925, 'n_words': 689}