<commit_before>#include <stdlib.h>
#include <string.h>
#include <math.h>

#include "Error.h"
#include "DataType.h"
#include "NDArray.h"
#include "Commands.h"
#include "Interfaces.h"
#include "Message.h"
#include "Strings.h"
#include "IdMap.h"
#include "Util.h"

typedef void (*StepInitFunction)(int32_t, double, double, void*);
static void initLinearF32(int32_t samples, double start, double step, float dataOut[restrict static samples]);
static void initLinearF64(int32_t samples, double start, double step, double dataOut[restrict static samples]);

static const StepInitFunction stepInitFunctions[] = {
	[FJS_DataType_F64] = (StepInitFunction) initLinearF64,
	[FJS_DataType_F32] = (StepInitFunction) initLinearF32
};

enum FJS_Empty_Argument {
	FJS_Empty_Argument_Out,
	FJS_Empty_Argument_DataType,
	FJS_Empty_Argument_Shape
};

static const struct FJS_VariableDescriptor createDescriptors[] =
{
	[FJS_Empty_Argument_Out] = { 
		.type = FJS_VariableType_Int32,
		.name = FJS_StringVariable_Out
	},
	[FJS_Empty_Argument_DataType] = {
		.type = FJS_VariableType_DataType,
		.name = FJS_StringVariable_Datatype
	},
	[FJS_Empty_Argument_Shape] = {
		.type = FJS_VariableType_Buffer,
		.name = FJS_StringVariable_Shape
	}
};

void FJS_Parse_Empty(PP_Instance instance, struct PP_Var message) {
	struct FJS_Variable variables[FJS_COUNT_OF(createDescriptors)];
	enum FJS_Error error = FJS_Error_Ok;

	error = FJS_Message_Parse(FJS_COUNT_OF(createDescriptors), createDescriptors, variables, message);
	if (error != FJS_Error_Ok) {
		FJS_LOG_ERROR("Parse error");
		goto cleanup;
	}

	error = FJS_Execute_Empty(instance,
		variables[FJS_Empty_Argument_Out].parsedValue.asInt32,
		variables[FJS_Empty_Argument_Shape].parsedValue.asBuffer.size / 4,
		variables[FJS_Empty_Argument_Shape].parsedValue.asBuffer.pointer,
		variables[FJS_Empty_Argument_DataType].parsedValue.asDatatype);
	if (!FJS_Message_SetStatus(instance, FJS_ResponseVariable, error)) {
		goto cleanup;
	}

	messagingInterface->PostMessage(instance, FJS_ResponseVariable);

	FJS_Message_RemoveStatus(FJS_ResponseVariable);
cleanup:
	FJS_Message_FreeVariables(FJS_COUNT_OF(variables), variables);
}

enum FJS_CreateFromBuffer_Argument {
	FJS_CreateFromBuffer_Argument_Out,
	FJS_CreateFromBuffer_Argument_DataType,
	FJS_CreateFromBuffer_Argument_Shape,
	FJS_CreateFromBuffer_Argument_Buffer
};

static const struct FJS_VariableDescriptor createFromBufferDescriptors[] =
{
	[FJS_CreateFromBuffer_Argument_Out] = { 
		.type = FJS_VariableType_Int32,
		.name = FJS_StringVariable_Out
	},
	[FJS_CreateFromBuffer_Argument_DataType] = {
		.type = FJS_VariableType_DataType,
		.name = FJS_StringVariable_Datatype
	},
	[FJS_CreateFromBuffer_Argument_Shape] = {
		.type = FJS_VariableType_Buffer,
		.name = FJS_StringVariable_Shape
	},
	[FJS_CreateFromBuffer_Argument_Buffer] = {
		.type = FJS_VariableType_Buffer,
		.name = FJS_StringVariable_Buffer
	}
};

void FJS_Parse_Array(PP_Instance instance, struct PP_Var message) {
	struct FJS_Variable variables[FJS_COUNT_OF(createFromBufferDescriptors)];
	enum FJS_Error error = FJS_Error_Ok;

	error = FJS_Message_Parse(FJS_COUNT_OF(createFromBufferDescriptors), createFromBufferDescriptors, variables, message);
	if (error != FJS_Error_Ok) {
		FJS_LOG_ERROR("Parse error");
		goto cleanup;
	}

	error = FJS_Execute_Array(instance,
		variables[FJS_CreateFromBuffer_Argument_Out].parsedValue.asInt32,
		variables[FJS_CreateFromBuffer_Argument_Shape].parsedValue.asBuffer.size / 4,
		variables[FJS_CreateFromBuffer_Argument_Shape].parsedValue.asBuffer.pointer,
		variables[FJS_CreateFromBuffer_Argument_DataType].parsedValue.asDatatype,
		variables[FJS_CreateFromBuffer_Argument_Buffer].parsedValue.asBuffer.size,
		variables[FJS_CreateFromBuffer_Argument_Buffer].parsedValue.asBuffer.pointer);
	if (!FJS_Message_SetStatus(instance, FJS_ResponseVariable, error)) {
		goto cleanup;
	}

	messagingInterface->PostMessage(instance, FJS_ResponseVariable);

	FJS_Message_RemoveStatus(FJS_ResponseVariable);
cleanup:
	FJS_Message_FreeVariables(FJS_COUNT_OF(variables), variables);
}

enum FJS_LinSpace_Argument {
	FJS_LinSpace_Argument_Out,
	FJS_LinSpace_Argument_Start,
	FJS_LinSpace_Argument_Stop,
	FJS_LinSpace_Argument_Samples,
	FJS_LinSpace_Argument_Closed,
	FJS_LinSpace_Argument_DataType,
};

static const struct FJS_VariableDescriptor linspaceDescriptors[] =
{
	[FJS_LinSpace_Argument_Out] = { 
		.type = FJS_VariableType_Int32,
		.name = FJS_StringVariable_Out
	},<commit_msg>PNaCl: refactoring of names: CreateFromArray -> array<commit_after>#include <stdlib.h>
#include <string.h>
#include <math.h>

#include "Error.h"
#include "DataType.h"
#include "NDArray.h"
#include "Commands.h"
#include "Interfaces.h"
#include "Message.h"
#include "Strings.h"
#include "IdMap.h"
#include "Util.h"

typedef void (*StepInitFunction)(int32_t, double, double, void*);
static void initLinearF32(int32_t samples, double start, double step, float dataOut[restrict static samples]);
static void initLinearF64(int32_t samples, double start, double step, double dataOut[restrict static samples]);

static const StepInitFunction stepInitFunctions[] = {
	[FJS_DataType_F64] = (StepInitFunction) initLinearF64,
	[FJS_DataType_F32] = (StepInitFunction) initLinearF32
};

enum FJS_Empty_Argument {
	FJS_Empty_Argument_Out,
	FJS_Empty_Argument_DataType,
	FJS_Empty_Argument_Shape
};

static const struct FJS_VariableDescriptor emptyDescriptors[] =
{
	[FJS_Empty_Argument_Out] = { 
		.type = FJS_VariableType_Int32,
		.name = FJS_StringVariable_Out
	},
	[FJS_Empty_Argument_DataType] = {
		.type = FJS_VariableType_DataType,
		.name = FJS_StringVariable_Datatype
	},
	[FJS_Empty_Argument_Shape] = {
		.type = FJS_VariableType_Buffer,
		.name = FJS_StringVariable_Shape
	}
};

void FJS_Parse_Empty(PP_Instance instance, struct PP_Var message) {
	struct FJS_Variable variables[FJS_COUNT_OF(emptyDescriptors)];
	enum FJS_Error error = FJS_Error_Ok;

	error = FJS_Message_Parse(FJS_COUNT_OF(emptyDescriptors), emptyDescriptors, variables, message);
	if (error != FJS_Error_Ok) {
		FJS_LOG_ERROR("Parse error");
		goto cleanup;
	}

	error = FJS_Execute_Empty(instance,
		variables[FJS_Empty_Argument_Out].parsedValue.asInt32,
		variables[FJS_Empty_Argument_Shape].parsedValue.asBuffer.size / 4,
		variables[FJS_Empty_Argument_Shape].parsedValue.asBuffer.pointer,
		variables[FJS_Empty_Argument_DataType].parsedValue.asDatatype);
	if (!FJS_Message_SetStatus(instance, FJS_ResponseVariable, error)) {
		goto cleanup;
	}

	messagingInterface->PostMessage(instance, FJS_ResponseVariable);

	FJS_Message_RemoveStatus(FJS_ResponseVariable);
cleanup:
	FJS_Message_FreeVariables(FJS_COUNT_OF(variables), variables);
}

enum FJS_Array_Argument {
	FJS_Array_Argument_Out,
	FJS_Array_Argument_DataType,
	FJS_Array_Argument_Shape,
	FJS_Array_Argument_Buffer
};

static const struct FJS_VariableDescriptor arrayDescriptors[] =
{
	[FJS_Array_Argument_Out] = { 
		.type = FJS_VariableType_Int32,
		.name = FJS_StringVariable_Out
	},
	[FJS_Array_Argument_DataType] = {
		.type = FJS_VariableType_DataType,
		.name = FJS_StringVariable_Datatype
	},
	[FJS_Array_Argument_Shape] = {
		.type = FJS_VariableType_Buffer,
		.name = FJS_StringVariable_Shape
	},
	[FJS_Array_Argument_Buffer] = {
		.type = FJS_VariableType_Buffer,
		.name = FJS_StringVariable_Buffer
	}
};

void FJS_Parse_Array(PP_Instance instance, struct PP_Var message) {
	struct FJS_Variable variables[FJS_COUNT_OF(arrayDescriptors)];
	enum FJS_Error error = FJS_Error_Ok;

	error = FJS_Message_Parse(FJS_COUNT_OF(arrayDescriptors), arrayDescriptors, variables, message);
	if (error != FJS_Error_Ok) {
		FJS_LOG_ERROR("Parse error");
		goto cleanup;
	}

	error = FJS_Execute_Array(instance,
		variables[FJS_Array_Argument_Out].parsedValue.asInt32,
		variables[FJS_Array_Argument_Shape].parsedValue.asBuffer.size / 4,
		variables[FJS_Array_Argument_Shape].parsedValue.asBuffer.pointer,
		variables[FJS_Array_Argument_DataType].parsedValue.asDatatype,
		variables[FJS_Array_Argument_Buffer].parsedValue.asBuffer.size,
		variables[FJS_Array_Argument_Buffer].parsedValue.asBuffer.pointer);
	if (!FJS_Message_SetStatus(instance, FJS_ResponseVariable, error)) {
		goto cleanup;
	}

	messagingInterface->PostMessage(instance, FJS_ResponseVariable);

	FJS_Message_RemoveStatus(FJS_ResponseVariable);
cleanup:
	FJS_Message_FreeVariables(FJS_COUNT_OF(variables), variables);
}

enum FJS_LinSpace_Argument {
	FJS_LinSpace_Argument_Out,
	FJS_LinSpace_Argument_Start,
	FJS_LinSpace_Argument_Stop,
	FJS_LinSpace_Argument_Samples,
	FJS_LinSpace_Argument_Closed,
	FJS_LinSpace_Argument_DataType,
};

static const struct FJS_VariableDescriptor linspaceDescriptors[] =
{
	[FJS_LinSpace_Argument_Out] = { 
		.type = FJS_VariableType_Int32,
		.name = FJS_StringVariable_Out
	},
{'fraction_non_alphanumeric': 0.09170753963727615, 'fraction_numerical': 0.006843846241587772, 'mean_word_length': 7.6129666011787815, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 14, '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': '1154272', 'n_tokens_mistral': 3161, 'n_tokens_neox': 3090, 'n_words': 461}